7 modprobe
-q af_packet
# For DHCP
12 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT
=15
13 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
15 if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
17 # support for Syslinux IPAPPEND parameter
18 # it sets the BOOTIF variable on the kernel parameter
22 # pxelinux sets BOOTIF to a value based on the mac address of the
23 # network card used to PXE boot, so use this value for DEVICE rather
24 # than a hard-coded device name from initramfs.conf. this facilitates
25 # network booting when machines may have multiple network cards.
26 # pxelinux sets BOOTIF to 01-$mac_address
28 # strip off the leading "01-", which isn't part of the mac
32 # convert to typical mac address format by replacing "-" with ":"
37 if [ -z "$bootif_mac" ]
41 bootif_mac
="$bootif_mac:$x"
46 # look for devices with matching mac address, and set DEVICE to
47 # appropriate value if match is found.
49 for device
in /sys
/class
/net
/*
51 if [ -f "$device/address" ]
53 current_mac
=$
(cat "$device/address")
55 if [ "$bootif_mac" = "$current_mac" ]
64 # if ethdevice was not specified on the kernel command line
65 # make sure we try to get a working network configuration
66 # for *every* present network device (except for loopback of course)
67 if [ -z "$ETHDEVICE" ]
69 echo "If you want to boot from a specific device use bootoption ethdevice=..."
70 for device
in /sys
/class
/net
/*
75 ETHDEVICE
="$ETHDEVICE $dev"
80 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
81 for device
in $
(echo $ETHDEVICE |
sed 's/,/ /g')
83 devlist
="$devlist $device"
86 # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
87 # an endless loop; if execution fails give it two further tries, that's
88 # why we use '$devlist $devlist $devlist' for the other for loop
89 for dev
in $devlist $devlist $devlist
91 echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
92 ipconfig
-t "$ETHDEV_TIMEOUT" $dev |
tee -a /netboot.config
&
94 sleep "$ETHDEV_TIMEOUT" ; sleep 1
95 if [ -r /proc
/"$jobid"/status
]
97 echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
101 # if configuration of device worked we should have an assigned
102 # IP address, if so let's use the device as $DEVICE for later usage.
103 # simple and primitive approach which seems to work fine
104 if ifconfig
$dev |
grep -q 'inet.*addr:'
111 for interface
in ${DEVICE}; do
112 ipconfig
-t "$ETHDEV_TIMEOUT" ${interface} |
tee /netboot-
${interface}.config
114 [ -e /run
/net-
${interface}.conf
] && .
/run
/net-
${interface}.conf
116 if [ "$IPV4ADDR" != "0.0.0.0" ]
123 for interface
in ${DEVICE}
125 # source relevant ipconfig output
126 OLDHOSTNAME
=${HOSTNAME}
128 [ -e /run
/net-
${interface}.conf
] && .
/run
/net-
${interface}.conf
130 [ -z ${HOSTNAME} ] && HOSTNAME
=${OLDHOSTNAME}
133 if [ -n "${interface}" ]
135 HWADDR
="$(cat /sys/class/net/${interface}/address)"
138 if [ ! -e "/etc/resolv.conf" ]
140 echo "Creating /etc/resolv.conf"
142 if [ -n "${DNSDOMAIN}" ]
144 echo "domain ${DNSDOMAIN}" > /etc
/resolv.conf
145 echo "search ${DNSDOMAIN}" >> /etc
/resolv.conf
148 for i
in ${IPV4DNS0} ${IPV4DNS1} ${IPV4DNS1}
150 if [ -n "$i" ] && [ "$i" != 0.0.0.0 ]
152 echo "nameserver $i" >> /etc
/resolv.conf
157 # Check if we have a network device at all
158 if ! ls /sys
/class
/net
/"$interface" > /dev
/null
2>&1 && \
159 ! ls /sys
/class
/net
/eth0
> /dev
/null
2>&1 && \
160 ! ls /sys
/class
/net
/wlan0
> /dev
/null
2>&1 && \
161 ! ls /sys
/class
/net
/ath0
> /dev
/null
2>&1 && \
162 ! ls /sys
/class
/net
/ra0
> /dev
/null
2>&1
164 panic
"No supported network device found, maybe a non-mainline driver is required."