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}$'
88 echo "NETDEV is a valid MAC address."
90 # Retrieve the device name associated with the MAC address
91 DEVICE_NAME=$(ip -o link | awk -v mac="$NETDEV" '$0 ~ mac{print substr($2, 1, length($2)-1)}')
92 if [ -n "$DEVICE_NAME" ]
94 echo "Device name for MAC address $NETDEV is $DEVICE_NAME."
98 echo "NETDEV is not a valid MAC address. Assuming it is a device name."
101 echo "DEVICE=$NETDEV" >> /conf/param.conf
102 echo "Found live-netdev parameter, forcing it to use network device $NETDEV."
103 Wait_for_carrier "$NETDEV"
109 l_interfaces="$DEVICE"
115 echo -n "Looking for a connected Ethernet interface ..."
117 for interface in $l_interfaces
119 # ATTR{carrier} is not set if this is not done
120 echo -n " $interface ?"
121 ipconfig -c none -d $interface -t 1 >/dev/null 2>&1
127 for step in 1 2 3 4 5
129 for interface in $l_interfaces
131 ip link set $interface up
132 carrier=$(cat /sys/class/net/$interface/carrier \
138 echo "Connected $interface found"
139 # inform initrd's init script :
140 found_eth_dev="$found_eth_dev $interface"
141 found_eth_dev="$(echo $found_eth_dev | sed -e "s/^[[:space:]]*//g")"
145 if [ -n "$found_eth_dev" ]
147 echo "DEVICE='$found_eth_dev'" >> /conf/param.conf