added run_ps for all the postscripts for diskful install
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11505 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -97,6 +97,30 @@ cd /xcatpost | ||||
| #/xcatpost/#TABLE:nodelist:THISNODE:node# | ||||
| export PATH=/xcatpost:$PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
| #save the postboot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -108,6 +108,31 @@ cd /xcatpost | ||||
| #/xcatpost/#TABLE:nodelist:THISNODE:node# | ||||
| export PATH=/xcatpost:$PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
| #save the postboot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -105,6 +105,32 @@ cd /xcatpost | ||||
| #/xcatpost/#TABLE:nodelist:THISNODE:node# | ||||
| export PATH=/xcatpost:$PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
|  | ||||
| #save the postboot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -85,6 +85,32 @@ done | ||||
| cd /xcatpost | ||||
| export PATH=/xcatpost:$PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
|  | ||||
| # Save post boot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -85,6 +85,32 @@ done | ||||
| cd /xcatpost | ||||
| export PATH=/xcatpost:$PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
|  | ||||
| # Save post boot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -138,6 +138,32 @@ echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
|  | ||||
| #save the postboot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -88,6 +88,31 @@ done | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
| #save the postboot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -1,142 +1,168 @@ | ||||
| 		<post-scripts config:type="list"> | ||||
| 			<script> | ||||
| 				<filename>post.sh</filename> | ||||
| 				<interpreter>shell</interpreter> | ||||
| 				<source> | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
|  | ||||
| # Set MAC address | ||||
| cat /etc/sysconfig/network/ifcfg-replace_device | grep -v "LLADDR" | grep -v "UNIQUE" > /tmp/ifcfg-replace_device | ||||
| echo "LLADDR='replace_lladdr'" >> /tmp/ifcfg-replace_device | ||||
| echo "UNIQUE=''" >> /tmp/ifcfg-replace_device | ||||
| cat /tmp/ifcfg-replace_device > /etc/sysconfig/network/ifcfg-replace_device | ||||
|  | ||||
| # Set layer = 2 | ||||
| cat /etc/sysconfig/hardware/hwcfg-replace_device | grep -v "QETH_LAYER2_SUPPORT" > /tmp/hwcfg-replace_device | ||||
| echo "QETH_LAYER2_SUPPORT='1'" >> /tmp/hwcfg-replace_device | ||||
| cat /tmp/hwcfg-replace_device > /etc/sysconfig/hardware/hwcfg-replace_device | ||||
|  | ||||
| # Get node hostname | ||||
| HOSTNAME=$(hostname -s) | ||||
|  | ||||
| # These variables are set by nodeset | ||||
| export MASTER_IPS=( replace_master ) | ||||
|  | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	 | ||||
| 	# Loop through the master/service nodes | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
| 		# Download postscripts from FTP server | ||||
| 		wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
| 		if [ "$?" = "0" ]; then | ||||
| 			# Exit if openssl is not executable | ||||
| 			if [ ! -x /usr/bin/openssl ]; then  | ||||
|             			exit 1 | ||||
| 			fi | ||||
| 		 | ||||
| 			# Get xcat server | ||||
| 			XCATSERVER=$i:3001 | ||||
| 			export XCATSERVER | ||||
| 			USEOPENSSLFORXCAT=1  | ||||
| 			export USEOPENSSLFORXCAT | ||||
|  | ||||
| 			# Move postscritps into /xcatpost | ||||
| 			mv $i/postscripts /xcatpost | ||||
| 			# Remove postscritps | ||||
| 			rm -rf $i | ||||
| 			# Make postscripts executable | ||||
| 			chmod +x /xcatpost/* | ||||
|  | ||||
| 			# Get postscript to run on this node from xcat server | ||||
| 			/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
| 			MYCONT=`grep MASTER /tmp/mypostscript` | ||||
| 			MAX_RETRIES=10 | ||||
| 			RETRY=0 | ||||
| 			while [ -z "$MYCONT" ]; do | ||||
| 				RETRY=$(($RETRY+1)) | ||||
| 				if [ $RETRY -eq $MAX_RETRIES ]; then | ||||
| 					break | ||||
| 				fi | ||||
|  | ||||
| 				# Sleep a couple of seconds before trying again			 | ||||
| 				let SLI=$RANDOM%10+10 | ||||
| 				sleep $SLI | ||||
|  | ||||
| 				# Get postscript to run on this node from xcat server | ||||
| 				/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
| 				MYCONT=`grep MASTER /tmp/mypostscript` | ||||
| 			done | ||||
|           | ||||
| 			# Make executable | ||||
| 			chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	 | ||||
| 	# If postscripts for this node are found | ||||
| 	if [ "$GOTIT" = "1" ]; then | ||||
| 		# Save the master/service node to /opt/xcat/xcatinfo file | ||||
| 		if [ ! -f /opt/xcat/xcatinfo ]; then | ||||
| 			mkdir -p /opt/xcat | ||||
| 			touch /opt/xcat/xcatinfo | ||||
| 		fi | ||||
|  | ||||
| 		echo "XCATSERVER=$i" > /opt/xcat/xcatinfo | ||||
| 	    break | ||||
| 	fi | ||||
|  | ||||
| 	# Sleep for a couple of seconds | ||||
| 	RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
| 	sleep $RAND | ||||
| done | ||||
|  | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| # Save post boot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| # Create post init | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| # Install directory variable is set by nodeset | ||||
| replace_install_dir/postscripts/xcatpostinit1 | ||||
| EOF | ||||
| # Change permissions | ||||
| chmod 755 /etc/init.d/xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc3.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc4.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc5.d/S84xcatpostinit1 | ||||
|  | ||||
| # Create post install  | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| # Install directory variable is set by nodeset | ||||
| replace_install_dir/postscripts/xcatinstallpost | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| # Change permissions | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| # Only run prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| # Run postscripts | ||||
| /tmp/mypostscript | ||||
|  | ||||
| # Master node is set by nodeset | ||||
| updateflag.awk replace_master 3002 | ||||
| cd / | ||||
| ]]> | ||||
| 				</source> | ||||
| 			</script> | ||||
| 		<post-scripts config:type="list"> | ||||
| 			<script> | ||||
| 				<filename>post.sh</filename> | ||||
| 				<interpreter>shell</interpreter> | ||||
| 				<source> | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
|  | ||||
| # Set MAC address | ||||
| cat /etc/sysconfig/network/ifcfg-replace_device | grep -v "LLADDR" | grep -v "UNIQUE" > /tmp/ifcfg-replace_device | ||||
| echo "LLADDR='replace_lladdr'" >> /tmp/ifcfg-replace_device | ||||
| echo "UNIQUE=''" >> /tmp/ifcfg-replace_device | ||||
| cat /tmp/ifcfg-replace_device > /etc/sysconfig/network/ifcfg-replace_device | ||||
|  | ||||
| # Set layer = 2 | ||||
| cat /etc/sysconfig/hardware/hwcfg-replace_device | grep -v "QETH_LAYER2_SUPPORT" > /tmp/hwcfg-replace_device | ||||
| echo "QETH_LAYER2_SUPPORT='1'" >> /tmp/hwcfg-replace_device | ||||
| cat /tmp/hwcfg-replace_device > /etc/sysconfig/hardware/hwcfg-replace_device | ||||
|  | ||||
| # Get node hostname | ||||
| HOSTNAME=$(hostname -s) | ||||
|  | ||||
| # These variables are set by nodeset | ||||
| export MASTER_IPS=( replace_master ) | ||||
|  | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	 | ||||
| 	# Loop through the master/service nodes | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
| 		# Download postscripts from FTP server | ||||
| 		wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
| 		if [ "$?" = "0" ]; then | ||||
| 			# Exit if openssl is not executable | ||||
| 			if [ ! -x /usr/bin/openssl ]; then  | ||||
|             			exit 1 | ||||
| 			fi | ||||
| 		 | ||||
| 			# Get xcat server | ||||
| 			XCATSERVER=$i:3001 | ||||
| 			export XCATSERVER | ||||
| 			USEOPENSSLFORXCAT=1  | ||||
| 			export USEOPENSSLFORXCAT | ||||
|  | ||||
| 			# Move postscritps into /xcatpost | ||||
| 			mv $i/postscripts /xcatpost | ||||
| 			# Remove postscritps | ||||
| 			rm -rf $i | ||||
| 			# Make postscripts executable | ||||
| 			chmod +x /xcatpost/* | ||||
|  | ||||
| 			# Get postscript to run on this node from xcat server | ||||
| 			/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
| 			MYCONT=`grep MASTER /tmp/mypostscript` | ||||
| 			MAX_RETRIES=10 | ||||
| 			RETRY=0 | ||||
| 			while [ -z "$MYCONT" ]; do | ||||
| 				RETRY=$(($RETRY+1)) | ||||
| 				if [ $RETRY -eq $MAX_RETRIES ]; then | ||||
| 					break | ||||
| 				fi | ||||
|  | ||||
| 				# Sleep a couple of seconds before trying again			 | ||||
| 				let SLI=$RANDOM%10+10 | ||||
| 				sleep $SLI | ||||
|  | ||||
| 				# Get postscript to run on this node from xcat server | ||||
| 				/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
| 				MYCONT=`grep MASTER /tmp/mypostscript` | ||||
| 			done | ||||
|           | ||||
| 			# Make executable | ||||
| 			chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	 | ||||
| 	# If postscripts for this node are found | ||||
| 	if [ "$GOTIT" = "1" ]; then | ||||
| 		# Save the master/service node to /opt/xcat/xcatinfo file | ||||
| 		if [ ! -f /opt/xcat/xcatinfo ]; then | ||||
| 			mkdir -p /opt/xcat | ||||
| 			touch /opt/xcat/xcatinfo | ||||
| 		fi | ||||
|  | ||||
| 		echo "XCATSERVER=$i" > /opt/xcat/xcatinfo | ||||
| 	    break | ||||
| 	fi | ||||
|  | ||||
| 	# Sleep for a couple of seconds | ||||
| 	RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
| 	sleep $RAND | ||||
| done | ||||
|  | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
|  | ||||
| # Save post boot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| # Create post init | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| # Install directory variable is set by nodeset | ||||
| replace_install_dir/postscripts/xcatpostinit1 | ||||
| EOF | ||||
| # Change permissions | ||||
| chmod 755 /etc/init.d/xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc3.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc4.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc5.d/S84xcatpostinit1 | ||||
|  | ||||
| # Create post install  | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| # Install directory variable is set by nodeset | ||||
| replace_install_dir/postscripts/xcatinstallpost | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| # Change permissions | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| # Only run prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| # Run postscripts | ||||
| /tmp/mypostscript | ||||
|  | ||||
| # Master node is set by nodeset | ||||
| updateflag.awk replace_master 3002 | ||||
| cd / | ||||
| ]]> | ||||
| 				</source> | ||||
| 			</script> | ||||
| 		</post-scripts> | ||||
| @@ -121,6 +121,32 @@ echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
|  | ||||
| #save the postboot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -98,6 +98,32 @@ done | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
|  | ||||
| #save the postboot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -126,6 +126,31 @@ parted /dev/sdb set 1 boot on | ||||
| dd if=/dev/sda1 of=/dev/sdb1 | ||||
| bootlist -m normal sda sdb | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
| #save the postboot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
|   | ||||
| @@ -1,138 +1,163 @@ | ||||
| 		<post-scripts config:type="list"> | ||||
| 			<script> | ||||
| 				<filename>post.sh</filename> | ||||
| 				<interpreter>shell</interpreter> | ||||
| 				<source> | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
|  | ||||
| # Set MAC address | ||||
| cat /etc/sysconfig/network/ifcfg-replace_device | grep -v "LLADDR" | grep -v "UNIQUE" > /tmp/ifcfg-replace_device | ||||
| echo "LLADDR='replace_lladdr'" >> /tmp/ifcfg-replace_device | ||||
| echo "UNIQUE=''" >> /tmp/ifcfg-replace_device | ||||
| echo "NAME='OSA Express Network card (replace_nic_addr)'" >> /tmp/ifcfg-replace_device | ||||
| cat /tmp/ifcfg-replace_device > /etc/sysconfig/network/ifcfg-replace_device					 | ||||
|  | ||||
| # Get node hostname | ||||
| HOSTNAME=$(hostname -s) | ||||
|  | ||||
| # These variables are set by nodeset | ||||
| export MASTER_IPS=( replace_master ) | ||||
|  | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	 | ||||
| 	# Loop through the master/service nodes | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
| 		# Download postscripts from FTP server | ||||
| 		wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
| 		if [ "$?" = "0" ]; then | ||||
| 			# Exit if openssl is not executable | ||||
| 			if [ ! -x /usr/bin/openssl ]; then  | ||||
|             			exit 1 | ||||
| 			fi | ||||
| 		 | ||||
| 			# Get xcat server | ||||
| 			XCATSERVER=$i:3001 | ||||
| 			export XCATSERVER | ||||
| 			USEOPENSSLFORXCAT=1  | ||||
| 			export USEOPENSSLFORXCAT | ||||
|  | ||||
| 			# Move postscritps into /xcatpost | ||||
| 			mv $i/postscripts /xcatpost | ||||
| 			# Remove postscritps | ||||
| 			rm -rf $i | ||||
| 			# Make postscripts executable | ||||
| 			chmod +x /xcatpost/* | ||||
|  | ||||
| 			# Get postscript to run on this node from xcat server | ||||
| 			/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
| 			MYCONT=`grep MASTER /tmp/mypostscript` | ||||
| 			MAX_RETRIES=10 | ||||
| 			RETRY=0 | ||||
| 			while [ -z "$MYCONT" ]; do | ||||
| 				RETRY=$(($RETRY+1)) | ||||
| 				if [ $RETRY -eq $MAX_RETRIES ]; then | ||||
| 					break | ||||
| 				fi | ||||
|  | ||||
| 				# Sleep a couple of seconds before trying again			 | ||||
| 				let SLI=$RANDOM%10+10 | ||||
| 				sleep $SLI | ||||
|  | ||||
| 				# Get postscript to run on this node from xcat server | ||||
| 				/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
| 				MYCONT=`grep MASTER /tmp/mypostscript` | ||||
| 			done | ||||
|           | ||||
| 			# Make executable | ||||
| 			chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	 | ||||
| 	# If postscripts for this node are found | ||||
| 	if [ "$GOTIT" = "1" ]; then | ||||
| 		# Save the master/service node to /opt/xcat/xcatinfo file | ||||
| 		if [ ! -f /opt/xcat/xcatinfo ]; then | ||||
| 			mkdir -p /opt/xcat | ||||
| 			touch /opt/xcat/xcatinfo | ||||
| 		fi | ||||
|  | ||||
| 		echo "XCATSERVER=$i" > /opt/xcat/xcatinfo | ||||
| 	    break | ||||
| 	fi | ||||
|  | ||||
| 	# Sleep for a couple of seconds | ||||
| 	RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
| 	sleep $RAND | ||||
| done | ||||
|  | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| # Save post boot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| # Create post init | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| # Install directory variable is set by nodeset | ||||
| replace_install_dir/postscripts/xcatpostinit1 | ||||
| EOF | ||||
| # Change permissions | ||||
| chmod 755 /etc/init.d/xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc3.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc4.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc5.d/S84xcatpostinit1 | ||||
|  | ||||
| # Create post install  | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| # Install directory variable is set by nodeset | ||||
| replace_install_dir/postscripts/xcatinstallpost | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| # Change permissions | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| # Only run prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| # Run postscripts | ||||
| /tmp/mypostscript | ||||
|  | ||||
| # Master node is set by nodeset | ||||
| updateflag.awk replace_master 3002 | ||||
| cd / | ||||
| ]]> | ||||
| 				</source> | ||||
| 			</script> | ||||
| 		<post-scripts config:type="list"> | ||||
| 			<script> | ||||
| 				<filename>post.sh</filename> | ||||
| 				<interpreter>shell</interpreter> | ||||
| 				<source> | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
|  | ||||
| # Set MAC address | ||||
| cat /etc/sysconfig/network/ifcfg-replace_device | grep -v "LLADDR" | grep -v "UNIQUE" > /tmp/ifcfg-replace_device | ||||
| echo "LLADDR='replace_lladdr'" >> /tmp/ifcfg-replace_device | ||||
| echo "UNIQUE=''" >> /tmp/ifcfg-replace_device | ||||
| echo "NAME='OSA Express Network card (replace_nic_addr)'" >> /tmp/ifcfg-replace_device | ||||
| cat /tmp/ifcfg-replace_device > /etc/sysconfig/network/ifcfg-replace_device					 | ||||
|  | ||||
| # Get node hostname | ||||
| HOSTNAME=$(hostname -s) | ||||
|  | ||||
| # These variables are set by nodeset | ||||
| export MASTER_IPS=( replace_master ) | ||||
|  | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	 | ||||
| 	# Loop through the master/service nodes | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
| 		# Download postscripts from FTP server | ||||
| 		wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
| 		if [ "$?" = "0" ]; then | ||||
| 			# Exit if openssl is not executable | ||||
| 			if [ ! -x /usr/bin/openssl ]; then  | ||||
|             			exit 1 | ||||
| 			fi | ||||
| 		 | ||||
| 			# Get xcat server | ||||
| 			XCATSERVER=$i:3001 | ||||
| 			export XCATSERVER | ||||
| 			USEOPENSSLFORXCAT=1  | ||||
| 			export USEOPENSSLFORXCAT | ||||
|  | ||||
| 			# Move postscritps into /xcatpost | ||||
| 			mv $i/postscripts /xcatpost | ||||
| 			# Remove postscritps | ||||
| 			rm -rf $i | ||||
| 			# Make postscripts executable | ||||
| 			chmod +x /xcatpost/* | ||||
|  | ||||
| 			# Get postscript to run on this node from xcat server | ||||
| 			/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
| 			MYCONT=`grep MASTER /tmp/mypostscript` | ||||
| 			MAX_RETRIES=10 | ||||
| 			RETRY=0 | ||||
| 			while [ -z "$MYCONT" ]; do | ||||
| 				RETRY=$(($RETRY+1)) | ||||
| 				if [ $RETRY -eq $MAX_RETRIES ]; then | ||||
| 					break | ||||
| 				fi | ||||
|  | ||||
| 				# Sleep a couple of seconds before trying again			 | ||||
| 				let SLI=$RANDOM%10+10 | ||||
| 				sleep $SLI | ||||
|  | ||||
| 				# Get postscript to run on this node from xcat server | ||||
| 				/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
| 				MYCONT=`grep MASTER /tmp/mypostscript` | ||||
| 			done | ||||
|           | ||||
| 			# Make executable | ||||
| 			chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	 | ||||
| 	# If postscripts for this node are found | ||||
| 	if [ "$GOTIT" = "1" ]; then | ||||
| 		# Save the master/service node to /opt/xcat/xcatinfo file | ||||
| 		if [ ! -f /opt/xcat/xcatinfo ]; then | ||||
| 			mkdir -p /opt/xcat | ||||
| 			touch /opt/xcat/xcatinfo | ||||
| 		fi | ||||
|  | ||||
| 		echo "XCATSERVER=$i" > /opt/xcat/xcatinfo | ||||
| 	    break | ||||
| 	fi | ||||
|  | ||||
| 	# Sleep for a couple of seconds | ||||
| 	RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
| 	sleep $RAND | ||||
| done | ||||
|  | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
| # Save post boot scripts to /tmp/mypostscript.post | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript.post | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| # Create post init | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| # Install directory variable is set by nodeset | ||||
| replace_install_dir/postscripts/xcatpostinit1 | ||||
| EOF | ||||
| # Change permissions | ||||
| chmod 755 /etc/init.d/xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc3.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc4.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/init.d/rc5.d/S84xcatpostinit1 | ||||
|  | ||||
| # Create post install  | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| # Install directory variable is set by nodeset | ||||
| replace_install_dir/postscripts/xcatinstallpost | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| # Change permissions | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| # Only run prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| # Run postscripts | ||||
| /tmp/mypostscript | ||||
|  | ||||
| # Master node is set by nodeset | ||||
| updateflag.awk replace_master 3002 | ||||
| cd / | ||||
| ]]> | ||||
| 				</source> | ||||
| 			</script> | ||||
| 		</post-scripts> | ||||
| @@ -100,6 +100,32 @@ export PATH=/xcatpost:$PATH | ||||
| #  mypostscript.post must survive a reboot.  Traditionally, xCAT has put mypostscript.post in /tmp. | ||||
| #  However, Ubuntu cleans /tmp on reboot.  So, for Ubuntu, /var/tmp is used instead. | ||||
|  | ||||
| # use the run_ps subroutine to run the postscripts | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo " | ||||
| # subroutine used to run postscripts | ||||
| run_ps () { | ||||
|  logdir=\"/var/log/xcat\" | ||||
|  mkdir -p \$logdir | ||||
|  logfile=\"/var/log/xcat/xcat.log\" | ||||
|   | ||||
|  if [ -f \$1 ]; then  | ||||
|   echo \"Running postscript: \$@\" | tee -a \$logfile | ||||
|   ./\$@ 2>&1 1> /tmp/tmp4xcatlog | ||||
|   cat /tmp/tmp4xcatlog | tee -a \$logfile | ||||
|  else | ||||
|   echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile | ||||
|  fi | ||||
| } | ||||
| # subroutine end | ||||
|  | ||||
| " > /tmp/mypostscript | ||||
| echo "$TMP" >> /tmp/mypostscript | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript  | ||||
|  | ||||
|  | ||||
|  | ||||
| TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /var/tmp/mypostscript.post | ||||
| chmod 755 /var/tmp/mypostscript.post | ||||
|   | ||||
		Reference in New Issue
	
	Block a user