Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2368 - (hide annotations) (download)
Fri Jan 17 10:17:41 2014 UTC (10 years, 3 months ago) by niro
File size: 9117 byte(s)
-udhcpc and dhcpcd support for the network module
1 niro 2368 diff -Naur dracut-034/modules.d/40network/ifup.sh dracut-034-udhcpc/modules.d/40network/ifup.sh
2     --- dracut-034/modules.d/40network/ifup.sh 2013-10-08 07:55:26.000000000 +0000
3     +++ dracut-034-udhcpc/modules.d/40network/ifup.sh 2014-01-17 12:49:15.467000000 +0000
4     @@ -12,6 +12,23 @@
5     type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
6     type ip_to_var >/dev/null 2>&1 || . /lib/net-lib.sh
7    
8     +# load magellan settings
9     +[ -f /etc/conf.d/network ] && . /etc/conf.d/network
10     +# some sane defaults
11     +if [[ -n ${DEFAULT_DHCP_PROG} ]]
12     +then
13     + DHCP_PROG="${DEFAULT_DHCP_PROG}"
14     +else
15     + DHCP_PROG="/sbin/dhcpcd"
16     +fi
17     +if [[ -n ${DEFAULT_DHCP_START} ]]
18     +then
19     + DHCP_START="${DEFAULT_DHCP_START}"
20     +else
21     + DHCP_START="-t 10"
22     +fi
23     +DHCP_PROG_NAME="${DHCP_PROG##*/}"
24     +
25     # Huh? No $1?
26     [ -z "$1" ] && exit 1
27    
28     @@ -84,12 +101,39 @@
29    
30     # Run dhclient
31     do_dhcp() {
32     - # dhclient-script will mark the netif up and generate the online
33     - # event for nfsroot
34     - # XXX add -V vendor class and option parsing per kernel
35     + local opts
36     +
37     echo "Starting dhcp for interface $netif"
38     - dhclient "$@" -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif \
39     - || echo "dhcp failed"
40     + case ${DHCP_PROG_NAME} in
41     + dhclient)
42     + opts="$@ -1 -q"
43     + opts+=" -cf /etc/dhclient.conf"
44     + opts+=" -pf /tmp/${DHCP_PROG_NAME}.$netif.pid"
45     + opts+=" -lf /tmp/${DHCP_PROG_NAME}.$netif.lease"
46     + ;;
47     +
48     + dhcpcd)
49     + opts="$@ -q"
50     + ;;
51     +
52     + udhcpc)
53     + opts="-q"
54     + opts+=" -p /tmp/${DHCP_PROG_NAME}.$netif.pid"
55     + ;;
56     + esac
57     +
58     + if iface_wait_online 5 $netif
59     + then
60     + ifconfig $netif up
61     + if iface_has_link $netif
62     + then
63     + $DHCP_PROG $opts $DHCP_START $netif || echo "dhcp failed"
64     + else
65     + echo "Interface $netif has no link. Not running $DHCP_PROG."
66     + fi
67     + else
68     + echo "Device $netif does not exist. Doing nothing."
69     + fi
70     }
71    
72     load_ipv6() {
73     diff -Naur dracut-034/modules.d/40network/kill-dhcpcd.sh dracut-034-udhcpc/modules.d/40network/kill-dhcpcd.sh
74     --- dracut-034/modules.d/40network/kill-dhcpcd.sh 1970-01-01 00:00:00.000000000 +0000
75     +++ dracut-034-udhcpc/modules.d/40network/kill-dhcpcd.sh 2014-01-17 12:09:06.153000000 +0000
76     @@ -0,0 +1,18 @@
77     +#!/bin/sh
78     +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
79     +# ex: ts=8 sw=4 sts=4 et filetype=sh
80     +
81     +for f in /run/dhcpcd.*.pid /run/dhcpcd.pid; do
82     + [ -e $f ] || continue
83     + read PID < $f;
84     + kill $PID >/dev/null 2>&1
85     +done
86     +
87     +sleep 0.1
88     +
89     +for f in /run/dhcpcd.*.pid /run/dhcpcd.pid; do
90     + [ -e $f ] || continue
91     + read PID < $f;
92     + kill -9 $PID >/dev/null 2>&1
93     +done
94     +
95     diff -Naur dracut-034/modules.d/40network/kill-udhcpc.sh dracut-034-udhcpc/modules.d/40network/kill-udhcpc.sh
96     --- dracut-034/modules.d/40network/kill-udhcpc.sh 1970-01-01 00:00:00.000000000 +0000
97     +++ dracut-034-udhcpc/modules.d/40network/kill-udhcpc.sh 2014-01-17 12:07:55.368000000 +0000
98     @@ -0,0 +1,17 @@
99     +#!/bin/sh
100     +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
101     +# ex: ts=8 sw=4 sts=4 et filetype=sh
102     +
103     +for f in /tmp/udhcpc.*.pid; do
104     + [ -e $f ] || continue
105     + read PID < $f;
106     + kill $PID >/dev/null 2>&1
107     +done
108     +
109     +sleep 0.1
110     +
111     +for f in /tmp/udhcpc.*.pid; do
112     + [ -e $f ] || continue
113     + read PID < $f;
114     + kill -9 $PID >/dev/null 2>&1
115     +done
116     diff -Naur dracut-034/modules.d/40network/module-setup.sh dracut-034-udhcpc/modules.d/40network/module-setup.sh
117     --- dracut-034/modules.d/40network/module-setup.sh 2013-10-08 07:55:26.000000000 +0000
118     +++ dracut-034-udhcpc/modules.d/40network/module-setup.sh 2014-01-17 12:46:37.210000000 +0000
119     @@ -4,8 +4,9 @@
120    
121     check() {
122     local _program
123     + . /etc/conf.d/network
124    
125     - for _program in ip arping dhclient ; do
126     + for _program in ip ifconfig route arping ${DEFAULT_DHCP_PROG} ; do
127     if ! type -P $_program >/dev/null; then
128     derror "Could not find program \"$_program\" required by network."
129     return 1
130     @@ -69,16 +70,19 @@
131    
132     install() {
133     local _arch _i _dir
134     - inst_multiple ip arping dhclient sed
135     + local dhcp_prog_name
136     + . /etc/conf.d/network
137     + dhcp_prog_name="${DEFAULT_DHCP_PROG##*/}"
138     +
139     + inst_multiple ip arping ${dhcp_prog_name} sed
140     + inst_multiple ifconfig route
141     inst_multiple -o ping ping6
142     inst_multiple -o brctl
143     inst_multiple -o teamd teamdctl teamnl
144     inst_simple /etc/libnl/classid
145     inst_script "$moddir/ifup.sh" "/sbin/ifup"
146     inst_script "$moddir/netroot.sh" "/sbin/netroot"
147     - inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
148     inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh"
149     - inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf"
150     inst_hook pre-udev 50 "$moddir/ifname-genrules.sh"
151     inst_hook pre-udev 60 "$moddir/net-genrules.sh"
152     inst_hook cmdline 91 "$moddir/dhcp-root.sh"
153     @@ -89,7 +93,35 @@
154     inst_hook cmdline 97 "$moddir/parse-bridge.sh"
155     inst_hook cmdline 98 "$moddir/parse-ip-opts.sh"
156     inst_hook cmdline 99 "$moddir/parse-ifname.sh"
157     - inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
158     + case $dhcp_prog_name in
159     + dhclient)
160     + inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script"
161     + inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf"
162     + inst_hook cleanup 10 "$moddir/kill-dhclient.sh"
163     + ;;
164     +
165     + udhcpc)
166     + inst_script /usr/share/udhcpc/default.script
167     + inst_hook cleanup 10 "$moddir/kill-udhcpc.sh"
168     + ;;
169     +
170     + dhcpcd)
171     + inst_simple /etc/dhcpcd.conf
172     + inst_script -o /usr/lib/dhcpcd/dhcpcd-run-hooks
173     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/01-test
174     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/02-dump
175     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/10-mtu
176     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/15-timezone
177     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/20-resolv.conf
178     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/29-lookup-hostname
179     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/30-hostname
180     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/50-dhcpcd-compat
181     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/50-ntp.conf
182     + inst_script -o /usr/lib/dhcpcd/dhcpcd-hooks/50-yp.conf
183     + inst_hook cleanup 10 "$moddir/kill-dhcpcd.sh"
184     + ;;
185     + esac
186     + inst_simple /etc/conf.d/network
187    
188     _arch=$(uname -m)
189    
190     diff -Naur dracut-034/modules.d/40network/net-lib.sh dracut-034-udhcpc/modules.d/40network/net-lib.sh
191     --- dracut-034/modules.d/40network/net-lib.sh 2013-10-08 07:55:26.000000000 +0000
192     +++ dracut-034-udhcpc/modules.d/40network/net-lib.sh 2014-01-17 12:37:07.880000000 +0000
193     @@ -119,6 +119,8 @@
194     [ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname
195     [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
196     [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
197     + [ -e /tmp/udhcpc.$netif.dhcpopts ] && . /tmp/udhcpc.$netif.dhcpopts
198     + [ -e /tmp/dhcpcd.$netif.dhcpopts ] && . /tmp/dhcpcd.$netif.dhcpopts
199     # set up resolv.conf
200     [ -e /tmp/net.$netif.resolv.conf ] && \
201     cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf
202     @@ -166,6 +168,15 @@
203     for f in /tmp/dhclient.$i.*; do
204     [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/dhclient.}
205     done
206     + for f in /tmp/udhcpc.$i.*; do
207     + [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/udhcpc.}
208     + done
209     + for f in /run/dhcpcd.$i.*; do
210     + [ -f $f ] && cp -f $f /tmp/net.${f#/run/dhcpcd.}
211     + done
212     + for f in /var/lib/dhcpcd/dhcpcd.$i.*; do
213     + [ -f $f ] && cp -f $f /tmp/net.${f#/var/lib/dhcpcd/dhcpcd.}
214     + done
215     done
216     echo $IFACES > /tmp/.net.ifaces.new
217     mv /tmp/.net.ifaces.new /tmp/net.ifaces
218     @@ -483,3 +494,20 @@
219     hostname() {
220     cat /proc/sys/kernel/hostname
221     }
222     +
223     +iface_wait_online()
224     +{
225     + local timeout="$1"
226     + local iface="$2"
227     +
228     + (( timeout *= 10 ))
229     +
230     + while [ ! -e /sys/class/net/$iface ]
231     + do
232     + (( timeout-- > 0 )) || return 1
233     + echo "Waiting 0.1 seconds for device '$iface' -- timeout->'$timeout'"
234     + sleep 0.1
235     + done
236     +
237     + return 0
238     +}
239     diff -Naur dracut-034/modules.d/40network/netroot.sh dracut-034-udhcpc/modules.d/40network/netroot.sh
240     --- dracut-034/modules.d/40network/netroot.sh 2013-10-08 07:55:26.000000000 +0000
241     +++ dracut-034-udhcpc/modules.d/40network/netroot.sh 2014-01-17 12:38:05.832000000 +0000
242     @@ -38,6 +38,8 @@
243     if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
244     # Load dhcp options
245     [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
246     + [ -e /tmp/udhcpc.$netif.dhcpopts ] && . /tmp/udhcpc.$netif.dhcpopts
247     + [ -e /tmp/dhcpcd.$netif.dhcpopts ] && . /tmp/dhcpcd.$netif.dhcpopts
248    
249     # If we have a specific bootdev with no dhcpoptions or empty root-path,
250     # we die. Otherwise we just warn