# (no other configuration file found)
DEFAULT_NET_CONF=0
+
net_init_failed()
{
echo
echo "pl_netinit: network initialization failed,"
echo "pl_netinit: shutting down machine in two hours"
- /bin/sleep 7200
+ /bin/sleep 2h
/sbin/shutdown -h now
exit 1
}
echo "pl_netinit: looking for node configuration file on flash based devices"
- echo "pl_netinit: waiting for flash devices if any to come online"
- # some usb flash based devices take a couple of seconds to initialize
- # also, try to read the partition table off the device to make sure
- # it shows up in /sys/block
- /bin/sleep 10s
-
- # make the sd* expansion fail to an empty string if there are no sd
+ # make the sd* hd* expansion fail to an empty string if there are no sd
# devices
shopt -s nullglob
- for device in /sys/block/sd*; do
+ for device in /sys/block/[hs]d*; do
removable=`cat $device/removable`
if [[ $removable -ne 1 ]]; then
continue
fi
- check_dev=/dev/`basename $device`1
+ partitions=$(/bin/awk "\$4 ~ /`basename $device`[0-9]*/ { print \$4 }" /proc/partitions)
+ for partition in $partitions ; do
+ check_dev=/dev/$partition
+
+ echo "pl_netinit: looking for node configuration file on device $check_dev"
+ /bin/mount -o ro -t $NODE_CONF_DEVICE_FS_TYPES $check_dev \
+ $CONF_DEVICE_MOUNT_POINT 2>&1 > /dev/null
+ if [[ $? -eq 0 ]]; then
+ if [ -r "$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME" ]; then
+ echo "pl_netinit: found node configuration file plnode.txt, using"
+
+ conf_file="$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME"
+ /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
+ echo "pl_netinit: found configuration"
+ /bin/umount $CONF_DEVICE_MOUNT_POINT
+ return 1
+ fi
+
+ echo "pl_netinit: not found"
- echo "pl_netinit: looking for node configuration file on device $check_dev"
- /bin/mount -o ro -t $NODE_CONF_DEVICE_FS_TYPES $check_dev \
- $CONF_DEVICE_MOUNT_POINT 2>&1 > /dev/null
- if [[ $? -eq 0 ]]; then
- if [ -r "$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME" ]; then
- echo "pl_netinit: found node configuration file plnode.txt, using"
-
- conf_file="$CONF_DEVICE_MOUNT_POINT/$NEW_NODE_CONF_NAME"
- /etc/init.d/pl_validateconf < $conf_file > $USED_NET_CONF
- echo "pl_netinit: found configuration"
/bin/umount $CONF_DEVICE_MOUNT_POINT
- return 1
fi
-
- echo "pl_netinit: not found"
-
- /bin/umount $CONF_DEVICE_MOUNT_POINT
- fi
+ done
done
# normal filename expansion setting
/bin/rm -f $USED_NET_CONF
fi
+# initialize IPMI device
+if [[ -n "$IPMI_ADDRESS" ]] ; then
+ echo -n "pl_netinit: initializing IPMI: "
+ cmd="ipnmac -i $IPMI_ADDRESS"
+ if [[ -n "$IPMI_MAC" ]] ; then
+ cmd="$cmd -m $IPMI_MAC"
+ fi
+ echo $cmd
+ $cmd
+fi
+
# now, we need to find which device to use (ie, eth0 or eth1). start out
# by defaulting to eth0, then see if the network configuration file specified
# either a mac address (in which case we will need to find the device), or
# the device itself
-if [[ -n "$PRIMARY_MAC" ]]; then
+if [[ -n "$NET_DEVICE" ]]; then
# the user specified a mac address we should use. find the network
# device for it.
- echo "pl_netinit: looking for a device with mac address $PRIMARY_MAC"
+ NET_DEVICE=$(tr A-Z a-z <<<$NET_DEVICE)
- pushd .
- cd /sys/class/net
+ pushd /sys/class/net
for device in *; do
- dev_address=`cat $device/address`
- if [[ "$dev_address" == "$PRIMARY_MAC" ]]; then
+ dev_address=`cat $device/address | tr A-Z a-z`
+ if [ "$device" == "$NET_DEVICE" -o "$dev_address" == "$NET_DEVICE" ]; then
ETH_DEVICE=$device
- echo "pl_netinit: found device $ETH_DEVICE"
+ echo "pl_netinit: found device $ETH_DEVICE with mac address $dev_address"
break
fi
done
popd
-
-elif [[ -n "$PRIMARY_DEV" ]]; then
- # the user specified a virtual ethernet device to use.
- ETH_DEVICE=$PRIMARY_DEV
- echo "pl_netinit: using user specified device $ETH_DEVICE"
-
else
ETH_DEVICE=$DEFAULT_NET_DEV
echo "pl_netinit: using default device $ETH_DEVICE"
fi
-# if we couldn't find a device (would happen if PRIMARY_MAC was specified
+# if we couldn't find a device (would happen if NET_DEVICE was specified
# but we couldn't find a device for that addresS), then abort the rest
# of the startup
if [[ -z "$ETH_DEVICE" ]]; then
echo "pl_netinit: unable to find a usable device, check to make sure"
- echo "pl_netinit: the PRIMARY_MAC field in the configuration file"
+ echo "pl_netinit: the NET_DEVICE field in the configuration file"
echo "pl_netinit: cooresponds with a network adapter on this system"
net_init_failed
fi
# actually check to make sure ifconfig <device> succeeds
/sbin/ifconfig $ETH_DEVICE up 2>&1 > /dev/null
if [[ $? -ne 0 ]]; then
- echo "pl_netinit: device $ETH_DEVICE does not exist,"
- echo "pl_netinit: this is due to either the device not existing,"
- echo "pl_netinit: or its device drivers not being loaded"
+ echo "pl_netinit: device $ETH_DEVICE does not exist, most likely"
+ echo "pl_netinit: this cd does not have hardware support for your"
+ echo "pl_netinit: network adapter. please send the following lines"
+ echo "pl_netinit: to PlanetLab Support: support@planet-lab.org"
+ echo "pl_netinit: for further assistance"
+ echo
+ /sbin/lspci -n | /bin/grep "Class 0200"
+ echo
+
net_init_failed
fi
/sbin/dhclient -1 -cf $DHCLIENT_CONF_FILE $ETH_DEVICE
if [[ $? -ne 0 ]]; then
echo "pl_netinit: dhcp failed, retrying in 2 minutes"
- /sbin/sleep 120
+ /bin/sleep 120
else
echo "pl_netinit: dhcp succeeded"
configured=1
/sbin/ifconfig $ETH_DEVICE $IP_ADDRESS broadcast $IP_BROADCASTADDR \
netmask $IP_NETMASK
/sbin/route add default gw $IP_GATEWAY dev $ETH_DEVICE
+ /bin/hostname "$HOST_NAME.$DOMAIN_NAME"
if [[ -z "$IP_DNS1" ]]; then
echo "pl_netinit: no dns server specified, cannot continue."