2007-10-26 22:44:33 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
2008-09-18 21:12:21 +00:00
|
|
|
#
|
|
|
|
# Raw commands to set BMCs to defaults
|
2008-09-30 13:59:10 +00:00
|
|
|
# dx320
|
|
|
|
# 0x2e 0x10 0x4d 0x4f 0x00 0xff
|
|
|
|
#
|
2008-09-18 21:12:21 +00:00
|
|
|
# dx340
|
|
|
|
# 0x30 0x13 0xff 0x00 0x00 0x00
|
|
|
|
#
|
2008-09-30 13:59:10 +00:00
|
|
|
# dx360/x3450
|
2008-09-18 21:12:21 +00:00
|
|
|
# 0x30 0x02 0x43 0x4c 0x52 0xaa
|
|
|
|
# 0x08 0x00 0x49 0x4e 0x54 0x45 0x4c
|
|
|
|
# 0x08 0x04
|
|
|
|
#
|
2008-09-06 22:36:02 +00:00
|
|
|
allowcred.awk &
|
|
|
|
CREDPID=$!
|
2010-06-25 19:46:00 +00:00
|
|
|
sleep 1
|
2007-10-26 22:44:33 +00:00
|
|
|
modprobe ipmi_si
|
|
|
|
modprobe ipmi_devintf
|
2009-05-22 18:45:00 +00:00
|
|
|
while [ -z "$BMCIP" ]; do
|
|
|
|
while ! getipmi
|
|
|
|
do
|
|
|
|
echo "Retrying retrieval of IPMI settings from server"
|
|
|
|
done
|
|
|
|
TIMEOUT=15
|
|
|
|
BMCIP=`grep bmcip /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
|
|
|
BMCGW=`grep gateway /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
|
|
|
BMCNM=`grep netmask /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
|
|
|
BMCUS=`grep username /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
|
|
|
BMCPW=`grep password /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
|
|
|
if [ -z "$BMCIP" ]; then
|
|
|
|
echo "FAILED TO RETRIEVE SETTINGS, RETRYING in 15 seconds"
|
|
|
|
sleep 15
|
|
|
|
fi
|
2007-10-26 22:44:33 +00:00
|
|
|
done
|
2010-06-25 19:46:00 +00:00
|
|
|
kill $CREDPID
|
2011-05-09 14:21:07 +00:00
|
|
|
NUMBMCS=`grep bmcip /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'|wc -l`
|
2008-10-30 15:22:31 +00:00
|
|
|
IPMIVER=`ipmitool mc info|grep ^IPMI|awk '{print $4}'`
|
2009-03-02 20:12:48 +00:00
|
|
|
IPMIMFG=`ipmitool mc info|grep "^Manufacturer ID"|awk '{print $4}'`
|
|
|
|
if [ "$IPMIMFG" == 2 ]; then #IBM
|
2010-11-10 15:21:04 +00:00
|
|
|
XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'`
|
|
|
|
if [ "$XPROD" == "220" ]; then
|
|
|
|
LOCKEDUSERS=1
|
2009-03-02 20:12:48 +00:00
|
|
|
BMCPORT=`grep bmcport /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
|
|
|
if [ ! -z "$BMCPORT" ]; then
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=0
|
|
|
|
for p in $BMCPORT; do
|
|
|
|
ipmitool -d $idev raw 0xc 1 1 0xc0 $BMCPORT > /dev/null
|
|
|
|
let idev=idev+1
|
|
|
|
done
|
2009-03-02 20:12:48 +00:00
|
|
|
fi
|
2010-11-10 15:21:04 +00:00
|
|
|
else
|
|
|
|
IBMFAM=`ipmitool raw 0x3a 0x50 |head -n 1| awk '{print $1 $2 $3 $4}'`
|
|
|
|
if [ "$IBMFAM" == "59554f4f" ]; then
|
|
|
|
BMCPORT=`grep bmcport /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
|
|
|
if [ ! -z "$BMCPORT" ]; then
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=0
|
|
|
|
for p in $BMCPORT; do
|
|
|
|
ipmitool -d $idev raw 0xc 1 1 0xc0 $BMCPORT > /dev/null
|
|
|
|
let idev=idev+1
|
|
|
|
done
|
2010-11-10 15:21:04 +00:00
|
|
|
fi
|
|
|
|
fi
|
2009-03-02 20:12:48 +00:00
|
|
|
fi
|
2010-06-25 14:16:46 +00:00
|
|
|
elif [ "$IPMIMFG" == 20301 ] ; then
|
|
|
|
XPROD=`ipmitool mc info|grep "^Product ID"|awk '{print $4}'`
|
|
|
|
if [ "$XPROD" == "220" ]; then
|
2010-06-25 19:46:00 +00:00
|
|
|
LOCKEDUSERS=1
|
2010-06-25 14:16:46 +00:00
|
|
|
BMCPORT=`grep bmcport /tmp/ipmi.data |awk -F\> '{print $2}'|awk -F\< '{print $1}'`
|
2010-06-25 14:37:18 +00:00
|
|
|
if [ ! -z "$BMCPORT" ]; then
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=0
|
|
|
|
for p in $BMCPORT; do
|
|
|
|
ipmitool -d $idev raw 0xc 1 1 0xc0 $BMCPORT > /dev/null
|
|
|
|
let idev=idev+1
|
|
|
|
done
|
2010-06-25 14:16:46 +00:00
|
|
|
fi
|
|
|
|
fi
|
2009-03-02 20:12:48 +00:00
|
|
|
fi
|
2010-06-25 19:46:00 +00:00
|
|
|
echo -n "Auto detecting LAN channel..."
|
2010-06-25 14:16:46 +00:00
|
|
|
|
|
|
|
for LANCHAN in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do
|
2010-06-25 14:37:18 +00:00
|
|
|
if ipmitool channel info $LANCHAN 2> /dev/null | grep 802.3 > /dev/null 2>&1 && ipmitool raw 0xc 2 $LANCHAN 5 0 0 > /dev/null 2>&1;
|
2010-06-25 14:16:46 +00:00
|
|
|
then break;
|
|
|
|
fi;
|
|
|
|
echo -n "."
|
|
|
|
done
|
|
|
|
echo "Detected LAN channel $LANCHAN"
|
2009-03-02 20:12:48 +00:00
|
|
|
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=NUMBMCS
|
|
|
|
while [ $idev -gt 0 ]; do
|
|
|
|
let idev=idev-1
|
|
|
|
TRIES=0
|
|
|
|
while ! ipmitool -d $idev lan set $LANCHAN ipsrc static; do
|
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=0
|
|
|
|
for b in $BMCIP; do
|
|
|
|
TRIES=0
|
|
|
|
while ! ipmitool -d $idev lan set $LANCHAN ipaddr $b; do
|
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
|
|
|
let idev=idev+1
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=0
|
|
|
|
for m in $BMCNM; do
|
|
|
|
TRIES=0
|
|
|
|
while ! ipmitool -d $idev lan set $LANCHAN netmask $m; do
|
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
|
|
|
let idev=idev+1
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2007-10-26 22:44:33 +00:00
|
|
|
if [ ! -z "$BMCGW" ]; then
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=0
|
|
|
|
for g in $BMCGW; do
|
|
|
|
TRIES=0
|
|
|
|
while ! ipmitool -d $idev lan set $LANCHAN defgw ipaddr $g; do
|
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
|
|
|
let idev=idev+1
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2007-10-26 22:44:33 +00:00
|
|
|
fi
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=0
|
|
|
|
for bmcu in $BMCUS; do
|
2010-06-25 19:46:00 +00:00
|
|
|
DISABLEUSERS="1 2 3 4"
|
|
|
|
if [ ! -z "$LOCKEDUSERS" ]; then
|
2011-05-09 14:21:07 +00:00
|
|
|
USERSLOT=`ipmitool -d $idev user list $LANCHAN |grep -v ^ID|awk '{print $1 " " $2}'|grep " $BMCUS"|awk '{print $1}'`
|
2010-06-25 19:46:00 +00:00
|
|
|
if [ -z "$USERSLOT" ]; then
|
|
|
|
USERSLOT=4
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
USERSLOT=2
|
|
|
|
fi
|
2011-05-09 14:21:07 +00:00
|
|
|
CURRENTUSER=`ipmitool -d $idev user list $LANCHAN|grep ^$USERSLOT|awk '{print $2}'`
|
2010-06-25 19:46:00 +00:00
|
|
|
DISABLEUSERS=`echo 1 2 3 4|sed -e s/$USERSLOT//`
|
|
|
|
for user in $DISABLEUSERS; do
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev user disable $user; do
|
2010-06-25 19:46:00 +00:00
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
|
|
|
TRIES=0
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev user enable $USERSLOT; do
|
2008-10-02 19:01:40 +00:00
|
|
|
sleep 1
|
2008-10-30 15:22:31 +00:00
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2010-06-11 20:34:25 +00:00
|
|
|
# Last param in ipmitool user priv is the channel to set it on.
|
|
|
|
# Penguin boxes are all channel 2
|
2011-05-09 14:21:07 +00:00
|
|
|
CURRPRIV=`ipmitool -d $idev user list 1|grep ^$USERSLOT|awk '{print $6}'`
|
2010-08-16 19:47:05 +00:00
|
|
|
if [ "$CURRPRIV" != "ADMINISTRATOR" ]; then
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev user priv $USERSLOT 4 $LANCHAN; do
|
2010-08-16 19:47:05 +00:00
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
2008-10-30 15:22:31 +00:00
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
2010-08-16 19:47:05 +00:00
|
|
|
done
|
|
|
|
TRIES=0
|
|
|
|
fi
|
2011-05-09 14:21:07 +00:00
|
|
|
if [ "$CURRENTUSER" != "$bmcu" ]; then
|
|
|
|
while ! ipmitool -d $idev user set name $USERSLOT $bmcu; do
|
2010-06-25 19:46:00 +00:00
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
|
|
|
fi
|
2011-05-09 14:21:07 +00:00
|
|
|
let idev=idev+1
|
|
|
|
done
|
|
|
|
let idev=0
|
|
|
|
for bmcp in $BMCPW; do
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev user set password $USERSLOT $bmcp; do
|
2008-10-02 19:01:40 +00:00
|
|
|
sleep 1
|
2008-10-30 15:22:31 +00:00
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2007-10-26 22:44:33 +00:00
|
|
|
echo "Set up following user table: "
|
2011-05-09 14:21:07 +00:00
|
|
|
ipmitool -d $idev user list $LANCHAN
|
|
|
|
let idev=idev+1
|
|
|
|
done
|
|
|
|
|
|
|
|
let idev=NUMBMCS
|
|
|
|
while [ $idev -gt 0 ]; do
|
|
|
|
let idev=idev-1
|
2007-10-26 22:44:33 +00:00
|
|
|
|
2008-01-16 01:53:29 +00:00
|
|
|
|
2010-06-25 19:46:00 +00:00
|
|
|
echo -n "Enabling Channel $LANCHAN: "
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x42 0x44 > /dev/null; do
|
2008-10-02 19:01:40 +00:00
|
|
|
sleep 1
|
2008-10-30 15:22:31 +00:00
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev raw 0x6 0x40 $LANCHAN 0x82 0x84 > /dev/null; do
|
2008-10-02 19:01:40 +00:00
|
|
|
sleep 1
|
2008-10-30 15:22:31 +00:00
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2010-06-25 19:46:00 +00:00
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2008-01-16 01:53:29 +00:00
|
|
|
|
2008-10-30 15:22:31 +00:00
|
|
|
echo -n "Enabling ARP responses: "
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev lan set $LANCHAN arp respond on > /dev/null; do
|
2008-10-02 19:01:40 +00:00
|
|
|
sleep 1
|
2008-10-30 15:22:31 +00:00
|
|
|
let TRIES=TRIES+1
|
|
|
|
echo -n .
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2010-06-25 19:46:00 +00:00
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2008-01-16 01:53:29 +00:00
|
|
|
|
2010-06-25 19:46:00 +00:00
|
|
|
echo -n "Enabling IPMI v 1.5 MD5 LAN access:"
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev lan set $LANCHAN auth admin md5 > /dev/null; do
|
2008-10-02 19:01:40 +00:00
|
|
|
sleep 1
|
2008-10-30 15:22:31 +00:00
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
2008-10-02 19:01:40 +00:00
|
|
|
done
|
2010-06-25 19:46:00 +00:00
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
|
|
|
if [ ! "$IPMIVER" == "1.5" ]; then
|
2010-06-25 19:46:00 +00:00
|
|
|
echo -n "Enabling IPMI v 2.0 LAN access:"
|
2011-05-09 14:21:07 +00:00
|
|
|
SUPPORTEDSUITES=`ipmitool -d $idev lan print $LANCHAN|grep Suites|awk -F: '{print $2}'|sed -e 's/ 0//'`
|
2010-06-25 19:46:00 +00:00
|
|
|
PRIVS="X"
|
2009-02-11 15:55:29 +00:00
|
|
|
for priv in 1 2 3 4 5 6 7 8 9 10 11 12 13 14; do
|
|
|
|
if echo $SUPPORTEDSUITES|grep $priv > /dev/null; then
|
|
|
|
PRIVS="$PRIVS"a
|
|
|
|
else
|
|
|
|
PRIVS="$PRIVS"X
|
|
|
|
fi
|
|
|
|
done
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev lan set $LANCHAN cipher_privs $PRIVS > /dev/null; do
|
2008-10-30 15:22:31 +00:00
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
2010-06-25 19:46:00 +00:00
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
2008-01-16 01:53:29 +00:00
|
|
|
|
2010-06-25 19:46:00 +00:00
|
|
|
echo -n "Enabling SOL for channel $LANCHAN:"
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 0x1 0x1 > /dev/null; do
|
2008-10-30 15:22:31 +00:00
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
2010-06-25 19:46:00 +00:00
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
2008-10-30 15:22:31 +00:00
|
|
|
TRIES=0
|
|
|
|
|
2010-06-25 19:46:00 +00:00
|
|
|
echo -n "Enabling SOL for $BMCUS:"
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev raw 6 0x4c $LANCHAN $USERSLOT 2 0 0 0 > /dev/null; do
|
2008-10-30 15:22:31 +00:00
|
|
|
sleep 1
|
|
|
|
let TRIES=TRIES+1
|
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then break; fi
|
|
|
|
done
|
2010-06-25 19:46:00 +00:00
|
|
|
if [ $TRIES -gt $TIMEOUT ]; then echo "ERROR"; else echo "OK"; fi
|
2011-03-03 14:59:00 +00:00
|
|
|
echo -n "Putting SOL on channel $LANCHAN:"
|
2011-05-09 14:21:07 +00:00
|
|
|
while ! ipmitool -d $idev raw 0xc 0x21 $LANCHAN 7 $LANCHAN > /dev/null; do
|
2011-03-03 14:59:00 +00:00
|
|
|
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
|
2008-10-30 15:22:31 +00:00
|
|
|
fi
|
2008-01-16 01:53:29 +00:00
|
|
|
|
2008-10-30 15:22:31 +00:00
|
|
|
#frume.awk
|
2008-09-22 23:40:33 +00:00
|
|
|
|
2008-05-21 18:03:46 +00:00
|
|
|
echo "Lighting Identify Light"
|
2008-10-02 19:01:40 +00:00
|
|
|
while :
|
2011-05-09 14:21:07 +00:00
|
|
|
do ipmitool -d $idev raw 0 4 10 > /dev/null
|
2010-06-25 19:46:00 +00:00
|
|
|
sleep 7
|
2008-10-02 19:01:40 +00:00
|
|
|
done &
|
2011-05-09 14:21:07 +00:00
|
|
|
done
|
2008-05-21 18:03:46 +00:00
|
|
|
|