2010-08-24 19:32:36 +00:00
|
|
|
echo ARP=no >> /etc/sysconfig/network-scripts/ifcfg-eth0
|
|
|
|
|
|
|
|
# Get hostname
|
|
|
|
export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}')
|
|
|
|
hostname $HOSTNAME
|
|
|
|
|
|
|
|
# Run xcat postscripts
|
|
|
|
# Master/service node set by nodeset
|
|
|
|
export MASTER_IPS=( replace_master )
|
|
|
|
export MASTER=replace_master
|
2012-09-01 03:28:41 +00:00
|
|
|
export INSTALLDIR=replace_install_dir
|
|
|
|
if [ -z "$INSTALLDIR" ]; then
|
|
|
|
INSTALLDIR="/install"
|
|
|
|
fi
|
|
|
|
|
2011-08-16 19:30:27 +00:00
|
|
|
cd /tmp
|
2010-08-24 19:32:36 +00:00
|
|
|
RAND=$(perl -e 'print int(rand(50)). "\n"')
|
|
|
|
sleep $RAND
|
|
|
|
|
|
|
|
# Loop through the master/service nodes
|
2012-05-04 14:27:19 +00:00
|
|
|
for t in $(seq 1 20)
|
2010-08-24 19:32:36 +00:00
|
|
|
do
|
2012-09-01 03:28:41 +00:00
|
|
|
GOTIT=0
|
|
|
|
for i in $MASTER_IPS
|
|
|
|
do
|
|
|
|
# Download postscripts from server
|
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -e robots=off -nH --cut-dirs=2 --reject "index.html*" --no-parent -t 0 -T 60 http://$i$INSTALLDIR/postscripts/ -P /xcatpost
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
# Exit if openssl is not executable
|
|
|
|
if [ ! -x /usr/bin/openssl ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
USEOPENSSLFORXCAT=1
|
|
|
|
export USEOPENSSLFORXCAT
|
|
|
|
|
|
|
|
# Get xcat server
|
|
|
|
XCATSERVER=$i:3001
|
|
|
|
export XCATSERVER
|
2010-08-24 19:32:36 +00:00
|
|
|
|
2012-09-01 03:28:41 +00:00
|
|
|
# Move postscritps into /xcatpost
|
|
|
|
mv $i/postscripts /xcatpost
|
|
|
|
# Remove postscritps
|
|
|
|
rm -rf $i
|
|
|
|
|
|
|
|
# Make postscripts executable
|
|
|
|
chmod +x /xcatpost/*
|
|
|
|
|
|
|
|
# Get postscript to run on this node from xcat server
|
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
|
|
|
|
MYCONT=`grep MASTER /xcatpost/mypostscript`
|
|
|
|
MAX_RETRIES=10
|
|
|
|
RETRY=0
|
|
|
|
while [ -z "$MYCONT" ]; do
|
|
|
|
RETRY=$(($RETRY+1))
|
|
|
|
if [ $RETRY -eq $MAX_RETRIES ]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Sleep a couple of seconds before trying again
|
|
|
|
let SLI=$RANDOM%10+10
|
|
|
|
sleep $SLI
|
|
|
|
|
|
|
|
# Get postscript to run on this node from xcat server
|
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript
|
|
|
|
MYCONT=`grep MASTER /xcatpost/mypostscript`
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make executable
|
|
|
|
chmod +x /xcatpost/mypostscript
|
|
|
|
GOTIT=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# If postscripts for this node are found
|
|
|
|
if [ "$GOTIT" = "1" ]; then
|
|
|
|
# Save the master/service node 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
|
|
|
|
echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
RAND=$(perl -e 'print int(rand(5)). "\n"')
|
|
|
|
sleep $RAND
|
2010-08-24 19:32:36 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
cd /xcatpost
|
|
|
|
export PATH=/xcatpost:$PATH
|
|
|
|
|
2012-09-01 03:28:41 +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*$//" /xcatpost/mypostscript`
|
2012-02-07 19:22:25 +00:00
|
|
|
echo "
|
2012-09-01 03:28:41 +00:00
|
|
|
# Subroutine used to run postscripts
|
2012-02-07 19:22:25 +00:00
|
|
|
run_ps () {
|
2012-09-01 03:28:41 +00:00
|
|
|
logdir=\"/var/log/xcat\"
|
|
|
|
mkdir -p \$logdir
|
|
|
|
logfile=\"/var/log/xcat/xcat.log\"
|
2012-02-07 19:22:25 +00:00
|
|
|
|
2012-09-01 03:28:41 +00:00
|
|
|
if [ -f \$1 ]; then
|
|
|
|
echo \"Running postscript: \$@\" | tee -a \$logfile
|
|
|
|
./\$@ 2>&1 | tee -a $logfile
|
|
|
|
else
|
|
|
|
echo \"Postscript \$1 does NOT exist.\" | tee -a \$logfile
|
|
|
|
fi
|
2012-02-07 19:22:25 +00:00
|
|
|
}
|
2012-09-01 03:28:41 +00:00
|
|
|
# Subroutine end
|
2012-02-07 19:22:25 +00:00
|
|
|
|
2012-09-01 03:28:41 +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
|
2012-02-07 19:22:25 +00:00
|
|
|
|
|
|
|
|
2012-09-01 03:28:41 +00:00
|
|
|
# Save post boot scripts to /xcatpost/mypostscript.post
|
|
|
|
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /xcatpost/mypostscript.post
|
|
|
|
chmod 755 /xcatpost/mypostscript.post
|
2010-08-24 19:32:36 +00:00
|
|
|
|
|
|
|
# Create post init
|
|
|
|
cat >/etc/init.d/xcatpostinit1 << 'EOF'
|
|
|
|
# Install directory variable set by nodeset
|
2012-09-01 03:28:41 +00:00
|
|
|
$INSTALLDIR/postscripts/xcatpostinit1
|
2010-08-24 19:32:36 +00:00
|
|
|
EOF
|
|
|
|
# Change permissions
|
|
|
|
chmod 755 /etc/init.d/xcatpostinit1
|
|
|
|
|
|
|
|
# Create post install
|
|
|
|
mkdir -p /opt/xcat
|
|
|
|
cat >/opt/xcat/xcatinstallpost << 'EOF'
|
|
|
|
# Install directory variable set by nodeset
|
2012-09-01 03:28:41 +00:00
|
|
|
$INSTALLDIR/postscripts/xcatinstallpost
|
2010-08-24 19:32:36 +00:00
|
|
|
EOF
|
|
|
|
chmod 755 /opt/xcat/xcatinstallpost
|
|
|
|
|
2012-10-04 21:02:15 +00:00
|
|
|
chkconfig --add xcatpostinit1
|
|
|
|
|
2012-10-03 11:27:29 +00:00
|
|
|
#create the dskls post
|
|
|
|
cat >/opt/xcat/xcatdsklspost << 'EOF'
|
|
|
|
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatdsklspost#
|
|
|
|
EOF
|
|
|
|
chmod 755 /opt/xcat/xcatdsklspost
|
2010-08-24 19:32:36 +00:00
|
|
|
|
|
|
|
# Only run preboot scripts here
|
2012-09-01 03:28:41 +00:00
|
|
|
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /xcatpost/mypostscript`
|
|
|
|
echo "$TMP" > /xcatpost/mypostscript
|
|
|
|
/xcatpost/mypostscript
|
2010-08-24 19:32:36 +00:00
|
|
|
|
|
|
|
# Master/service node variable set by nodeset
|
2012-09-01 03:28:41 +00:00
|
|
|
updateflag.awk $MASTER 3002
|