2013-03-04 22:32:17 +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
|
2013-07-17 15:28:13 +00:00
|
|
|
# The syntax of this script:
|
|
|
|
# xcatdsklspost {mode} {-m|-M} [postscripts] --tftp /tftpboot --installdir /install --nfsv4 no -c -V
|
2012-08-31 15:52:31 +00:00
|
|
|
# This script is called in the following different places:
|
2010-03-21 13:11:47 +00:00
|
|
|
# updatenode -P ... --> xcatdsklspost 1 -m/-M ...
|
|
|
|
# updatenode -S --> xcatdsklspost 2 -m/-M otherpkgs
|
2009-07-29 21:25:59 +00:00
|
|
|
# moncfg rmcmon --> xcatdsklspost 3 configrmcnodes
|
|
|
|
# node deployment --> xcatdsklspost
|
2010-01-25 11:34:42 +00:00
|
|
|
# statelite mode --> xcatdsklspost 4
|
2010-03-21 13:11:47 +00:00
|
|
|
# update security --> xcatdsklspost 5 -m/-M ...
|
2012-08-31 15:52:31 +00:00
|
|
|
# node reboot - xcatpostinit1 --> xcatdsklspost 6
|
2013-06-18 13:51:54 +00:00
|
|
|
# This script has a debug mode, if XCATDEBUG env variable is set, then
|
|
|
|
# /xcatpost becomes /xcatpost.<nodename>. This allow running multiple
|
|
|
|
# instances of the script to simulate many node on one physical node
|
2008-04-14 12:20:34 +00:00
|
|
|
#
|
|
|
|
#####################################################
|
2011-05-17 05:53:56 +00:00
|
|
|
|
|
|
|
update_VPD()
|
|
|
|
{
|
2011-08-04 12:29:52 +00:00
|
|
|
if [ -f /usr/sbin/vpdupdate ]; then
|
2011-05-17 05:53:56 +00:00
|
|
|
vpdupdate
|
2012-05-15 03:40:49 +00:00
|
|
|
logger -t xCAT -p local4.info "xcatdsklspost: updating VPD database"
|
2011-05-17 05:53:56 +00:00
|
|
|
fi
|
|
|
|
}
|
2012-02-15 02:56:51 +00:00
|
|
|
|
|
|
|
# Run updatevpd only when necessary
|
2012-04-01 02:14:04 +00:00
|
|
|
if [ -f /usr/sbin/lsvpd ]; then
|
2014-11-03 08:34:33 +00:00
|
|
|
/usr/sbin/lsvpd | grep -i -E 'cpu|processor' 2>&1 1>/dev/null
|
2012-04-01 02:14:04 +00:00
|
|
|
if [ "$?" = "1" ]; then
|
|
|
|
update_VPD
|
|
|
|
fi
|
2012-02-15 02:56:51 +00:00
|
|
|
fi
|
2011-05-17 05:53:56 +00:00
|
|
|
|
2009-12-04 21:22:07 +00:00
|
|
|
download_postscripts()
|
|
|
|
{
|
|
|
|
server=$1
|
|
|
|
if [ -z $server ]; then
|
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
|
2014-04-03 14:44:29 +00:00
|
|
|
# Do not override the parameter --installdir
|
2011-11-10 14:26:08 +00:00
|
|
|
if [ -z "$INSTALLDIR" ]; then
|
2014-04-03 14:44:29 +00:00
|
|
|
if [ -f /opt/xcat/xcatinfo ]; then
|
|
|
|
INSTALLDIR=`grep 'INSTALLDIR' /opt/xcat/xcatinfo |cut -d= -f2`
|
|
|
|
fi
|
|
|
|
if [ -z "$INSTALLDIR" ]; then
|
|
|
|
INSTALLDIR="/install"
|
|
|
|
fi
|
2011-11-10 14:26:08 +00:00
|
|
|
fi
|
2014-04-03 14:44:29 +00:00
|
|
|
|
2009-12-04 21:22:07 +00:00
|
|
|
max_retries=5
|
|
|
|
retry=0
|
2013-05-16 13:56:17 +00:00
|
|
|
rc=1 # this is a fail return
|
2009-12-04 21:22:07 +00:00
|
|
|
while [ 0 -eq 0 ]; do
|
2012-08-28 11:43:52 +00:00
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
export LANG=C; wget -l inf -nH -N -r --waitretry=10 --random-wait -e robots=off -T 60 -nH --cut-dirs=2 --reject "index.html*" --no-parent http://$server$INSTALLDIR/postscripts/ -P /$xcatpost 2> /tmp/wget.log
|
2013-05-16 13:56:17 +00:00
|
|
|
rc=$?
|
|
|
|
if [ $rc -eq 0 ]; then
|
|
|
|
# return from wget was 0 but some OS do not return errors, so we
|
|
|
|
# have additional checks for
|
|
|
|
# failed: Connection httpd not running
|
|
|
|
# 404: Not Found - if directory does not exist
|
2013-05-22 17:07:17 +00:00
|
|
|
grep -i -E "... failed: Connection refused.$" /tmp/wget.log
|
2013-05-16 13:56:17 +00:00
|
|
|
rc1=$?
|
2013-05-22 17:07:17 +00:00
|
|
|
grep -i -E "ERROR 404: Not Found.$" /tmp/wget.log
|
2013-05-16 13:56:17 +00:00
|
|
|
rc2=$?
|
|
|
|
# check to see no errors at all, grep returns 1
|
|
|
|
if [ $rc1 -eq 1 ] && [ $rc2 -eq 1 ]; then
|
|
|
|
return 0
|
2012-08-28 11:43:52 +00:00
|
|
|
fi
|
2013-05-16 13:56:17 +00:00
|
|
|
fi
|
2009-12-04 21:22:07 +00:00
|
|
|
|
|
|
|
retry=$(($retry+1))
|
2013-05-16 13:56:17 +00:00
|
|
|
logger -t xCAT -p local4.err "download_postscripts retry $retry"
|
2009-12-04 21:22:07 +00:00
|
|
|
if [ $retry -eq $max_retries ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
2011-09-07 02:32:49 +00:00
|
|
|
SLI=$(awk 'BEGIN{srand(); printf("%d\n",rand()*20)}')
|
|
|
|
sleep $SLI
|
2009-12-04 21:22:07 +00:00
|
|
|
done
|
|
|
|
return $rc
|
|
|
|
}
|
|
|
|
|
2013-01-06 05:23:44 +00:00
|
|
|
|
2012-10-12 05:43:45 +00:00
|
|
|
download_mypostscript()
|
|
|
|
{
|
|
|
|
server=$1
|
2013-01-06 05:23:44 +00:00
|
|
|
node=$2
|
2013-05-16 13:56:17 +00:00
|
|
|
max_retries=$3
|
|
|
|
TFTPDIR=$4
|
2012-10-12 05:43:45 +00:00
|
|
|
if [ -z $server ]; then
|
|
|
|
return 1;
|
|
|
|
fi
|
|
|
|
if [ -z "$TFTPDIR" ]; then
|
2012-11-23 07:14:09 +00:00
|
|
|
TFTPDIR="/tftpboot"
|
2012-10-12 05:43:45 +00:00
|
|
|
fi
|
2013-02-05 03:21:22 +00:00
|
|
|
retry=0
|
2012-10-12 05:43:45 +00:00
|
|
|
rc=1
|
|
|
|
|
|
|
|
|
|
|
|
while [ 0 -eq 0 ]; do
|
2013-06-18 13:51:54 +00:00
|
|
|
wget -N --waitretry=10 --random-wait -T 60 http://$server$TFTPDIR/mypostscripts/mypostscript.$node -P /$xcatpost 2>> /tmp/wget.log
|
2013-05-16 13:56:17 +00:00
|
|
|
rc=$?
|
|
|
|
# if no error and the file was downloaded
|
2013-06-18 13:51:54 +00:00
|
|
|
if [ $rc -eq 0 ] && [ -f /$xcatpost/mypostscript.$node ]; then
|
|
|
|
mv /$xcatpost/mypostscript.$node /$xcatpost/mypostscript
|
2013-01-17 09:20:12 +00:00
|
|
|
return 0;
|
|
|
|
fi
|
2013-05-16 13:56:17 +00:00
|
|
|
|
2013-01-17 09:20:12 +00:00
|
|
|
|
2012-10-12 05:43:45 +00:00
|
|
|
retry=$(($retry+1))
|
|
|
|
if [ $retry -eq $max_retries ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
done
|
|
|
|
return $rc
|
|
|
|
}
|
|
|
|
|
2013-01-06 05:23:44 +00:00
|
|
|
|
|
|
|
|
2012-10-15 17:13:49 +00:00
|
|
|
# pmatch determines if 1st argument string is matched by 2nd argument pattern
|
|
|
|
|
|
|
|
pmatch ()
|
|
|
|
{
|
|
|
|
case $1 in
|
|
|
|
$2) return 0;; # zero return code means string matched by pattern
|
|
|
|
esac
|
|
|
|
|
|
|
|
return 1 # non-zero return code means string not matched by pattern
|
|
|
|
}
|
2013-05-01 16:40:12 +00:00
|
|
|
# Main
|
2010-03-21 13:11:47 +00:00
|
|
|
# parse the arguments
|
|
|
|
ARGNUM=$#;
|
|
|
|
if [ -z $1 ]; then
|
2010-03-24 12:05:58 +00:00
|
|
|
NODE_DEPLOYMENT=1
|
2010-03-21 13:11:47 +00:00
|
|
|
else
|
2010-03-24 12:05:58 +00:00
|
|
|
NODE_DEPLOYMENT=0
|
2010-03-21 13:11:47 +00:00
|
|
|
case $1 in
|
|
|
|
1|2|5)
|
|
|
|
MODE=$1
|
|
|
|
if [ $ARGNUM -gt 1 ]; then
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ $2 = "-m" ]; then
|
2010-03-21 13:11:47 +00:00
|
|
|
P_SIP=$3
|
|
|
|
else
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ $2 = "-M" ]; then
|
2010-03-21 13:11:47 +00:00
|
|
|
P_SIP=$3
|
2013-05-16 13:56:17 +00:00
|
|
|
new_ms=$P_SIP # -M means we will update xcatinfo file XCATSERVER
|
2010-03-21 13:11:47 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $ARGNUM -gt 3 ]; then
|
|
|
|
POSTSCRIPTS=$4
|
|
|
|
fi
|
2012-11-23 07:14:09 +00:00
|
|
|
if [ $ARGNUM -gt 4 ]; then
|
|
|
|
if [ $5 = "--tftp" ]; then
|
|
|
|
TFTPDIR=$6
|
|
|
|
fi
|
|
|
|
fi
|
2012-12-05 12:54:57 +00:00
|
|
|
if [ $ARGNUM -gt 6 ]; then
|
2012-12-04 20:40:11 +00:00
|
|
|
if [ $7 = "--installdir" ]; then
|
|
|
|
INSTALLDIR=$8
|
|
|
|
fi
|
|
|
|
fi
|
2012-12-05 12:54:57 +00:00
|
|
|
if [ $ARGNUM -gt 8 ]; then
|
2012-12-04 20:40:11 +00:00
|
|
|
if [ $9 = "--nfsv4" ]; then
|
2013-02-06 19:46:29 +00:00
|
|
|
NFSV4=${10}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $ARGNUM -gt 10 ]; then
|
2013-07-17 15:28:13 +00:00
|
|
|
if [ ${11} = "-c" ]; then
|
2013-02-06 19:46:29 +00:00
|
|
|
CFLAG=${11}
|
2012-12-04 20:40:11 +00:00
|
|
|
fi
|
|
|
|
fi
|
2013-07-17 15:28:13 +00:00
|
|
|
if [ $ARGNUM -gt 11 ]; then
|
|
|
|
if [ ${12} = "-V" ]; then
|
|
|
|
export VERBOSE=1
|
|
|
|
fi
|
2013-10-10 15:25:36 +00:00
|
|
|
if [ ${12} = "-F" ]; then
|
|
|
|
export USEFLOWCONTROL=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $ARGNUM -gt 12 ]; then
|
|
|
|
if [ ${13} = "-V" ]; then
|
|
|
|
export VERBOSE=1
|
|
|
|
fi
|
2013-07-17 15:28:13 +00:00
|
|
|
fi
|
2010-03-21 13:11:47 +00:00
|
|
|
;;
|
2012-08-31 15:52:31 +00:00
|
|
|
3|4|6) MODE=$1;;
|
2010-03-21 13:11:47 +00:00
|
|
|
esac
|
|
|
|
fi
|
2013-06-18 13:51:54 +00:00
|
|
|
# set the default path for the xcatpost directory
|
|
|
|
xcatpost="/xcatpost"
|
|
|
|
# Check for debug mode and you have nodename available you can change the path for debug
|
|
|
|
|
|
|
|
if [ -n "$XCATDEBUG" ]; then
|
|
|
|
if [ -n "$NODE" ]; then
|
|
|
|
xcatpost="/xcatpost.$NODE"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
#echo "xcatpost = $xcatpost"
|
2013-10-10 15:25:36 +00:00
|
|
|
|
|
|
|
useflowcontrol=0
|
2013-10-10 18:53:24 +00:00
|
|
|
if [ "$USEFLOWCONTROL" = "1" ]; then
|
|
|
|
useflowcontrol=1
|
|
|
|
fi
|
|
|
|
# from install kcmdline
|
|
|
|
if [ "$FC" = "1" ] || [ "$FC" = "yes" ] || [ "$FC" = "YES" ]; then
|
2013-10-10 15:25:36 +00:00
|
|
|
useflowcontrol=1
|
|
|
|
fi
|
|
|
|
|
2013-05-01 16:40:12 +00:00
|
|
|
|
2012-12-04 20:40:11 +00:00
|
|
|
# If on AIX node
|
|
|
|
if [ ! `uname` = Linux ]; then
|
|
|
|
#Get a new copy of xcataixpost on the node
|
2013-06-18 13:51:54 +00:00
|
|
|
mkdir -p /$xcatpost;
|
2012-12-04 20:40:11 +00:00
|
|
|
mkdir -p /xcatmnt;
|
|
|
|
if [ "$NFSV4" = "yes" ]; then
|
|
|
|
mount -o vers=4 $P_SIP:$INSTALLDIR/postscripts /xcatmnt
|
|
|
|
else
|
|
|
|
mount $P_SIP:$INSTALLDIR/postscripts /xcatmnt
|
|
|
|
fi
|
2013-06-18 13:51:54 +00:00
|
|
|
cp /xcatmnt/xcataixpost /$xcatpost
|
2012-12-04 20:40:11 +00:00
|
|
|
umount /xcatmnt
|
|
|
|
rmdir /xcatmnt
|
2013-02-06 19:46:29 +00:00
|
|
|
logger -t xCAT -p local4.err "Running xcataixpost $*"
|
2013-10-10 15:25:36 +00:00
|
|
|
# note not supporting -F or -V on AIX
|
2013-07-17 15:56:08 +00:00
|
|
|
echo "/$xcatpost/xcataixpost $1 $2 $3 '"$4"' $5 $6 $7 $8 $9 ${10} ${11}"
|
|
|
|
exec /$xcatpost/xcataixpost $1 $2 $3 "$4" $5 $6 $7 $8 $9 ${10} ${11}
|
2012-12-04 20:40:11 +00:00
|
|
|
exit
|
|
|
|
fi
|
2009-12-04 21:22:07 +00:00
|
|
|
|
2012-08-28 11:43:52 +00:00
|
|
|
#SLI=$(awk 'BEGIN{srand(); printf("%d\n",rand()*10)}')
|
|
|
|
#sleep $SLI
|
2008-05-01 20:52:16 +00:00
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
if [ ! -d /$xcatpost ]; then
|
|
|
|
mkdir -p /$xcatpost;
|
2010-01-25 11:34:42 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d /tmp/postage ]; then
|
|
|
|
mkdir -p /tmp/postage
|
|
|
|
fi
|
2009-12-04 21:22:07 +00:00
|
|
|
rm -R -f /tmp/postage/*
|
2008-05-27 18:21:23 +00:00
|
|
|
|
2009-12-04 21:22:07 +00:00
|
|
|
#here we get all the postscripts. Please do not change this behaviour because some scripts depend on others
|
|
|
|
cd /tmp/postage
|
2009-02-16 07:22:21 +00:00
|
|
|
|
2010-01-25 11:34:42 +00:00
|
|
|
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ "$MODE" = "4" ]; then # for statelite mode
|
2010-01-25 11:34:42 +00:00
|
|
|
# We have written the xCATSERVER info into the kernel command line!!
|
|
|
|
for i in `cat /proc/cmdline`; do
|
|
|
|
KEY=`echo $i | awk -F= '{print $1}'`
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ "$KEY" = "XCAT" ]; then
|
2010-01-25 11:34:42 +00:00
|
|
|
TMP=`echo $i | awk -F= '{print $2}'`
|
|
|
|
XCATSERVER=`echo $TMP | cut -d: -f1`
|
|
|
|
echo "XCATSERVER=$XCATSERVER" > /opt/xcat/xcatinfo
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -f /opt/xcat/xcatinfo ]; then
|
2013-06-03 15:37:27 +00:00
|
|
|
SIP=`grep 'XCATSERVER' /opt/xcat/xcatinfo |cut -d= -f2`
|
2010-04-23 05:37:55 +00:00
|
|
|
if [ -n "$SIP" ]; then
|
|
|
|
download_postscripts $SIP
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
downloaded=1
|
|
|
|
fi
|
|
|
|
fi
|
2010-01-25 11:34:42 +00:00
|
|
|
else
|
2011-09-07 02:32:49 +00:00
|
|
|
echo "xCAT management server IP can't be determined.";
|
|
|
|
echo "exiting...";
|
2012-05-15 03:40:49 +00:00
|
|
|
logger -t xCAT -p local4.err "xcatdsklspost:xCAT management server IP can't be determined.\nexiting...";
|
2010-01-25 11:34:42 +00:00
|
|
|
exit;
|
2009-12-04 21:22:07 +00:00
|
|
|
fi
|
2013-05-16 13:56:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
else # for common mode MODE=1,2,3,5 (updatenode,moncfg,node deployment)
|
|
|
|
# non-Statelite MODE
|
|
|
|
|
2013-05-28 13:52:39 +00:00
|
|
|
# If we have written the NODE info into the kernel command line,
|
|
|
|
# put in in xcatinfo
|
|
|
|
if [ ! -f /opt/xcat/xcatinfo ]; then
|
|
|
|
mkdir -p /opt/xcat
|
|
|
|
touch /opt/xcat/xcatinfo
|
|
|
|
fi
|
|
|
|
for i in `cat /proc/cmdline`; do
|
|
|
|
KEY=`echo $i | awk -F= '{print $1}'`
|
|
|
|
if [ "$KEY" = "NODE" ]; then
|
|
|
|
NODE=`echo $i | awk -F= '{print $2}'`
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
grep 'NODE' /opt/xcat/xcatinfo 2>&1 > /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
sed -i "s/NODE=.*/NODE=$NODE/" /opt/xcat/xcatinfo
|
|
|
|
else
|
|
|
|
echo "NODE=$NODE" >> /opt/xcat/xcatinfo
|
|
|
|
fi
|
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
downloaded=0; # have not downloaded the postscripts
|
|
|
|
# try the -m/-M input (P_SIP) if it is specified,
|
|
|
|
# -m/-M is passed in the updatenode command
|
|
|
|
# and is the address of the xcatmaster for this node. Using -M just means
|
|
|
|
# also update the XCATSERVER in the /etc/xcat/xcatinfo file with this
|
|
|
|
# address
|
|
|
|
if [ -n "$P_SIP" ]; then # passed in with updatenode on -M/-m
|
|
|
|
SIP=$P_SIP
|
|
|
|
download_postscripts $SIP
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
downloaded=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# if the download failed then, if not updatenode
|
|
|
|
# open the xcatinfo file to look for an XCATSERVER address to try
|
|
|
|
# if the address if not the same as the one on the -m/M flag then
|
|
|
|
# try it
|
2010-03-21 13:11:47 +00:00
|
|
|
if [ $downloaded -eq 0 ]; then
|
2013-05-16 13:56:17 +00:00
|
|
|
|
|
|
|
# if this is an updatenode call, then stop trying and
|
|
|
|
# return an error
|
|
|
|
if [ "$MODE" = "1" ] || [ "$MODE" = "2" ] || [ "$MODE" = "5" ]; then # updatenode
|
|
|
|
hn=`hostname`
|
|
|
|
echo "Cannot download the postscripts from $SIP for $hn check /tmp/wget.log on the node."
|
|
|
|
logger -t xCAT -p local4.err "xcatdsklspost:Cannot download the postscripts from the xCAT server $SIP for node $hn check /tmp/wget.log on the node."
|
|
|
|
exit
|
2010-03-21 13:11:47 +00:00
|
|
|
fi
|
2012-04-29 00:14:59 +00:00
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
# if not updatenode, then look in xcatinfo for the xcatmaster
|
2012-04-29 00:14:59 +00:00
|
|
|
if [ -f /opt/xcat/xcatinfo ]; then
|
|
|
|
SIP=`grep 'XCATSERVER' /opt/xcat/xcatinfo |cut -d= -f2`
|
|
|
|
if [ -n "$SIP" ]; then
|
|
|
|
download_postscripts $SIP
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
downloaded=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
# download postscripts has not worked yet
|
2012-06-29 07:58:59 +00:00
|
|
|
if [ $downloaded -eq 0 ]; then
|
2013-05-16 13:56:17 +00:00
|
|
|
|
|
|
|
# for the non-updatenode calls try the host in the XCAT kernel param.
|
2012-06-29 07:58:59 +00:00
|
|
|
for i in `cat /proc/cmdline`; do
|
|
|
|
KEY=`echo $i | awk -F= '{print $1}'`
|
|
|
|
if [ "$KEY" = "XCAT" ]; then
|
|
|
|
TMP=`echo $i | awk -F= '{print $2}'`
|
|
|
|
SIP=`echo $TMP | cut -d: -f1`
|
|
|
|
if [ -n "$SIP" ]; then
|
|
|
|
download_postscripts $SIP
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
downloaded=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
# download poscripts has not worked yet
|
2010-03-21 13:11:47 +00:00
|
|
|
#try the dhcp server, this is used for initial boot for the node.
|
|
|
|
if [ $downloaded -eq 0 ]; then
|
|
|
|
#setup $OSVER ,for SLES11
|
|
|
|
if [ -e '/etc/SuSE-release' ]; then
|
|
|
|
OSVER=`grep -h VERSION /etc/SuSE-release |awk '{print $3}'`
|
|
|
|
fi
|
2011-09-15 23:47:54 +00:00
|
|
|
SIPS=`grep -h dhcp-server-identifier /var/lib/dhclient/dhclient*eth*.leases 2> /dev/null|awk '{print $3}'|sed -e 's/;//'`
|
2010-03-21 13:11:47 +00:00
|
|
|
if [ -z "$SIPS" ]; then
|
2012-03-19 05:37:09 +00:00
|
|
|
SIPS=`grep -h dhcp-server-identifier /var/lib/dhclient/dhclient*hf*.leases 2> /dev/null|awk '{print $3}'|sed -e 's/;//'`
|
|
|
|
if [ -z "$SIPS" ]; then
|
|
|
|
SIPS=`grep -h DHCPSID /var/lib/dhcpcd/*.info 2> /dev/null|awk -F= '{print $2}'|sed -e s/\'//g`
|
|
|
|
fi
|
2010-03-21 13:11:47 +00:00
|
|
|
fi
|
|
|
|
SIP=`echo $SIPS|awk '{printf $NF}' | tail -n 1` #Pick one for wget
|
|
|
|
if [ -n "$SIP" ]; then
|
|
|
|
download_postscripts $SIP
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
downloaded=1
|
|
|
|
fi
|
|
|
|
elif [ -x "/sbin/dhcpcd" ]; then
|
|
|
|
# New dhcpcd doesn't creates *.info files.
|
|
|
|
for lease in $(ls "/var/lib/dhcpcd/"); do
|
|
|
|
iface="$(echo "$lease" | sed -n -e 's/^dhcpcd-\(.*\)\.lease$/\1/p')"
|
|
|
|
if [ -n "$iface" ]; then
|
|
|
|
SIP="$(dhcpcd -q -T "$iface" | sed -n -e '/new_dhcp_server_identifier/ s/.*=//p')"
|
|
|
|
if [ -n "$SIP" ]; then
|
|
|
|
download_postscripts $SIP
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
downloaded=1
|
|
|
|
break
|
|
|
|
fi
|
2010-02-24 09:44:42 +00:00
|
|
|
fi
|
|
|
|
fi
|
2010-03-21 13:11:47 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
#no hope to download postscripts, now let's get out of here.
|
2010-03-21 13:11:47 +00:00
|
|
|
if [ $downloaded -eq 0 ]; then
|
|
|
|
hn=`hostname`
|
|
|
|
echo "Cannot download the postscripts from the xCAT server for node $hn"
|
2012-05-15 03:40:49 +00:00
|
|
|
logger -t xCAT -p local4.err "xcatdsklspost:Cannot download the postscripts from the xCAT server for node $hn"
|
2010-03-21 13:11:47 +00:00
|
|
|
exit
|
2009-12-04 21:22:07 +00:00
|
|
|
fi
|
2009-09-09 20:36:53 +00:00
|
|
|
|
2010-03-21 13:11:47 +00:00
|
|
|
fi # finish the postscripts download
|
2010-01-25 11:34:42 +00:00
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
# remove the current mypostscript file
|
2013-06-18 13:51:54 +00:00
|
|
|
rm -rf /$xcatpost/mypostscript
|
2012-10-12 05:43:45 +00:00
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
# if NODE is exported ( updatenode call or from kernel parameter)
|
|
|
|
# use it as the nodename to get the mypostscript file.
|
|
|
|
if [ -n "$NODE" ]; then
|
|
|
|
node_short=$NODE
|
|
|
|
else
|
|
|
|
#get node name and download the mypostscript.$node file
|
|
|
|
#try to get the node ip address that connects to the server.
|
|
|
|
#then resolve the name of the ip
|
|
|
|
real_SIP=`getent hosts $SIP |awk {'print $1'}`
|
|
|
|
if [ $? -ne 0 ]; then
|
2013-03-19 21:17:46 +00:00
|
|
|
real_SIP=$SIP
|
2013-05-16 13:56:17 +00:00
|
|
|
fi
|
2013-03-19 21:17:46 +00:00
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
NIP=`ip route get $real_SIP | head -n 1 | sed 's/^.*src//g' | awk {'print $1'}`
|
|
|
|
if [ $? -eq 0 ] && [ -n "$NIP" ]; then
|
|
|
|
#resolve the name of the node from ip address
|
2013-03-13 19:05:27 +00:00
|
|
|
result=`getent hosts $NIP`
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
node1=`echo $result | awk {'print $2'}`
|
|
|
|
node2=`echo $result | awk {'print $3'}`
|
|
|
|
if [ ${#node1} -gt ${#node2} ]; then
|
|
|
|
node=$node1
|
|
|
|
node_short=$node2
|
|
|
|
else
|
|
|
|
node=$node2
|
|
|
|
node_short=$node1
|
|
|
|
fi
|
|
|
|
if [ -z "$node_short" ]; then
|
|
|
|
node_short=`echo $node |awk -F. {'print $1'}`
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -z "$node" ]; then
|
|
|
|
node=`hostname`
|
|
|
|
node_short=`hostname -s`
|
|
|
|
fi
|
2013-03-04 22:32:17 +00:00
|
|
|
fi
|
2013-05-16 13:56:17 +00:00
|
|
|
else
|
2013-03-04 22:32:17 +00:00
|
|
|
node=`hostname`
|
2013-03-13 19:05:27 +00:00
|
|
|
node_short=`hostname -s`
|
2013-05-16 13:56:17 +00:00
|
|
|
fi
|
2013-03-04 22:32:17 +00:00
|
|
|
fi
|
2013-03-13 19:05:27 +00:00
|
|
|
|
2013-01-06 05:23:44 +00:00
|
|
|
max_retries=2
|
2013-05-22 12:42:02 +00:00
|
|
|
# try short hostname first
|
2013-03-13 19:05:27 +00:00
|
|
|
if [ -n "$node_short" ]; then
|
2013-05-16 13:56:17 +00:00
|
|
|
download_mypostscript $SIP $node_short $max_retries $TFTPDIR
|
2013-05-22 12:42:02 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
# try long hostname
|
|
|
|
if [ "$node" != "$node_short" ]; then
|
|
|
|
download_mypostscript $SIP $node $postfix $max_retries $TFTPDIR
|
|
|
|
fi
|
|
|
|
fi
|
2013-03-04 22:32:17 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-12 05:43:45 +00:00
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
# on reboot and shutdown, make sure /ro and /rw are not stuck mounted
|
2011-09-07 02:32:49 +00:00
|
|
|
if grep 'rw /rw tmpfs ' /proc/mounts >/dev/null 2>&1; then
|
2008-05-09 17:20:04 +00:00
|
|
|
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
|
|
|
|
|
2013-11-12 08:42:03 +00:00
|
|
|
# To support the postscripts in the subdirectories under /install/postscripts
|
|
|
|
#chmod +x /$xcatpost/*;
|
|
|
|
chmod -R +x `find $xcatpost/ -maxdepth 1 -print | grep -E -v "^($xcatpost/|$xcatpost/_xcat|$xcatpost/_ssh|$xcatpost/ca|$xcatpost/hostkeys)$"`
|
2008-09-08 18:54:30 +00:00
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
cd /$xcatpost;
|
|
|
|
PATH=/$xcatpost:$PATH
|
2008-05-01 20:52:16 +00:00
|
|
|
export PATH
|
2009-12-04 21:22:07 +00:00
|
|
|
|
|
|
|
if [ -x /usr/bin/openssl ]; then
|
|
|
|
XCATSERVER="$SIP: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
|
|
|
|
fi
|
|
|
|
|
2013-05-16 13:56:17 +00:00
|
|
|
# if download of postscript failed,
|
|
|
|
# probably the /tftpboot/mypostcript/mypostscript.<nodename> does not exist.
|
|
|
|
# We need to call getpostscript.awk .
|
2013-02-05 03:21:22 +00:00
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
if [ ! -x /$xcatpost/mypostscript ]; then
|
2013-10-10 15:25:36 +00:00
|
|
|
if [ $useflowcontrol = "1" ]; then
|
|
|
|
# first contact daemon xcatflowrequest <server> 3001
|
|
|
|
logger -t xCAT -p local4.info "xcatdsklspost:sending xcatflowrequest $SIP 3001"
|
|
|
|
/$xcatpost/xcatflowrequest $SIP 3001
|
2013-10-17 15:46:12 +00:00
|
|
|
rc=$?
|
|
|
|
logger -t xCAT -p local4.info "xcatdsklspost:xcatflowrequest return=$rc"
|
|
|
|
if [ $rc -ne 0 ]; then
|
|
|
|
logger -t xCAT -p local4.info "xcatdsklspost: error from xcatflowrequest, will not use flow control"
|
|
|
|
useflowcontrol=0
|
|
|
|
fi
|
2013-10-10 15:25:36 +00:00
|
|
|
fi
|
2014-05-23 07:03:30 +00:00
|
|
|
/$xcatpost/getpostscript.awk | egrep '<data>' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /$xcatpost/mypostscript;
|
2013-10-10 15:25:36 +00:00
|
|
|
|
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
MYCONT=`grep MASTER /$xcatpost/mypostscript`
|
2013-05-16 13:56:17 +00:00
|
|
|
MAX_RETRIES=10
|
|
|
|
RETRY=0
|
|
|
|
while [ -z "$MYCONT" ]; do
|
2013-10-10 15:25:36 +00:00
|
|
|
# not using flow control , need to sleep
|
|
|
|
if [ $useflowcontrol = "0" ]; then
|
|
|
|
let SLI=$RANDOM%10
|
|
|
|
let SLI=SLI+10
|
|
|
|
sleep $SLI
|
|
|
|
fi
|
|
|
|
|
2009-09-16 08:28:04 +00:00
|
|
|
RETRY=$(($RETRY+1))
|
|
|
|
if [ $RETRY -eq $MAX_RETRIES ]
|
|
|
|
then
|
2013-05-16 13:56:17 +00:00
|
|
|
break
|
2009-09-16 08:28:04 +00:00
|
|
|
fi
|
|
|
|
|
2013-10-10 15:25:36 +00:00
|
|
|
if [ $useflowcontrol = "1" ]; then
|
|
|
|
# contact daemon xcatflowrequest <server> 3001
|
|
|
|
logger -t xCAT -p local4.info "xcatdsklspost: sending xcatflowrequest $SIP 3001"
|
|
|
|
/$xcatpost/xcatflowrequest $SIP 3001
|
2013-10-17 15:46:12 +00:00
|
|
|
rc=$?
|
|
|
|
logger -t xCAT -p local4.info "xcatdsklspost:xcatflowrequest return=$rc"
|
|
|
|
if [ $rc -ne 0 ]; then
|
|
|
|
logger -t xCAT -p local4.info "xcatdsklspost: error from xcatflowrequest, will not use flow control"
|
|
|
|
useflowcontrol=0
|
|
|
|
fi
|
2013-10-10 15:25:36 +00:00
|
|
|
fi
|
2014-05-23 07:03:30 +00:00
|
|
|
/$xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/</</g' -e 's/>/>/g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /$xcatpost/mypostscript;
|
2013-06-18 13:51:54 +00:00
|
|
|
MYCONT=`grep MASTER /$xcatpost/mypostscript`
|
2010-03-21 13:11:47 +00:00
|
|
|
if [ ! -z "$MYCONT" ]; then
|
|
|
|
break;
|
2010-01-25 11:34:42 +00:00
|
|
|
fi
|
2013-05-16 13:56:17 +00:00
|
|
|
done
|
|
|
|
fi
|
2012-10-12 05:43:45 +00:00
|
|
|
|
2009-12-04 21:22:07 +00:00
|
|
|
#save the MASTER into the xcatinfo file for node deployment case,
|
|
|
|
#for updatenode case, only save it when -M is specified
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ]; then
|
2013-06-18 13:51:54 +00:00
|
|
|
new_ms=`grep '^MASTER' /$xcatpost/mypostscript |cut -d= -f2`
|
2009-12-04 21:22:07 +00:00
|
|
|
fi
|
|
|
|
if [ -n "$new_ms" ]; then
|
2009-09-21 14:12:48 +00:00
|
|
|
if [ ! -f /opt/xcat/xcatinfo ]; then
|
|
|
|
mkdir -p /opt/xcat
|
2009-12-04 21:22:07 +00:00
|
|
|
touch /opt/xcat/xcatinfo
|
2009-09-21 14:12:48 +00:00
|
|
|
fi
|
|
|
|
grep 'XCATSERVER' /opt/xcat/xcatinfo 2>&1 > /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
2009-12-04 21:22:07 +00:00
|
|
|
sed -i "s/XCATSERVER=.*/XCATSERVER=$new_ms/" /opt/xcat/xcatinfo
|
2009-09-21 14:12:48 +00:00
|
|
|
else
|
2009-12-04 21:22:07 +00:00
|
|
|
echo "XCATSERVER=$new_ms" >> /opt/xcat/xcatinfo
|
2009-09-21 14:12:48 +00:00
|
|
|
fi
|
2009-12-04 21:22:07 +00:00
|
|
|
fi
|
2013-03-04 22:32:17 +00:00
|
|
|
|
2013-10-15 14:21:53 +00:00
|
|
|
#save the USEFLOWCONTROL into the xcatinfo file
|
|
|
|
#for updatenode case, passwd in with the -f flag
|
|
|
|
if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ]; then
|
|
|
|
useflowcontrol=`grep '^USEFLOWCONTROL' /$xcatpost/mypostscript |cut -d= -f2`
|
|
|
|
fi
|
|
|
|
if [ ! -f /opt/xcat/xcatinfo ]; then
|
|
|
|
mkdir -p /opt/xcat
|
|
|
|
touch /opt/xcat/xcatinfo
|
|
|
|
fi
|
|
|
|
if [ -n "$useflowcontrol" ]; then
|
|
|
|
# lets just put YES or NO in xcatinfo
|
|
|
|
if [ "$useflowcontrol" = "1" ] || [ "$useflowcontrol" = "yes" ] || [ "$useflowcontrol" = "YES" ]; then
|
|
|
|
new_fc="YES"
|
|
|
|
else
|
|
|
|
new_fc="NO"
|
|
|
|
fi
|
|
|
|
grep 'USEFLOWCONTROL' /opt/xcat/xcatinfo 2>&1 > /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
sed -i "s/USEFLOWCONTROL=.*/USEFLOWCONTROL=$new_fc/" /opt/xcat/xcatinfo
|
|
|
|
else
|
|
|
|
echo "USEFLOWCONTROL=$new_fc" >> /opt/xcat/xcatinfo
|
|
|
|
fi
|
|
|
|
# no setting means do not use flowcontrol
|
|
|
|
else
|
|
|
|
echo "USEFLOWCONTROL=NO" >> /opt/xcat/xcatinfo
|
|
|
|
fi
|
|
|
|
|
2009-09-21 14:12:48 +00:00
|
|
|
|
2013-05-01 16:40:12 +00:00
|
|
|
# when called by the updatenode command MODE=1,2
|
|
|
|
# the nodename is passed in by xdsh in the NODE environment variable by xdsh.
|
|
|
|
|
2009-07-29 21:25:59 +00:00
|
|
|
#modify the UPDATENODE flag to 1
|
2013-05-01 16:40:12 +00:00
|
|
|
# put NODE in /opt/xcat/xcatinfo
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ "$MODE" = "1" ] || [ "$MODE" = "2" ]; then
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed -e 's/UPDATENODE=0/UPDATENODE=1/g' /$xcatpost/mypostscript`;
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript;
|
2013-05-01 16:40:12 +00:00
|
|
|
if [ ! -f /opt/xcat/xcatinfo ]; then
|
|
|
|
mkdir -p /opt/xcat
|
|
|
|
touch /opt/xcat/xcatinfo
|
|
|
|
fi
|
|
|
|
grep 'NODE' /opt/xcat/xcatinfo 2>&1 > /dev/null
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
sed -i "s/NODE=.*/NODE=$NODE/" /opt/xcat/xcatinfo
|
|
|
|
else
|
|
|
|
echo "NODE=$NODE" >> /opt/xcat/xcatinfo
|
|
|
|
fi
|
|
|
|
#echo "xcatdsklspost:my nodename in the database is $NODE"
|
2009-06-04 15:33:44 +00:00
|
|
|
fi
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ "$MODE" = "5" ]; then
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed -e 's/UPDATENODE=0/UPDATENODE=1\nUPDATESECURITY=1\nexport UPDATESECURITY/g' /$xcatpost/mypostscript`;
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript;
|
2010-03-21 13:11:47 +00:00
|
|
|
fi
|
2009-06-04 15:33:44 +00:00
|
|
|
|
2012-08-31 15:52:31 +00:00
|
|
|
#when a diskfull reboot mode
|
|
|
|
if [ "$MODE" = "6" ]; then
|
|
|
|
# remove the post scripts so that they are not run on reboot
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-08-31 15:52:31 +00:00
|
|
|
# get the RUNBOOTSCRIPTS site variable
|
2013-06-18 13:51:54 +00:00
|
|
|
if [ -f /$xcatpost/mypostscript ]; then
|
|
|
|
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /$xcatpost/mypostscript |cut -d= -f2`
|
2012-08-31 15:52:31 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-12 13:47:41 +00:00
|
|
|
# if admin did not requested running of post boot scripts - then remove PBS
|
2012-08-31 15:52:31 +00:00
|
|
|
if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
|
|
|
|
#remove all the postscripts
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-11 08:48:20 +00:00
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
#TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /$xcatpost/mypostscript.post`
|
|
|
|
#echo "$TMP" > /$xcatpost/mypostscript.post
|
2012-08-31 15:52:31 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2009-12-22 04:34:29 +00:00
|
|
|
# postscript name is specified with the updatenode
|
2013-06-18 13:51:54 +00:00
|
|
|
#cp /$xcatpost/mypostscript /$xcatpost/mypostscript.backup
|
2012-10-15 17:13:49 +00:00
|
|
|
# if the list has a postscript named *start-here* then we must rebuild the
|
|
|
|
# mypostscript file with only the matching *start-here stanza.
|
|
|
|
|
|
|
|
|
|
|
|
if ( pmatch $POSTSCRIPTS "*start-here*" ); then
|
|
|
|
if ( pmatch $POSTSCRIPTS "*osimage-postbootscripts-start-here" ); then
|
|
|
|
# remove all sections but the osimage-postbootscripts section
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# defaults-postbootscripts-start-here/,/# defaults-postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# node-postbootscripts-start-here/,/# node-postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
fi
|
|
|
|
if ( pmatch $POSTSCRIPTS "*postscripts-start-here" ); then
|
|
|
|
#remove all the postbootscripts
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
fi
|
|
|
|
if ( pmatch $POSTSCRIPTS "*postbootscripts-start-here" ); then
|
|
|
|
#remove all the postscripts
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
|
|
|
|
fi
|
|
|
|
if ( pmatch $POSTSCRIPTS "*defaults-postscripts-start-here" ); then
|
|
|
|
# remove all sections but the defaults-postscripts section
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# osimage-postscripts-start-here/,/# osimage-postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# node-postscripts-start-here/,/# node-postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
fi
|
2012-10-11 08:48:20 +00:00
|
|
|
|
2012-10-15 17:13:49 +00:00
|
|
|
if ( pmatch $POSTSCRIPTS "*node-postscripts-start-here" ); then
|
|
|
|
# remove all sections but the node-postscripts section
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# osimage-postscripts-start-here/,/# osimage-postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# defaults-postscripts-start-here/,/# defaults-postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
fi
|
2012-10-11 08:48:20 +00:00
|
|
|
|
2012-10-15 17:13:49 +00:00
|
|
|
if ( pmatch $POSTSCRIPTS "*defaults-postbootscripts-start-here" ); then
|
|
|
|
# remove all sections but the defaults-postbootscripts section
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# osimage-postbootscripts-start-here/,/# osimage-postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# node-postbootscripts-start-here/,/# node-postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if ( pmatch $POSTSCRIPTS "*node-postbootscripts-start-here" ); then
|
|
|
|
# remove all sections but the node-postbootscripts section
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# osimage-postbootscripts-start-here/,/# osimage-postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# defaults-postbootscripts-start-here/,/# defaults-postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# check to see if input postscript list is not empty. If there is a list
|
|
|
|
# remove the built postscripts and only add the ones for the list.
|
|
|
|
else
|
2013-05-16 13:56:17 +00:00
|
|
|
if [ -n "$POSTSCRIPTS" ]; then
|
2012-10-15 17:13:49 +00:00
|
|
|
#remove all the postbootscripts, and replace with list provided
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
#remove all the postscripts
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ d" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
|
|
|
echo "# postscripts-start-here" >> /$xcatpost/mypostscript
|
2012-10-15 17:13:49 +00:00
|
|
|
#add requested postscripts in
|
2013-06-18 13:51:54 +00:00
|
|
|
echo "$POSTSCRIPTS" | tr "," "\n" >> /$xcatpost/mypostscript
|
|
|
|
echo "# postscripts-end-here" >> /$xcatpost/mypostscript
|
2012-10-11 08:48:20 +00:00
|
|
|
|
2012-10-15 17:13:49 +00:00
|
|
|
fi
|
2008-09-08 18:54:30 +00:00
|
|
|
fi
|
2009-07-23 20:56:57 +00:00
|
|
|
|
|
|
|
#ADDSITEYUM is set by post.rh and post.rh.iscsi for full installtion
|
2009-12-15 14:25:36 +00:00
|
|
|
#if [[ "$ADDSITEYUM" = "1" ]]; then
|
2013-06-18 13:51:54 +00:00
|
|
|
# TMP=`sed "/postscripts-start-here/ a addsiteyum" /$xcatpost/mypostscript`
|
|
|
|
# echo "$TMP" > /$xcatpost/mypostscript
|
2009-12-15 14:25:36 +00:00
|
|
|
#fi
|
2009-07-23 20:56:57 +00:00
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
#MYCONT=`cat /$xcatpost/mypostscript`
|
2008-09-08 18:54:30 +00:00
|
|
|
#echo "$MYCONT"
|
|
|
|
|
2009-09-18 11:28:34 +00:00
|
|
|
# use the run_ps subroutine to run the postscripts
|
2013-06-18 13:51:54 +00:00
|
|
|
TMP=`sed "/# postscripts-start-here/,/# postscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /$xcatpost/mypostscript`
|
2009-09-18 11:28:34 +00:00
|
|
|
echo "
|
2012-09-14 02:31:14 +00:00
|
|
|
# global value to store the running status of the postbootscripts,the value is non-zero if one postbootscript failed
|
|
|
|
return_value=0
|
2009-09-18 11:28:34 +00:00
|
|
|
# subroutine used to run postscripts
|
2010-04-09 06:12:40 +00:00
|
|
|
run_ps () {
|
2012-09-14 02:31:14 +00:00
|
|
|
local ret_local=0
|
2010-04-27 05:52:26 +00:00
|
|
|
logdir=\"/var/log/xcat\"
|
2010-04-13 03:48:29 +00:00
|
|
|
mkdir -p \$logdir
|
2010-04-27 05:52:26 +00:00
|
|
|
logfile=\"/var/log/xcat/xcat.log\"
|
2010-04-09 06:12:40 +00:00
|
|
|
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ -f \$1 ]; then
|
2012-04-01 02:14:04 +00:00
|
|
|
echo \"\`date\` Running postscript: \$@\" | tee -a \$logfile
|
2012-12-18 02:52:15 +00:00
|
|
|
./\$@ 2>&1 | tee -a \$logfile
|
2012-09-14 02:31:14 +00:00
|
|
|
ret_local=\${PIPESTATUS[0]}
|
|
|
|
if [ \"\$ret_local\" -ne \"0\" ]; then
|
|
|
|
return_value=\$ret_local
|
|
|
|
fi
|
2013-06-24 12:57:49 +00:00
|
|
|
echo \"Postscript: \$@ exited with code \$ret_local\" | tee -a \$logfile
|
2009-09-18 11:28:34 +00:00
|
|
|
else
|
2012-04-01 02:14:04 +00:00
|
|
|
echo \"\`date\` Postscript \$1 does NOT exist.\" | tee -a \$logfile
|
2012-09-14 02:31:14 +00:00
|
|
|
return_value=-1
|
2009-09-18 11:28:34 +00:00
|
|
|
fi
|
2012-09-14 02:31:14 +00:00
|
|
|
|
|
|
|
return 0
|
2009-09-18 11:28:34 +00:00
|
|
|
}
|
|
|
|
# subroutine end
|
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
" > /$xcatpost/mypostscript
|
|
|
|
echo "$TMP" >> /$xcatpost/mypostscript
|
|
|
|
TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ s/\(.*\)/run_ps \1/;s/run_ps\s*#/#/;s/run_ps\s*$//" /$xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /$xcatpost/mypostscript
|
2009-09-18 11:28:34 +00:00
|
|
|
|
2013-10-25 07:27:46 +00:00
|
|
|
if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ] || [ "$MODE" = "6" ]; then
|
2008-09-26 23:07:45 +00:00
|
|
|
#notify the server that we are done with netbooting
|
2013-06-18 13:51:54 +00:00
|
|
|
CNS=`grep NODESTATUS= /$xcatpost/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
|
2013-06-18 13:51:54 +00:00
|
|
|
# TMP=`sed "/postscripts-start-here/ i\updateflag.awk \\$MASTER 3002 \\"installstatus configuring\\"" /$xcatpost/mypostscript`
|
|
|
|
# echo "$TMP"> /$xcatpost/mypostscript
|
2012-09-14 02:31:14 +00:00
|
|
|
echo "
|
|
|
|
if [ \"\$return_value\" -eq \"0\" ]; then
|
|
|
|
updateflag.awk \$MASTER 3002 \"installstatus booted\"
|
|
|
|
else
|
|
|
|
updateflag.awk \$MASTER 3002 \"installstatus failed\"
|
|
|
|
fi
|
2013-06-18 13:51:54 +00:00
|
|
|
" >> /$xcatpost/mypostscript
|
2009-03-24 03:12:03 +00:00
|
|
|
fi
|
2008-09-26 23:07:45 +00:00
|
|
|
fi
|
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /$xcatpost/mypostscript`
|
|
|
|
echo "$DHCP_TMP" > /$xcatpost/mypostscript
|
2009-02-16 07:22:21 +00:00
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
CLEANUPXCATPOST=`grep CLEANUPXCATPOST= /$xcatpost/mypostscript |awk -F = '{print $2}'`
|
2011-07-04 08:58:30 +00:00
|
|
|
if [ "$CLEANUPXCATPOST" = "'1'" ] || [ "$CLEANUPXCATPOST" = "'yes'" ]; then
|
2013-06-18 13:51:54 +00:00
|
|
|
echo "cd /" >> /$xcatpost/mypostscript
|
2011-07-04 08:58:30 +00:00
|
|
|
# /xcatpost might be read-only for statelite nodes
|
2013-06-18 13:51:54 +00:00
|
|
|
echo "rm -rf /$xcatpost/*" >> /$xcatpost/mypostscript
|
2011-07-04 08:58:30 +00:00
|
|
|
fi
|
|
|
|
|
2012-10-11 08:48:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
if [ "$MODE" = "1" ] || [ "$MODE" = "2" ] || [ "$MODE" = "5" ]; then
|
2013-06-18 13:51:54 +00:00
|
|
|
echo "exit \$return_value" >> /$xcatpost/mypostscript
|
2012-10-11 08:48:20 +00:00
|
|
|
fi
|
|
|
|
|
2013-06-18 13:51:54 +00:00
|
|
|
chmod +x /$xcatpost/mypostscript
|
|
|
|
if [ -x /$xcatpost/mypostscript ];then
|
|
|
|
/$xcatpost/mypostscript
|
2012-10-11 08:48:20 +00:00
|
|
|
VRET_POST=$?
|
2008-05-01 20:52:16 +00:00
|
|
|
fi
|
2008-09-25 03:04:56 +00:00
|
|
|
|
2008-11-09 03:20:21 +00:00
|
|
|
#tell user it is done when this is called by updatenode command
|
2011-09-07 02:32:49 +00:00
|
|
|
if [ "$MODE" = "1" ] || [ "$MODE" = "2" ] || [ "$MODE" = "5" ]; then
|
2009-08-03 11:41:16 +00:00
|
|
|
echo "returned from postscript"
|
2008-11-09 03:20:21 +00:00
|
|
|
fi
|
2008-09-08 18:54:30 +00:00
|
|
|
|
2012-10-11 08:48:20 +00:00
|
|
|
exit $VRET_POST
|