mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-29 09:13:08 +00:00
Merge pull request #1206 from xuweibj/S101003
Add genesis log in doxcat, dodiscovery and bmcsetup
This commit is contained in:
commit
2d193ad6bf
@ -12,6 +12,8 @@
|
||||
# 0x08 0x00 0x49 0x4e 0x54 0x45 0x4c
|
||||
# 0x08 0x04
|
||||
#
|
||||
log_label="xcat.genesis.bmcsetup"
|
||||
|
||||
allowcred.awk &
|
||||
CREDPID=$!
|
||||
sleep 5
|
||||
@ -19,7 +21,7 @@ IPCFGMETHOD=static
|
||||
while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do
|
||||
while ! getipmi
|
||||
do
|
||||
echo "Retrying retrieval of IPMI settings from server"
|
||||
logger -s -t $log_label -p local4.info "Retrying retrieval of IPMI settings from server"
|
||||
done
|
||||
TIMEOUT=15
|
||||
BMCIP=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
||||
@ -36,7 +38,7 @@ while [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; do
|
||||
IPCFGMETHOD="static"
|
||||
fi
|
||||
if [ -z "$BMCIP" -a $IPCFGMETHOD="static" ]; then
|
||||
echo "FAILED TO RETRIEVE SETTINGS, RETRYING in 15 seconds"
|
||||
logger -s -t $log_label -p local4.err "FAILED TO RETRIEVE SETTINGS, RETRYING in 15 seconds"
|
||||
sleep 15
|
||||
fi
|
||||
done
|
||||
@ -44,12 +46,15 @@ kill $CREDPID
|
||||
NUMBMCS=`grep bmcip /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l`
|
||||
IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'`
|
||||
IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'`
|
||||
logger -t $log_label -p local4.info "NUMBMCS is $NUMBMCS, IPMIVER is $IPMIVER, IPMIMFG is $IPMIMFG"
|
||||
|
||||
if [ "$IPMIMFG" == 2 ]; then #IBM
|
||||
XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'`
|
||||
logger -t $log_label -p local4.info "XPROD is $XPROD"
|
||||
if [ "$XPROD" == "220" ]; then
|
||||
LOCKEDUSERS=1
|
||||
BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
||||
logger -t $log_label -p local4.info "BMCPORT is $BMCPORT"
|
||||
if [ ! -z "$BMCPORT" ]; then
|
||||
let idev=0
|
||||
IFS=','
|
||||
@ -57,6 +62,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM
|
||||
ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null
|
||||
ipmitool -d $idev raw 0x04 0x12 0x09 0x01 0x18 0x${p}1 0x00 > /dev/null
|
||||
CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'`
|
||||
logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT"
|
||||
while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do
|
||||
sleep 1
|
||||
CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'`
|
||||
@ -69,6 +75,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM
|
||||
LOCKEDUSERS=1
|
||||
else
|
||||
IBMFAM=`ipmitool raw 0x3a 0x50 |head -n 1| awk '{print $1 $2 $3 $4}'`
|
||||
logger -t $log_label -p local4.info "IBMFAM is $IBMFAM"
|
||||
if [ "$IBMFAM" == "59554f4f" ]; then
|
||||
BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
||||
if [ ! -z "$BMCPORT" ]; then
|
||||
@ -77,6 +84,7 @@ if [ "$IPMIMFG" == 2 ]; then #IBM
|
||||
for p in $BMCPORT; do
|
||||
ipmitool -d $idev raw 0xc 1 1 0xc0 $p > /dev/null
|
||||
CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'`
|
||||
logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT"
|
||||
while [ "$CURBMCPORT" -ne "$BMCPORT" ]; do
|
||||
sleep 1
|
||||
CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'`
|
||||
@ -90,11 +98,13 @@ if [ "$IPMIMFG" == 2 ]; then #IBM
|
||||
elif [ "$IPMIMFG" == 20301 -o "$IPMIMFG" == 19046 ] ; then
|
||||
XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'`
|
||||
IBMVPDV=`ipmitool raw 0x3a 0xb 2 0 16 1`
|
||||
logger -t $log_label -p local4.info "XPROD is $XPROD, IBMVPDV is $IBMVPDV"
|
||||
if [ $IBMVPDV -eq 2 ]; then
|
||||
ISITE=1;
|
||||
fi
|
||||
LOCKEDUSERS=1
|
||||
BMCPORT=`grep bmcport /tmp/ipmicfg.xml |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
||||
logger -t $log_label -p local4.info "BMCPORT is $BMCPORT"
|
||||
if [ ! -z "$BMCPORT" ]; then
|
||||
let idev=0
|
||||
IFS=','
|
||||
@ -109,6 +119,7 @@ elif [ "$IPMIMFG" == 20301 -o "$IPMIMFG" == 19046 ] ; then
|
||||
# reverts to dhcp then static, which setting a static ip for is
|
||||
# considered invalid
|
||||
CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'`
|
||||
logger -t $log_label -p local4.info "CURBMCPORT is $CURBMCPORT"
|
||||
while [ -z "$CURBMCPORT" -o 0"$CURBMCPORT" -ne "$BMCPORT" ]; do
|
||||
sleep 1
|
||||
CURBMCPORT=`ipmitool -d $idev raw 0xc 2 1 0xc0 0 0 | awk '{print $2}'`
|
||||
@ -121,7 +132,7 @@ elif [ "$IPMIMFG" == "47488" ]; then
|
||||
LOCKEDUSERS=1
|
||||
fi
|
||||
|
||||
echo -n "Auto detecting LAN channel..."
|
||||
logger -s -t $log_label -p local4.info "Auto detecting LAN channel..."
|
||||
while [ -z "$LANCHAN" ]; do
|
||||
for TLANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
|
||||
if ipmitool channel info $TLANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $TLANCHAN 5 0 0 > /dev/null 2>&1;
|
||||
@ -132,11 +143,11 @@ while [ -z "$LANCHAN" ]; do
|
||||
echo -n "."
|
||||
done
|
||||
if [ -z "$LANCHAN" ]; then
|
||||
echo "Unable to detect lan channel, retrying in 10 seconds";
|
||||
logger -s -t $log_label -p local4.info "Unable to detect lan channel, retrying in 10 seconds"
|
||||
sleep 10
|
||||
fi
|
||||
done
|
||||
echo "Detected LAN channel $LANCHAN"
|
||||
logger -s -t $log_label -p local4.info "Detected LAN channel $LANCHAN"
|
||||
|
||||
let idev=NUMBMCS
|
||||
if [ $IPCFGMETHOD="static" ]; then
|
||||
@ -236,12 +247,13 @@ if [ "$ISITE" = 1 ]; then
|
||||
CREDPID=$!
|
||||
while ! remoteimmsetup
|
||||
do
|
||||
echo "Waiting for xCAT remote configuration of service processor via CMM.."
|
||||
logger -s -t $log_label -p local4.info "Waiting for xCAT remote configuration of service processor via CMM.."
|
||||
done
|
||||
kill $CREDPID
|
||||
fi
|
||||
CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'`
|
||||
DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//`
|
||||
logger -t $log_label -p local4.info "CURRENTUSER is $CURRENTUSER, DISABLEUSERS is $DISABLEUSERS"
|
||||
for user in $DISABLEUSERS; do
|
||||
while ! ipmitool -d $idev user disable $user; do
|
||||
sleep 1
|
||||
@ -260,6 +272,7 @@ TRIES=0
|
||||
# Last param in ipmitool user priv is the channel to set it on.
|
||||
# Penguin boxes are all channel 2
|
||||
CURRPRIV=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $6}'`
|
||||
logger -t $log_label -p local4.info "CURRPRIV is $CURRPRIV"
|
||||
if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then
|
||||
while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do
|
||||
sleep 1
|
||||
@ -294,7 +307,7 @@ while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do
|
||||
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
||||
done
|
||||
TRIES=0
|
||||
echo "Set up following user table: "
|
||||
logger -s -t $log_label -p local4.info "Set up following user table: "
|
||||
ipmitool -d $idev user list $LANCHAN
|
||||
let idev=idev-1
|
||||
done
|
||||
@ -303,8 +316,7 @@ let idev=NUMBMCS
|
||||
while [ $idev -gt 0 ]; do
|
||||
let idev=idev-1
|
||||
|
||||
|
||||
echo -n "Enabling Channel $LANCHAN: "
|
||||
logger -s -t $log_label -p local4.info "Enabling Channel $LANCHAN: "
|
||||
while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do
|
||||
sleep 1
|
||||
let TRIES=TRIES+1
|
||||
@ -316,29 +328,29 @@ while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do
|
||||
let TRIES=TRIES+1
|
||||
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
||||
done
|
||||
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
||||
if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi
|
||||
TRIES=0
|
||||
|
||||
echo -n "Enabling ARP responses: "
|
||||
logger -s -t $log_label -p local4.info "Enabling ARP responses: "
|
||||
while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do
|
||||
sleep 1
|
||||
let TRIES=TRIES+1
|
||||
echo -n .
|
||||
echo -n "."
|
||||
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
||||
done
|
||||
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
||||
if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi
|
||||
TRIES=0
|
||||
|
||||
echo -n "Enabling IPMI v 1.5 MD5 LAN access:"
|
||||
logger -s -t $log_label -p local4.info "Enabling IPMI v 1.5 MD5 LAN access:"
|
||||
while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do
|
||||
sleep 1
|
||||
let TRIES=TRIES+1
|
||||
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
||||
done
|
||||
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
||||
if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi
|
||||
TRIES=0
|
||||
if [ ! "$IPMIVER" == "1.5" ]; then
|
||||
echo -n "Enabling IPMI v 2.0 LAN access: "
|
||||
logger -s -t $log_label -p local4.info "Enabling IPMI v 2.0 LAN access: "
|
||||
#the following goals:
|
||||
#disable cipher suite 0 (if present, avoid password bypass)
|
||||
#disable cipher suite 1 (if present, to avoid weaking Kg if used)
|
||||
@ -351,6 +363,7 @@ if [ ! "$IPMIVER" == "1.5" ]; then
|
||||
THREEIDX=$(ipmitool lan print $LANCHAN|grep ^RMCP+|cut -d: -f 2|sed -e 's/ //' -e 's/,/\n/g'|grep -n '^3$'|sed -e 's/:.*//')
|
||||
ACCESS=$(ipmitool lan print $LANCHAN|grep 'Cipher Suite Priv Max'|cut -d: -f 2|sed -e 's/ //g' -e 's/\(.\)/\1\n/g'|grep -v '^$')
|
||||
NEWACCESS=""
|
||||
logger -t $log_label -p local4.info "ZEROIDX is $ZEROIDX, ONEIDX is $ONEIDX, TWOIDX is $TWOIDX, THREEIDX is $THREEIDX, ACCESS is $ACCESS"
|
||||
i=1
|
||||
for elem in $ACCESS; do
|
||||
if [ $i = "$ZEROIDX" -o $i = "$ONEIDX" ]; then
|
||||
@ -364,28 +377,28 @@ if [ ! "$IPMIVER" == "1.5" ]; then
|
||||
i=$((i+1))
|
||||
done
|
||||
if ipmitool lan set $LANCHAN cipher_privs $NEWACCESS > /dev/null; then
|
||||
echo OK
|
||||
logger -s -t $log_label -p local4.info "OK"
|
||||
else
|
||||
echo ERROR
|
||||
logger -s -t $log_label -p local4.err "ERROR"
|
||||
fi
|
||||
|
||||
TRIES=0
|
||||
echo -n "Enabling SOL for channel $LANCHAN:"
|
||||
logger -s -t $log_label -p local4.info "Enabling SOL for channel $LANCHAN:"
|
||||
while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do
|
||||
sleep 1
|
||||
let TRIES=TRIES+1
|
||||
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
||||
done
|
||||
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
||||
if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi
|
||||
TRIES=0
|
||||
|
||||
echo -n "Enabling SOL for $BMCUS:"
|
||||
logger -s -t $log_label -p local4.info "Enabling SOL for $BMCUS:"
|
||||
while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do
|
||||
sleep 1
|
||||
let TRIES=TRIES+1
|
||||
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
||||
done
|
||||
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
||||
if [ $TRIES -gt $TIMEOUT ]; then logger -s -t $log_label -p local4.err "ERROR"; else logger -s -t $log_label -p local4.info "OK"; fi
|
||||
|
||||
# 0xc 0x21 with data 7 is used to set payload channel, it is readonly in the ipmiv2.0 doc, so comment this section out.
|
||||
#echo -n "Putting SOL on channel $LANCHAN:"
|
||||
@ -416,9 +429,9 @@ if [ "$XPROD" = "309" -o "$XPROD" = "43707" ] ; then
|
||||
# have a sleep here for 30 seconds, then issue the reset of the BMC
|
||||
sleep 30
|
||||
fi
|
||||
echo "Resetting BMC ..."
|
||||
logger -s -t $log_label -p local4.info "Resetting BMC ..."
|
||||
ipmitool mc reset cold
|
||||
echo "Waiting for the BMC to appear ..."
|
||||
logger -s -t $log_label -p local4.info "Waiting for the BMC to appear ..."
|
||||
sleep 15
|
||||
TRIES=0
|
||||
while ! ipmitool lan print $LANCHAN > /dev/null; do
|
||||
@ -439,7 +452,7 @@ if [ ! -z "$XCATMASTER" ]; then
|
||||
updateflag.awk $XCATMASTER 3002 "installstatus bmcready"
|
||||
fi
|
||||
|
||||
echo "Lighting Identify Light"
|
||||
logger -s -t $log_label -p local4.info "Lighting Identify Light"
|
||||
while :
|
||||
do ipmitool -d $idev raw 0 4 10 > /dev/null
|
||||
sleep 7
|
||||
|
@ -1,10 +1,12 @@
|
||||
#!/bin/bash
|
||||
log_label="xcat.genesis.dodiscovery"
|
||||
|
||||
minixcatd.awk &
|
||||
PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"`
|
||||
PUBKEY=`echo $PUBKEY|sed -e 's/ //g'`
|
||||
export PUBKEY
|
||||
|
||||
echo "Beginning node discovery process"
|
||||
logger -s -t $log_label -p local4.info "Beginning node discovery process..."
|
||||
for nic in `ip link|grep mtu|grep -v LOOPBACK|grep -v usb|grep -v ,LOWER_UP|awk -F: '{print $2}'`; do
|
||||
ip link set $nic up
|
||||
done
|
||||
@ -14,12 +16,12 @@ while [ ! -z "$NICSTOBRINGUP" -a $waitforlink -gt 0 ]; do
|
||||
waitforlink=$((waitforlink - 1))
|
||||
sleep 0.1
|
||||
if [ $waitforlink = 1 ]; then
|
||||
echo "No link detected on $NICSTOBRINGUP"
|
||||
logger -s -t $log_label -p local4.warning "No link detected on $NICSTOBRINGUP after 10 seconds"
|
||||
fi
|
||||
done
|
||||
NICSGETTINGADDR=`ip link|grep mtu|grep -v LOOPBACK|grep -v usb|grep ,LOWER_UP|awk -F: '{print $2}'`
|
||||
timewaiting=0
|
||||
echo "Waiting for nics to get addresses"
|
||||
logger -s -t $log_label -p local4.info "Waiting for nics to get addresses"
|
||||
while [ ! -z "$NICSGETTINGADDR" -a $timewaiting != 700 ]; do
|
||||
NEWNICSGETTINGADDR=""
|
||||
for nic in $NICSGETTINGADDR; do
|
||||
@ -33,14 +35,14 @@ while [ ! -z "$NICSGETTINGADDR" -a $timewaiting != 700 ]; do
|
||||
sleep 0.1
|
||||
timewaiting=$((timewaiting+1))
|
||||
if [ $timewaiting = 699 ]; then
|
||||
echo "No DHCP answer for $nic, ignoring interface"
|
||||
logger -s -t $log_label -p local4.warning "No DHCP answer for $nic, ignoring interface..."
|
||||
fi
|
||||
NICSGETTINGADDR=$NEWNICSGETTINGADDR
|
||||
done
|
||||
if [ $timewaiting != 700 -a $timewaiting -gt 450 ]; then
|
||||
echo "Got an address, but it took inordinately long, you may want to check spanning tree configuration"
|
||||
logger -s -t $log_label -p local4.warning "Obtained an IP address $NICSGETTINGADDR but it took $timewaiting cycles, you may want to check the spanning tree configuration in the switch."
|
||||
fi
|
||||
echo "Network configuration complete, commencing transmit of discovery packets"
|
||||
logger -s -t $log_label -p local4.info "Network configuration complete, commencing transmit of discovery packets"
|
||||
XCATPORT=3001
|
||||
export XCATPORT
|
||||
for parm in `cat /proc/cmdline`; do
|
||||
@ -109,6 +111,8 @@ DISKSIZE=`cat /proc/partitions |grep -e "sd.\>" |awk -F' ' '{printf "%s:%.0fGB\n
|
||||
# echo $line > /tmp/cpumod
|
||||
#done
|
||||
#CPUTYPE=`cat /tmp/cpumod|awk -F':' '{print $2}'|sed -e 's/^ //'`
|
||||
|
||||
logger -t $log_label -p local4.info "Beginning echo infomation to discovery packet file..."
|
||||
echo '<xcatrequest>' > /tmp/discopacket
|
||||
echo "<command>findme</command>" >> /tmp/discopacket
|
||||
echo "<arch>$ARCH</arch>" >> /tmp/discopacket
|
||||
@ -243,16 +247,20 @@ cat /tmp/discopacket |while read line; do
|
||||
echo $line >> /tmp/discopacket.new
|
||||
done
|
||||
mv /tmp/discopacket.new /tmp/discopacket
|
||||
|
||||
logger -t $log_label -p local4.info "Discovery packet file is ready."
|
||||
rm -f /tmp/discopacket.gz
|
||||
gzip -9 /tmp/discopacket
|
||||
if [ ! -z "$XCATMASTER" ]; then
|
||||
logger -t $log_label -p local4.info "Sending the discovery packet to xCAT ($XCATMASTER:$XCATPORT)..."
|
||||
(cat /tmp/discopacket.gz | udpcat.awk $XCATMASTER $XCATPORT ) &
|
||||
fi
|
||||
for dhcps in `grep dhcp-server /var/lib/dhclient/dhclient.leases|awk '{print $4}'|sed -s 's/;//'`; do
|
||||
logger -t $log_label -p local4.info "Sending the discovery packet to xCAT ($dhcps:$XCATPORT)..."
|
||||
(cat /tmp/discopacket.gz | udpcat.awk $dhcps $XCATPORT ) &
|
||||
done
|
||||
#cat /tmp/discopacket
|
||||
logger -t $log_label -p local4.info "Sleeping 5 seconds..."
|
||||
sleep 5
|
||||
done
|
||||
logger -t $log_label -p local4.info "Restart..."
|
||||
/bin/restart
|
||||
|
@ -3,6 +3,21 @@
|
||||
# - Added slash in front of "var" in the NICSTOBRINGUP dhclient section.
|
||||
# Bug reported by Jeff Lang <jrlang@uwyo.edu>. Thanks, Jeff!
|
||||
#
|
||||
log_label="xcat.genesis.doxcat"
|
||||
|
||||
# Start rsyslogd and log into a local file specified in /etc/rsyslog.conf
|
||||
# Later, once xCAT MN is known, dhclient-script will change
|
||||
# rsyslog.conf file to send log entries to xCAT MN
|
||||
RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1`
|
||||
if [ $RSYSLOGD_VERSION -ge 8 ]; then
|
||||
/sbin/rsyslogd
|
||||
# Newer vers of rsyslogd (8 and higher) do not support -c flag anymore
|
||||
else
|
||||
/sbin/rsyslogd -c4
|
||||
fi
|
||||
|
||||
logger -t $log_label -p local4.info "Beginning doxcat process..."
|
||||
|
||||
modprobe acpi_cpufreq 2>/dev/null # on some machines this fails
|
||||
modprobe cpufreq_ondemand
|
||||
if ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor &>/dev/null; then
|
||||
@ -12,14 +27,13 @@ if ls /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor &>/dev/null; then
|
||||
fi
|
||||
if [ ! -z "$BOOTIF" ]; then
|
||||
BOOTIF=`echo $BOOTIF|sed -e s/01-// -e s/-/:/g`
|
||||
echo -n "Waiting for device with address $BOOTIF to appear.."
|
||||
logger -s -t $log_label -p local4.info "Waiting for device with address $BOOTIF to appear.."
|
||||
gripeiter=6000
|
||||
while [ -z "$bootnic" ]; do
|
||||
bootnic=`ip link show|grep -B1 $BOOTIF|grep mtu|awk '{print $2}'|sed -e 's/:$//'`
|
||||
sleep 0.1
|
||||
if [ $gripeiter = 0 ]; then
|
||||
echo "ERROR"
|
||||
echo "Unable to find boot device (maybe the nbroot is missing the driver for your nic?)"
|
||||
logger -s -t $log_label -p local4.err "Unable to find boot device (maybe the nbroot is missing the driver for your nic?)"
|
||||
while :; do sleep 365d; done
|
||||
fi
|
||||
gripeiter=$((gripeiter-1))
|
||||
@ -27,7 +41,7 @@ if [ ! -z "$BOOTIF" ]; then
|
||||
fi
|
||||
echo "Done"
|
||||
if [ -z "$bootnic" ]; then
|
||||
echo "ERROR: BOOTIF missing, can't detect boot nic"
|
||||
logger -s -t $log_label -p local4.err "BOOTIF missing, can't detect boot nic"
|
||||
fi
|
||||
|
||||
if [ -r /sys/devices/virtual/dmi/id/product_uuid ]; then
|
||||
@ -61,22 +75,14 @@ echo "[ req ]
|
||||
distinguished_name = nodedn
|
||||
|
||||
[ nodedn ]" > /etc/pki/tls/openssl.cnf
|
||||
echo -n "Generating private key..."
|
||||
logger -s -t $log_label -p local4.info "Generating private key..."
|
||||
openssl genrsa -out /etc/xcat/privkey.pem 1024 >& /dev/null
|
||||
echo "Done"
|
||||
logger -s -t $log_label -p local4.info "Done"
|
||||
PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"`
|
||||
PUBKEY=`echo $PUBKEY|sed -e 's/ //g'`
|
||||
export PUBKEY
|
||||
RSYSLOGD_VERSION=`rsyslogd -v | grep "rsyslogd" | cut -d" " -f2 | cut -d"." -f1`
|
||||
# Start rsyslogd and log into a local file specified in /etc/rsyslog.conf
|
||||
# Later, once xCAT MN is known, dhclient-script will change
|
||||
# rsyslog.conf file to send log entries to xCAT MN
|
||||
if [ $RSYSLOGD_VERSION -ge 8 ]; then
|
||||
# Newer vers of rsyslogd (8 and higher) do not support -c flag anymore
|
||||
/sbin/rsyslogd
|
||||
else
|
||||
/sbin/rsyslogd -c4
|
||||
fi
|
||||
|
||||
logger -t $log_label -p local4.info "Creating /var/lib/lldpad file..."
|
||||
mkdir -p /var/lib/lldpad
|
||||
echo 'lldp :' >> /var/lib/lldpad/lldpad.conf
|
||||
echo '{' >> /var/lib/lldpad/lldpad.conf
|
||||
@ -93,6 +99,7 @@ echo '};' >> /var/lib/lldpad/lldpad.conf
|
||||
done
|
||||
echo '};' >> /var/lib/lldpad/lldpad.conf
|
||||
lldpad -d
|
||||
logger -t $log_label -p local4.info "lldpad started."
|
||||
|
||||
# Caclulate the broadcast address of a given IP address and mask.
|
||||
bcastcalc(){
|
||||
@ -126,7 +133,7 @@ mask2prefix() {
|
||||
192) let nbits+=2;;
|
||||
128) let nbits+=1;;
|
||||
0);;
|
||||
*) echo "Error: $dec is not recognised"; exit 1
|
||||
*) logger -s -t $log_label -p local4.err "$dec is not recognised"; exit 1
|
||||
esac
|
||||
done
|
||||
IFS=$old_ifs
|
||||
@ -152,23 +159,25 @@ done
|
||||
export XCATPORT
|
||||
export XCATMASTER
|
||||
|
||||
logger -t $log_label -p local4.info "XCATMASTER is $XCATMASTER, XCATPORT is $XCATPORT"
|
||||
|
||||
if [[ -n $hostip && -n $netmask && -n $gateway && -n $bootnic ]]; then
|
||||
# doing static ip
|
||||
# the device was determined above from the bootif mac, and put in bootnic
|
||||
numbits=$(mask2prefix $netmask)
|
||||
broadcast=$(bcastcalc $hostip $netmask)
|
||||
echo "Setting static IP=$hostip/$numbits broadcast=$broadcast gateway=$gateway device=$bootnic BOOTIF=$BOOTIF ..."
|
||||
logger -s -t $log_label -p local4.info "Setting static IP=$hostip/$numbits broadcast=$broadcast gateway=$gateway device=$bootnic BOOTIF=$BOOTIF ..."
|
||||
ip addr add $hostip/$numbits broadcast $broadcast dev $bootnic scope global label $bootnic
|
||||
ip link set $bootnic up
|
||||
ip route replace to default via $gateway dev $bootnic
|
||||
# in softlayer it takes up to 60 seconds for the nic to actually be able to communicate
|
||||
echo -n Waiting to reach xCAT mgmt node $gateway.
|
||||
logger -s -t $log_label -p local4.info "Waiting to reach xCAT mgmt node $gateway."
|
||||
xcatretries=60
|
||||
while [ $((xcati+=1)) -le $xcatretries ] && ! ping -c2 -w3 $gateway >/dev/null 2>&1; do echo -n .; done
|
||||
if [ $xcati -le $xcatretries ]; then echo " success"; else echo " failed"; fi
|
||||
sleep 3
|
||||
else
|
||||
echo "Setting IP via DHCP..."
|
||||
logger -s -t $log_label -p local4.info "Setting IP via DHCP..."
|
||||
# This section is for System P hardware discovery, which won't have a BOOTIF value set
|
||||
if [ -z "$bootnic" ]; then
|
||||
tries=0
|
||||
@ -187,13 +196,14 @@ else
|
||||
tries=$(($tries+1))
|
||||
done
|
||||
|
||||
echo -n "Acquiring network addresses.."
|
||||
logger -s -t $log_label -p local4.info "Acquiring network addresses.."
|
||||
tries=0
|
||||
while [ -z "$bootnic" ]; do
|
||||
for tmp1 in $ALLUP_NICS; do
|
||||
if ip addr show dev $tmp1|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet > /dev/null; then
|
||||
result=`ping -c1 -I $tmp1 $XCATMASTER 2>&1`
|
||||
if [ $? -eq 0 ]; then
|
||||
logger -s -t $log_label -p local4.info "the nic $tmp1 can ping $XCATMASTER"
|
||||
bootnic=$tmp1
|
||||
break
|
||||
fi
|
||||
@ -207,6 +217,7 @@ else
|
||||
done
|
||||
if [ -z "$bootnic" ]; then
|
||||
/bin/bash
|
||||
logger -s -t $log_label -p local4.info "still can not get $bootnic, go into /bin/bash"
|
||||
fi
|
||||
else
|
||||
dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic &
|
||||
@ -222,21 +233,36 @@ else
|
||||
done
|
||||
|
||||
gripeiter=101
|
||||
echo -n "Acquiring network addresses.."
|
||||
logger -s -t $log_label -p local4.info "Acquiring network addresses.."
|
||||
while ! ip addr show dev $bootnic|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet > /dev/null; do
|
||||
sleep 0.1
|
||||
if [ $gripeiter = 1 ]; then
|
||||
echo
|
||||
echo "It seems to be taking a while to acquire an IPv4 address, you may want to check spanning tree..."
|
||||
logger -s -t $log_label -p local4.info "It seems to be taking a while to acquire an IPv4 address, you may want to check spanning tree..."
|
||||
fi
|
||||
gripeiter=$((gripeiter-1))
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
count_f=0
|
||||
while [ $count_f -le 8 ]; do
|
||||
rsyslogd_ps=`ps -ef | grep 'rsyslogd' | grep -v 'grep'`
|
||||
if [ "$rsyslogd_ps" ]; then
|
||||
break
|
||||
else
|
||||
((count_f++))
|
||||
sleep 0.5
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $count_f -gt 8 ]; then
|
||||
echo "rsyslogd maybe off"
|
||||
fi
|
||||
|
||||
openssl genrsa -out /etc/xcat/certkey.pem 4096 > /dev/null 2>&1 &
|
||||
|
||||
echo -n "Acquired IPv4 address on $bootnic: "
|
||||
logger -s -t $log_label -p local4.info "Acquired IPv4 address on $bootnic"
|
||||
|
||||
ip addr show dev $bootnic|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet|awk '{print $2}'
|
||||
ntpd -g -x
|
||||
# rv 0 state does not work with the new ntp versions
|
||||
@ -265,70 +291,94 @@ DEVICE=$bootnic
|
||||
export DEVICE
|
||||
|
||||
if [ "$destiny" != "discover" ]; then #we aren't discoverying, we probably can and should get a cert
|
||||
logger -t $log_label -p local4.info "Run getcert $XCATMASTER:$XCATPORT..."
|
||||
/bin/getcert $XCATMASTER:$XCATPORT
|
||||
logger -t $log_label -p local4.info "Getcert done."
|
||||
fi
|
||||
while :; do
|
||||
|
||||
grepconfigraid=`echo $destiny|grep "configraid"`
|
||||
if [ -z "$destiny" -o -n "$grepconfigraid" ]; then
|
||||
logger -t $log_label -p local4.info "Run getdestiny $XCATMASTER:$XCATPORT..."
|
||||
destiny=`getdestiny $XCATMASTER:$XCATPORT`
|
||||
logger -t $log_label -p local4.info "Getdestiny done."
|
||||
fi
|
||||
|
||||
destparameter=`echo $destiny|cut -d '=' -f 2-`
|
||||
destparameter=`echo $destiny|cut -d '=' -f 2-`
|
||||
logger -t $log_label -p local4.info "The destparameter is $destparameter"
|
||||
|
||||
destiny=`echo $destiny|awk -F= '{print $1}'`
|
||||
dest=`echo $destiny|awk '{print $1}'` #could probably use bash but oh well
|
||||
logger -t $log_label -p local4.info "The destiny is $destiny"
|
||||
|
||||
dest=`echo $destiny|awk '{print $1}'` #could probably use bash but oh well
|
||||
logger -t $log_label -p local4.info "The dest is $dest"
|
||||
|
||||
if [ "$dest" = "discover" ]; then #skip a query to xCAT when /proc/cmdline will do
|
||||
logger -t $log_label -p local4.info "Run dodiscovery..."
|
||||
/bin/dodiscovery
|
||||
logger -t $log_label -p local4.info "Dodiscovery done."
|
||||
logger -t $log_label -p local4.info "Run getcert $XCATMASTER:$XCATPORT..."
|
||||
/bin/getcert $XCATMASTER:$XCATPORT
|
||||
logger -t $log_label -p local4.info "Getcert done."
|
||||
destiny=''
|
||||
dest=''
|
||||
elif [ "$dest" = shell ]; then
|
||||
echo "Dropping to debug shell, exit to run next destiny"
|
||||
logger -s -t $log_label -p local4.info "Dropping to debug shell(exit to run next destiny)..."
|
||||
destiny=''
|
||||
dest=''
|
||||
/bin/bash
|
||||
/bin/nextdestiny $XCATMASTER:$XCATPORT
|
||||
logger -t $log_label -p local4.info "Exit shell."
|
||||
logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..."
|
||||
/bin/nextdestiny $XCATMASTER:$XCATPORT
|
||||
logger -t $log_label -p local4.info "Nextdestiny done."
|
||||
elif [ "$dest" = runcmd ]; then
|
||||
logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..."
|
||||
destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT`
|
||||
dest=`echo $destiny|awk -F= '{print $1}'`
|
||||
$destparameter
|
||||
$destparameter
|
||||
logger -t $log_label -p local4.info "Nextdestiny done."
|
||||
elif [ "$dest" = runimage ]; then
|
||||
logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..."
|
||||
destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT`
|
||||
dest=`echo $destiny|awk -F= '{print $1}'`
|
||||
logger -t $log_label -p local4.info "Nextdestiny done."
|
||||
mkdir /tmp/`basename $destparameter`
|
||||
cd /tmp/`basename $destparameter`
|
||||
eval destparameter=$destparameter
|
||||
ERROR=`wget $destparameter 2>&1`
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
echo "Failed to wget $destparameter"
|
||||
echo $ERROR
|
||||
logger -s -t $log_label -p local4.err "Failed to wget $destparameter, $ERROR"
|
||||
fi
|
||||
while [ $rc -ne 0 ] && echo $ERROR|grep -v 416; do
|
||||
sleep 10
|
||||
ERROR=`wget -c $destparameter 2>&1`
|
||||
rc=$?
|
||||
if [ $rc -ne 0 ]; then
|
||||
echo "Failed to wget $destparameter"
|
||||
echo $ERROR
|
||||
logger -s -t $log_label -p local4.err "Failed to wget $destparameter, $ERROR"
|
||||
fi
|
||||
done
|
||||
tar xvf `basename $destparameter`
|
||||
./runme.sh
|
||||
cd -
|
||||
elif [ "$dest" = "reboot" -o "$dest" = "boot" ]; then
|
||||
logger -t $log_label -p local4.info "Run nextdestiny $XCATMASTER:$XCATPORT..."
|
||||
/bin/nextdestiny $XCATMASTER:$XCATPORT
|
||||
if [ $IPMI_SUPPORT -ne 0 ]; then
|
||||
logger -t $log_label -p local4.info "Nextdestiny done."
|
||||
if [ $IPMI_SUPPORT -ne 0 ]; then
|
||||
ipmitool chassis bootdev pxe
|
||||
fi
|
||||
fi
|
||||
reboot -f
|
||||
elif [ "$dest" = "install" -o "$dest" = "netboot" ]; then
|
||||
if [ $IPMI_SUPPORT -ne 0 ]; then
|
||||
if [ $IPMI_SUPPORT -ne 0 ]; then
|
||||
ipmitool chassis bootdev pxe
|
||||
fi
|
||||
fi
|
||||
logger -t $log_label -p local4.info "Reboot..."
|
||||
reboot -f
|
||||
elif [ "$dest" = sysclone ]; then
|
||||
logger -t $log_label -p local4.info "Run dosysclone..."
|
||||
/bin/dosysclone
|
||||
logger -t $log_label -p local4.info "Dosysclone done."
|
||||
destiny=''
|
||||
dest=''
|
||||
elif [ "$dest" = standby ]; then
|
||||
@ -336,24 +386,27 @@ while :; do
|
||||
dest=''
|
||||
delay=$((30+$RANDOM%270))
|
||||
while [ $delay -gt 0 ]; do
|
||||
echo -en "Received request to retry in a bit, will call xCAT back in $delay seconds \r"
|
||||
logger -s -t $log_label -p local4.info "Received request to retry in a bit, will call xCAT back in $delay seconds"
|
||||
delay=$((delay-1))
|
||||
sleep 1
|
||||
done
|
||||
echo "Retrying ";
|
||||
elif [ "$dest" = shutdown ]; then
|
||||
logger -t $log_label -p local4.info "Poweroff..."
|
||||
poweroff -f
|
||||
else
|
||||
echo "Unrecognized directive $dest"
|
||||
logger -s -t $log_label -p local4.err "Unrecognized directive $dest"
|
||||
destiny=''
|
||||
dest=''
|
||||
delay=$((30+$RANDOM%270))
|
||||
while [ $delay -gt 0 ]; do
|
||||
echo -en "Will retry in $delay seconds \r"
|
||||
logger -s -t $log_label -p local4.info "Will retry in $delay seconds"
|
||||
delay=$((delay-1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
logger -t $log_label -p local4.info "doxcat is done"
|
||||
set +x
|
||||
|
Loading…
x
Reference in New Issue
Block a user