2010-08-23 20:41:41 +00:00
|
|
|
echo ARP=no >> /etc/sysconfig/network-scripts/ifcfg-eth0
|
|
|
|
|
2010-08-24 03:08:19 +00:00
|
|
|
# Get hostname
|
|
|
|
export HOSTNAME=$(host $IP 2>/dev/null | awk '{print $5}' | awk -F. '{print $1}')
|
|
|
|
hostname $HOSTNAME
|
2010-08-23 20:41:41 +00:00
|
|
|
|
2010-08-24 03:08:19 +00:00
|
|
|
# Run xcat postscripts
|
|
|
|
# Master/service node set by nodeset
|
2010-08-23 20:41:41 +00:00
|
|
|
export MASTER_IPS=( replace_master )
|
2010-08-24 03:08:19 +00:00
|
|
|
export MASTER=replace_master
|
|
|
|
cd /tmp
|
|
|
|
RAND=$(perl -e 'print int(rand(50)). "\n"')
|
|
|
|
sleep $RAND
|
2010-08-23 20:41:41 +00:00
|
|
|
|
2010-08-24 03:08:19 +00:00
|
|
|
# Loop through the master/service nodes
|
2010-08-23 20:41:41 +00:00
|
|
|
for i in $(seq 1 20)
|
|
|
|
do
|
|
|
|
GOTIT=0
|
|
|
|
for i in $MASTER_IPS
|
|
|
|
do
|
|
|
|
# Download postscripts from FTP server
|
|
|
|
wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/postscripts
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
# Exit if openssl is not executable
|
2010-08-24 03:08:19 +00:00
|
|
|
if [ ! -x /usr/bin/openssl ]; then
|
|
|
|
exit 1
|
2010-08-23 20:41:41 +00:00
|
|
|
fi
|
2010-08-24 03:08:19 +00:00
|
|
|
|
|
|
|
USEOPENSSLFORXCAT=1
|
|
|
|
export USEOPENSSLFORXCAT
|
|
|
|
|
2010-08-23 20:41:41 +00:00
|
|
|
# Get xcat server
|
|
|
|
XCATSERVER=$i:3001
|
|
|
|
export XCATSERVER
|
2010-08-24 03:08:19 +00:00
|
|
|
|
2010-08-23 20:41: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/^ *//' > /tmp/mypostscript
|
|
|
|
MYCONT=`grep MASTER /tmp/mypostscript`
|
2010-08-24 03:08:19 +00:00
|
|
|
MAX_RETRIES=10
|
2010-08-23 20:41:41 +00:00
|
|
|
RETRY=0
|
|
|
|
while [ -z "$MYCONT" ]; do
|
|
|
|
RETRY=$(($RETRY+1))
|
2010-08-24 03:08:19 +00:00
|
|
|
if [ $RETRY -eq $MAX_RETRIES ]
|
|
|
|
then
|
2010-08-23 20:41:41 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
2010-08-24 03:08:19 +00:00
|
|
|
# Sleep a couple of seconds before trying again
|
2010-08-23 20:41:41 +00:00
|
|
|
let SLI=$RANDOM%10+10
|
|
|
|
sleep $SLI
|
2010-08-24 03:08:19 +00:00
|
|
|
|
2010-08-23 20:41:41 +00:00
|
|
|
# Get postscript to run on this node from xcat server
|
|
|
|
/xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript
|
|
|
|
MYCONT=`grep MASTER /tmp/mypostscript`
|
|
|
|
done
|
2010-08-24 03:08:19 +00:00
|
|
|
|
2010-08-23 20:41:41 +00:00
|
|
|
# Make executable
|
|
|
|
chmod +x /tmp/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
|
2010-08-24 03:08:19 +00:00
|
|
|
break
|
2010-08-23 20:41:41 +00:00
|
|
|
fi
|
|
|
|
RAND=$(perl -e 'print int(rand(5)). "\n"')
|
|
|
|
sleep $RAND
|
|
|
|
done
|
|
|
|
|
2010-08-24 03:08:19 +00:00
|
|
|
cd /xcatpost
|
|
|
|
export PATH=/xcatpost:$PATH
|
2010-08-23 20:41:41 +00:00
|
|
|
|
|
|
|
# Save post boot scripts to /tmp/mypostscript.post
|
|
|
|
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /tmp/mypostscript`
|
|
|
|
echo "$TMP" > /tmp/mypostscript.post
|
|
|
|
chmod 755 /tmp/mypostscript.post
|
|
|
|
|
|
|
|
# Create post init
|
|
|
|
cat >/etc/init.d/xcatpostinit1 << 'EOF'
|
2010-08-24 03:08:19 +00:00
|
|
|
# Install directory variable set by nodeset
|
2010-08-23 20:41:41 +00:00
|
|
|
replace_install_dir/postscripts/xcatpostinit1
|
|
|
|
EOF
|
|
|
|
# Change permissions
|
|
|
|
chmod 755 /etc/init.d/xcatpostinit1
|
|
|
|
|
2010-08-24 03:08:19 +00:00
|
|
|
# Create post install
|
2010-08-23 20:41:41 +00:00
|
|
|
mkdir -p /opt/xcat
|
|
|
|
cat >/opt/xcat/xcatinstallpost << 'EOF'
|
2010-08-24 03:08:19 +00:00
|
|
|
# Install directory variable set by nodeset
|
2010-08-23 20:41:41 +00:00
|
|
|
replace_install_dir/postscripts/xcatinstallpost
|
|
|
|
chkconfig xcatpostinit1 off
|
|
|
|
EOF
|
|
|
|
chmod 755 /opt/xcat/xcatinstallpost
|
|
|
|
|
|
|
|
chkconfig --add xcatpostinit1
|
|
|
|
|
2010-08-24 03:08:19 +00:00
|
|
|
# Only run preboot scripts here
|
2010-08-23 20:41:41 +00:00
|
|
|
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /tmp/mypostscript`
|
|
|
|
echo "$TMP" > /tmp/mypostscript
|
|
|
|
/tmp/mypostscript
|
|
|
|
|
2010-08-24 03:08:19 +00:00
|
|
|
# Master/service node variable set by nodeset
|
2010-08-23 20:41:41 +00:00
|
|
|
updateflag.awk replace_master 3002
|
2010-08-24 03:08:19 +00:00
|
|
|
cd /
|
|
|
|
|
|
|
|
exit 0
|