mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	fix for bug 3487614: Full installation, extract the common code for generating the mypostscript file and make it common across all scripts
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11952 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -1,174 +1,4 @@ | ||||
| # | ||||
| # Setup hostname | ||||
| # | ||||
| echo "post scripts" >/root/post.log | ||||
| export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# | ||||
| if [ "$PRINIC" == "mac" ] | ||||
| then | ||||
|     export PRINIC='#TABLE:mac:THISNODE:mac#' | ||||
| fi | ||||
| if [ -z "$PRINIC" ] | ||||
| then | ||||
|     for karg in $(cat /proc/cmdline |sed -e 's/-/:/g' -e 's/ /\n/g'); do | ||||
|         if  [ "${karg%%=*}" = "BOOTIF" ]; then | ||||
|             export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'` | ||||
|         fi | ||||
|     done | ||||
|     if [ -z "$PRINIC" ]; then | ||||
|         export PRINIC=eth0 | ||||
|     fi | ||||
| fi | ||||
| if [ -z "$PRINIC" ] | ||||
| then | ||||
|     export PRINIC=eth0 | ||||
| elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then | ||||
|     export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` | ||||
| fi | ||||
| IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') | ||||
| if [ -z $IP ] | ||||
| then | ||||
| 	dhclient eth0 | ||||
| 	IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') | ||||
| fi | ||||
|  | ||||
| export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}') | ||||
| hostname $HOSTNAME | ||||
| # | ||||
| # Run xCAT post install | ||||
| # | ||||
| export MASTER_IP="#XCATVAR:XCATMASTER#" | ||||
| export MASTER_IPS="#XCATVAR:XCATMASTER#" | ||||
| export MASTER="#XCATVAR:XCATMASTER#" | ||||
| export INSTALLDIR=#TABLE:site:key=installdir:value# | ||||
| if [ -z "$INSTALLDIR" ]; then | ||||
|     INSTALLDIR="/install" | ||||
| fi | ||||
| cd /tmp | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
|       #wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
|       wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 0 -T 60 http://$i$INSTALLDIR/postscripts/ -P /xcatpost | ||||
| 		if [ "$?" = "0" ] | ||||
| 		then | ||||
|          if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit | ||||
|             exit 1 | ||||
|          fi | ||||
|        	 USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images | ||||
|      	 export USEOPENSSLFORXCAT | ||||
|          XCATSERVER=$i:3001 | ||||
|          export XCATSERVER | ||||
|          mv $i/postscripts /xcatpost | ||||
|          rm -rf $i | ||||
|          chmod +x /xcatpost/* | ||||
|          /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 | ||||
|  | ||||
|             let SLI=$RANDOM%10+10 | ||||
|             sleep $SLI | ||||
|             /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
|             MYCONT=`grep MASTER /tmp/mypostscript` | ||||
|          done | ||||
|  | ||||
|              | ||||
|          chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	if [ "$GOTIT" = "1" ] | ||||
| 	then | ||||
|             #save the master 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 | ||||
| 	RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
| 	sleep $RAND | ||||
| done | ||||
| echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo | ||||
| cd /xcatpost | ||||
| #gunzip xcatpost.tar.gz | ||||
| #tar -xvf xcatpost.tar | ||||
| #/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 | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| #create the post init  | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# | ||||
| EOF | ||||
| chmod 755 /etc/init.d/xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/rc3.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/rc4.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/rc5.d/S84xcatpostinit1 | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| #only run the prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| /tmp/mypostscript | ||||
| export NODE=#TABLE:nodelist:THISNODE:node# | ||||
| export OSVER=#TABLE:nodetype:THISNODE:os# | ||||
| export ARCH=#TABLE:nodetype:THISNODE:arch# | ||||
| addsiteyum | ||||
| sed -i 's/^serial/#serial/' /boot/grub/grub.conf | ||||
| sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf | ||||
| updateflag.awk $MASTER 3002 | ||||
| cd / | ||||
| #rm -Rf /xcatpost | ||||
| #rm -f /tmp/mypostscript | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.rh.common# | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# | ||||
| exit 0 | ||||
|  | ||||
|   | ||||
							
								
								
									
										36
									
								
								xCAT-server/share/xcat/install/scripts/post.rh.common
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								xCAT-server/share/xcat/install/scripts/post.rh.common
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,36 @@ | ||||
| # | ||||
| # Setup hostname | ||||
| # | ||||
| echo "post scripts" >/root/post.log | ||||
| export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# | ||||
| if [ "$PRINIC" == "mac" ] | ||||
| then | ||||
|     export PRINIC='#TABLE:mac:THISNODE:mac#' | ||||
| fi | ||||
| if [ -z "$PRINIC" ] | ||||
| then | ||||
|     for karg in $(cat /proc/cmdline |sed -e 's/-/:/g' -e 's/ /\n/g'); do | ||||
|         if  [ "${karg%%=*}" = "BOOTIF" ]; then | ||||
|             export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'` | ||||
|         fi | ||||
|     done | ||||
|     if [ -z "$PRINIC" ]; then | ||||
|         export PRINIC=eth0 | ||||
|     fi | ||||
| fi | ||||
| if [ -z "$PRINIC" ] | ||||
| then | ||||
|     export PRINIC=eth0 | ||||
| elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then | ||||
|     export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` | ||||
| fi | ||||
| IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') | ||||
| if [ -z $IP ] | ||||
| then | ||||
| 	dhclient eth0 | ||||
| 	IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') | ||||
| fi | ||||
|  | ||||
| export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}') | ||||
| hostname $HOSTNAME | ||||
|  | ||||
| @@ -1,173 +1,8 @@ | ||||
| # | ||||
| # Setup hostname | ||||
| # | ||||
| echo "post scripts" >/root/post.log | ||||
| export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# | ||||
| if [ "$PRINIC" == "mac" ] | ||||
| then | ||||
|     export PRINIC='#TABLE:mac:THISNODE:mac#' | ||||
| fi | ||||
| if [ -z "$PRINIC" ] | ||||
| then | ||||
|     for karg in $(cat /proc/cmdline |sed -e 's/-/:/g' -e 's/ /\n/g'); do | ||||
|         if  [ "${karg%%=*}" = "BOOTIF" ]; then | ||||
|             export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'` | ||||
|         fi | ||||
|     done | ||||
|     if [ -z "$PRINIC" ]; then | ||||
|         export PRINIC=eth0 | ||||
|     fi | ||||
| fi | ||||
| if [ -z "$PRINIC" ] | ||||
| then | ||||
|     export PRINIC=eth0 | ||||
| elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then | ||||
|     export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` | ||||
| fi | ||||
| IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') | ||||
| if [ -z $IP ] | ||||
| then | ||||
| 	dhclient eth0 | ||||
| 	IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}') | ||||
| fi | ||||
| echo "search #TABLE:site:key=domain:value#" >/etc/resolv.conf | ||||
| for i in $(echo #TABLE:site:key=nameservers:value# | tr ',' ' ') | ||||
| do | ||||
| 	echo "nameserver $i" | ||||
| done >>/etc/resolv.conf | ||||
| export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}') | ||||
| hostname $HOSTNAME | ||||
| # | ||||
| # Run xCAT post install | ||||
| # | ||||
| export MASTER_IP="#XCATVAR:XCATMASTER#" | ||||
| export MASTER_IPS="#XCATVAR:XCATMASTER#" | ||||
| export MASTER="#XCATVAR:XCATMASTER#" | ||||
| cd /tmp | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
|       wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
| 		#wget --wait=10 --random-wait --waitretry=10 --retry-connrefused -t 0 -T 60 http://$i/install/autoinst/xcatpost.tar.gz | ||||
| 		if [ "$?" = "0" ] | ||||
| 		then | ||||
|          if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit | ||||
|             exit 1; | ||||
|          fi | ||||
|          XCATSERVER=$i:3001 | ||||
|          export XCATSERVER | ||||
|        	 USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images | ||||
|      	 export USEOPENSSLFORXCAT | ||||
|          mv $i/postscripts /xcatpost | ||||
|          rm -rf $i | ||||
|          chmod +x /xcatpost/* | ||||
|          /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 | ||||
|  | ||||
|             let SLI=$RANDOM%10+10 | ||||
|             sleep $SLI | ||||
|             /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
|             MYCONT=`grep MASTER /tmp/mypostscript` | ||||
|          done | ||||
|          chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	if [ "$GOTIT" = "1" ] | ||||
| 	then | ||||
|             #save the master 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 | ||||
| 	RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
| 	sleep $RAND | ||||
| done | ||||
| cd /xcatpost | ||||
| #gunzip xcatpost.tar.gz | ||||
| #tar -xvf xcatpost.tar | ||||
| #/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 | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| #create the post init  | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# | ||||
| EOF | ||||
| 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 | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| #only run the prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| /tmp/mypostscript | ||||
| export NODE=#TABLE:nodelist:THISNODE:node# | ||||
| export OSVER=#TABLE:nodetype:THISNODE:os# | ||||
| export ARCH=#TABLE:nodetype:THISNODE:arch# | ||||
| addsiteyum | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.rh.common# | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# | ||||
| iscsiadm -m discovery -t st -p #TABLE:iscsi:$NODE:server# | ||||
| sed -i 's/^serial/#serial/' /boot/grub/menu.lst | ||||
| sed -i 's/^terminal/#terminal/' /boot/grub/menu.lst | ||||
| uploadboot | ||||
| cd / | ||||
| #rm -Rf /xcatpost | ||||
| #rm -f /tmp/mypostscript | ||||
| exit 0 | ||||
|  | ||||
|   | ||||
| @@ -7,196 +7,8 @@ | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
|  | ||||
| cd /etc/sysconfig/network | ||||
| rm -f ifcfg-eth-id* | ||||
| rm -f ifcfg-myri* | ||||
| cat >ifcfg-eth0 <<EOF | ||||
| DEVICE=eth0 | ||||
| BOOTPROTO=dhcp | ||||
| STARTMODE=onboot | ||||
| EOF | ||||
|  | ||||
| export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic# | ||||
| if [ "$PRINIC" == "mac" ] | ||||
| then | ||||
|     export PRINIC='#TABLE:mac:THISNODE:mac#' | ||||
| fi | ||||
| if [ -z "$PRINIC" ] | ||||
| then | ||||
|     for karg in $(cat /proc/cmdline |sed -e 's/-/:/g' -e 's/ /\n/g'); do | ||||
|         if  [ "${karg%%=*}" = "BOOTIF" ]; then | ||||
|             export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'` | ||||
|         fi | ||||
|     done | ||||
|     if [ -z "$PRINIC" ]; then | ||||
|         export PRINIC=eth0 | ||||
|     fi | ||||
| fi | ||||
| if [ -z "$PRINIC" ] | ||||
| then | ||||
|     export PRINIC=eth0 | ||||
| elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then | ||||
|     export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'` | ||||
| fi | ||||
| if [ "$PRINIC" != "eth0" ] | ||||
| then | ||||
| 	cd /etc/sysconfig/network | ||||
| 	if [ ! -r ifcfg-$PRINIC ] | ||||
| 	then | ||||
| 		cp -f ifcfg-eth0 ifcfg-$PRINIC | ||||
| 		perl -pi -e "s/eth0/$PRINIC/" ifcfg-$PRINIC | ||||
| 		echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC | ||||
| 	fi | ||||
| fi | ||||
| perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config | ||||
| /etc/init.d/network restart | ||||
|  | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| jsi=0 | ||||
| while [ $(hostname) == 'linux' ] | ||||
| do | ||||
| 	if [ $jsi -gt 10 ]; then | ||||
| 		logger "Slept too long!" | ||||
| 		exit | ||||
| 	fi | ||||
| 	let jsi=jsi+1 | ||||
| 	sleep 1 | ||||
| done | ||||
| echo "Slept $jsi seconds before hostname made sense." | ||||
|  | ||||
| HOSTNAME=$(hostname -s) | ||||
| echo $HOSTNAME | ||||
|  | ||||
| /sbin/portmap | ||||
| export MASTER_IP=#XCATVAR:XCATMASTER# | ||||
| export MASTER_IPS=#XCATVAR:XCATMASTER# | ||||
| export MASTER="#XCATVAR:XCATMASTER#" | ||||
| export INSTALLDIR=#TABLE:site:key=installdir:value# | ||||
| if [ -z "$INSTALLDIR" ]; then | ||||
|     INSTALLDIR="/install" | ||||
| fi | ||||
|  | ||||
| # | ||||
| #  This script has not yet been updated to work with service nodes | ||||
| # | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
| 		#mount -r $i:/install/postscripts /xcatpost | ||||
|       #wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
|       wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 0 -T 60 http://$i$INSTALLDIR/postscripts/ -P /xcatpost | ||||
| 		if [ "$?" = "0" ] | ||||
| 		then | ||||
|          if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit | ||||
|             exit 1 | ||||
|          fi | ||||
|          XCATSERVER=$i:3001 | ||||
|          export XCATSERVER | ||||
|      	USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images | ||||
|      	export USEOPENSSLFORXCAT | ||||
|          mv $i/postscripts /xcatpost | ||||
|          rm -rf $i | ||||
|          chmod +x /xcatpost/* | ||||
|          /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 | ||||
|  | ||||
|             let SLI=$RANDOM%10+10 | ||||
|             sleep $SLI | ||||
|             /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
|             MYCONT=`grep MASTER /tmp/mypostscript` | ||||
|          done | ||||
|          chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	if [ "$GOTIT" = "1" ] | ||||
| 	then | ||||
|             #save the master 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 | ||||
| 	RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
| 	sleep $RAND | ||||
| done | ||||
| 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 "cd /xcatpost" >> /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 | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| #create the post init  | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# | ||||
| EOF | ||||
| 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 | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| #only run the prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
| /tmp/mypostscript | ||||
| updateflag.awk $MASTER 3002 | ||||
| cd / | ||||
| /xcatpost/#TABLE:nodelist:$NODE:node# | ||||
| #rm -Rf /xcatpost | ||||
| #rm -f /tmp/mypostscript | ||||
| #rmdir /xcatpost | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sles.common# | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# | ||||
| ]]> | ||||
|  | ||||
|           </source> | ||||
|   | ||||
							
								
								
									
										47
									
								
								xCAT-server/share/xcat/install/scripts/post.sles.common
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								xCAT-server/share/xcat/install/scripts/post.sles.common
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | ||||
| #!/bin/sh | ||||
|  | ||||
| cd /etc/sysconfig/network | ||||
| rm -f ifcfg-eth-id* | ||||
| rm -f ifcfg-myri* | ||||
| cat >ifcfg-eth0 <<EOF | ||||
| DEVICE=eth0 | ||||
| BOOTPROTO=dhcp | ||||
| STARTMODE=onboot | ||||
| EOF | ||||
|  | ||||
| . /tmp/prinicsetting | ||||
| rm /tmp/prinicsetting | ||||
| if [ "$PRINIC" != "eth0" ] | ||||
| then | ||||
| 	cd /etc/sysconfig/network | ||||
| 	if [ ! -r ifcfg-$PRINIC ] | ||||
| 	then | ||||
| #		cp -f ifcfg-eth0 ifcfg-$PRINIC | ||||
| 		mv -f ifcfg-eth0 ifcfg-$PRINIC | ||||
| 		perl -pi -e "s/eth0/$PRINIC/" ifcfg-$PRINIC | ||||
| #		echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC | ||||
| 	fi | ||||
| fi | ||||
| echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC | ||||
| perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config | ||||
| /etc/init.d/network restart | ||||
|  | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| jsi=0 | ||||
| while [ $(hostname) == 'linux' ] | ||||
| do | ||||
| 	if [ $jsi -gt 10 ]; then | ||||
| 		logger "Slept too long!" | ||||
| 		exit | ||||
| 	fi | ||||
| 	let jsi=jsi+1 | ||||
| 	sleep 1 | ||||
| done | ||||
| echo "Slept $jsi seconds before hostname made sense." | ||||
|  | ||||
| HOSTNAME=$(hostname -s) | ||||
| echo $HOSTNAME | ||||
|  | ||||
| /sbin/portmap | ||||
|  | ||||
| @@ -6,145 +6,8 @@ | ||||
|  | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
|  | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| jsi=0 | ||||
| while [ $(hostname) == 'linux' ] | ||||
| do | ||||
| 	if [ $jsi -gt 10 ]; then | ||||
| 		logger "Slept too long!" | ||||
| 		exit | ||||
| 	fi | ||||
| 	let jsi=jsi+1 | ||||
| 	sleep 1 | ||||
| done | ||||
| echo "Slept $jsi seconds before hostname made sense." | ||||
|  | ||||
| HOSTNAME=$(hostname -s) | ||||
| echo $HOSTNAME | ||||
|  | ||||
| /sbin/portmap | ||||
| export MASTER_IP=#XCATVAR:XCATMASTER# | ||||
| export MASTER_IPS=#XCATVAR:XCATMASTER# | ||||
| export MASTER="#XCATVAR:XCATMASTER#" | ||||
|  | ||||
| # | ||||
| #  This script has not yet been updated to work with service nodes | ||||
| # | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
| 		#mount -r $i:/install/postscripts /xcatpost | ||||
|       wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
| 		if [ "$?" = "0" ] | ||||
| 		then | ||||
|          if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit | ||||
|             exit 1 | ||||
|          fi | ||||
|          XCATSERVER=$i:3001 | ||||
|          export XCATSERVER | ||||
|      	USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images | ||||
|      	export USEOPENSSLFORXCAT | ||||
|          mv $i/postscripts /xcatpost | ||||
|          rm -rf $i | ||||
|          chmod +x /xcatpost/* | ||||
|          /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 | ||||
|  | ||||
|             let SLI=$RANDOM%10+10 | ||||
|             sleep $SLI | ||||
|             /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
|             MYCONT=`grep MASTER /tmp/mypostscript` | ||||
|          done | ||||
|          chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	if [ "$GOTIT" = "1" ] | ||||
| 	then | ||||
|             #save the master 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 | ||||
| 	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 the postboot 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 the post init  | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# | ||||
| EOF | ||||
| 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 | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| #only run the prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
| /tmp/mypostscript | ||||
| updateflag.awk $MASTER 3002 | ||||
| cd / | ||||
| /xcatpost/#TABLE:nodelist:$NODE:node# | ||||
| #rm -Rf /xcatpost | ||||
| #rm -f /tmp/mypostscript | ||||
| #rmdir /xcatpost | ||||
| INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.rh.common# | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# | ||||
| ]]> | ||||
|  | ||||
|           </source> | ||||
|   | ||||
| @@ -5,183 +5,9 @@ | ||||
|           <source> | ||||
|  | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sles.common# | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# | ||||
|  | ||||
| cd /etc/sysconfig/network | ||||
| rm -f ifcfg-eth-id* | ||||
| rm -f ifcfg-myri* | ||||
| cat >ifcfg-eth0 <<EOF | ||||
| DEVICE=eth0 | ||||
| BOOTPROTO=dhcp | ||||
| STARTMODE=onboot | ||||
| EOF | ||||
|  | ||||
| . /tmp/prinicsetting | ||||
| rm /tmp/prinicsetting | ||||
| if [ "$PRINIC" != "eth0" ] | ||||
| then | ||||
| 	cd /etc/sysconfig/network | ||||
| 	if [ ! -r ifcfg-$PRINIC ] | ||||
| 	then | ||||
| #		cp -f ifcfg-eth0 ifcfg-$PRINIC | ||||
| 		mv -f ifcfg-eth0 ifcfg-$PRINIC | ||||
| 		perl -pi -e "s/eth0/$PRINIC/" ifcfg-$PRINIC | ||||
| #		echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC | ||||
| 	fi | ||||
| fi | ||||
| echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC | ||||
| perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config | ||||
| /etc/init.d/network restart | ||||
|  | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| jsi=0 | ||||
| while [ $(hostname) == 'linux' ] | ||||
| do | ||||
| 	if [ $jsi -gt 10 ]; then | ||||
| 		logger "Slept too long!" | ||||
| 		exit | ||||
| 	fi | ||||
| 	let jsi=jsi+1 | ||||
| 	sleep 1 | ||||
| done | ||||
| echo "Slept $jsi seconds before hostname made sense." | ||||
|  | ||||
| HOSTNAME=$(hostname -s) | ||||
| echo $HOSTNAME | ||||
|  | ||||
| /sbin/portmap | ||||
| export MASTER_IP=#XCATVAR:XCATMASTER# | ||||
| export MASTER_IPS=#XCATVAR:XCATMASTER# | ||||
| export MASTER="#XCATVAR:XCATMASTER#" | ||||
| export INSTALLDIR=#TABLE:site:key=installdir:value# | ||||
| if [ -z "$INSTALLDIR" ]; then | ||||
|     INSTALLDIR="/install" | ||||
| fi | ||||
|  | ||||
| # | ||||
| #  This script has not yet been updated to work with service nodes | ||||
| # | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
|     GOTIT=0 | ||||
|     for i in $MASTER_IPS | ||||
|     do | ||||
|         #mount -r $i:/install/postscripts /xcatpost | ||||
|         #wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
|         wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 0 -T 60 http://$i$INSTALLDIR/postscripts/ -P /xcatpost | ||||
|         if [ "$?" = "0" ] | ||||
|         then | ||||
|             if [ -x  /usr/bin/openssl ]; then | ||||
|                 XCATSERVER=$i:3001 | ||||
|                 export XCATSERVER | ||||
|      		USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images | ||||
|      		export USEOPENSSLFORXCAT | ||||
|             else | ||||
|                 exit 1 | ||||
|             fi | ||||
|              mv $i/postscripts /xcatpost | ||||
|              rm -rf $i | ||||
|              chmod +x /xcatpost/* | ||||
|              /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 | ||||
|  | ||||
|                 let SLI=$RANDOM%10+10 | ||||
|                 sleep $SLI | ||||
|                 /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
|                 MYCONT=`grep MASTER /tmp/mypostscript` | ||||
|              done | ||||
|              chmod +x /tmp/mypostscript | ||||
|              GOTIT=1 | ||||
|              break | ||||
|         fi | ||||
|     done | ||||
|     if [ "$GOTIT" = "1" ] | ||||
|     then | ||||
|         #save the master 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 | ||||
|     RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
|     sleep $RAND | ||||
| done | ||||
| 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 "cd /xcatpost" >> /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 | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| #create the post init  | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# | ||||
| EOF | ||||
| 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 | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| #only run the prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
| cd /xcatpost | ||||
| /tmp/mypostscript | ||||
|  | ||||
| updateflag.awk $MASTER 3002 | ||||
| cd / | ||||
| /xcatpost/#TABLE:nodelist:$NODE:node# | ||||
| #rm -Rf /xcatpost | ||||
| #rm -f /tmp/mypostscript | ||||
| #rmdir /xcatpost | ||||
| ]]> | ||||
|  | ||||
|           </source> | ||||
|   | ||||
| @@ -7,31 +7,8 @@ | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
|  | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| jsi=0 | ||||
| while [ $(hostname) == 'linux' ] | ||||
| do | ||||
| 	if [ $jsi -gt 10 ]; then | ||||
| 		logger "Slept too long!" | ||||
| 		exit | ||||
| 	fi | ||||
| 	let jsi=jsi+1 | ||||
| 	sleep 1 | ||||
| done | ||||
| echo "Slept $jsi seconds before hostname made sense." | ||||
|  | ||||
| HOSTNAME=$(hostname -s) | ||||
| echo $HOSTNAME | ||||
|  | ||||
| /sbin/portmap | ||||
| export MASTER_IP=#XCATVAR:XCATMASTER# | ||||
| export MASTER_IPS=#XCATVAR:XCATMASTER# | ||||
| export MASTER="#XCATVAR:XCATMASTER#" | ||||
| export INSTALLDIR=#TABLE:site:key=installdir:value# | ||||
| if [ -z "$INSTALLDIR" ]; then | ||||
|     INSTALLDIR="/install" | ||||
| fi | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sles.common# | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# | ||||
|  | ||||
| # for servicenode, add /install to /etc/fstab | ||||
| echo "$MASTER:/install  /install    nfs timeo=14,intr   1 2" >>/etc/fstab | ||||
| @@ -39,124 +16,6 @@ echo "$MASTER:/install  /install    nfs timeo=14,intr   1 2" >>/etc/fstab | ||||
| # check the arch for nodetype | ||||
| NODE_ARCH=#TABLE:nodetype:$NODE:arch# | ||||
|  | ||||
| # | ||||
| #  This script has not yet been updated to work with service nodes | ||||
| # | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
| 		#mount -r $i:/install/postscripts /xcatpost | ||||
|          wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
|  | ||||
| 	if [ "$?" = "0" ] | ||||
| 		then | ||||
|          XCATSERVER=$i:3001 | ||||
|          export XCATSERVER | ||||
|          if [ -x  /usr/bin/openssl ]; then | ||||
|      	    USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images | ||||
|      	    export USEOPENSSLFORXCAT | ||||
|          fi | ||||
|          mv $i/postscripts /xcatpost | ||||
|          rm -rf $i | ||||
|          chmod +x /xcatpost/* | ||||
|          /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 | ||||
|  | ||||
|             let SLI=$RANDOM%10+10 | ||||
|             sleep $SLI | ||||
|             /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
|             MYCONT=`grep MASTER /tmp/mypostscript` | ||||
|          done | ||||
|          chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	if [ "$GOTIT" = "1" ] | ||||
| 	then | ||||
|             #save the master 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 | ||||
| 	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 the postboot 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 the post init  | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# | ||||
| EOF | ||||
| 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 | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| #only run the prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| /tmp/mypostscript | ||||
| updateflag.awk $MASTER 3002 | ||||
| cd / | ||||
| /xcatpost/#TABLE:nodelist:$NODE:node# | ||||
| #rm -Rf /xcatpost | ||||
| #rm -f /tmp/mypostscript | ||||
| #rmdir /xcatpost | ||||
| ]]> | ||||
|  | ||||
|           </source> | ||||
|   | ||||
| @@ -6,119 +6,8 @@ | ||||
|  | ||||
| <![CDATA[ | ||||
| #!/bin/sh | ||||
|  | ||||
| cd /etc/sysconfig/network | ||||
| rm -f ifcfg-eth-id* | ||||
| rm -f ifcfg-myri* | ||||
| cat >ifcfg-eth0 <<EOF | ||||
| DEVICE=eth0 | ||||
| BOOTPROTO=dhcp | ||||
| STARTMODE=onboot | ||||
| EOF | ||||
|  | ||||
| . /tmp/prinicsetting | ||||
| rm /tmp/prinicsetting | ||||
| if [ "$PRINIC" != "eth0" ] | ||||
| then | ||||
| 	cd /etc/sysconfig/network | ||||
| 	if [ ! -r ifcfg-$PRINIC ] | ||||
| 	then | ||||
| #		cp -f ifcfg-eth0 ifcfg-$PRINIC | ||||
| 		mv -f ifcfg-eth0 ifcfg-$PRINIC | ||||
| 		perl -pi -e "s/eth0/$PRINIC/" ifcfg-$PRINIC | ||||
| #		echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC | ||||
| 	fi | ||||
| fi | ||||
| echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC | ||||
| perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config | ||||
| /etc/init.d/network restart | ||||
|  | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| jsi=0 | ||||
| while [ $(hostname) == 'linux' ] | ||||
| do | ||||
| 	if [ $jsi -gt 10 ]; then | ||||
| 		logger "Slept too long!" | ||||
| 		exit | ||||
| 	fi | ||||
| 	let jsi=jsi+1 | ||||
| 	sleep 1 | ||||
| done | ||||
| echo "Slept $jsi seconds before hostname made sense." | ||||
|  | ||||
| HOSTNAME=$(hostname -s) | ||||
| echo $HOSTNAME | ||||
|  | ||||
| /sbin/portmap | ||||
| export MASTER_IP=#XCATVAR:XCATMASTER# | ||||
| export MASTER_IPS=#XCATVAR:XCATMASTER# | ||||
| export MASTER="#XCATVAR:XCATMASTER#" | ||||
| export INSTALLDIR=#TABLE:site:key=installdir:value# | ||||
| if [ -z "$INSTALLDIR" ]; then | ||||
|     INSTALLDIR="/install" | ||||
| fi | ||||
|  | ||||
| # | ||||
| #  This script has not yet been updated to work with service nodes | ||||
| # | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
|     GOTIT=0 | ||||
|     for i in $MASTER_IPS | ||||
|     do | ||||
|         #mount -r $i:/install/postscripts /xcatpost | ||||
|         wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
|         if [ "$?" = "0" ] | ||||
|         then | ||||
|             if [ -x  /usr/bin/openssl ]; then | ||||
|                 XCATSERVER=$i:3001 | ||||
|                 export XCATSERVER | ||||
|      		USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images | ||||
|      		export USEOPENSSLFORXCAT | ||||
|             else | ||||
|                 exit 1 | ||||
|             fi | ||||
|              mv $i/postscripts /xcatpost | ||||
|              rm -rf $i | ||||
|              chmod +x /xcatpost/* | ||||
|              /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 | ||||
|  | ||||
|                 let SLI=$RANDOM%10+10 | ||||
|                 sleep $SLI | ||||
|                 /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
|                 MYCONT=`grep MASTER /tmp/mypostscript` | ||||
|              done | ||||
|              chmod +x /tmp/mypostscript | ||||
|              GOTIT=1 | ||||
|              break | ||||
|         fi | ||||
|     done | ||||
|     if [ "$GOTIT" = "1" ] | ||||
|     then | ||||
|         #save the master 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 | ||||
|     RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
|     sleep $RAND | ||||
| done | ||||
| PATH=/xcatpost:$PATH | ||||
| export PATH | ||||
|  | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.sles.common# | ||||
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/post.xcat# | ||||
| # Set the second disk to be bootable for RAID1 setup | ||||
| parted -s /dev/sdb mkfs 1 fat16 | ||||
| parted /dev/sdb set 1 type 6 | ||||
| @@ -126,65 +15,6 @@ 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 | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| #create the post init  | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# | ||||
| EOF | ||||
| 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 | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| #only run the prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| /tmp/mypostscript | ||||
|  | ||||
| updateflag.awk $MASTER 3002 | ||||
| cd / | ||||
| /xcatpost/#TABLE:nodelist:$NODE:node# | ||||
| #rm -Rf /xcatpost | ||||
| #rm -f /tmp/mypostscript | ||||
| #rmdir /xcatpost | ||||
| ]]> | ||||
|  | ||||
|           </source> | ||||
|   | ||||
							
								
								
									
										137
									
								
								xCAT-server/share/xcat/install/scripts/post.xcat
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										137
									
								
								xCAT-server/share/xcat/install/scripts/post.xcat
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,137 @@ | ||||
| # | ||||
| # Run xCAT post install | ||||
| # | ||||
| export MASTER_IP="#XCATVAR:XCATMASTER#" | ||||
| export MASTER_IPS="#XCATVAR:XCATMASTER#" | ||||
| export MASTER="#XCATVAR:XCATMASTER#" | ||||
| export INSTALLDIR=#TABLE:site:key=installdir:value# | ||||
| if [ -z "$INSTALLDIR" ]; then | ||||
|     INSTALLDIR="/install" | ||||
| fi | ||||
| cd /tmp | ||||
| RAND=$(perl -e 'print int(rand(50)). "\n"') | ||||
| sleep $RAND | ||||
| for i in $(seq 1 20) | ||||
| do | ||||
| 	GOTIT=0 | ||||
| 	for i in $MASTER_IPS | ||||
| 	do | ||||
|       #wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -t 0 -T 60 ftp://$i/postscripts | ||||
|       wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 0 -T 60 http://$i$INSTALLDIR/postscripts/ -P /xcatpost | ||||
| 		if [ "$?" = "0" ] | ||||
| 		then | ||||
|          if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit | ||||
|             exit 1 | ||||
|          fi | ||||
|        	 USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images | ||||
|      	 export USEOPENSSLFORXCAT | ||||
|          XCATSERVER=$i:3001 | ||||
|          export XCATSERVER | ||||
|          mv $i/postscripts /xcatpost | ||||
|          rm -rf $i | ||||
|          chmod +x /xcatpost/* | ||||
|          /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 | ||||
|  | ||||
|             let SLI=$RANDOM%10+10 | ||||
|             sleep $SLI | ||||
|             /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript | ||||
|             MYCONT=`grep MASTER /tmp/mypostscript` | ||||
|          done | ||||
|  | ||||
|              | ||||
|          chmod +x /tmp/mypostscript | ||||
| 			GOTIT=1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	if [ "$GOTIT" = "1" ] | ||||
| 	then | ||||
|             #save the master 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 | ||||
| 	RAND=$(perl -e 'print int(rand(5)). "\n"') | ||||
| 	sleep $RAND | ||||
| done | ||||
| echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo | ||||
| cd /xcatpost | ||||
| #gunzip xcatpost.tar.gz | ||||
| #tar -xvf xcatpost.tar | ||||
| #/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 | ||||
| chmod 755 /tmp/mypostscript.post | ||||
|  | ||||
| #create the post init  | ||||
| cat >/etc/init.d/xcatpostinit1 << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# | ||||
| EOF | ||||
| chmod 755 /etc/init.d/xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/rc3.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/rc4.d/S84xcatpostinit1 | ||||
| ln -s /etc/init.d/xcatpostinit1 /etc/rc5.d/S84xcatpostinit1 | ||||
| mkdir -p /opt/xcat | ||||
| cat >/opt/xcat/xcatinstallpost << 'EOF' | ||||
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# | ||||
| chkconfig xcatpostinit1 off | ||||
| EOF | ||||
| chmod 755 /opt/xcat/xcatinstallpost | ||||
|  | ||||
| chkconfig --add xcatpostinit1 | ||||
|  | ||||
| #only run the prebooot scripts here | ||||
| TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` | ||||
| echo "$TMP" > /tmp/mypostscript | ||||
|  | ||||
| /tmp/mypostscript | ||||
| export NODE=#TABLE:nodelist:THISNODE:node# | ||||
| export OSVER=#TABLE:nodetype:THISNODE:os# | ||||
| export ARCH=#TABLE:nodetype:THISNODE:arch# | ||||
| addsiteyum | ||||
| sed -i 's/^serial/#serial/' /boot/grub/grub.conf | ||||
| sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf | ||||
| updateflag.awk $MASTER 3002 | ||||
| cd / | ||||
| #rm -Rf /xcatpost | ||||
| #rm -f /tmp/mypostscript | ||||
		Reference in New Issue
	
	Block a user