Magellan Linux

Annotation of /trunk/dracut/patches/dracut-037-network-support-udhcpc-dhcpcd-2.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2481 - (hide annotations) (download)
Fri Jul 11 12:08:21 2014 UTC (9 years, 10 months ago) by niro
File size: 11772 byte(s)
-added missing udhcpc/dhcpcd client script which respect netroot
1 niro 2481 diff -Naur dracut-037/modules.d/40network/dhcpcd-script.sh dracut-037-udhcpc/modules.d/40network/dhcpcd-script.sh
2     --- dracut-037/modules.d/40network/dhcpcd-script.sh 1970-01-01 01:00:00.000000000 +0100
3     +++ dracut-037-udhcpc/modules.d/40network/dhcpcd-script.sh 2014-07-11 18:22:19.200620077 +0200
4     @@ -0,0 +1,30 @@
5     +# start netroot
6     +
7     +PATH=/usr/sbin:/usr/bin:/sbin:/bin
8     +
9     +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
10     +type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
11     +
12     +# We already need a set netif here
13     +netif="$interface"
14     +
15     +# Huh? Interface configured?
16     +[ -f "/tmp/net.$netif.up" ] && exit 0
17     +
18     +if [ "$reason" = "BOUND" ]; then
19     + set | while read line; do
20     + [ "${line#new_}" = "$line" ] && continue
21     + echo "$line"
22     + done >/tmp/dhcpcd.$netif.dhcpopts
23     +
24     + {
25     + echo '. /lib/net-lib.sh'
26     + echo "setup_net $netif"
27     + echo "source_hook initqueue/online $netif"
28     + [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
29     + echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
30     + } > $hookdir/initqueue/setup_net_$netif.sh
31     +
32     + echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/dhcpcd-$netif.sh
33     + >/tmp/net.$netif.up
34     +fi
35     diff -Naur dracut-037/modules.d/40network/ifup.sh dracut-037-udhcpc/modules.d/40network/ifup.sh
36     --- dracut-037/modules.d/40network/ifup.sh 2014-03-19 17:16:08.000000000 +0100
37     +++ dracut-037-udhcpc/modules.d/40network/ifup.sh 2014-07-11 18:21:46.055620310 +0200
38     @@ -12,6 +12,23 @@
39     type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
40     type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
41    
42     +# load magellan settings
43     +[ -f /etc/conf.d/network ] && . /etc/conf.d/network
44     +# some sane defaults
45     +if [[ -n $DEFAULT_DHCP_PROG ]]
46     +then
47     + DHCP_PROG="$DEFAULT_DHCP_PROG"
48     +else
49     + DHCP_PROG="/sbin/dhcpcd"
50     +fi
51     +if [[ -n $DEFAULT_DHCP_START ]]
52     +then
53     + DHCP_START="$DEFAULT_DHCP_START"
54     +else
55     + DHCP_START="-t 10"
56     +fi
57     +DHCP_PROG_NAME="${DHCP_PROG##*/}"
58     +
59     # Huh? No $1?
60     [ -z "$1" ] && exit 1
61    
62     @@ -90,6 +107,8 @@
63    
64     # Run dhclient
65     do_dhcp() {
66     + local opts
67     +
68     # dhclient-script will mark the netif up and generate the online
69     # event for nfsroot
70     # XXX add -V vendor class and option parsing per kernel
71     @@ -100,9 +119,27 @@
72     echo "No carrier detected"
73     return 1
74     fi
75     - echo "Starting dhcp for interface $netif"
76     - dhclient "$@" -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif \
77     - || echo "dhcp failed"
78     +
79     + case $DHCP_PROG_NAME in
80     + dhclient)
81     + opts="$@ -1 -q"
82     + opts+=" -cf /etc/dhclient.conf"
83     + opts+=" -pf /tmp/$DHCP_PROG_NAME.$netif.pid"
84     + opts+=" -lf /tmp/$DHCP_PROG_NAME.$netif.lease"
85     + ;;
86     +
87     + dhcpcd)
88     + opts="$@ -q"
89     + ;;
90     +
91     + udhcpc)
92     + opts="-q"
93     + opts+=" -p /tmp/$DHCP_PROG_NAME.$netif.pid"
94     + ;;
95     + esac
96     +
97     + echo "Starting dhcp ($DHCP_PROG_NAME) for interface $netif"
98     + $DHCP_PROG $opts $DHCP_START $netif || echo "dhcp failed"
99     }
100    
101     load_ipv6() {
102     diff -Naur dracut-037/modules.d/40network/kill-dhcpcd.sh dracut-037-udhcpc/modules.d/40network/kill-dhcpcd.sh
103     --- dracut-037/modules.d/40network/kill-dhcpcd.sh 1970-01-01 01:00:00.000000000 +0100
104     +++ dracut-037-udhcpc/modules.d/40network/kill-dhcpcd.sh 2014-07-11 18:21:46.056620310 +0200
105     @@ -0,0 +1,17 @@
106     +#!/bin/sh
107     +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
108     +# ex: ts=8 sw=4 sts=4 et filetype=sh
109     +
110     +for f in /run/dhcpcd.*.pid /run/dhcpcd.pid; do
111     + [ -e $f ] || continue
112     + read PID < $f;
113     + kill $PID >/dev/null 2>&1
114     +done
115     +
116     +sleep 0.1
117     +
118     +for f in /tmp/dhcpcd.*.pid /run/dhcpcd.pid; do
119     + [ -e $f ] || continue
120     + read PID < $f;
121     + kill -9 $PID >/dev/null 2>&1
122     +done
123     diff -Naur dracut-037/modules.d/40network/kill-udhcpc.sh dracut-037-udhcpc/modules.d/40network/kill-udhcpc.sh
124     --- dracut-037/modules.d/40network/kill-udhcpc.sh 1970-01-01 01:00:00.000000000 +0100
125     +++ dracut-037-udhcpc/modules.d/40network/kill-udhcpc.sh 2014-07-11 18:21:46.056620310 +0200
126     @@ -0,0 +1,17 @@
127     +#!/bin/sh
128     +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
129     +# ex: ts=8 sw=4 sts=4 et filetype=sh
130     +
131     +for f in /tmp/udhcpc.*.pid; do
132     + [ -e $f ] || continue
133     + read PID < $f;
134     + kill $PID >/dev/null 2>&1
135     +done
136     +
137     +sleep 0.1
138     +
139     +for f in /tmp/udhcpc.*.pid; do
140     + [ -e $f ] || continue
141     + read PID < $f;
142     + kill -9 $PID >/dev/null 2>&1
143     +done
144     diff -Naur dracut-037/modules.d/40network/module-setup.sh dracut-037-udhcpc/modules.d/40network/module-setup.sh
145     --- dracut-037/modules.d/40network/module-setup.sh 2014-03-19 17:16:08.000000000 +0100
146     +++ dracut-037-udhcpc/modules.d/40network/module-setup.sh 2014-07-11 18:24:15.631619260 +0200
147     @@ -5,8 +5,9 @@
148     # called by dracut
149     check() {
150     local _program
151     + . /etc/conf.d/network
152    
153     - require_binaries ip arping dhclient || return 1
154     + require_binaries ip ifconfig route arping $DEFAULT_DHCP_PROG || return 1
155    
156     return 255
157     }
158     @@ -72,16 +73,20 @@
159     # called by dracut
160     install() {
161     local _arch _i _dir
162     - inst_multiple ip arping dhclient sed
163     + local _dhcp_prog_name
164     + local _file
165     + . /etc/conf.d/network
166     + _dhcp_prog_name="${DEFAULT_DHCP_PROG##*/}"
167     +
168     + inst_multiple ip arping $_dhcp_prog_name sed
169     + inst_multiple ifconfig route
170     inst_multiple -o ping ping6
171     inst_multiple -o brctl
172     inst_multiple -o teamd teamdctl teamnl
173     inst_simple /etc/libnl/classid
174     inst_script "$moddir/ifup.sh" "/sbin/ifup"
175     inst_script "$moddir/netroot.sh" "/sbin/netroot"
176     - inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
177     inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh"
178     - inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf"
179     inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
180     inst_hook pre-udev 60 "$moddir/net-genrules.sh"
181     inst_hook cmdline 91 "$moddir/dhcp-root.sh"
182     @@ -92,7 +97,29 @@
183     inst_hook cmdline 97 "$moddir/parse-bridge.sh"
184     inst_hook cmdline 98 "$moddir/parse-ip-opts.sh"
185     inst_hook cmdline 99 "$moddir/parse-ifname.sh"
186     - inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
187     + case $_dhcp_prog_name in
188     + dhclient)
189     + inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
190     + inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf"
191     + inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
192     + ;;
193     +
194     + udhcpc)
195     + inst_script "$moddir/udhcpc-script.sh" "/usr/share/udhcpc/default.script"
196     + inst_hook cleanup 10 "$moddir/kill-udhcpc.sh"
197     + ;;
198     +
199     + dhcpcd)
200     + inst_simple /etc/dhcpcd.conf
201     + inst_script -o /usr/lib/dhcpcd/dhcpcd-run-hooks
202     + for _file in $(find /usr/lib/dhcpcd/dhcpcd-hooks -type f); do
203     + inst_simple -o $_file
204     + done
205     + inst_simple "$moddir/dhcpcd-script.sh" "/usr/lib/dhcpcd/dhcpcd-hooks/90-netroot"
206     + inst_hook cleanup 10 "$moddir/kill-dhcpcd.sh"
207     + ;;
208     + esac
209     + inst_simple /etc/conf.d/network
210    
211     _arch=$(uname -m)
212    
213     diff -Naur dracut-037/modules.d/40network/net-lib.sh dracut-037-udhcpc/modules.d/40network/net-lib.sh
214     --- dracut-037/modules.d/40network/net-lib.sh 2014-03-19 17:16:08.000000000 +0100
215     +++ dracut-037-udhcpc/modules.d/40network/net-lib.sh 2014-07-11 18:21:46.057620310 +0200
216     @@ -99,6 +99,8 @@
217     [ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
218     [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
219     [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
220     + [ -e /tmp/udhcpc.$netif.dhcpopts ] && . /tmp/udhcpc.$netif.dhcpopts
221     + [ -e /tmp/dhcpcd.$netif.dhcpopts ] && . /tmp/dhcpcd.$netif.dhcpopts
222     # set up resolv.conf
223     [ -e /tmp/net.$netif.resolv.conf ] && \
224     cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
225     @@ -148,6 +150,15 @@
226     for f in /tmp/dhclient.$i.*; do
227     [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/dhclient.}
228     done
229     + for f in /tmp/udhcpc.$i.*; do
230     + [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/udhcpc.}
231     + done
232     + for f in /run/dhcpcd.$i.*; do
233     + [ -f $f ] && cp -f $f /tmp/net.${f#/run/dhcpcd.}
234     + done
235     + for f in /var/lib/dhcpcd/dhcpcd.$i.*; do
236     + [ -f $f ] && cp -f $f /tmp/net.${f#/var/lib/dhcpcd/dhcpcd.}
237     + done
238     done
239     echo $IFACES > /tmp/.net.ifaces.new
240     mv /tmp/.net.ifaces.new /tmp/net.ifaces
241     diff -Naur dracut-037/modules.d/40network/netroot.sh dracut-037-udhcpc/modules.d/40network/netroot.sh
242     --- dracut-037/modules.d/40network/netroot.sh 2014-03-19 17:16:08.000000000 +0100
243     +++ dracut-037-udhcpc/modules.d/40network/netroot.sh 2014-07-11 18:21:46.057620310 +0200
244     @@ -38,6 +38,8 @@
245     if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
246     # Load dhcp options
247     [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
248     + [ -e /tmp/udhcpc.$netif.dhcpopts ] && . /tmp/udhcpc.$netif.dhcpopts
249     + [ -e /tmp/dhcpcd.$netif.dhcpopts ] && . /tmp/dhcpcd.$netif.dhcpopts
250    
251     # If we have a specific bootdev with no dhcpoptions or empty root-path,
252     # we die. Otherwise we just warn
253     diff -Naur dracut-037/modules.d/40network/udhcpc-script.sh dracut-037-udhcpc/modules.d/40network/udhcpc-script.sh
254     --- dracut-037/modules.d/40network/udhcpc-script.sh 1970-01-01 01:00:00.000000000 +0100
255     +++ dracut-037-udhcpc/modules.d/40network/udhcpc-script.sh 2014-07-11 18:22:16.296620098 +0200
256     @@ -0,0 +1,100 @@
257     +#!/bin/sh
258     +
259     +# global options passed by udhcpc
260     +# what to run
261     +# $1 - which command to run, possible are: bound|deconfig|nak|renew
262     +# router - routers address
263     +# subnet - the subnet
264     +# dhcptype - type of dhcp
265     +# interface - which iface gets configured
266     +# serverid - ip of the dhcd server
267     +# dns - dns to use
268     +# ip - ip-address to use
269     +# lease - lease time of a dhcp configuration
270     +# mask - network mask to use
271     +
272     +type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
273     +type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
274     +
275     +# We already need a set netif here
276     +netif="${interface}"
277     +
278     +# Huh? Interface configured?
279     + [ -f "/tmp/net.$netif.up" ] && exit 0
280     +
281     +# renew dhcp leases
282     +bound()
283     +{
284     + local RESOLV_CONF="/etc/resolv.conf"
285     + local BROADCAST
286     + local NETMASK
287     + local i
288     +
289     + [[ -n ${broadcast} ]] && BROADCAST="broadcast ${broadcast}"
290     + [[ -n ${subnet} ]] && NETMASK="netmask ${subnet}"
291     +
292     + /sbin/ifconfig ${interface} ${ip} ${BROADCAST} ${NETMASK}
293     +
294     + if [ -n "${router}" ]
295     + then
296     + echo "deleting routers"
297     + while /sbin/route del default gw 0.0.0.0 dev ${interface}
298     + do :
299     + done
300     +
301     + metric=0
302     + for i in ${router}
303     + do
304     + /sbin/route add default gw ${i} dev ${interface} metric $((metric++))
305     + done
306     + fi
307     +
308     + echo -n > ${RESOLV_CONF}
309     + [[ -n ${domain} ]] && echo "domain ${domain}" >> ${RESOLV_CONF}
310     + for i in ${dns}
311     + do
312     + echo adding dns ${i}
313     + echo "nameserver ${i}" >> ${RESOLV_CONF}
314     + done
315     +
316     + set | while read line; do
317     + [ "${line#new_}" = "$line" ] && continue
318     + echo "$line"
319     + done >/tmp/udhcpc.$netif.dhcpopts
320     +
321     + {
322     + echo '. /lib/net-lib.sh'
323     + echo "setup_net $netif"
324     + echo "source_hook initqueue/online $netif"
325     + [ -e /tmp/net.$netif.manualup ] || echo "/sbin/netroot $netif"
326     + echo "rm -f -- $hookdir/initqueue/setup_net_$netif.sh"
327     + } > $hookdir/initqueue/setup_net_$netif.sh
328     +
329     + echo "[ -f /tmp/net.$netif.did-setup ]" > $hookdir/initqueue/finished/udhcpc-$netif.sh
330     + >/tmp/net.$netif.up
331     +}
332     +
333     +renew()
334     +{
335     + # same as bound()
336     + bound
337     +}
338     +
339     +deconfig()
340     +{
341     + /sbin/ifconfig ${interface} 0.0.0.0
342     +}
343     +
344     +# what to do if a dhcp request failed
345     +nak()
346     +{
347     + echo "Received a NAK: ${message}"
348     +}
349     +
350     +
351     +case $1 in
352     + bound) bound ;;
353     + renew) renew ;;
354     + deconfig) deconfig ;;
355     + nak) nak ;;
356     +esac