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}')"
if egrep "^[^ ]*[ ]*$VID[ ]*$DID" /lib/modules/*/modules.pcimap >/dev/null
then
TYPE=$(
lspci | \
grep "^$PCI " | \
awk '{print $2}' | \
tr '[A-Z]' '[a-z]'
)
DESC=$(
lspci | \
grep "^$PCI " | \
awk -F: '{print $3}' | \
sed 's/^ *//'
)
MOD=$(
egrep "^[^ ]*[ ]*$VID[ ]*$DID" /lib/modules/*/modules.pcimap | \
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
modprobe $MOD
2008-03-19 18:33:48 +00:00
ifconfig eth$nic up
udhcpc -i eth$nic -b &
NICSTOWAIT="$NICSTOWAIT eth$nic"
2008-03-07 00:01:14 +00:00
nic=$(($nic + 1))
2007-10-26 22:44:33 +00:00
fi
;;
scsi|raid)
echo "Found ($MOD) $DESC"
GOTHBA=1
modprobe $MOD
modprobe sd_mod
modprobe scsi_mod
hba=$(($hba + 1))
;;
*)
continue
;;
esac
fi
done
2007-11-26 18:43:11 +00:00
if [ -d /proc/device-tree/vdevice/l-lan* ]; then
modprobe ibmveth
for i in /sys/bus/vio/drivers/ibmveth/*/net*; do
udhcpc -i eth$nic -b
2008-03-06 18:46:46 +00:00
let extrat=0
until ifconfig eth$nic|grep "inet addr" || [ $extrat == 30 ]; do
sleep 1
let extrat=extrat+1
done
2008-03-07 00:01:14 +00:00
nic=$(($nic + 1))
2007-11-26 18:43:11 +00:00
done
fi
2007-11-12 18:30:02 +00:00
if [ -d /proc/device-tree/lhea* ]; then
modprobe ehea
for i in /sys/bus/ibmebus/devices/port*; do
udhcpc -i eth$nic -b
2008-03-06 18:46:46 +00:00
let extrat=0
until ifconfig eth$nic|grep "inet addr" || [ $extrat == 30 ]; do
sleep 1
let extrat=extrat+1
done
2008-03-07 00:01:14 +00:00
nic=$(($nic + 1))
2007-11-12 18:30:02 +00:00
done
fi
2007-10-26 22:44:33 +00:00
2008-03-19 18:33:48 +00:00
let extrat=0
until [ $extrat == 80 -o -z "$NICSTOWAIT" ]; do
sleep 1
let extrat=extrat+1
for nic in $NICSTOWAIT; do
if ifconfig $nic|grep "inet addr"; then
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
elif [ $extrat == 15 ]; then
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