Adding upstream version 1.177.1.
[live-boot-grml.git] / scripts / live-premount / select_eth_device
similarity index 64%
rename from scripts/init-premount/select_eth_device
rename to scripts/live-premount/select_eth_device
index 4323880..dfeac3d 100755 (executable)
@@ -30,28 +30,25 @@ for ARGUMENT in $(cat /proc/cmdline); do
        esac
 done
 
-if [ "$bootconf" != "BOOT=nfs" ] && [ "$NETBOOT" = "" ]; then
-       # Not a net boot : nothing to do
-       exit 0
-fi
-
-# be sure this has been run (*should* be done by scripts/init-premount/udev)
-if [ -x /sbin/udevadm ]
+if [ "$bootconf" != "BOOT=nfs" ] &&
+   [ "$NETBOOT" = "" ] &&
+   [ "$FETCH" = "" ] &&
+   [ "$FTPFS" = "" ] &&
+   [ "$HTTPFS" = "" ]
 then
-       # lenny
-       udevadm trigger
-       udevadm settle
-else
-       # etch
-       udevtrigger
-       udevsettle
+    # Not a net boot : nothing to do
+    exit 0
 fi
 
 # we want to do some basic IP
 modprobe -q af_packet
 
 # Available Ethernet interfaces ?
-l_interfaces=$(cd /sys/class/net/ && ls -d eth* 2>/dev/null)
+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 ]; then
        # only one interface : no choice
@@ -59,6 +56,18 @@ if [ $(echo $l_interfaces | wc -w) -lt 2 ]; then
        exit 0
 fi
 
+# If user force to use specific device, write it
+for ARGUMENT in $(cat /proc/cmdline); do
+    case "${ARGUMENT}" in
+        live-netdev=*)
+        NETDEV="${ARGUMENT#live-netdev=}"
+        echo "DEVICE=$NETDEV" >> /conf/param.conf
+       echo "Found live-netdev parameter in /proc/cmdline. Force to use network device $NETDEV."
+        exit 0
+        ;;
+    esac
+done
+
 while true; do
        echo -n "Looking for a connected Ethernet interface ..."