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.
17 + if [ $# != 1 ] ; then
18 + echo "Missin parameter for $0"
22 + for ip in ${STATICIP} ; do
35 modprobe -q af_packet # For DHCP
37 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
38 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
40 - if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
41 - [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
43 + # Our modus operandi for getting a working network setup is this:
44 + # * If ip=* is set, pass that to ipconfig and be done
45 + # * Else, try dhcp on all devices in this order:
46 + # ethdevice= bootif= <all interfaces>
48 + ALLDEVICES="$(cd /sys/class/net/ && ls -1 2>/dev/null | grep -v '^lo$' )"
50 + # Turn on all interfaces before doing anything, to avoid timing problems
51 + # during link negotiation.
52 + echo "Net: Turning on all device links..."
53 + for device in ${ALLDEVICES}; do
54 + ipconfig -c none -d $device -t 1 2>/dev/null >/dev/null
58 # support for Syslinux IPAPPEND parameter
61 if [ "$bootif_mac" = "$current_mac" ]
63 - DEVICE=${device##*/}
64 + ETHDEVICE="${device##*/},$ETHDEVICE" # use ethdevice
69 # for *every* present network device (except for loopback of course)
70 if [ -z "$ETHDEVICE" ] ; then
71 echo "If you want to boot from a specific device use bootoption ethdevice=..."
72 - for device in /sys/class/net/*; do
74 - if [ "$dev" != "lo" ] ; then
75 - ETHDEVICE="$ETHDEVICE $dev"
78 + ETHDEVICE="$ALLDEVICES"
81 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
83 devlist="$devlist $device"
86 - # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
87 - # an endless loop; iff execution fails give it two further tries, that's
88 - # why we use '$devlist $devlist $devlist' for the other for loop
89 - for dev in $devlist $devlist $devlist ; do
90 - echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
91 - ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
93 - sleep "$ETHDEV_TIMEOUT" ; sleep 1
94 - if [ -r /proc/"$jobid"/status ] ; then
95 - echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
97 + for dev in $devlist ; do
98 + param="$(get_ipconfig_para $dev)"
99 + if [ -n "$NODHCP" ] && [ "$param" = "$dev" ] ; then
100 + echo "Ignoring network device $dev due to nodhcp." | tee -a /live-boot.log
103 + echo "Executing ipconfig -t $ETHDEV_TIMEOUT $param"
104 + ipconfig -t "$ETHDEV_TIMEOUT" "$param" | tee -a /netboot.config
106 # if configuration of device worked we should have an assigned
107 # IP address, iff so let's use the according as $DEVICE for later usage
108 # simple and primitive approach which seems to work fine
109 - if ifconfig $dev | grep -q 'inet.*addr:' ; then
110 - export DEVICE="$dev"
113 + if [ -e "/run/net-${device}.conf" ]; then
114 + . /run/net-${device}.conf
116 + if [ "${IPV4ADDR}" != "0.0.0.0" ]; then
117 + export DEVICE="$dev $DEVICE"
118 + # break # exit loop as we just use the irst
123 - for interface in ${DEVICE}; do
124 - ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
125 - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
126 - if [ "$IPV4ADDR" != "0.0.0.0" ]
135 for interface in ${DEVICE}; do
136 # source relevant ipconfig output
137 OLDHOSTNAME=${HOSTNAME}
138 - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
139 + [ -e /run/net-${interface}.conf ] && . /run/net-${interface}.conf
140 [ -z ${HOSTNAME} ] && HOSTNAME=${OLDHOSTNAME}
143 --- a/scripts/live-helpers
144 +++ b/scripts/live-helpers
149 - DEVICE="${ARGUMENT#ethdevice=}"
150 - ETHDEVICE="${DEVICE}"
151 - export DEVICE ETHDEVICE
152 + ETHDEVICE="${ARGUMENT#ethdevice=}"
161 - STATICIP="${ARGUMENT#ip=}"
163 - if [ -z "${STATICIP}" ]
165 - STATICIP="frommedia"
168 + # copy complete ip=args into staticip, and
169 + # keep multiple uses.
170 + STATICIP="${STATICIP} ${ARGUMENT}"