2007-10-26 22:44:33 +00:00
|
|
|
<post-scripts config:type="list">
|
|
|
|
<script>
|
|
|
|
<filename>xcat.sh</filename>
|
|
|
|
<interpreter>shell</interpreter>
|
|
|
|
<source>
|
|
|
|
|
|
|
|
<![CDATA[
|
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
cd /etc/sysconfig/network
|
|
|
|
rm -f ifcfg-eth-id*
|
|
|
|
rm -f ifcfg-myri*
|
|
|
|
cat >ifcfg-eth0 <<EOF
|
|
|
|
DEVICE=eth0
|
|
|
|
BOOTPROTO=dhcp
|
|
|
|
STARTMODE=onboot
|
|
|
|
EOF
|
|
|
|
|
2010-05-04 18:22:41 +00:00
|
|
|
export PRINIC=#TABLEBLANKOKAY:noderes:THISNODE:primarynic#
|
2010-05-07 15:56:03 +00:00
|
|
|
if [ "$PRINIC" == "mac" ]
|
2010-03-03 03:27:16 +00:00
|
|
|
then
|
2010-05-07 15:56:03 +00:00
|
|
|
export PRINIC='#TABLE:mac:THISNODE:mac#'
|
2010-03-03 03:27:16 +00:00
|
|
|
fi
|
2010-05-04 18:22:41 +00:00
|
|
|
if [ -z "$PRINIC" ]
|
|
|
|
then
|
2010-06-04 13:32:43 +00:00
|
|
|
for karg in $(cat /proc/cmdline |sed -e 's/-/:/g' -e 's/ /\n/g'); do
|
2010-05-04 18:22:41 +00:00
|
|
|
if [ "${karg%%=*}" = "BOOTIF" ]; then
|
2010-06-04 13:32:43 +00:00
|
|
|
export PRINIC=`ifconfig -a|grep -i "hwaddr ${karg#*=01:}"|awk '{print $1}'`
|
2010-05-04 18:22:41 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [ -z "$PRINIC" ]; then
|
|
|
|
export PRINIC=eth0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -z "$PRINIC" ]
|
|
|
|
then
|
2007-10-26 22:44:33 +00:00
|
|
|
export PRINIC=eth0
|
2010-03-02 11:29:01 +00:00
|
|
|
elif [[ `echo "$PRINIC" | grep -sqE ^[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+:[A-Fa-f0-9]+$ ;echo $?` == "0" ]]; then
|
|
|
|
export PRINIC=`ifconfig -a | grep -i "HWaddr $PRINIC" | awk '{print $1}'`
|
2007-10-26 22:44:33 +00:00
|
|
|
fi
|
|
|
|
if [ "$PRINIC" != "eth0" ]
|
|
|
|
then
|
|
|
|
cd /etc/sysconfig/network
|
|
|
|
if [ ! -r ifcfg-$PRINIC ]
|
|
|
|
then
|
|
|
|
cp -f ifcfg-eth0 ifcfg-$PRINIC
|
|
|
|
perl -pi -e "s/eth0/$PRINIC/" ifcfg-$PRINIC
|
|
|
|
echo "DHCLIENT_PRIMARY_DEVICE=yes" >> ifcfg-$PRINIC
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
perl -pi -e 's/^FIREWALL="yes"/FIREWALL="no"/' /etc/sysconfig/network/config
|
|
|
|
/etc/init.d/network restart
|
|
|
|
|
|
|
|
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
|
2009-12-15 15:10:07 +00:00
|
|
|
export MASTER_IP=#XCATVAR:XCATMASTER#
|
|
|
|
export MASTER_IPS=#XCATVAR:XCATMASTER#
|
|
|
|
export MASTER="#XCATVAR:XCATMASTER#"
|
2011-11-11 05:59:28 +00:00
|
|
|
export INSTALLDIR=#TABLE:site:key=installdir:value#
|
|
|
|
if [ -z "$INSTALLDIR" ]; then
|
|
|
|
INSTALLDIR="/install"
|
|
|
|
fi
|
2008-04-22 14:14:33 +00:00
|
|
|
|
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
|
2011-11-10 14:26:08 +00:00
|
|
|
#wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/postscripts
|
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 0 -T 60 http://$i$INSTALLDIR/postscripts/ -P /xcatpost
|
2009-12-15 15:10:07 +00:00
|
|
|
if [ "$?" = "0" ]
|
|
|
|
then
|
|
|
|
if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
XCATSERVER=$i: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
|
|
|
|
mv $i/postscripts /xcatpost
|
|
|
|
rm -rf $i
|
|
|
|
chmod +x /xcatpost/*
|
2011-08-16 19:30:27 +00:00
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript
|
|
|
|
MYCONT=`grep MASTER /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-16 19:30:27 +00:00
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript
|
|
|
|
MYCONT=`grep MASTER /tmp/mypostscript`
|
2009-12-15 15:10:07 +00:00
|
|
|
done
|
2011-08-16 19:30:27 +00:00
|
|
|
chmod +x /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
|
2011-11-11 05:59:28 +00:00
|
|
|
echo "INSTALLDIR=$INSTALLDIR" >> /opt/xcat/xcatinfo
|
2009-12-15 15:10:07 +00:00
|
|
|
PATH=/xcatpost:$PATH
|
|
|
|
export PATH
|
|
|
|
|
2012-02-07 19:22:25 +00:00
|
|
|
# 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`
|
|
|
|
echo "
|
|
|
|
# subroutine used to run postscripts
|
|
|
|
run_ps () {
|
|
|
|
logdir=\"/var/log/xcat\"
|
|
|
|
mkdir -p \$logdir
|
|
|
|
logfile=\"/var/log/xcat/xcat.log\"
|
|
|
|
|
|
|
|
if [ -f \$1 ]; then
|
|
|
|
echo \"Running postscript: \$@\" | tee -a \$logfile
|
|
|
|
./\$@ 2>&1 1> /tmp/tmp4xcatlog
|
|
|
|
cat /tmp/tmp4xcatlog | tee -a \$logfile
|
|
|
|
else
|
|
|
|
echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
# subroutine end
|
|
|
|
|
|
|
|
" > /tmp/mypostscript
|
2012-02-14 18:00:40 +00:00
|
|
|
echo "cd /xcatpost" >> /tmp/mypostscript
|
2012-02-07 19:22:25 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-15 15:10:07 +00:00
|
|
|
#save the postboot scripts to /tmp/mypostscript.post
|
2011-08-16 19:30:27 +00:00
|
|
|
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript`
|
|
|
|
echo "$TMP" > /tmp/mypostscript.post
|
|
|
|
chmod 755 /tmp/mypostscript.post
|
2009-07-10 18:34:09 +00:00
|
|
|
|
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-16 19:30:27 +00:00
|
|
|
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript`
|
|
|
|
echo "$TMP" > /tmp/mypostscript
|
|
|
|
/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
|
2007-10-26 22:44:33 +00:00
|
|
|
]]>
|
|
|
|
|
|
|
|
</source>
|
|
|
|
</script>
|
|
|
|
</post-scripts>
|
2009-12-15 15:10:07 +00:00
|
|
|
|