diff --git a/xCAT-server/share/xcat/install/scripts/post.ubuntu b/xCAT-server/share/xcat/install/scripts/post.ubuntu index 3e32d4712..6c4249b1c 100644 --- a/xCAT-server/share/xcat/install/scripts/post.ubuntu +++ b/xCAT-server/share/xcat/install/scripts/post.ubuntu @@ -31,7 +31,7 @@ done >>/etc/resolv.conf export MASTER_IP="#XCATVAR:XCATMASTER#" export MASTER_IPS="#XCATVAR:XCATMASTER#" export MASTER="#XCATVAR:XCATMASTER#" -cd /var/tmp +cd /tmp RAND=$(perl -e 'print int(rand(50)). "\n"') sleep $RAND for i in $(seq 1 20) @@ -53,8 +53,8 @@ do mv $i/postscripts /xcatpost rm -rf $i chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /var/tmp/mypostscript - MYCONT=`grep MASTER /var/tmp/mypostscript` + /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 @@ -66,12 +66,12 @@ do let SLI=$RANDOM%10+10 sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /var/tmp/mypostscript - MYCONT=`grep MASTER /var/tmp/mypostscript` + /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript + MYCONT=`grep MASTER /tmp/mypostscript` done - chmod +x /var/tmp/mypostscript + chmod +x /tmp/mypostscript GOTIT=1 break fi @@ -96,7 +96,11 @@ cd /xcatpost export PATH=/xcatpost:$PATH #save the postboot scripts to /var/tmp/mypostscript.post -TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /var/tmp/mypostscript` +# +# 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. + +TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript` echo "$TMP" > /var/tmp/mypostscript.post chmod 755 /var/tmp/mypostscript.post @@ -114,10 +118,10 @@ EOF chmod 755 /opt/xcat/xcatinstallpost #only run the prebooot scripts here -TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /var/tmp/mypostscript` -echo "$TMP" > /var/tmp/mypostscript +TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript` +echo "$TMP" > /tmp/mypostscript -/var/tmp/mypostscript +/tmp/mypostscript export NODE=#TABLE:nodelist:THISNODE:node# export OSVER=#TABLE:nodetype:THISNODE:os# export ARCH=#TABLE:nodetype:THISNODE:arch# @@ -134,6 +138,6 @@ sed -i 's/\(deb.*security.*\)/#\1/' /etc/apt/sources.list updateflag.awk $MASTER 3002 cd / #rm -Rf /xcatpost -#rm -f /var/tmp/mypostscript +#rm -f /tmp/mypostscript exit 0 diff --git a/xCAT/postscripts/xcatinstallpost b/xCAT/postscripts/xcatinstallpost index 087ee014a..054b4b01a 100755 --- a/xCAT/postscripts/xcatinstallpost +++ b/xCAT/postscripts/xcatinstallpost @@ -19,21 +19,32 @@ 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 + if [ -x /usr/bin/openssl ]; then - SIP=`grep "^MASTER=" /var/tmp/mypostscript.post |cut -d= -f2` + SIP=`grep "^MASTER=" ${POST_IN_DIR}/mypostscript.post |cut -d= -f2` XCATSERVER="$SIP: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 fi +# Regardless of where mypostscript.post was found, modify and run it in /tmp. -DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /var/tmp/mypostscript.post` -echo "$DHCP_TMP" > /var/tmp/mypostscript.post +DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' ${POST_IN_DIR}/mypostscript.post` +echo "$DHCP_TMP" > /tmp/mypostscript.post -echo "updateflag.awk \$MASTER 3002 \"installstatus booted\"" >> /var/tmp/mypostscript.post +echo "updateflag.awk \$MASTER 3002 \"installstatus booted\"" >> /tmp/mypostscript.post -chmod +x /var/tmp/mypostscript.post -if [ -x /var/tmp/mypostscript.post ];then - /var/tmp/mypostscript.post +chmod +x /tmp/mypostscript.post +if [ -x /tmp/mypostscript.post ];then + /tmp/mypostscript.post fi diff --git a/xCAT/postscripts/xcatpostinit b/xCAT/postscripts/xcatpostinit index c213fc0fd..da837ce6f 100755 --- a/xCAT/postscripts/xcatpostinit +++ b/xCAT/postscripts/xcatpostinit @@ -34,9 +34,6 @@ stop) logger -t xcat "nothing to stop" ;; start) - # For nodes that unmount/remove /tmp at install time, like ubuntu - #cp /root/mypostscript* /tmp/. - # Node is stateless by default STATELITE="No" diff --git a/xCAT/postscripts/xcatpostinit1 b/xCAT/postscripts/xcatpostinit1 index e4f4cc010..f3ae9f4f6 100755 --- a/xCAT/postscripts/xcatpostinit1 +++ b/xCAT/postscripts/xcatpostinit1 @@ -31,9 +31,6 @@ stop) echo -n "nothing to stop " ;; start) - # For nodes that unmount/remove /tmp at install time, like ubuntu - #cp /root/mypostscript* /tmp/. - # run /opt/xcat/xcatinstallpost if [ -r /opt/xcat/xcatinstallpost ]; then /opt/xcat/xcatinstallpost