Making multiple connected NICs work.
authorSteven Shiau <steven@nchc.org.tw>
Wed, 18 Aug 2010 12:30:06 +0000 (14:30 +0200)
committerDaniel Baumann <daniel@debian.org>
Wed, 9 Mar 2011 16:59:20 +0000 (17:59 +0100)
scripts/live
scripts/live-premount/select_eth_device

index 2976dae..07226fa 100755 (executable)
@@ -581,6 +581,9 @@ do_netsetup ()
        udevadm trigger
        udevadm settle
 
+       [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
+       echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
+
        if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
           [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
        then
@@ -651,9 +654,6 @@ do_netsetup ()
                devlist="$devlist $device"
        done
 
-       [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
-       echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
-
        # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
        # an endless loop; iff execution fails give it two further tries, that's
        # why we use '$devlist $devlist $devlist' for the other for loop
@@ -677,45 +677,54 @@ do_netsetup ()
        done
 
        else
-       ipconfig ${DEVICE} | tee /netboot.config
-       fi
-
-       # source relevant ipconfig output
-       OLDHOSTNAME=${HOSTNAME}
-       . /tmp/net-${DEVICE}.conf
-       [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
-       export HOSTNAME
-
-       if [ -n "${DEVICE}" ]
-       then
-               HWADDR="$(cat /sys/class/net/${DEVICE}/address)"
+               for interface in ${DEVICE}; do
+                       ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
+                       [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
+                       if [ "$IPV4ADDR" != "0.0.0.0" ]
+                       then
+                               break
+                       fi
+               done
        fi
 
-       if [ ! -e "/etc/resolv.conf" ]
-       then
-               echo "Creating /etc/resolv.conf"
+       for interface in ${DEVICE}; do
+               # source relevant ipconfig output
+               OLDHOSTNAME=${HOSTNAME}
+               [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
+               [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
+               export HOSTNAME
 
-               if [ -n "${DNSDOMAIN}" ]
+               if [ -n "${interface}" ]
                then
-                       echo "domain ${DNSDOMAIN}" > /etc/resolv.conf
-                       echo "search ${DNSDOMAIN}" > /etc/resolv.conf
+                       HWADDR="$(cat /sys/class/net/${interface}/address)"
                fi
 
-               for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
-               do
-                       echo "nameserver $i" >> /etc/resolv.conf
-               done
-       fi
+               if [ ! -e "/etc/resolv.conf" ]
+               then
+                       echo "Creating /etc/resolv.conf"
 
-       # Check if we have a network device at all
-       if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \
-          ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
-          ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
-          ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
-          ! ls /sys/class/net/ra0 > /dev/null 2>&1
-       then
-               panic "No supported network device found, maybe a non-mainline driver is required."
-       fi
+                       if [ -n "${DNSDOMAIN}" ]
+                       then
+                               echo "domain ${DNSDOMAIN}" > /etc/resolv.conf
+                               echo "search ${DNSDOMAIN}" > /etc/resolv.conf
+                       fi
+
+                       for i in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
+                       do
+                               echo "nameserver $i" >> /etc/resolv.conf
+                       done
+               fi
+
+               # Check if we have a network device at all
+               if ! ls /sys/class/net/"$interface" > /dev/null 2>&1 && \
+                  ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
+                  ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
+                  ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
+                  ! ls /sys/class/net/ra0 > /dev/null 2>&1
+               then
+                       panic "No supported network device found, maybe a non-mainline driver is required."
+               fi
+       done
 }
 
 do_netmount()
index dfeac3d..fe86313 100755 (executable)
@@ -68,6 +68,7 @@ for ARGUMENT in $(cat /proc/cmdline); do
     esac
 done
 
+found_eth_dev=""
 while true; do
        echo -n "Looking for a connected Ethernet interface ..."
 
@@ -85,13 +86,17 @@ while true; do
                                2>/dev/null)
                        # link detected
                        if [ "$carrier" = 1 ]; then
-                               echo " found $interface."
+                               echo "Connected $interface found"
                                # inform initrd's init script :
-                               echo "DEVICE=$interface" >> /conf/param.conf
-                               exit 0
+                               found_eth_dev="$found_eth_dev $interface"
                        fi
                done
-               # wait a bit
-               sleep 1
+               if [ -n "$found_eth_dev" ]; then
+                       echo "DEVICE='$found_eth_dev'" >> /conf/param.conf
+                       exit 0
+               else
+                       # wait a bit
+                       sleep 1
+               fi
        done
 done