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..2d09e3f 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,23 @@ copy_live_to ()
47 + if [ $# != 1 ] ; then
48 + echo "Missin parameter for $0"
52 + for ip in ${STATICIP} ; do
64 modprobe -q af_packet # For DHCP
65 @@ -612,6 +624,20 @@ do_netsetup ()
66 [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
69 + # Our modus operandi for getting a working network setup is this:
70 + # * If ip=* is set, pass that to ipconfig and be done
71 + # * Else, try dhcp on all devices in this order:
72 + # ethdevice= bootif= <all interfaces>
74 + ALLDEVICES="$(cd /sys/class/net/ && ls -1 2>/dev/null | grep -v '^lo$' )"
76 + # Turn on all interfaces before doing anything, to avoid timing problems
77 + # during link negotiation.
78 + echo "Net: Turning on all device links..."
79 + for device in ${ALLDEVICES}; do
80 + ipconfig -c none -d $device -t 1 2>/dev/null >/dev/null
84 # support for Syslinux IPAPPEND parameter
85 # it sets the BOOTIF variable on the kernel parameter
86 @@ -653,7 +679,7 @@ do_netsetup ()
88 if [ "$bootif_mac" = "$current_mac" ]
90 - DEVICE=${device##*/}
91 + ETHDEVICE="${device##*/},$ETHDEVICE" # use ethdevice
95 @@ -678,37 +704,22 @@ do_netsetup ()
96 devlist="$devlist $device"
99 - # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
100 - # an endless loop; iff execution fails give it two further tries, that's
101 - # why we use '$devlist $devlist $devlist' for the other for loop
102 - for dev in $devlist $devlist $devlist ; do
103 - echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
104 - ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
106 - sleep "$ETHDEV_TIMEOUT" ; sleep 1
107 - if [ -r /proc/"$jobid"/status ] ; then
108 - echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
111 + for dev in $devlist ; do
112 + echo "Executing ipconfig -t $ETHDEV_TIMEOUT $(get_ipconfig_para $dev)"
113 + ipconfig -t "$ETHDEV_TIMEOUT" $(get_ipconfig_para $dev) | tee -a /netboot.config
115 # if configuration of device worked we should have an assigned
116 # IP address, iff so let's use the according as $DEVICE for later usage
117 # simple and primitive approach which seems to work fine
118 - if ifconfig $dev | grep -q 'inet.*addr:' ; then
119 - export DEVICE="$dev"
122 + . /tmp/net-${device}.conf
123 + if [ "${IPV4ADDR}" != "0.0.0.0" ]; then
124 + export DEVICE="$dev $DEVICE"
125 + # break # exit loop as we just use the irst
131 - for interface in ${DEVICE}; do
132 - ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
133 - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
134 - if [ "$IPV4ADDR" != "0.0.0.0" ]
141 for interface in ${DEVICE}; do