1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 10_support_ethdevice.dpatch by <mika@grml.org>
4 ## All lines beginning with `## DP:' are a description of the patch.
5 ## DP: Support bootoptions ethdevice and ethdevice-timeout for
6 ## DP: specifying from which device you want to boot from and
7 ## DP: using which timeout (being 30 seconds if unconfigured), if
8 ## DP: ethdevice is not specified try to get a working network
9 ## DP: configuration for each existing network device.
12 diff -urNad live-initramfs-grml~/scripts/live live-initramfs-grml/scripts/live
13 --- live-initramfs-grml~/scripts/live 2009-12-29 22:00:53.858638095 +0100
14 +++ live-initramfs-grml/scripts/live 2009-12-29 22:04:16.588656569 +0100
20 + ETHDEVICE="${ARGUMENT#ethdevice=}"
24 + ethdevice-timeout=*)
25 + ETHDEV_TIMEOUT="${ARGUMENT#ethdevice-timeout=}"
26 + export ETHDEV_TIMEOUT
30 FETCH="${ARGUMENT#fetch=}"
36 - ipconfig ${DEVICE} | tee /netboot.config
37 + # if ethdevice was not specified on the kernel command line
38 + # make sure we try to get a working network configuration
39 + # for *every* present network device (except for loopback of course)
40 + if [ -z "$ETHDEVICE" ] ; then
41 + echo "If you want to boot from a specific device use bootoption ethdevice=..."
42 + for device in /sys/class/net/*; do
44 + if [ "$dev" != "lo" ] ; then
45 + ETHDEVICE="$ETHDEVICE $dev"
50 + # split args of ethdevice=eth0,eth1 into "eth0 eth1"
51 + for device in $(echo $ETHDEVICE | sed 's/,/ /g') ; do
52 + devlist="$devlist $device"
55 + [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
56 + echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
58 + # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
59 + # an endless loop; iff execution fails give it two further tries, that's
60 + # why we use '$devlist $devlist $devlist' for the other for loop
61 + for dev in $devlist $devlist $devlist ; do
62 + echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
63 + ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
65 + sleep "$ETHDEV_TIMEOUT" ; sleep 1
66 + if [ -r /proc/"$jobid"/status ] ; then
67 + echo "Killing job $jobid for device $dev as ipconfig ran into recursioni..."
71 + # if configuration of device worked we should have an assigned
72 + # IP address, iff so let's use the according as $DEVICE for later usage
73 + # simple and primitive approach which seems to work fine
74 + if ifconfig $dev | grep -q 'inet.*addr:' ; then
75 + export DEVICE="$dev"
80 # source relevant ipconfig output
81 OLDHOSTNAME=${HOSTNAME}
85 # Check if we have a network device at all
86 - if ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
87 + if ! ls /sys/class/net/"$DEVICE" > /dev/null 2>&1 && \
88 + ! ls /sys/class/net/eth0 > /dev/null 2>&1 && \
89 ! ls /sys/class/net/wlan0 > /dev/null 2>&1 && \
90 ! ls /sys/class/net/ath0 > /dev/null 2>&1 && \
91 ! ls /sys/class/net/ra0 > /dev/null 2>&1