xcat-core/xCAT-server/share/xcat/install/scripts/post.rh.iscsi

87 lines
2.4 KiB
Plaintext
Raw Normal View History

#
# Setup hostname
#
echo "post scripts" >/root/post.log
export PRINIC=#TABLE:noderes:THISNODE:primarynic#
if [ -z "$PRINIC" ]
then
export PRINIC=eth0
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
echo "search #TABLE:site:key=domain:value#" >/etc/resolv.conf
for i in $(echo #TABLE:site:key=nameservers:value# | tr ',' ' ')
do
echo "nameserver $i"
done >>/etc/resolv.conf
export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}')
hostname $HOSTNAME
#
# Run xCAT post install
#
export MASTER_IP="#XCATVAR:XCATMASTER#"
export MASTER_IPS="#XCATVAR:XCATMASTER#"
export MASTER="#XCATVAR:XCATMASTER#"
cd /tmp
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
XCATSERVER=$i:3001
export XCATSERVER
mv $i/postscripts /xcatpost
rm -rf $i
chmod +x /xcatpost/*
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript
MYCONT=`cat /tmp/mypostscript`
while [ -z "$MYCONT" ]; do
let SLI=$RANDOM%10+10
sleep $SLI
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript
MYCONT=`cat /tmp/mypostscript`
done
chmod +x /tmp/mypostscript
GOTIT=1
break
fi
done
if [ "$GOTIT" = "1" ]
then
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
/tmp/mypostscript
export NODE=#TABLE:nodelist:THISNODE:node#
export OSVER=#TABLE:nodetype:THISNODE:os#
export ARCH=#TABLE:nodetype:THISNODE:arch#
addsiteyum
iscsiadm -m discovery -t st -p #TABLE:iscsi:$NODE:server#
sed -i 's/^serial/#serial/' /boot/grub/menu.lst
sed -i 's/^terminal/#terminal/' /boot/grub/menu.lst
uploadboot
cd /
rm -Rf /xcatpost
rm -f /tmp/mypostscript
exit 0