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 Index: live-boot-grml/components/9990-networking.sh
10 ===================================================================
11 --- live-boot-grml.orig/components/9990-networking.sh 2014-03-08 13:35:17.832580835 +0100
12 +++ live-boot-grml/components/9990-networking.sh 2014-03-08 13:35:33.106789237 +0100
15 if [ "$bootif_mac" = "$current_mac" ]
17 - DEVICE=${device##*/}
18 + ETHDEVICE="${device##*/},$ETHDEVICE" # use ethdevice
28 + if [ $# != 1 ] ; then
29 + echo "Missin parameter for $0"
33 + for ip in ${STATICIP} ; do
46 modprobe -q af_packet # For DHCP
48 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
49 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
51 - if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
53 + # Our modus operandi for getting a working network setup is this:
54 + # * If ip=* is set, pass that to ipconfig and be done
55 + # * Else, try dhcp on all devices in this order:
56 + # ethdevice= bootif= <all interfaces>
58 + ALLDEVICES="$(cd /sys/class/net/ && ls -1 2>/dev/null | grep -v '^lo$' )"
60 + # Turn on all interfaces before doing anything, to avoid timing problems
61 + # during link negotiation.
62 + echo "Net: Turning on all device links..."
63 + for device in ${ALLDEVICES}; do
64 + ipconfig -c none -d $device -t 1 2>/dev/null >/dev/null
67 # See if we can select the device from BOOTIF
71 if [ -z "$ETHDEVICE" ]
73 echo "If you want to boot from a specific device use bootoption ethdevice=..."
74 - for device in /sys/class/net/*
77 - if [ "$dev" != "lo" ]
79 - ETHDEVICE="$ETHDEVICE $dev"
82 + ETHDEVICE="$ALLDEVICES"
85 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
87 devlist="$devlist $device"
90 - # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
91 - # an endless loop; if execution fails give it two further tries, that's
92 - # why we use '$devlist $devlist $devlist' for the other for loop
93 - for dev in $devlist $devlist $devlist
95 - echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
96 - ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
98 - sleep "$ETHDEV_TIMEOUT" ; sleep 1
99 - if [ -r /proc/"$jobid"/status ]
101 - echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
103 + for dev in $devlist ; do
104 + param="$(get_ipconfig_para $dev)"
105 + if [ -n "$NODHCP" ] && [ "$param" = "$dev" ] ; then
106 + echo "Ignoring network device $dev due to nodhcp." | tee -a /boot.log
109 + echo "Executing ipconfig -t $ETHDEV_TIMEOUT $param"
110 + ipconfig -t "$ETHDEV_TIMEOUT" "$param" | tee -a /netboot.config
112 # if configuration of device worked we should have an assigned
113 # IP address, if so let's use the device as $DEVICE for later usage.
114 # simple and primitive approach which seems to work fine
115 - if ifconfig $dev | grep -q 'inet.*addr:'
117 - export DEVICE="$dev"
121 + if [ -e "/run/net-${device}.conf" ]; then
122 + . /run/net-${device}.conf
126 - for interface in ${DEVICE}; do
127 - ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
129 - [ -e /run/net-${interface}.conf ] && . /run/net-${interface}.conf
131 - if [ "$IPV4ADDR" != "0.0.0.0" ]
134 + if [ "${IPV4ADDR}" != "0.0.0.0" ]; then
135 + export DEVICE="$dev $DEVICE"
136 + # break # exit loop as we just use the irst
142 for interface in ${DEVICE}
144 Index: live-boot-grml/components/9990-cmdline-old
145 ===================================================================
146 --- live-boot-grml.orig/components/9990-cmdline-old 2014-03-08 13:35:17.832580835 +0100
147 +++ live-boot-grml/components/9990-cmdline-old 2014-03-08 13:35:17.828581304 +0100
152 - DEVICE="${_PARAMETER#ethdevice=}"
153 - ETHDEVICE="${DEVICE}"
154 - export DEVICE ETHDEVICE
155 + ETHDEVICE="${_PARAMETER#ethdevice=}"
164 - STATICIP="${_PARAMETER#ip=}"
166 - if [ -z "${STATICIP}" ]
168 - STATICIP="frommedia"
171 + # copy complete ip=args into staticip, and
172 + # keep multiple uses.
173 + STATICIP="${STATICIP} ${_PARAMETER}"