2009-04-08 19:07:57 +00:00
|
|
|
<post-scripts config:type="list">
|
|
|
|
<script>
|
|
|
|
<filename>xcat.sh</filename>
|
|
|
|
<interpreter>shell</interpreter>
|
|
|
|
<source>
|
|
|
|
|
|
|
|
<![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#"
|
|
|
|
|
|
|
|
# for servicenode, add /install to /etc/fstab
|
|
|
|
echo "$MASTER:/install /install nfs timeo=14,intr 1 2" >>/etc/fstab
|
|
|
|
|
|
|
|
# check the arch for nodetype
|
|
|
|
NODE_ARCH=#TABLE:nodetype:$NODE:arch#
|
|
|
|
|
2009-12-15 15:10:07 +00:00
|
|
|
#
|
|
|
|
# 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/*
|
2011-08-15 15:55:42 +00:00
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /var/tmp/mypostscript
|
|
|
|
MYCONT=`grep MASTER /var/tmp/mypostscript`
|
2009-12-15 15:10:07 +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
|
2011-08-15 15:55:42 +00:00
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /var/tmp/mypostscript
|
|
|
|
MYCONT=`grep MASTER /var/tmp/mypostscript`
|
2009-12-15 15:10:07 +00:00
|
|
|
done
|
2011-08-15 15:55:42 +00:00
|
|
|
chmod +x /var/tmp/mypostscript
|
2009-12-15 15:10:07 +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
|
|
|
|
PATH=/xcatpost:$PATH
|
|
|
|
export PATH
|
2009-07-10 18:34:09 +00:00
|
|
|
|
2009-12-15 15:10:07 +00:00
|
|
|
#save the postboot scripts to /tmp/mypostscript.post
|
2011-08-15 15:55:42 +00:00
|
|
|
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /var/tmp/mypostscript`
|
|
|
|
echo "$TMP" > /var/tmp/mypostscript.post
|
|
|
|
chmod 755 /var/tmp/mypostscript.post
|
2009-12-15 15:10:07 +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
|
|
|
|
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
|
2009-07-10 18:34:09 +00:00
|
|
|
mkdir -p /opt/xcat
|
2009-12-15 15:10:07 +00:00
|
|
|
cat >/opt/xcat/xcatinstallpost << 'EOF'
|
|
|
|
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
|
|
|
|
chkconfig xcatpostinit1 off
|
2009-07-10 18:34:09 +00:00
|
|
|
EOF
|
2009-12-15 15:10:07 +00:00
|
|
|
chmod 755 /opt/xcat/xcatinstallpost
|
2009-07-10 18:34:09 +00:00
|
|
|
|
2009-12-15 15:10:07 +00:00
|
|
|
chkconfig --add xcatpostinit1
|
2009-09-09 20:36:53 +00:00
|
|
|
|
2009-12-15 15:10:07 +00:00
|
|
|
#only run the prebooot scripts here
|
2011-08-15 15:55:42 +00:00
|
|
|
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /var/tmp/mypostscript`
|
|
|
|
echo "$TMP" > /var/tmp/mypostscript
|
2009-12-15 15:10:07 +00:00
|
|
|
|
2011-08-15 15:55:42 +00:00
|
|
|
/var/tmp/mypostscript
|
2009-12-15 15:10:07 +00:00
|
|
|
updateflag.awk $MASTER 3002
|
|
|
|
cd /
|
|
|
|
/xcatpost/#TABLE:nodelist:$NODE:node#
|
|
|
|
#rm -Rf /xcatpost
|
|
|
|
#rm -f /tmp/mypostscript
|
|
|
|
#rmdir /xcatpost
|
2009-04-08 19:07:57 +00:00
|
|
|
]]>
|
|
|
|
|
|
|
|
</source>
|
|
|
|
</script>
|
|
|
|
</post-scripts>
|
2009-12-15 15:10:07 +00:00
|
|
|
|