2007-10-26 22:44:33 +00:00
|
|
|
#
|
|
|
|
# Setup hostname
|
|
|
|
#
|
|
|
|
echo "post scripts" >/root/post.log
|
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-05-04 18:22:41 +00:00
|
|
|
fi
|
|
|
|
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
|
2010-03-03 03:27:16 +00:00
|
|
|
fi
|
2007-10-26 22:44:33 +00:00
|
|
|
if [ -z "$PRINIC" ]
|
|
|
|
then
|
|
|
|
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
|
|
|
|
IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}')
|
|
|
|
if [ -z $IP ]
|
|
|
|
then
|
|
|
|
dhclient eth0
|
|
|
|
IP=$(ifconfig $PRINIC | grep inet | awk '{print $2}' | awk -F: '{print $2}')
|
|
|
|
fi
|
2011-05-25 02:27:44 +00:00
|
|
|
|
2007-10-26 22:44:33 +00:00
|
|
|
export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}')
|
|
|
|
hostname $HOSTNAME
|
|
|
|
#
|
2009-12-15 15:10:07 +00:00
|
|
|
# Run xCAT post install
|
2007-10-26 22:44:33 +00:00
|
|
|
#
|
2009-12-15 15:10:07 +00:00
|
|
|
export MASTER_IP="#XCATVAR:XCATMASTER#"
|
|
|
|
export MASTER_IPS="#XCATVAR:XCATMASTER#"
|
|
|
|
export MASTER="#XCATVAR:XCATMASTER#"
|
2011-08-16 19:30:27 +00:00
|
|
|
cd /tmp
|
2009-12-15 15:10:07 +00:00
|
|
|
RAND=$(perl -e 'print int(rand(50)). "\n"')
|
|
|
|
sleep $RAND
|
|
|
|
for i in $(seq 1 20)
|
|
|
|
do
|
|
|
|
GOTIT=0
|
|
|
|
for i in $MASTER_IPS
|
|
|
|
do
|
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/postscripts
|
|
|
|
#wget --wait=10 --random-wait --waitretry=10 --retry-connrefused -t 0 -T 60 http://$i/install/autoinst/xcatpost.tar.gz
|
|
|
|
if [ "$?" = "0" ]
|
|
|
|
then
|
|
|
|
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
|
|
|
|
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
|
2009-07-23 21:03:49 +00:00
|
|
|
|
2009-12-15 15:10:07 +00:00
|
|
|
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
|
2009-07-23 21:03:49 +00:00
|
|
|
|
2009-12-15 15:10:07 +00:00
|
|
|
|
2011-08-16 19:30:27 +00:00
|
|
|
chmod +x /tmp/mypostscript
|
2009-12-15 15:10:07 +00:00
|
|
|
GOTIT=1
|
2009-07-23 21:03:49 +00:00
|
|
|
break
|
2009-12-15 15:10:07 +00:00
|
|
|
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
|
|
|
|
cd /xcatpost
|
|
|
|
#gunzip xcatpost.tar.gz
|
|
|
|
#tar -xvf xcatpost.tar
|
|
|
|
#/xcatpost/#TABLE:nodelist:THISNODE:node#
|
|
|
|
export PATH=/xcatpost:$PATH
|
2009-07-23 21:03:49 +00:00
|
|
|
|
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-23 21:03:49 +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
|
2011-03-28 01:42:09 +00:00
|
|
|
ln -s /etc/init.d/xcatpostinit1 /etc/rc3.d/S84xcatpostinit1
|
|
|
|
ln -s /etc/init.d/xcatpostinit1 /etc/rc4.d/S84xcatpostinit1
|
|
|
|
ln -s /etc/init.d/xcatpostinit1 /etc/rc5.d/S84xcatpostinit1
|
2009-12-15 15:10:07 +00:00
|
|
|
mkdir -p /opt/xcat
|
|
|
|
cat >/opt/xcat/xcatinstallpost << 'EOF'
|
|
|
|
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
|
|
|
|
chkconfig xcatpostinit1 off
|
2009-07-23 21:03:49 +00:00
|
|
|
EOF
|
2009-12-15 15:10:07 +00:00
|
|
|
chmod 755 /opt/xcat/xcatinstallpost
|
2009-07-23 21:03:49 +00:00
|
|
|
|
2009-12-15 15:10:07 +00:00
|
|
|
chkconfig --add xcatpostinit1
|
2009-07-23 21:03:49 +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
|
2009-12-15 15:10:07 +00:00
|
|
|
|
2011-08-16 19:30:27 +00:00
|
|
|
/tmp/mypostscript
|
2009-12-15 15:10:07 +00:00
|
|
|
export NODE=#TABLE:nodelist:THISNODE:node#
|
|
|
|
export OSVER=#TABLE:nodetype:THISNODE:os#
|
|
|
|
export ARCH=#TABLE:nodetype:THISNODE:arch#
|
|
|
|
addsiteyum
|
2011-05-18 06:48:02 +00:00
|
|
|
sed -i 's/^serial/#serial/' /boot/grub/grub.conf
|
|
|
|
sed -i 's/^terminal/#terminal/' /boot/grub/grub.conf
|
2009-12-15 15:10:07 +00:00
|
|
|
updateflag.awk $MASTER 3002
|
|
|
|
cd /
|
|
|
|
#rm -Rf /xcatpost
|
|
|
|
#rm -f /tmp/mypostscript
|
2007-10-26 22:44:33 +00:00
|
|
|
exit 0
|
2009-12-15 15:10:07 +00:00
|
|
|
|