#set -e
+Device_from_bootif ()
+{
+ # support for Syslinux IPAPPEND parameter
+ # it sets the BOOTIF variable on the kernel parameter
+
+ if [ -n "${BOOTIF}" ]
+ then
+ # pxelinux sets BOOTIF to a value based on the mac address of the
+ # network card used to PXE boot, so use this value for DEVICE rather
+ # than a hard-coded device name from initramfs.conf. this facilitates
+ # network booting when machines may have multiple network cards.
+ # pxelinux sets BOOTIF to 01-$mac_address
+
+ # strip off the leading "01-", which isn't part of the mac
+ # address
+ temp_mac=${BOOTIF#*-}
+
+ # convert to typical mac address format by replacing "-" with ":"
+ bootif_mac=""
+ IFS='-'
+ for x in $temp_mac
+ do
+ if [ -z "$bootif_mac" ]
+ then
+ bootif_mac="$x"
+ else
+ bootif_mac="$bootif_mac:$x"
+ fi
+ done
+ unset IFS
+
+ # look for devices with matching mac address, and set DEVICE to
+ # appropriate value if match is found.
+
+ for device in /sys/class/net/*
+ do
+ if [ -f "$device/address" ]
+ then
+ current_mac=$(cat "$device/address")
+
+ if [ "$bootif_mac" = "$current_mac" ]
+ then
+ DEVICE=${device##*/}
+ break
+ fi
+ fi
+ done
+ fi
+
+}
+
do_netsetup ()
{
modprobe -q af_packet # For DHCP
if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
then
- # support for Syslinux IPAPPEND parameter
- # it sets the BOOTIF variable on the kernel parameter
-
- if [ -n "${BOOTIF}" ]
- then
- # pxelinux sets BOOTIF to a value based on the mac address of the
- # network card used to PXE boot, so use this value for DEVICE rather
- # than a hard-coded device name from initramfs.conf. this facilitates
- # network booting when machines may have multiple network cards.
- # pxelinux sets BOOTIF to 01-$mac_address
-
- # strip off the leading "01-", which isn't part of the mac
- # address
- temp_mac=${BOOTIF#*-}
-
- # convert to typical mac address format by replacing "-" with ":"
- bootif_mac=""
- IFS='-'
- for x in $temp_mac
- do
- if [ -z "$bootif_mac" ]
- then
- bootif_mac="$x"
- else
- bootif_mac="$bootif_mac:$x"
- fi
- done
- unset IFS
-
- # look for devices with matching mac address, and set DEVICE to
- # appropriate value if match is found.
-
- for device in /sys/class/net/*
- do
- if [ -f "$device/address" ]
- then
- current_mac=$(cat "$device/address")
-
- if [ "$bootif_mac" = "$current_mac" ]
- then
- DEVICE=${device##*/}
- break
- fi
- fi
- done
- fi
+ # See if we can select the device from BOOTIF
+ Device_from_bootif
# if ethdevice was not specified on the kernel command line
# make sure we try to get a working network configuration
# Available Ethernet interfaces ?
l_interfaces=""
- echo "Waiting for ethernet card(s) up... If this fails, maybe the ethernet card is not supported by the kernel `uname -r`?"
- while [ -z "$l_interfaces" ]
- do
- l_interfaces="$(cd /sys/class/net/ && ls -d eth* 2>/dev/null)"
- done
- if [ $(echo $l_interfaces | wc -w) -lt 2 ]
+ # See if we can derive the boot device
+ Device_from_bootif
+
+ if [ -z "$DEVICE" ]
then
- # only one interface : no choice
- echo "DEVICE=$l_interfaces" >> /conf/param.conf
- return
- fi
+ echo "Waiting for ethernet card(s) up... If this fails, maybe the ethernet card is not supported by the kernel `uname -r`?"
+ while [ -z "$l_interfaces" ]
+ do
+ l_interfaces="$(cd /sys/class/net/ && ls -d eth* 2>/dev/null)"
+ done
- # If user force to use specific device, write it
- for ARGUMENT in ${_CMDLINE}
- do
- case "${ARGUMENT}" in
- live-netdev=*)
+ if [ $(echo $l_interfaces | wc -w) -lt 2 ]
+ then
+ # only one interface : no choice
+ echo "DEVICE=$l_interfaces" >> /conf/param.conf
+ return
+ fi
+
+ # If user force to use specific device, write it
+ for ARGUMENT in ${_CMDLINE}
+ do
+ case "${ARGUMENT}" in
+ live-netdev=*)
NETDEV="${ARGUMENT#live-netdev=}"
echo "DEVICE=$NETDEV" >> /conf/param.conf
echo "Found live-netdev parameter, forcing to to use network device $NETDEV."
return
;;
- esac
- done
+ esac
+ done
+ else
+ l_interfaces="$DEVICE"
+ fi
found_eth_dev=""
while true