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.
9 diff --git a/scripts/live b/scripts/live
10 index 5681362..bf20cce 100755
13 @@ -91,9 +91,8 @@ Arguments ()
17 - DEVICE="${ARGUMENT#ethdevice=}"
18 - ETHDEVICE="${DEVICE}"
19 - export DEVICE ETHDEVICE
20 + ETHDEVICE="${ARGUMENT#ethdevice=}"
25 @@ -150,13 +149,9 @@ Arguments ()
29 - STATICIP="${ARGUMENT#ip=}"
31 - if [ -z "${STATICIP}" ]
33 - STATICIP="frommedia"
36 + # copy complete ip=args into staticip, and
37 + # keep multiple uses.
38 + STATICIP="${STATICIP} ${ARGUMENT}"
42 @@ -598,6 +593,24 @@ copy_live_to ()
48 + if [ $# != 1 ] ; then
49 + echo "Missin parameter for $0"
53 + for ip in ${STATICIP} ; do
66 modprobe -q af_packet # For DHCP
67 @@ -608,9 +621,19 @@ do_netsetup ()
68 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
69 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
71 - if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
72 - [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
74 + # Our modus operandi for getting a working network setup is this:
75 + # * If ip=* is set, pass that to ipconfig and be done
76 + # * Else, try dhcp on all devices in this order:
77 + # ethdevice= bootif= <all interfaces>
79 + ALLDEVICES="$(cd /sys/class/net/ && ls -1 2>/dev/null | grep -v '^lo$' )"
81 + # Turn on all interfaces before doing anything, to avoid timing problems
82 + # during link negotiation.
83 + echo "Net: Turning on all device links..."
84 + for device in ${ALLDEVICES}; do
85 + ipconfig -c none -d $device -t 1 2>/dev/null >/dev/null
89 # support for Syslinux IPAPPEND parameter
90 @@ -653,7 +676,7 @@ do_netsetup ()
92 if [ "$bootif_mac" = "$current_mac" ]
94 - DEVICE=${device##*/}
95 + ETHDEVICE="${device##*/},$ETHDEVICE" # use ethdevice
99 @@ -665,12 +688,7 @@ do_netsetup ()
100 # for *every* present network device (except for loopback of course)
101 if [ -z "$ETHDEVICE" ] ; then
102 echo "If you want to boot from a specific device use bootoption ethdevice=..."
103 - for device in /sys/class/net/*; do
104 - dev=${device##*/} ;
105 - if [ "$dev" != "lo" ] ; then
106 - ETHDEVICE="$ETHDEVICE $dev"
109 + ETHDEVICE="$ALLDEVICES"
112 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
113 @@ -678,38 +696,27 @@ do_netsetup ()
114 devlist="$devlist $device"
117 - # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
118 - # an endless loop; iff execution fails give it two further tries, that's
119 - # why we use '$devlist $devlist $devlist' for the other for loop
120 - for dev in $devlist $devlist $devlist ; do
121 - echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
122 - ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
124 - sleep "$ETHDEV_TIMEOUT" ; sleep 1
125 - if [ -r /proc/"$jobid"/status ] ; then
126 - echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
128 + for dev in $devlist ; do
129 + param="$(get_ipconfig_para $dev)"
130 + if [ -n "$NODHCP" ] && [ "$param" = "$dev" ] ; then
131 + echo "Ignoring network device $dev due to nodhcp." | tee -a /live-boot.log
134 + echo "Executing ipconfig -t $ETHDEV_TIMEOUT $param"
135 + ipconfig -t "$ETHDEV_TIMEOUT" "$param" | tee -a /netboot.config
137 # if configuration of device worked we should have an assigned
138 # IP address, iff so let's use the according as $DEVICE for later usage
139 # simple and primitive approach which seems to work fine
140 - if ifconfig $dev | grep -q 'inet.*addr:' ; then
141 - export DEVICE="$dev"
144 + . /tmp/net-${device}.conf
145 + if [ "${IPV4ADDR}" != "0.0.0.0" ]; then
146 + export DEVICE="$dev $DEVICE"
147 + # break # exit loop as we just use the irst
152 - for interface in ${DEVICE}; do
153 - ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
154 - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
155 - if [ "$IPV4ADDR" != "0.0.0.0" ]
164 for interface in ${DEVICE}; do
165 # source relevant ipconfig output