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/scripts/boot/9990-networking.sh
10 ===================================================================
11 --- live-boot-grml.orig/scripts/boot/9990-networking.sh 2012-12-03 07:59:14.790837135 +0100
12 +++ live-boot-grml/scripts/boot/9990-networking.sh 2012-12-03 07:59:19.665258773 +0100
19 + if [ $# != 1 ] ; then
20 + echo "Missin parameter for $0"
24 + for ip in ${STATICIP} ; do
37 modprobe -q af_packet # For DHCP
39 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
40 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
42 - if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
44 + # Our modus operandi for getting a working network setup is this:
45 + # * If ip=* is set, pass that to ipconfig and be done
46 + # * Else, try dhcp on all devices in this order:
47 + # ethdevice= bootif= <all interfaces>
49 + ALLDEVICES="$(cd /sys/class/net/ && ls -1 2>/dev/null | grep -v '^lo$' )"
51 + # Turn on all interfaces before doing anything, to avoid timing problems
52 + # during link negotiation.
53 + echo "Net: Turning on all device links..."
54 + for device in ${ALLDEVICES}; do
55 + ipconfig -c none -d $device -t 1 2>/dev/null >/dev/null
57 # support for Syslinux IPAPPEND parameter
58 # it sets the BOOTIF variable on the kernel parameter
62 if [ "$bootif_mac" = "$current_mac" ]
64 - DEVICE=${device##*/}
65 + ETHDEVICE="${device##*/},$ETHDEVICE" # use ethdevice
70 if [ -z "$ETHDEVICE" ]
72 echo "If you want to boot from a specific device use bootoption ethdevice=..."
73 - for device in /sys/class/net/*
76 - if [ "$dev" != "lo" ]
78 - ETHDEVICE="$ETHDEVICE $dev"
81 + ETHDEVICE="$ALLDEVICES"
84 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
86 devlist="$devlist $device"
89 - # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
90 - # an endless loop; if execution fails give it two further tries, that's
91 - # why we use '$devlist $devlist $devlist' for the other for loop
92 - for dev in $devlist $devlist $devlist
94 - echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
95 - ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
97 - sleep "$ETHDEV_TIMEOUT" ; sleep 1
98 - if [ -r /proc/"$jobid"/status ]
100 - echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
102 + for dev in $devlist ; do
103 + param="$(get_ipconfig_para $dev)"
104 + if [ -n "$NODHCP" ] && [ "$param" = "$dev" ] ; then
105 + echo "Ignoring network device $dev due to nodhcp." | tee -a /live-boot.log
108 + echo "Executing ipconfig -t $ETHDEV_TIMEOUT $param"
109 + ipconfig -t "$ETHDEV_TIMEOUT" "$param" | tee -a /netboot.config
111 # if configuration of device worked we should have an assigned
112 # IP address, if so let's use the device as $DEVICE for later usage.
113 # simple and primitive approach which seems to work fine
114 - if ifconfig $dev | grep -q 'inet.*addr:'
116 - export DEVICE="$dev"
119 + if [ -e "/run/net-${device}.conf" ]; then
120 + . /run/net-${device}.conf
122 + if [ "${IPV4ADDR}" != "0.0.0.0" ]; then
123 + export DEVICE="$dev $DEVICE"
124 + # break # exit loop as we just use the irst
128 - for interface in ${DEVICE}; do
129 - ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
132 - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
135 - [ -e /run/net-${interface}.conf ] && . /run/net-${interface}.conf
137 - if [ "$IPV4ADDR" != "0.0.0.0" ]
145 for interface in ${DEVICE}
147 Index: live-boot-grml/scripts/boot/9990-cmdline-old
148 ===================================================================
149 --- live-boot-grml.orig/scripts/boot/9990-cmdline-old 2012-12-03 07:59:14.794839124 +0100
150 +++ live-boot-grml/scripts/boot/9990-cmdline-old 2012-12-03 07:59:19.665258773 +0100
155 - DEVICE="${_PARAMETER#ethdevice=}"
156 - ETHDEVICE="${DEVICE}"
157 - export DEVICE ETHDEVICE
158 + ETHDEVICE="${_PARAMETER#ethdevice=}"
167 - STATICIP="${_PARAMETER#ip=}"
169 - if [ -z "${STATICIP}" ]
171 - STATICIP="frommedia"
174 + # copy complete ip=args into staticip, and
175 + # keep multiple uses.
176 + STATICIP="${STATICIP} ${_PARAMETER}"