1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## 27_support_staticip.dpatch by <mru@grml.org>
4 ## All lines beginning with `## DP:' are a description of the patch.
8 diff --git a/scripts/live b/scripts/live
9 index 5681362..feeaea2 100755
12 @@ -91,9 +91,8 @@ Arguments ()
16 - DEVICE="${ARGUMENT#ethdevice=}"
17 - ETHDEVICE="${DEVICE}"
18 - export DEVICE ETHDEVICE
19 + ETHDEVICE="${ARGUMENT#ethdevice=}"
24 @@ -150,13 +149,9 @@ Arguments ()
28 - STATICIP="${ARGUMENT#ip=}"
30 - if [ -z "${STATICIP}" ]
32 - STATICIP="frommedia"
35 + # copy complete ip=args into staticip, and
36 + # keep multiple uses.
37 + STATICIP="${STATICIP} ${ARGUMENT}"
41 @@ -598,6 +593,24 @@ copy_live_to ()
47 + if [ $# != 1 ] ; then
48 + echo "Missin parameter for $0"
52 + for ip in ${STATICIP} ; do
65 modprobe -q af_packet # For DHCP
66 @@ -608,9 +621,19 @@ do_netsetup ()
67 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
68 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
70 - if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
71 - [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
73 + # Our modus operandi for getting a working network setup is this:
74 + # * If ip=* is set, pass that to ipconfig and be done
75 + # * Else, try dhcp on all devices in this order:
76 + # ethdevice= bootif= <all interfaces>
78 + ALLDEVICES="$(cd /sys/class/net/ && ls -1 2>/dev/null | grep -v '^lo$' )"
80 + # Turn on all interfaces before doing anything, to avoid timing problems
81 + # during link negotiation.
82 + echo "Net: Turning on all device links..."
83 + for device in ${ALLDEVICES}; do
84 + ipconfig -c none -d $device -t 1 2>/dev/null >/dev/null
88 # support for Syslinux IPAPPEND parameter
89 @@ -653,7 +676,7 @@ do_netsetup ()
91 if [ "$bootif_mac" = "$current_mac" ]
93 - DEVICE=${device##*/}
94 + ETHDEVICE="${device##*/},$ETHDEVICE" # use ethdevice
98 @@ -665,12 +688,7 @@ do_netsetup ()
99 # for *every* present network device (except for loopback of course)
100 if [ -z "$ETHDEVICE" ] ; then
101 echo "If you want to boot from a specific device use bootoption ethdevice=..."
102 - for device in /sys/class/net/*; do
103 - dev=${device##*/} ;
104 - if [ "$dev" != "lo" ] ; then
105 - ETHDEVICE="$ETHDEVICE $dev"
108 + ETHDEVICE="$ALLDEVICES"
111 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
112 @@ -678,38 +696,22 @@ do_netsetup ()
113 devlist="$devlist $device"
116 - # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
117 - # an endless loop; iff execution fails give it two further tries, that's
118 - # why we use '$devlist $devlist $devlist' for the other for loop
119 - for dev in $devlist $devlist $devlist ; do
120 - echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
121 - ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
123 - sleep "$ETHDEV_TIMEOUT" ; sleep 1
124 - if [ -r /proc/"$jobid"/status ] ; then
125 - echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
128 + for dev in $devlist ; do
129 + echo "Executing ipconfig -t $ETHDEV_TIMEOUT $(get_ipconfig_para $dev)"
130 + ipconfig -t "$ETHDEV_TIMEOUT" $(get_ipconfig_para $dev) | tee -a /netboot.config
132 # if configuration of device worked we should have an assigned
133 # IP address, iff so let's use the according as $DEVICE for later usage
134 # simple and primitive approach which seems to work fine
135 - if ifconfig $dev | grep -q 'inet.*addr:' ; then
136 - export DEVICE="$dev"
139 + . /tmp/net-${device}.conf
140 + if [ "${IPV4ADDR}" != "0.0.0.0" ]; then
141 + export DEVICE="$dev $DEVICE"
142 + # break # exit loop as we just use the irst
147 - for interface in ${DEVICE}; do
148 - ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
149 - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
150 - if [ "$IPV4ADDR" != "0.0.0.0" ]
159 for interface in ${DEVICE}; do
160 # source relevant ipconfig output