From 5b31caf7ac2ea11d4dc33229f720b5069d454dcd Mon Sep 17 00:00:00 2001 From: ligc Date: Thu, 29 Mar 2012 03:14:16 +0000 Subject: [PATCH] fix for bug 3487614: move scripts to /xcatpost/mypostscript* and the requirement from bug 3497125 git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@12043 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../share/xcat/install/scripts/post.xcat | 41 ++++++++++--------- xCAT/postscripts/xcatinstallpost | 24 ++++------- 2 files changed, 29 insertions(+), 36 deletions(-) diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index 538d35909..c8ba9e337 100644 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -30,8 +30,8 @@ do 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` + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript + MYCONT=`grep MASTER /xcatpost/mypostscript` MAX_RETRIES=10 RETRY=0 while [ -z "$MYCONT" ]; do @@ -43,12 +43,12 @@ do 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` + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript + MYCONT=`grep MASTER /xcatpost/mypostscript` done - chmod +x /tmp/mypostscript + chmod +x /xcatpost/mypostscript GOTIT=1 break fi @@ -74,7 +74,7 @@ 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` +TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` echo " # subroutine used to run postscripts run_ps () { @@ -84,24 +84,25 @@ run_ps () { if [ -f \$1 ]; then echo \"Running postscript: \$@\" | tee -a \$logfile - ./\$@ 2>&1 1> /tmp/tmp4xcatlog - cat /tmp/tmp4xcatlog | tee -a \$logfile + #./\$@ 2>&1 1> /tmp/tmp4xcatlog + #cat /tmp/tmp4xcatlog | tee -a \$logfile + ./\$@ 2>&1 | 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 +" > /xcatpost/mypostscript +echo "$TMP" >> /xcatpost/mypostscript +TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript` +echo "$TMP" > /xcatpost/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 +#save the postboot scripts to /xcatpost/mypostscript.post +TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /xcatpost/mypostscript` +echo "$TMP" > /xcatpost/mypostscript.post +chmod 755 /xcatpost/mypostscript.post #create the post init cat >/etc/init.d/xcatpostinit1 << 'EOF' @@ -121,10 +122,10 @@ 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=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /xcatpost/mypostscript` +echo "$TMP" > /xcatpost/mypostscript -/tmp/mypostscript +/xcatpost/mypostscript export NODE=#TABLE:nodelist:THISNODE:node# export OSVER=#TABLE:nodetype:THISNODE:os# export ARCH=#TABLE:nodetype:THISNODE:arch# @@ -134,4 +135,4 @@ sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf updateflag.awk $MASTER 3002 cd / #rm -Rf /xcatpost -#rm -f /tmp/mypostscript +#rm -f /xcatpost/mypostscript diff --git a/xCAT/postscripts/xcatinstallpost b/xCAT/postscripts/xcatinstallpost index beb768e31..caea1602e 100755 --- a/xCAT/postscripts/xcatinstallpost +++ b/xCAT/postscripts/xcatinstallpost @@ -19,15 +19,7 @@ PATH=/xcatpost:$PATH export PATH chmod +x /xcatpost/*; -# Traditionally, mypostscript.post has been kept in /tmp across the first boot. -# However, Ubuntu cleans /tmp on reboot. So, for Ubuntu, /var/tmp is used instead. -# Therefore, allow for finding mypostscript.post in /var/tmp or /tmp. - -if [ -e /var/tmp/mypostscript.post ]; then - POST_IN_DIR="/var/tmp" -else - POST_IN_DIR="/tmp" -fi +POST_IN_DIR="/xcatpost" if [ -x /usr/bin/openssl ]; then SIP=`grep "^MASTER=" ${POST_IN_DIR}/mypostscript.post |cut -d= -f2` @@ -37,14 +29,14 @@ if [ -x /usr/bin/openssl ]; then export USEOPENSSLFORXCAT fi -# Regardless of where mypostscript.post was found, modify and run it in /tmp. +# Regardless of where mypostscript.post was found, modify and run it in /xcatpost. -DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' ${POST_IN_DIR}/mypostscript.post` -echo "$DHCP_TMP" > /tmp/mypostscript.post +DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /xcatpost/mypostscript.post` +echo "$DHCP_TMP" > /xcatpost/mypostscript.post -echo "updateflag.awk \$MASTER 3002 \"installstatus booted\"" >> /tmp/mypostscript.post +echo "updateflag.awk \$MASTER 3002 \"installstatus booted\"" >> /xcatpost/mypostscript.post -chmod +x /tmp/mypostscript.post -if [ -x /tmp/mypostscript.post ];then - /tmp/mypostscript.post +chmod +x /xcatpost/mypostscript.post +if [ -x /xcatpost/mypostscript.post ];then + /xcatpost/mypostscript.post fi