2013-02-08 05:43:18 +00:00
#
# 2013.02.07 Brian Elliott Finley <bfinley@us.ibm.com>
# - Added slash in front of "var" in the NICSTOBRINGUP dhclient section.
# Bug reported by Jeff Lang <jrlang@uwyo.edu>. Thanks, Jeff!
#
2011-06-17 20:16:38 +00:00
if [ ! -z "$BOOTIF" ]; then
BOOTIF=`echo $BOOTIF|sed -e s/01-// -e s/-/:/g`
echo -n "Waiting for device with address $BOOTIF to appear.."
2012-07-09 19:23:23 +00:00
gripeiter=6000
2011-06-17 20:16:38 +00:00
while [ -z "$bootnic" ]; do
2011-07-14 17:37:30 +00:00
bootnic=`ip link show|grep -B1 $BOOTIF|grep mtu|awk '{print $2}'|sed -e 's/:$//'`
2011-06-17 20:16:38 +00:00
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?)"
while :; do sleep 365d; done
fi
gripeiter=$((gripeiter-1))
done
fi
echo "Done"
if [ -z "$bootnic" ]; then
echo "ERROR: BOOTIF missing, can't detect boot nic"
fi
if [ -r /sys/devices/virtual/dmi/id/product_uuid ]; then
duid='default-duid "\\000\\004';
2012-03-06 15:55:30 +00:00
#product_uuid in sysfs fails to cope with endianness of SMBIOS 2.6, unconditionnaly swap. Technically leads to incorrect DUID in 'older' systems but matches MS behavior
for i in `sed -e 's/\(..\)\(..\)\(..\)\(..\)-\(..\)\(..\)-\(..\)\(..\)/\4\3\2\1-\6\5-\8\7/;s/-//g;s/\(..\)/\1 /g' /sys/devices/virtual/dmi/id/product_uuid`; do
2011-06-17 20:16:38 +00:00
octnum="\\"`printf "\\%03o" 0x$i`
duid=$duid$octnum
done
duid=$duid'";'
echo $duid > /var/lib/dhclient/dhclient6.leases
fi
2011-07-28 17:18:10 +00:00
rpcbind
rpc.statd
2011-06-17 15:47:37 +00:00
ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C '' -N ''
ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C '' -N ''
echo 'Protocol 2' >> /etc/ssh/sshd_config
/usr/sbin/sshd
2011-07-08 18:46:24 +00:00
mkdir -p /etc/xcat
2011-07-13 18:13:11 +00:00
mkdir -p /etc/pki/tls
2011-08-31 17:59:33 +00:00
echo "[ req ]
distinguished_name = nodedn
[ nodedn ]" > /etc/pki/tls/openssl.cnf
2011-09-15 22:00:55 +00:00
echo -n "Generating private key..."
openssl genrsa -out /etc/xcat/privkey.pem 1024 >& /dev/null
echo "Done"
PUBKEY=`openssl rsa -in /etc/xcat/privkey.pem -pubout 2> /dev/null|grep -v "PUBLIC KEY"`
2011-07-08 18:46:24 +00:00
PUBKEY=`echo $PUBKEY|sed -e 's/ //g'`
2011-07-11 18:52:03 +00:00
export PUBKEY
2011-07-28 18:31:30 +00:00
/sbin/rsyslogd -c4
2011-07-08 18:46:24 +00:00
mkdir -p /var/lib/lldpad
echo 'lldp :' >> /var/lib/lldpad/lldpad.conf
echo '{' >> /var/lib/lldpad/lldpad.conf
2011-07-14 16:44:38 +00:00
for iface in `ip link |grep -v '^ '|awk '{print $2}'|sed -e 's/:$//'|grep -v lo`; do
2011-07-08 18:46:24 +00:00
echo "$iface :" >> /var/lib/lldpad/lldpad.conf
echo "{" >> /var/lib/lldpad/lldpad.conf
echo "tlvid00000006 :" >> /var/lib/lldpad/lldpad.conf
echo "{" >> /var/lib/lldpad/lldpad.conf
echo info = '"'$PUBKEY'";' >> /var/lib/lldpad/lldpad.conf
2011-07-14 16:36:29 +00:00
echo 'enableTx = true;' >> /var/lib/lldpad/lldpad.conf
2011-07-08 18:46:24 +00:00
echo '};' >> /var/lib/lldpad/lldpad.conf
echo 'adminStatus = 3;' >> /var/lib/lldpad/lldpad.conf
echo '};' >> /var/lib/lldpad/lldpad.conf
done
echo '};' >> /var/lib/lldpad/lldpad.conf
lldpad -d
2011-08-31 14:21:14 +00:00
dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$bootnic.pid $bootnic &
2012-02-05 17:12:49 +00:00
#we'll kick of IPv6 and IPv4 on all nics, but not wait for them to come up unless doing discovery, to reduce
#chances that we'll perform a partial discovery
#in other scenarios where downed non-bootnics cause issues, will rely on retries to fix things up
2011-08-31 14:21:14 +00:00
dhclient -6 -pf /var/run/dhclient6.$bootnic.pid $bootnic -lf /var/lib/dhclient/dhclient6.leases &
2012-02-05 17:12:49 +00:00
NICSTOBRINGUP=`ip link|grep mtu|grep -v LOOPBACK|grep -v $bootnic|grep -v usb|grep -v ,UP|awk -F: '{print $2}'`
export NICSTOBRINGUP
for nic in $NICSTOBRINGUP; do
dhclient -cf /etc/dhclient.conf -pf /var/run/dhclient.$nic.pid $nic &
2013-02-08 05:43:18 +00:00
dhclient -cf /etc/dhclient.conf -6 -pf /var/run/dhclient6.$nic.pid -lf /var/lib/dhclient/dhclient6.leases $nic &
2012-02-05 17:12:49 +00:00
done
2011-08-31 14:21:14 +00:00
openssl genrsa -out /etc/xcat/certkey.pem 4096 > /dev/null 2>&1 &
2011-07-08 18:46:24 +00:00
2011-06-17 20:16:38 +00:00
gripeiter=101
echo -n "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..."
fi
gripeiter=$((gripeiter-1))
done
2012-02-05 17:12:49 +00:00
echo -n "Acquired IPv4 address on $bootnic: "
2011-06-17 20:16:38 +00:00
ip addr show dev $bootnic|grep -v 'scope link'|grep -v 'dynamic'|grep -v inet6|grep inet|awk '{print $2}'
2011-07-19 15:00:21 +00:00
ntpd -g -x
(while ! ntpq -c "rv 0 state"|grep 'state=4' > /dev/null; do sleep 1; done; hwclock --systohc) &
2011-08-02 15:27:52 +00:00
if dmidecode|grep IPMI > /dev/null; then
modprobe ipmi_si
modprobe ipmi_devintf
fi
2011-08-31 17:59:33 +00:00
XCATPORT=3001
export XCATPORT
for parm in `cat /proc/cmdline`; do
key=`echo $parm|awk -F= '{print $1}'`
if [ "$key" = "xcatd" ]; then
XCATMASTER=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $1}'`
XCATPORT=`echo $parm|awk -F= '{print $2}'|awk -F: '{print $2}'`
fi
done
2011-09-02 17:12:27 +00:00
if [ "$destiny" != "discover" ]; then #we aren't discoverying, we probably can and should get a cert
/bin/getcert $XCATMASTER:$XCATPORT
2011-06-17 21:00:46 +00:00
fi
2011-09-02 17:12:27 +00:00
while :; do
if [ -z "$destiny" ]; then
2011-09-06 16:26:16 +00:00
destiny=`getdestiny $XCATMASTER:$XCATPORT`
2011-09-02 17:12:27 +00:00
fi
destparameter=`echo $destiny|awk -F= '{print $2}'`
destiny=`echo $destiny|awk -F= '{print $1}'`
2012-01-05 21:52:24 +00:00
dest=`echo $destiny|awk '{print $1}'` #could probably use bash but oh well
2012-01-18 21:16:24 +00:00
if [ "$dest" = "discover" ]; then #skip a query to xCAT when /proc/cmdline will do
2011-09-02 17:12:27 +00:00
/bin/dodiscovery
/bin/getcert $XCATMASTER:$XCATPORT
destiny=''
2012-01-18 21:16:24 +00:00
dest=''
elif [ "$dest" = shell ]; then
2011-09-02 17:12:27 +00:00
echo "Dropping to debug shell, exit to check for further action"
destiny=''
2012-01-18 21:16:24 +00:00
dest=''
2011-09-15 22:00:55 +00:00
/bin/bash
2012-01-18 21:16:24 +00:00
elif [ "$dest" = runcmd ]; then
2011-09-06 16:26:16 +00:00
destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT`
2012-01-18 21:16:24 +00:00
dest=`echo $destiny|awk -F= '{print $1}'`
2011-09-02 17:12:27 +00:00
$destparameter
2012-01-18 21:16:24 +00:00
elif [ "$dest" = runimage ]; then
2011-09-06 16:26:16 +00:00
destiny=`/bin/nextdestiny $XCATMASTER:$XCATPORT`
2012-01-18 21:16:24 +00:00
dest=`echo $destiny|awk -F= '{print $1}'`
2011-09-06 16:26:16 +00:00
mkdir /tmp/`basename $destparameter`
cd /tmp/`basename $destparameter`
2012-03-23 15:02:26 +00:00
ERROR=`wget $destparameter 2>&1`
2011-09-06 16:26:16 +00:00
while [ $? == 1 ] && echo $ERROR|grep -v 416; do
sleep 10
2012-03-23 15:14:43 +00:00
ERROR=`wget -c $destparameter 2>&1`
2011-09-06 16:26:16 +00:00
done
2012-03-23 15:14:43 +00:00
tar xvf `basename $destparameter`
2011-09-06 16:26:16 +00:00
./runme.sh
cd -
2012-01-18 21:16:24 +00:00
elif [ "$dest" = "reboot" -o "$dest" = "boot" ]; then
2011-09-06 16:26:16 +00:00
/bin/nextdestiny $XCATMASTER:$XCATPORT
2011-09-02 17:12:27 +00:00
reboot -f
2012-01-05 21:52:24 +00:00
elif [ "$dest" = "install" -o "$dest" = "netboot" ]; then
reboot -f
2012-01-18 21:16:24 +00:00
elif [ "$dest" = standby ]; then
2011-09-02 17:12:27 +00:00
destiny=''
2012-01-18 21:16:24 +00:00
dest=''
2011-09-02 17:12:27 +00:00
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"
delay=$((delay-1))
sleep 1
done
echo "Retrying ";
else
2012-01-18 21:16:24 +00:00
echo "Unrecognized directive $dest"
2011-09-02 17:12:27 +00:00
destiny=''
2012-01-18 21:16:24 +00:00
dest=''
2011-09-02 17:12:27 +00:00
delay=$((30+$RANDOM%270))
while [ $delay -gt 0 ]; do
echo -en "Will retry in $delay seconds \r"
delay=$((delay-1))
sleep 1
done
fi
done