2012-03-23 08:26:38 +00:00
|
|
|
#
|
|
|
|
# Run xCAT post install
|
|
|
|
#
|
|
|
|
export MASTER_IP="#XCATVAR:XCATMASTER#"
|
|
|
|
export MASTER_IPS="#XCATVAR:XCATMASTER#"
|
|
|
|
export MASTER="#XCATVAR:XCATMASTER#"
|
2012-09-14 02:46:50 +00:00
|
|
|
export NODESTATUS="#XCATVAR:NODESTATUS#"
|
2012-03-23 08:26:38 +00:00
|
|
|
export INSTALLDIR=#TABLE:site:key=installdir:value#
|
2012-10-15 07:36:06 +00:00
|
|
|
export TFTPDIR=#TABLE:site:key=tftpdir:value#
|
2012-03-23 08:26:38 +00:00
|
|
|
if [ -z "$INSTALLDIR" ]; then
|
|
|
|
INSTALLDIR="/install"
|
|
|
|
fi
|
2012-10-15 07:36:06 +00:00
|
|
|
if [ -z "$TFTPDIR" ]; then
|
|
|
|
|
|
|
|
TFTPDIR="/tftpboot"
|
|
|
|
fi
|
|
|
|
|
2012-03-23 08:26:38 +00:00
|
|
|
cd /tmp
|
|
|
|
RAND=$(perl -e 'print int(rand(50)). "\n"')
|
|
|
|
sleep $RAND
|
2012-05-04 14:27:19 +00:00
|
|
|
for t in $(seq 1 20)
|
2012-03-23 08:26:38 +00:00
|
|
|
do
|
|
|
|
GOTIT=0
|
|
|
|
for i in $MASTER_IPS
|
|
|
|
do
|
2012-04-26 12:40:46 +00:00
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 0 -T 60 http://$i$INSTALLDIR/postscripts/ -P /xcatpost
|
2012-03-23 08:26:38 +00:00
|
|
|
if [ "$?" = "0" ]
|
|
|
|
then
|
2012-10-15 07:36:06 +00:00
|
|
|
|
|
|
|
rm -rf /xcatpost/mypostscript
|
|
|
|
export NODE=#TABLE:nodelist:THISNODE:node#
|
|
|
|
wget -N --waitretry=10 --random-wait -T 60 http://$i$TFTPDIR/mypostscripts/mypostscript.$NODE -P /xcatpost 2> /tmp/wget.log
|
|
|
|
mv /xcatpost/mypostscript.$NODE /xcatpost/mypostscript
|
|
|
|
|
2012-03-23 08:26:38 +00:00
|
|
|
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
|
2012-10-15 07:36:06 +00:00
|
|
|
|
2013-05-21 18:16:33 +00:00
|
|
|
# If mypostscript doesn't exist, we will get it through getpostscript.awk
|
2012-10-15 07:36:06 +00:00
|
|
|
if [ ! -x /xcatpost/mypostscript ]; then
|
|
|
|
|
2012-03-23 08:26:38 +00:00
|
|
|
chmod +x /xcatpost/*
|
2013-05-21 18:16:33 +00:00
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
|
2012-11-22 07:18:38 +00:00
|
|
|
|
|
|
|
|
2012-03-29 03:16:38 +00:00
|
|
|
MYCONT=`grep MASTER /xcatpost/mypostscript`
|
2012-03-23 08:26:38 +00:00
|
|
|
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
|
2013-05-21 18:16:33 +00:00
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
|
2012-11-22 07:18:38 +00:00
|
|
|
|
2012-03-29 03:16:38 +00:00
|
|
|
MYCONT=`grep MASTER /xcatpost/mypostscript`
|
2012-03-23 08:26:38 +00:00
|
|
|
done
|
|
|
|
|
2012-10-15 07:36:06 +00:00
|
|
|
fi
|
2012-03-23 08:26:38 +00:00
|
|
|
|
2012-03-29 03:16:38 +00:00
|
|
|
chmod +x /xcatpost/mypostscript
|
2012-03-23 08:26:38 +00:00
|
|
|
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
|
2013-03-06 15:20:58 +00:00
|
|
|
|
2012-09-17 11:12:39 +00:00
|
|
|
#echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo
|
2012-03-23 08:26:38 +00:00
|
|
|
cd /xcatpost
|
|
|
|
#gunzip xcatpost.tar.gz
|
|
|
|
#tar -xvf xcatpost.tar
|
|
|
|
#/xcatpost/#TABLE:nodelist:THISNODE:node#
|
2013-03-06 15:20:58 +00:00
|
|
|
export PATH=$PATH:/xcatpost
|
2012-03-23 08:26:38 +00:00
|
|
|
|
|
|
|
# use the run_ps subroutine to run the postscripts
|
2012-03-29 03:16:38 +00:00
|
|
|
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /xcatpost/mypostscript`
|
2012-03-23 08:26:38 +00:00
|
|
|
echo "
|
2012-09-14 02:46:50 +00:00
|
|
|
# global value to store the running status of the postbootscripts,the value is non-zero if one postbootscript failed
|
|
|
|
return_value=0
|
2012-03-23 08:26:38 +00:00
|
|
|
# subroutine used to run postscripts
|
|
|
|
run_ps () {
|
2012-09-14 02:46:50 +00:00
|
|
|
local ret_local=0
|
2012-03-23 08:26:38 +00:00
|
|
|
logdir=\"/var/log/xcat\"
|
|
|
|
mkdir -p \$logdir
|
|
|
|
logfile=\"/var/log/xcat/xcat.log\"
|
|
|
|
|
|
|
|
if [ -f \$1 ]; then
|
2012-03-31 02:58:07 +00:00
|
|
|
echo "\"\`date\` Running postscript: \$@\"" | tee -a \$logfile
|
2012-03-29 03:16:38 +00:00
|
|
|
#./\$@ 2>&1 1> /tmp/tmp4xcatlog
|
|
|
|
#cat /tmp/tmp4xcatlog | tee -a \$logfile
|
2012-12-18 02:58:44 +00:00
|
|
|
./\$@ 2>&1 | tee -a \$logfile
|
2012-09-14 02:46:50 +00:00
|
|
|
ret_local=\${PIPESTATUS[0]}
|
|
|
|
if [ \"\$ret_local\" -ne \"0\" ]; then
|
|
|
|
return_value=\$ret_local
|
|
|
|
fi
|
2012-03-23 08:26:38 +00:00
|
|
|
else
|
2012-03-31 02:58:07 +00:00
|
|
|
echo "\"\`date\` Postscript \$1 does NOT exist.\"" | tee -a \$logfile
|
2012-09-14 02:46:50 +00:00
|
|
|
return_value=-1
|
2012-03-23 08:26:38 +00:00
|
|
|
fi
|
2012-09-14 02:46:50 +00:00
|
|
|
|
|
|
|
return 0
|
2012-03-23 08:26:38 +00:00
|
|
|
}
|
|
|
|
# subroutine end
|
|
|
|
|
2012-03-29 03:16:38 +00:00
|
|
|
" > /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
|
2012-03-23 08:26:38 +00:00
|
|
|
|
|
|
|
|
2012-03-29 03:16:38 +00:00
|
|
|
#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
|
2012-03-23 08:26:38 +00:00
|
|
|
|
|
|
|
#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
|
2012-11-01 21:04:26 +00:00
|
|
|
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
|
2012-03-23 08:26:38 +00:00
|
|
|
mkdir -p /opt/xcat
|
|
|
|
cat >/opt/xcat/xcatinstallpost << 'EOF'
|
|
|
|
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
|
2012-11-12 20:38:52 +00:00
|
|
|
if [ -f /xcatpost/mypostscript.post ]; then
|
|
|
|
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2`
|
|
|
|
fi
|
|
|
|
if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
|
|
|
|
chkconfig xcatpostinit1 off
|
|
|
|
fi
|
2013-01-11 11:02:25 +00:00
|
|
|
#echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo
|
2012-03-23 08:26:38 +00:00
|
|
|
EOF
|
|
|
|
chmod 755 /opt/xcat/xcatinstallpost
|
|
|
|
|
2013-01-14 07:48:09 +00:00
|
|
|
export OSVER=#TABLE:nodetype:THISNODE:os#
|
|
|
|
if [[ $OSVER == sles* ]]; then
|
2013-11-05 06:51:25 +00:00
|
|
|
if [[ $OSVER == sles10* ]];then
|
|
|
|
/sbin/insserv xcatpostinit1
|
|
|
|
else
|
|
|
|
/sbin/insserv -p /etc/init.d xcatpostinit1
|
|
|
|
fi
|
2013-01-14 07:48:09 +00:00
|
|
|
fi
|
|
|
|
#chkconfig --add xcatpostinit1
|
2013-01-11 11:34:31 +00:00
|
|
|
chkconfig xcatpostinit1 on
|
2012-03-23 08:26:38 +00:00
|
|
|
|
2012-08-31 15:52:31 +00:00
|
|
|
#create the dskls post
|
|
|
|
cat >/opt/xcat/xcatdsklspost << 'EOF'
|
|
|
|
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatdsklspost#
|
|
|
|
EOF
|
|
|
|
chmod 755 /opt/xcat/xcatdsklspost
|
|
|
|
|
2012-03-23 08:26:38 +00:00
|
|
|
#only run the prebooot scripts here
|
2012-03-29 03:16:38 +00:00
|
|
|
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /xcatpost/mypostscript
|
2012-03-23 08:26:38 +00:00
|
|
|
|
|
|
|
export NODE=#TABLE:nodelist:THISNODE:node#
|
|
|
|
export ARCH=#TABLE:nodetype:THISNODE:arch#
|
|
|
|
addsiteyum
|
2013-03-14 02:43:26 +00:00
|
|
|
/xcatpost/mypostscript
|
2012-03-23 08:26:38 +00:00
|
|
|
sed -i 's/^serial/#serial/' /boot/grub/grub.conf
|
|
|
|
sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf
|
2012-09-14 02:46:50 +00:00
|
|
|
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
|
|
|
|
updateflag.awk $MASTER 3002
|
|
|
|
fi
|
2012-03-23 08:26:38 +00:00
|
|
|
cd /
|
|
|
|
#rm -Rf /xcatpost
|
2012-03-29 03:16:38 +00:00
|
|
|
#rm -f /xcatpost/mypostscript
|