mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-30 19:02:27 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			469 lines
		
	
	
		
			17 KiB
		
	
	
	
		
			Plaintext
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			469 lines
		
	
	
		
			17 KiB
		
	
	
	
		
			Plaintext
		
	
	
		
			Executable File
		
	
	
	
	
| #
 | |
| # Run xCAT post install
 | |
| #
 | |
| export MASTER_IP="#ENV:MASTER_IP#"
 | |
| export MASTER="#XCATVAR:XCATMASTER#"
 | |
| export NODESTATUS="#XCATVAR:NODESTATUS#"
 | |
| export XCATIPORT=#TABLE:site:key=xcatiport:value#
 | |
| export INSTALLDIR=#TABLE:site:key=installdir:value#
 | |
| export TFTPDIR=#TABLE:site:key=tftpdir:value#
 | |
| export XCATDEBUGMODE="#TABLEBLANKOKAY:site:key=xcatdebugmode:value#"
 | |
| 
 | |
| #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib#
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     set -x
 | |
| fi
 | |
| 
 | |
| if [ -z "$XCATIPORT" ]; then
 | |
|     XCATIPORT="3002"
 | |
| fi
 | |
| if [ -z "$INSTALLDIR" ]; then
 | |
|     INSTALLDIR="/install"
 | |
| fi
 | |
| if [ -z "$TFTPDIR" ]; then
 | |
|     TFTPDIR="/tftpboot"
 | |
| fi
 | |
| if [[ $TFTPDIR != /* ]]; then
 | |
|     TFTPDIR="/"$TFTPDIR
 | |
| fi
 | |
| 
 | |
| 
 | |
| (cat  << 'EOF'
 | |
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk#
 | |
| EOF
 | |
| ) >/tmp/updateflag
 | |
| 
 | |
| cd /tmp
 | |
| RAND=$(perl -e 'print int(rand(50)). "\n"')
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|    msgutil_r "$MASTER_IP" "debug" "sleep $RAND" "/var/log/xcat/xcat.log"
 | |
| fi
 | |
| sleep $RAND
 | |
| 
 | |
| # Stop if no openssl to help the next bit
 | |
| if [ ! -x /usr/bin/openssl ]; then
 | |
|     msgutil_r "$MASTER_IP" "debug" "/usr/bin/openssl does not exist, halt ..." "/var/log/xcat/xcat.log"
 | |
|     /tmp/updateflag $MASTER $XCATIPORT "installstatus failed"
 | |
|     sleep 36500d
 | |
| fi
 | |
| 
 | |
| #save to /opt/xcat/xcatinfo file
 | |
| if [ ! -f /opt/xcat/xcatinfo ]; then
 | |
|     mkdir -p /opt/xcat
 | |
|     touch /opt/xcat/xcatinfo
 | |
| fi
 | |
| 
 | |
| grep 'XCATSERVER' /opt/xcat/xcatinfo > /dev/null 2>&1
 | |
| if [ $? -eq 0 ]; then
 | |
|     sed -i "s/XCATSERVER=.*/XCATSERVER=$MASTER_IP/" /opt/xcat/xcatinfo
 | |
| else
 | |
|     echo "XCATSERVER=$MASTER_IP" >> /opt/xcat/xcatinfo
 | |
| fi
 | |
| 
 | |
| grep 'INSTALLDIR' /opt/xcat/xcatinfo > /dev/null 2>&1
 | |
| if [ $? -eq 0 ]; then
 | |
|     sed -i "s/INSTALLDIR=.*/INSTALLDIR=$INSTALLDIR/" /opt/xcat/xcatinfo
 | |
| else
 | |
|     echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo
 | |
| fi
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     msgutil_r "$MASTER_IP" "debug" "/opt/xcat/xcatinfo generated" "/var/log/xcat/xcat.log"
 | |
| fi
 | |
| 
 | |
| 
 | |
| # download the postscripts
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     msgutil_r "$MASTER_IP" "debug" "trying to download postscripts from http://$MASTER_IP$INSTALLDIR/postscripts/" "/var/log/xcat/xcat.log"
 | |
| fi
 | |
| 
 | |
| # Stop if no wget to help the next bit
 | |
| if [ ! -x /usr/bin/wget ]; then
 | |
|     msgutil_r "$MASTER_IP" "debug" "/usr/bin/wget does not exist, halt ..." "/var/log/xcat/xcat.log"
 | |
|     /tmp/updateflag $MASTER $XCATIPORT "installstatus failed"
 | |
|     sleep 36500d
 | |
| fi
 | |
| 
 | |
| wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused  -e robots=off -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 20 -T 60 http://$MASTER_IP$INSTALLDIR/postscripts/ -P /xcatpost
 | |
| if [ "$?" != "0" ]; then
 | |
|     msgutil_r "$MASTER_IP" "debug" "failed to download postscripts from http://$MASTER_IP$INSTALLDIR/postscripts/, halt ..." "/var/log/xcat/xcat.log"
 | |
|     /tmp/updateflag $MASTER $XCATIPORT "installstatus failed"
 | |
|     sleep 36500d
 | |
| fi
 | |
| chmod -R +x `find /xcatpost/ -maxdepth 1 -print | grep -E -v '^(/xcatpost/|/xcatpost/_xcat|/xcatpost/_ssh|/xcatpost/ca|/xcatpost/hostkeys)$'`
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     msgutil_r "$MASTER_IP" "debug" "postscripts downloaded successfully" "/var/log/xcat/xcat.log"
 | |
| fi
 | |
| 
 | |
| 
 | |
| # get the precreated mypostscript file
 | |
| if [ -x /xcatpost/mypostscript ]; then
 | |
|     rm -rf /xcatpost/mypostscript
 | |
| fi
 | |
| export NODE=#TABLE:nodelist:THISNODE:node#
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     msgutil_r "$MASTER_IP" "debug" "trying to download precreated mypostscript file http://$MASTER_IP$TFTPDIR/mypostscripts/mypostscript.$NODE" "/var/log/xcat/xcat.log"
 | |
| fi
 | |
| 
 | |
| wget -N --waitretry=10 --random-wait --retry-connrefused -t 20 -T 60 http://$MASTER_IP$TFTPDIR/mypostscripts/mypostscript.$NODE  -P /xcatpost 2> /tmp/wget.log
 | |
| if [ "$?" = "0" ]; then
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "precreated mypostscript downloaded successfully" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
|     mv /xcatpost/mypostscript.$NODE /xcatpost/mypostscript
 | |
|     chmod +x /xcatpost/mypostscript
 | |
| 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=$MASTER_IP:3001
 | |
| export XCATSERVER
 | |
| 
 | |
| # If mypostscript doesn't exist, we will get it through getpostscript.awk
 | |
| if [ ! -x /xcatpost/mypostscript ]; then
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "failed to download precreated mypostscript, trying to generate with getpostscript.awk" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| 
 | |
|     # To support the postscripts in the subdirectories under /install/postscripts
 | |
|     # chmod +x /xcatpost/*
 | |
|     # Stop if no getpostscript.awk to help the next bit
 | |
|     if [ ! -x /xcatpost/getpostscript.awk ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "/xcatpost/getpostscript.awk does not exist, halt ..." "/var/log/xcat/xcat.log"
 | |
|         /tmp/updateflag $MASTER $XCATIPORT "installstatus failed"
 | |
|         sleep 36500d
 | |
|     fi
 | |
|     /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript
 | |
| 
 | |
|     MYCONT=`grep ^MASTER= /xcatpost/mypostscript`
 | |
|     RETRY=0
 | |
|     while [ -z "$MYCONT" ]; do
 | |
|         RETRY=$(($RETRY+1))
 | |
|         if [ $RETRY -eq "10" ]; then
 | |
|             break
 | |
|         fi
 | |
| 
 | |
|         let SLI=$RANDOM%10+10
 | |
|         sleep $SLI
 | |
|         /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /xcatpost/mypostscript
 | |
| 
 | |
|         MYCONT=`grep ^MASTER= /xcatpost/mypostscript`
 | |
|     done
 | |
| fi
 | |
| 
 | |
| TMP=`sed "/^#\s*postscripts-start-here/,/^#\s*postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
 | |
| echo "$TMP" > /xcatpost/mypostscript
 | |
| TMP=`sed "/^#\s*postbootscripts-start-here/,/^#\s*postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
 | |
| 
 | |
| cd /xcatpost
 | |
| #gunzip xcatpost.tar.gz
 | |
| #tar -xvf xcatpost.tar
 | |
| #/xcatpost/#TABLE:nodelist:THISNODE:node#
 | |
| export PATH=$PATH:/xcatpost
 | |
| 
 | |
| # use the run_ps subroutine to run the postscripts
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     echo "set -x" > /xcatpost/mypostscript
 | |
| else
 | |
|     cat /dev/null > /xcatpost/mypostscript
 | |
| fi
 | |
| 
 | |
| echo "
 | |
| 
 | |
| . /xcatpost/xcatlib.sh
 | |
| 
 | |
| # global value to store the running status of the postbootscripts,the value is non-zero if one postbootscript failed
 | |
| return_value=0
 | |
| # subroutine used to run postscripts
 | |
| run_ps () {
 | |
|  local ret_local=0
 | |
|  mkdir -p "\"/var/log/xcat\""
 | |
|  # On some Linux distro, the rsyslogd daemon write log files with permision
 | |
|  # other than root:root. And in some case, the directory /var/log/xcat was
 | |
|  # created by xCAT, and had root:root ownership. In this way, rsyslogd
 | |
|  # did not have enough permission to write to log files under this directory.
 | |
|  # As a dirty hack, change the ownership of directory /var/log/xcat to the
 | |
|  # same ownership of directory /var/log.
 | |
|  chown `ls -ld /var/log | awk '{ print \$3\":\"\$4 }'` "\"/var/log/xcat\""
 | |
|  local logfile=\"/var/log/xcat/xcat.log\"
 | |
| 
 | |
|  if [ -f \$1 ]; then
 | |
|   echo \"\`date\` Running postscript: \$*\"
 | |
|   msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Running postscript: \$*\"" \"\$logfile\"
 | |
|   if [ \"\$XCATDEBUGMODE\" = \"1\" ] || [ \"\$XCATDEBUGMODE\" = \"2\" ]; then
 | |
|      local compt=\$(file \$1)
 | |
|      local reg=\"shell script\"
 | |
|      if [[ \"\$compt\" =~ \$reg ]]; then
 | |
|         bash -x ./\$@ 2>&1
 | |
|         ret_local=\$?
 | |
|      else
 | |
|         ./\$@ 2>&1 | tee -a \$logfile |  logger -t xcat -p debug
 | |
|         ret_local=\${PIPESTATUS[0]}
 | |
|      fi
 | |
|   else
 | |
|      ./\$@ 2>&1 | tee -a \$logfile
 | |
|      ret_local=\${PIPESTATUS[0]}
 | |
|   fi
 | |
| 
 | |
|   if [ \"\$ret_local\" -ne \"0\" ]; then
 | |
|      return_value=\$ret_local
 | |
|   fi
 | |
|   echo \"Postscript: \$* exited with code \$ret_local\"
 | |
|   msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` postscript \$* return with \$ret_local\"" \"\$logfile\"
 | |
|  else
 | |
|   echo \"\`date\` Postscript \$1 does NOT exist.\" 
 | |
|   msgutil_r \"\$MASTER_IP\" \"info\" "\"\`date\` Postscript \$1 does NOT exist.\"" \"\$logfile\"
 | |
|   return_value=-1
 | |
|  fi
 | |
| 
 | |
|  return 0
 | |
| }
 | |
| # subroutine end
 | |
| 
 | |
| " >> /xcatpost/mypostscript
 | |
| echo "$TMP" >> /xcatpost/mypostscript
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     echo "set +x" >> /xcatpost/mypostscript
 | |
| fi
 | |
| 
 | |
| chmod +x /xcatpost/mypostscript
 | |
| if [ ! -x /xcatpost/mypostscript ]; then
 | |
|     msgutil_r "$MASTER_IP" "debug" "generate mypostscript file failure, halt ..." "/var/log/xcat/xcat.log"
 | |
|     /tmp/updateflag $MASTER $XCATIPORT "installstatus failed"
 | |
|     sleep 36500d
 | |
| else
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "generate mypostscript file successfully" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| 
 | |
| #save the postboot scripts to /xcatpost/mypostscript.post
 | |
| TMP=`sed "/^#\s*postscripts-start-here/,/^#\s*postscripts-end-here/ d" /xcatpost/mypostscript`
 | |
| echo "$TMP" > /xcatpost/mypostscript.post
 | |
| chmod 755 /xcatpost/mypostscript.post
 | |
| 
 | |
| if [ ! -x /xcatpost/mypostscript.post ]; then
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "failed to generate /xcatpost/mypostscript.post" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| else
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "/xcatpost/mypostscript.post generated" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| 
 | |
| #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
 | |
| 
 | |
| if [ ! -x /etc/init.d/xcatpostinit1 ]; then
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "failed to generate /etc/init.d/xcatpostinit1" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| else
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "/etc/init.d/xcatpostinit1 generated" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| export OSVER=#TABLE:nodetype:THISNODE:os#
 | |
| 
 | |
| if [[ $OSVER == ubuntu* ]]; then
 | |
|     ln -s /etc/init.d/xcatpostinit1 /etc/rc2.d/S84xcatpostinit1
 | |
| else
 | |
|     ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc3.d/S84xcatpostinit1
 | |
|     ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc4.d/S84xcatpostinit1
 | |
|     ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc5.d/S84xcatpostinit1
 | |
| fi
 | |
| 
 | |
| if [[ $OSVER == ubuntu* ]]; then
 | |
|     update-rc.d xcatpostinit1 defaults
 | |
| else
 | |
|     if [[ $OSVER == sles* ]]; then
 | |
|         if [[ $OSVER == sles10* ]]; then
 | |
|             /sbin/insserv xcatpostinit1
 | |
|         else
 | |
|             /sbin/insserv -p /etc/init.d xcatpostinit1
 | |
|         fi
 | |
|     fi
 | |
|     #chkconfig --add xcatpostinit1
 | |
|     chkconfig xcatpostinit1 on
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "service xcatpostinit1 enabled" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| 
 | |
| #create the xcatinstallpost
 | |
| mkdir -p /opt/xcat
 | |
| cat >/opt/xcat/xcatinstallpost << 'EOF'
 | |
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
 | |
| 
 | |
| if [ -f /xcatpost/mypostscript.post ]; then
 | |
|     RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2`
 | |
| fi
 | |
| 
 | |
| if [[ $OSVER == ubuntu* ]]; then
 | |
|     if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
 | |
|         update-rc.d -f xcatpostinit1 remove
 | |
|     fi
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "update-rc.d -f xcatpostinit1 remove" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| else
 | |
|     if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
 | |
|         chkconfig xcatpostinit1 off
 | |
|     fi
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "service xcatpostinit1 disabled" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| EOF
 | |
| chmod 755 /opt/xcat/xcatinstallpost
 | |
| 
 | |
| if [ ! -x /opt/xcat/xcatinstallpost ]; then
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "failed to generate /opt/xcat/xcatinstallpost" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| else
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "/opt/xcat/xcatinstallpost generated" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| 
 | |
| #create the dskls post 
 | |
| cat >/opt/xcat/xcatdsklspost << 'EOF'
 | |
| #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatdsklspost#
 | |
| EOF
 | |
| chmod 755 /opt/xcat/xcatdsklspost
 | |
| 
 | |
| if [ ! -x /opt/xcat/xcatdsklspost ]; then
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "failed to generate /opt/xcat/xcatdsklspost" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| else
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|         msgutil_r "$MASTER_IP" "debug" "/opt/xcat/xcatdsklspost generated" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| 
 | |
| #create the preboot script and run here
 | |
| TMP=`sed "/^#\s*postbootscripts-start-here/,/^#\s*postbootscripts-end-here/ d" /xcatpost/mypostscript`
 | |
| echo "$TMP" > /xcatpost/mypostscript
 | |
| chmod 755 /xcatpost/mypostscript
 | |
| 
 | |
| export ARCH=#TABLE:nodetype:THISNODE:arch#
 | |
| export CONSOLEPORT=#TABLEBLANKOKAY:nodehm:THISNODE:serialport#
 | |
| if [[ $OSVER != ubuntu* ]]; then
 | |
|     addsiteyum
 | |
| fi
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|    msgutil_r "$MASTER_IP" "info" "running mypostscript" "/var/log/xcat/xcat.log"
 | |
| fi
 | |
| /xcatpost/mypostscript
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|    msgutil_r "$MASTER_IP" "info" "mypostscript returned" "/var/log/xcat/xcat.log"
 | |
| fi
 | |
| 
 | |
| 
 | |
| if [[ $OSVER == ubuntu* ]]; then
 | |
|     if [[ -r /boot/grub/menu.lst ]]; then
 | |
|         sed -i 's/^serial/#serial/' /boot/grub/menu.lst
 | |
|         sed -i 's/^terminal/#terminal/' /boot/grub/menu.lst
 | |
|     elif [[ -r /boot/grub/grub.cfg ]] ; then
 | |
|         update-grub
 | |
|     fi
 | |
|     
 | |
|     #print the kernel messages and service start messages with systemd on the console during system bootup
 | |
|     [ -f /etc/default/grub ] && sed -i -e '/GRUB_CMDLINE_LINUX_DEFAULT=/s/quiet//;s/splash//' -e '/#GRUB_TERMINAL=/s/#//' -e 's/#GRUB_GFXMODE=.*/GRUB_GFXMODE=text/' /etc/default/grub && update-grub
 | |
| 
 | |
|     if echo "$ARCH" | grep -i 'x86_64'; then
 | |
|         #grab the install-time console configuration from /proc/cmdline inside os installer
 | |
|         CONSOLECFG=$(awk 'BEGIN{RS="[ \n]" ;ORS=" "} $0 ~ /^console=/{print $0}' /proc/cmdline)
 | |
|         #if the console configuration is not applied to the grub configuration,apply it 
 | |
|         cat /boot/grub/grub.cfg |grep "$CONSOLECFG" >/dev/null 2>&1 || ([ -f /etc/default/grub ] && sed -i -e "/GRUB_CMDLINE_LINUX_DEFAULT=/s/=\"/=\" $CONSOLECFG /" /etc/default/grub && update-grub)
 | |
|     fi 
 | |
|     if echo "$ARCH" | grep -i 'ppc64'; then
 | |
|         if [ -z "$CONSOLEPORT" ] ; then
 | |
|             export CONSOLEPORT=0
 | |
|         fi
 | |
|         CONSOLE="hvc$CONSOLEPORT"
 | |
|         if [[ -r /etc/default/grub ]] ; then
 | |
|             sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"/" /etc/default/grub
 | |
|         else
 | |
|             echo "GRUB_CMDLINE_LINUX_DEFAULT=\"console=$CONSOLE\"" > /etc/default/grub
 | |
|         fi
 | |
|         update-grub
 | |
| 
 | |
| cat >/etc/init/$CONSOLE\.conf << 'EOF'
 | |
| start on stopped rc RUNLEVEL=[2345] and (
 | |
|          not-container or 
 | |
|          container CONTAINER=lxc or 
 | |
|          container CONTAINER=lxc-libvirt)
 | |
| 
 | |
| stop on runlevel [!2345]
 | |
| respawn
 | |
| #exec /sbin/getty -L 115200 hvc0 vt102
 | |
| script
 | |
|     for i in `cat /proc/cmdline`; do
 | |
|         KEY=`echo $i|cut -d= -f 1`
 | |
|         if [ "$KEY" == "console" -a "$i" != "console=tty0" ]; then
 | |
|             VALUE=`echo $i | awk -F= '{print $2}'`
 | |
|             COTTY=`echo $VALUE|awk -F, '{print $1}'`
 | |
|             COSPEED=`echo $VALUE|awk -F, '{print $2}'|awk -Fn '{print $1}'`
 | |
| 
 | |
|             break
 | |
|         fi
 | |
|     done
 | |
| 
 | |
|     exec /sbin/getty -L $COSPEED $COTTY vt102
 | |
| end script
 | |
| EOF
 | |
|     fi
 | |
|     sed -i '/127.0.1.1/d' /etc/hosts
 | |
| else
 | |
|     sed -i 's/^serial/#serial/' /boot/grub/grub.conf
 | |
|     sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf
 | |
|     if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|        msgutil_r "$MASTER_IP" "debug" "/boot/grub/grub.conf updated" "/var/log/xcat/xcat.log"
 | |
|     fi
 | |
| fi
 | |
| 
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|    msgutil_r "$MASTER_IP" "info" "finished node installation, reporting status..." "/var/log/xcat/xcat.log"
 | |
| fi
 | |
| #the following command should always be run to prevent infinite installation loops
 | |
| updateflag.awk $MASTER 3002
 | |
| 
 | |
| cd /
 | |
| 
 | |
| # fix the issue#929@github, the "service network restart" in <sles post scripts>  
 | |
| # makes the 'network' service in start status, then it causes the
 | |
| # services YaST2-Second-Stage.service and xcatpostinit1 services to be run in parallel.
 | |
| # But the YaST2-Second-Stage.service calls the Yast2 which conflics with the zypper
 | |
| # which is called in xcatpostinit1->otherpkgs. 
 | |
| # The correct services start order is 'YaST2-Second-Stage.service'->'network'->'xcatpostinit1' in serial.
 | |
| # To skip the conflict, the network service should be stoped in the yast first stage. Then base on the service
 | |
| # dependency, the service start order will be 'YaST2-Second-Stage.service'->'network'->'xcatpostinit1' in serial.
 | |
| # Then the Yast2 will be stopped before running the zypper in otherpkgs.
 | |
| if [[ $OSVER =~ sles && $OSVER != sles11* ]]; then
 | |
|     service network stop
 | |
| fi
 | |
| 
 | |
| if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
 | |
|     set +x
 | |
| fi
 |