2007-10-26 22:44:33 +00:00
#!/bin/sh
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
nic=0
hba=0
MOD=""
2008-03-19 18:33:48 +00:00
NICSTOWAIT=""
2008-03-21 20:00:07 +00:00
touch /etc/motd
2008-03-19 18:33:48 +00:00
echo "cat /etc/motd" >> /etc/profile
2007-10-26 22:44:33 +00:00
#Load common usb drivers
modprobe ohci-hcd
modprobe uhci-hcd
modprobe ehci-hcd
2008-03-21 21:17:57 +00:00
for d in /proc/sys/net/ipv4/conf/*; do
echo 1 > $d/arp_filter
echo 1 > $d/arp_ignore
done
2007-10-26 22:44:33 +00:00
for i in $(lspci -n | awk '{print $1 "%" $3}')
do
PCI=$(echo $i | awk -F% '{print $1}')
VID="0x0000$(echo $i | awk -F% '{print $2}' |awk -F: '{print $1}')"
DID="0x0000$(echo $i | awk -F% '{print $2}' |awk -F: '{print $2}')"
2009-09-01 18:02:44 +00:00
if egrep "^[^ ]*[ ]*$VID[ ]*$DID" /lib/modules/`uname -r`/modules.pcimap >/dev/null
2007-10-26 22:44:33 +00:00
then
TYPE=$(
lspci | \
grep "^$PCI " | \
awk '{print $2}' | \
tr '[A-Z]' '[a-z]'
)
DESC=$(
lspci | \
grep "^$PCI " | \
awk -F: '{print $3}' | \
sed 's/^ *//'
)
MOD=$(
2009-09-01 18:02:44 +00:00
egrep "^[^ ]*[ ]*$VID[ ]*$DID" /lib/modules/`uname -r`/modules.pcimap | \
2007-10-26 22:44:33 +00:00
head -1 | \
awk '{print $1}' | \
tr -d '"'
)
case "$TYPE" in
ethernet|network)
echo "Found ($MOD) $DESC"
GOTNIC=1
if [ "$MOD" = "gm" ]
then
echo "alias myri0 $MOD"
echo "alias myri0 $MOD" >>/etc/modules.conf
echo "alias myri0 $MOD" >>/etc/modprobe.conf
else
2009-11-21 17:01:06 +00:00
modprobe $MOD
if [ "mlx4_core" = "$MOD" ]; then
modprobe mlx4_en
fi
2007-10-26 22:44:33 +00:00
fi
;;
scsi|raid)
echo "Found ($MOD) $DESC"
GOTHBA=1
2008-04-24 17:41:53 +00:00
modprobe $MOD & #We background so that messed up SANs don't stop shell
2007-10-26 22:44:33 +00:00
modprobe sd_mod
modprobe scsi_mod
hba=$(($hba + 1))
;;
*)
continue
;;
esac
fi
done
2009-09-18 19:12:19 +00:00
NEEDVETH=0;
for dir in /proc/device-tree/vdevice/l-lan*; do
if [ -d $dir ]; then NEEDVETH=1; fi
done
2010-04-26 18:04:35 +00:00
if [ $NEEDVETH = 1 ]; then
2007-11-26 18:43:11 +00:00
modprobe ibmveth
fi
2009-09-18 19:12:19 +00:00
NEEDEHEA=0;
for dir in /proc/device-tree/lhea*; do
if [ -d $dir ]; then NEEDEHEA=1; fi
done
2010-04-26 18:04:35 +00:00
if [ $NEEDEHEA = 1 ]; then
2007-11-12 18:30:02 +00:00
modprobe ehea
fi
2007-10-26 22:44:33 +00:00
2009-11-21 17:01:06 +00:00
NICSTOWAIT=`/sbin/ifconfig -a|grep HWaddr|grep ^eth|sed -e 's/ .*//'`
2010-06-17 20:39:20 +00:00
#run udhcpc in two ways, to flush out leases with uid and leases without uid, and actually use the results of the more 'linux-like' lease, either way, on exit will release all to hold no leases
2009-11-21 17:01:06 +00:00
for nic in $NICSTOWAIT; do
2010-06-22 17:35:42 +00:00
touch /tmp/ignorenic.$nic
2009-11-21 17:01:06 +00:00
ifconfig $nic up
2010-06-22 18:15:42 +00:00
(udhcpc -i $nic -R;kill -USR2 `ps axf|grep -v grep|grep "udhcpc -i $nic -R"|awk '{print $1}'`;kill `ps axf|grep -v grep|grep "udhcpc -i $nic -R"|awk '{print $1}'`; rm /tmp/ignorenic.$nic; udhcpc -i $nic -R -C) &
2009-11-21 17:01:06 +00:00
done
2010-04-28 19:06:31 +00:00
extrat=0
2010-04-26 18:04:35 +00:00
until [ $extrat = 80 -o -z "$NICSTOWAIT" ]; do
2008-03-19 18:33:48 +00:00
sleep 1
2010-04-28 19:06:31 +00:00
extrat=$(($extrat+1))
2008-03-19 18:33:48 +00:00
for nic in $NICSTOWAIT; do
2010-06-22 17:35:42 +00:00
if [ ! -f /tmp/ignorenic.$nic ] && ifconfig $nic|grep "inet addr"; then
2008-03-19 18:33:48 +00:00
NICSTOWAIT=`echo $NICSTOWAIT|sed -e s/$nic//`
if [ $extrat -gt 45 ]; then
echo "Warning: $nic took more than 45 seconds to receive DHCP reply, spanning-tree may not be configured well, examine switch configuration" >> /etc/motd
2008-04-09 20:41:44 +00:00
echo "Warning: $nic took more than 45 seconds to receive DHCP reply, spanning-tree may not be configured well, examine switch configuration"
2008-03-19 18:33:48 +00:00
fi
2010-04-26 18:04:35 +00:00
elif [ $extrat = 15 ]; then
2008-03-19 18:33:48 +00:00
if ethtool $nic | grep "Link detected: no"; then
2008-04-09 20:41:44 +00:00
echo "$nic did not have any link when bringing up network"
2008-03-19 18:33:48 +00:00
echo "$nic did not have any link when bringing up network" >> /etc/motd
NICSTOWAIT=`echo $NICSTOWAIT|sed -e s/$nic//`
fi
fi
done
done
if [ ! -z "$NICSTOWAIT" ]; then
2008-04-09 20:41:44 +00:00
echo "Warning: the following network devices appeared to be connected to networks, but received no DHCP response: $NICSTOWAIT" >> /etc/motd
2008-03-19 18:33:48 +00:00
echo "Warning: the following network devices appeared to be connected to networks, but received no DHCP response: $NICSTOWAIT"
fi