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.
15 - DEVICE="${ARGUMENT#ethdevice=}"
16 - ETHDEVICE="${DEVICE}"
17 - export DEVICE ETHDEVICE
18 + ETHDEVICE="${ARGUMENT#ethdevice=}"
27 - STATICIP="${ARGUMENT#ip=}"
29 - if [ -z "${STATICIP}" ]
31 - STATICIP="frommedia"
34 + # copy complete ip=args into staticip, and
35 + # keep multiple uses.
36 + STATICIP="${STATICIP} ${ARGUMENT}"
46 + if [ $# != 1 ] ; then
47 + echo "Missin parameter for $0"
51 + for ip in ${STATICIP} ; do
64 modprobe -q af_packet # For DHCP
66 [ -n "$ETHDEV_TIMEOUT" ] || ETHDEV_TIMEOUT=15
67 echo "Using timeout of $ETHDEV_TIMEOUT seconds for network configuration."
69 - if [ -z "${NETBOOT}" ] && [ -z "${FETCH}" ] && \
70 - [ -z "${HTTPFS}" ] && [ -z "${FTPFS}" ]
72 + # Our modus operandi for getting a working network setup is this:
73 + # * If ip=* is set, pass that to ipconfig and be done
74 + # * Else, try dhcp on all devices in this order:
75 + # ethdevice= bootif= <all interfaces>
77 + ALLDEVICES="$(cd /sys/class/net/ && ls -1 2>/dev/null | grep -v '^lo$' )"
79 + # Turn on all interfaces before doing anything, to avoid timing problems
80 + # during link negotiation.
81 + echo "Net: Turning on all device links..."
82 + for device in ${ALLDEVICES}; do
83 + ipconfig -c none -d $device -t 1 2>/dev/null >/dev/null
87 # support for Syslinux IPAPPEND parameter
90 if [ "$bootif_mac" = "$current_mac" ]
92 - DEVICE=${device##*/}
93 + ETHDEVICE="${device##*/},$ETHDEVICE" # use ethdevice
98 # for *every* present network device (except for loopback of course)
99 if [ -z "$ETHDEVICE" ] ; then
100 echo "If you want to boot from a specific device use bootoption ethdevice=..."
101 - for device in /sys/class/net/*; do
102 - dev=${device##*/} ;
103 - if [ "$dev" != "lo" ] ; then
104 - ETHDEVICE="$ETHDEVICE $dev"
107 + ETHDEVICE="$ALLDEVICES"
110 # split args of ethdevice=eth0,eth1 into "eth0 eth1"
111 @@ -747,38 +765,27 @@
112 devlist="$devlist $device"
115 - # this is tricky (and ugly) because ipconfig sometimes just hangs/runs into
116 - # an endless loop; iff execution fails give it two further tries, that's
117 - # why we use '$devlist $devlist $devlist' for the other for loop
118 - for dev in $devlist $devlist $devlist ; do
119 - echo "Executing ipconfig -t $ETHDEV_TIMEOUT $dev"
120 - ipconfig -t "$ETHDEV_TIMEOUT" $dev | tee -a /netboot.config &
122 - sleep "$ETHDEV_TIMEOUT" ; sleep 1
123 - if [ -r /proc/"$jobid"/status ] ; then
124 - echo "Killing job $jobid for device $dev as ipconfig ran into recursion..."
126 + for dev in $devlist ; do
127 + param="$(get_ipconfig_para $dev)"
128 + if [ -n "$NODHCP" ] && [ "$param" = "$dev" ] ; then
129 + echo "Ignoring network device $dev due to nodhcp." | tee -a /live-boot.log
132 + echo "Executing ipconfig -t $ETHDEV_TIMEOUT $param"
133 + ipconfig -t "$ETHDEV_TIMEOUT" "$param" | tee -a /netboot.config
135 # if configuration of device worked we should have an assigned
136 # IP address, iff so let's use the according as $DEVICE for later usage
137 # simple and primitive approach which seems to work fine
138 - if ifconfig $dev | grep -q 'inet.*addr:' ; then
139 - export DEVICE="$dev"
142 + . /tmp/net-${device}.conf
143 + if [ "${IPV4ADDR}" != "0.0.0.0" ]; then
144 + export DEVICE="$dev $DEVICE"
145 + # break # exit loop as we just use the irst
150 - for interface in ${DEVICE}; do
151 - ipconfig -t "$ETHDEV_TIMEOUT" ${interface} | tee /netboot-${interface}.config
152 - [ -e /tmp/net-${interface}.conf ] && . /tmp/net-${interface}.conf
153 - if [ "$IPV4ADDR" != "0.0.0.0" ]
162 for interface in ${DEVICE}; do
163 # source relevant ipconfig output