6 echo -n "Waiting for link to come up on $1... "
8 for step in $(seq 1 15)
10 carrier=$(cat /sys/class/net/$1/carrier \
14 echo -e "\nLink is up"
24 echo -e "\nError - carrier not detected on $1."
30 # Boot type in initramfs's config
31 bootconf=$(egrep '^BOOT=' /conf/initramfs.conf | tail -1)
33 # can be superseded by command line (used by Debian-Live's netboot for example)
34 for ARGUMENT in ${LIVE_BOOT_CMDLINE}
38 NETBOOT="${ARGUMENT#netboot=}"
43 if [ "$bootconf" != "BOOT=nfs" ] && [ -z "$NETBOOT" ] && [ -z "$FETCH" ] && [ -z "$FTPFS" ] && [ -z "$HTTPFS" ]
45 # Not a net boot : nothing to do
49 # we want to do some basic IP
52 # Ensure all our net modules get loaded so we can actually compare MAC addresses...
56 # Available Ethernet interfaces ?
59 # See if we can derive the boot device
64 echo "Waiting for ethernet card(s) up... If this fails, maybe the ethernet card is not supported by the kernel `uname -r`?"
65 while [ -z "$l_interfaces" ]
67 l_interfaces="$(cd /sys/class/net/ && ls -d * 2>/dev/null | grep -v "lo")"
70 if [ $(echo $l_interfaces | wc -w) -lt 2 ]
72 # only one interface : no choice
73 echo "DEVICE=$l_interfaces" >> /conf/param.conf
74 Wait_for_carrier $l_interfaces
78 # If user force to use specific device, write it
79 for ARGUMENT in ${LIVE_BOOT_CMDLINE}
83 NETDEV="${ARGUMENT#live-netdev=}"
85 # Check if NETDEV is a valid MAC address
86 if echo "$NETDEV" | grep -Eq '^[0-9A-Fa-f]{2}[:-]([0-9A-Fa-f]{2}[:-]){4}[0-9A-Fa-f]{2}$'; then
87 echo "NETDEV is a valid MAC address."
89 # Retrieve the device name associated with the MAC address
90 DEVICE_NAME=$(ip -o link | awk -v mac="$NETDEV" '$0 ~ mac{print substr($2, 1, length($2)-1)}')
91 if [ -n "$DEVICE_NAME" ]; then
92 echo "Device name for MAC address $NETDEV is $DEVICE_NAME."
96 echo "NETDEV is not a valid MAC address. Assuming it is a device name."
97 # Assign NETDEV directly to $NETDEV
100 echo "DEVICE=$NETDEV" >> /conf/param.conf
101 echo "Found live-netdev parameter, forcing it to use network device $NETDEV."
102 Wait_for_carrier "$NETDEV"
108 l_interfaces="$DEVICE"
114 echo -n "Looking for a connected Ethernet interface ..."
116 for interface in $l_interfaces
118 # ATTR{carrier} is not set if this is not done
119 echo -n " $interface ?"
120 ipconfig -c none -d $interface -t 1 >/dev/null 2>&1
126 for step in 1 2 3 4 5
128 for interface in $l_interfaces
130 ip link set $interface up
131 carrier=$(cat /sys/class/net/$interface/carrier \
137 echo "Connected $interface found"
138 # inform initrd's init script :
139 found_eth_dev="$found_eth_dev $interface"
140 found_eth_dev="$(echo $found_eth_dev | sed -e "s/^[[:space:]]*//g")"
144 if [ -n "$found_eth_dev" ]
146 echo "DEVICE='$found_eth_dev'" >> /conf/param.conf