2008-05-01 20:52:16 +00:00
|
|
|
#!/bin/sh
|
2008-04-14 12:20:34 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#####################################################
|
|
|
|
#
|
|
|
|
# Generic xCAT post script for diskless nodes
|
|
|
|
#
|
|
|
|
#####################################################
|
2008-05-01 20:52:16 +00:00
|
|
|
if [ ! `uname` == Linux ]; then
|
|
|
|
MYDIR=`dirname $0`
|
|
|
|
exec $MYDIR/xcatdsklspost.aix
|
|
|
|
exit
|
|
|
|
fi
|
2008-05-13 23:33:16 +00:00
|
|
|
let SLI=$RANDOM%10
|
|
|
|
sleep $SLI
|
2008-05-01 20:52:16 +00:00
|
|
|
|
2009-02-16 07:22:21 +00:00
|
|
|
#setup $OSVER ,for SLES11
|
|
|
|
if [ -e '/etc/SuSE-release' ]; then
|
|
|
|
OSVER=`grep -h VERSION /etc/SuSE-release |awk '{print $3}'`
|
|
|
|
fi
|
|
|
|
|
2008-05-15 21:00:34 +00:00
|
|
|
SIP=`grep -h dhcp-server-identifier /var/lib/dhclient/dhclient-*.leases|tail -n 1|awk '{print $3}'|sed -e 's/;//'`
|
2008-05-27 18:21:23 +00:00
|
|
|
if [ -z "$SIP" ]; then
|
|
|
|
SIP=`grep -h DHCPSID /var/lib/dhcpcd/*.info|awk -F= '{print $2}'|tail -n 1`
|
|
|
|
fi
|
|
|
|
|
2008-09-08 18:54:30 +00:00
|
|
|
#echo "SIP=$SIP"
|
2009-02-16 12:12:21 +00:00
|
|
|
if [ "$OSVER" = "11" ]; then
|
2009-02-16 07:22:21 +00:00
|
|
|
SIP=`echo $SIP |awk -F\' '{print $2}'` #trim '
|
|
|
|
fi
|
|
|
|
|
2008-05-09 17:20:04 +00:00
|
|
|
if grep 'rw /rw tmpfs ' /proc/mounts >& /dev/null; then
|
|
|
|
touch /var/lock/subsys/xcatmounts
|
|
|
|
echo '#!/bin/bash' > /etc/rc6.d/K10xcatmounts
|
|
|
|
echo umount -l /ro >> /etc/rc6.d/K10xcatmounts
|
|
|
|
echo umount -l /rw >> /etc/rc6.d/K10xcatmounts
|
|
|
|
chmod 755 /etc/rc6.d/K10xcatmounts
|
|
|
|
ln -sf /etc/rc6.d/K10xcatmounts /etc/rc0.d/K10xcatmounts
|
|
|
|
fi
|
|
|
|
|
2008-05-01 20:52:16 +00:00
|
|
|
|
2009-04-08 14:44:16 +00:00
|
|
|
if [ -x /usr/bin/stunnel -o -x /usr/sbin/stunnel ]; then
|
|
|
|
mkdir -p /etc/stunnel
|
|
|
|
mkdir -p /var/stunnel
|
|
|
|
mkdir -p /usr/var/run/stunnel #at least for SLES11
|
|
|
|
|
2008-05-01 20:52:16 +00:00
|
|
|
cat > /etc/stunnel/stunnel.conf << EOF
|
|
|
|
client=yes
|
|
|
|
foreground=no
|
|
|
|
output=/dev/null
|
2008-09-08 18:54:30 +00:00
|
|
|
#output=/var/log/stunnel.log
|
2008-05-01 20:52:16 +00:00
|
|
|
verify=0
|
|
|
|
[xcatd]
|
|
|
|
accept=400
|
|
|
|
EOF
|
|
|
|
echo "connect=$SIP:3001" >> /etc/stunnel/stunnel.conf
|
|
|
|
stunnel;
|
|
|
|
sleep 1;
|
2009-04-08 14:44:16 +00:00
|
|
|
elif [ -x /usr/bin/openssl ]; then
|
|
|
|
XCATSERVER="$SIP:3001"
|
|
|
|
export XCATSERVER
|
|
|
|
USEOPENSSLFORXCAT=1
|
|
|
|
export USEOPENSSLFORXCAT
|
|
|
|
fi
|
2008-05-01 20:52:16 +00:00
|
|
|
mkdir -p /xcatpost;
|
2008-09-08 18:54:30 +00:00
|
|
|
mkdir -p /tmp/postage
|
|
|
|
rm -R -f /xcatpost/*
|
|
|
|
rm -R -f /tmp/postage/*
|
|
|
|
|
2008-05-01 20:52:16 +00:00
|
|
|
cd /tmp/postage
|
2008-05-13 16:58:11 +00:00
|
|
|
#wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$SIP/install/postscripts 2> /tmp/wget.log
|
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$SIP/postscripts 2> /tmp/wget.log
|
|
|
|
#mv $SIP/install/postscripts/* /xcatpost;
|
|
|
|
mv $SIP/postscripts/* /xcatpost;
|
2008-05-01 20:52:16 +00:00
|
|
|
rm -rf $SIP
|
|
|
|
cd /xcatpost;
|
|
|
|
PATH=/xcatpost:$PATH
|
|
|
|
export PATH
|
2008-09-08 18:54:30 +00:00
|
|
|
chmod +x /xcatpost/*;
|
|
|
|
echo "PATH=$PATH"
|
2008-05-01 20:52:16 +00:00
|
|
|
/xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript;
|
2008-05-13 23:33:16 +00:00
|
|
|
MYCONT=`cat /tmp/mypostscript`
|
2008-09-08 18:54:30 +00:00
|
|
|
#echo "MYCONT=$MYCONT"
|
2008-05-13 23:33:16 +00:00
|
|
|
while [ -z "$MYCONT" ]; do
|
|
|
|
let SLI=$RANDOM%10
|
|
|
|
let SLI=10+$SLI
|
|
|
|
sleep $SLI
|
|
|
|
/xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript;
|
|
|
|
MYCONT=`cat /tmp/mypostscript`
|
2008-09-08 18:54:30 +00:00
|
|
|
# echo "MYCONT=$MYCONT"
|
2008-05-13 23:33:16 +00:00
|
|
|
done
|
2009-06-04 15:33:44 +00:00
|
|
|
|
|
|
|
# when called by the updatenode command,
|
|
|
|
#modify the UPDATENODE flag to 1
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
TMP=`sed -e 's/UPDATENODE=0/UPDATENODE=1/g' /tmp/mypostscript`;
|
|
|
|
echo "$TMP" > /tmp/mypostscript;
|
|
|
|
fi
|
|
|
|
|
2008-09-25 03:04:56 +00:00
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
POSTS=$2
|
2008-09-08 18:54:30 +00:00
|
|
|
#remove all the postscripts
|
|
|
|
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript`
|
|
|
|
echo "$TMP" > /tmp/mypostscript
|
|
|
|
#add requested postscripts in
|
|
|
|
echo "$POSTS" | tr "," "\n" >> /tmp/mypostscript
|
|
|
|
fi
|
|
|
|
#MYCONT=`cat /tmp/mypostscript`
|
|
|
|
#echo "$MYCONT"
|
|
|
|
|
2008-09-26 23:07:45 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
#notify the server that we are done with netbooting
|
2009-03-24 19:44:23 +00:00
|
|
|
CNS=`grep NODESTATUS= /tmp/mypostscript |awk -F = '{print $2}'`
|
2009-03-25 03:25:59 +00:00
|
|
|
if [ -z "$CNS" ] || [ "$CNS" != "'0'" -a "$CNS" != "'N'" -a "$CNS" != "'n'" ]; then
|
2009-03-24 03:12:03 +00:00
|
|
|
echo "updateflag.awk \$MASTER 3002 \"installstatus booted\"" >> /tmp/mypostscript
|
|
|
|
fi
|
2008-09-26 23:07:45 +00:00
|
|
|
fi
|
|
|
|
|
2009-02-19 08:45:16 +00:00
|
|
|
DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /tmp/mypostscript`
|
|
|
|
echo "$DHCP_TMP" > /tmp/mypostscript
|
2009-02-16 07:22:21 +00:00
|
|
|
|
2008-05-01 20:52:16 +00:00
|
|
|
chmod +x /tmp/mypostscript
|
|
|
|
if [ -x /tmp/mypostscript ];then
|
|
|
|
/tmp/mypostscript
|
|
|
|
fi
|
|
|
|
rm -f /tmp/mypostscript
|
2008-09-25 03:04:56 +00:00
|
|
|
|
2009-04-08 14:44:16 +00:00
|
|
|
if [ -x /usr/bin/stunnel -o -x /usr/sbin/stunnel ]; then
|
2008-05-01 20:52:16 +00:00
|
|
|
killall stunnel
|
|
|
|
rm -rf /etc/stunnel
|
2009-04-08 14:44:16 +00:00
|
|
|
fi
|
2008-09-08 18:54:30 +00:00
|
|
|
|
2008-11-09 03:20:21 +00:00
|
|
|
#tell user it is done when this is called by updatenode command
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
echo "returned"
|
|
|
|
fi
|
2008-09-08 18:54:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|