Contents of /trunk/dracut/patches/dracut-034-network-support-udhcpc-dhcpcd-2.patch
Parent Directory | Revision Log
Revision 2371 -
(show annotations)
(download)
Mon Jan 20 09:54:21 2014 UTC (10 years, 8 months ago) by niro
File size: 7998 byte(s)
Mon Jan 20 09:54:21 2014 UTC (10 years, 8 months ago) by niro
File size: 7998 byte(s)
-re-diffed patch against new network patches and included some optimizations
1 | 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 2014-01-20 12:05:26.190000000 +0000 |
3 | +++ dracut-034-udhcpc/modules.d/40network/ifup.sh 2014-01-20 12:10:28.388000000 +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,6 +101,8 @@ |
29 | |
30 | # Run dhclient |
31 | do_dhcp() { |
32 | + local opts |
33 | + |
34 | # dhclient-script will mark the netif up and generate the online |
35 | # event for nfsroot |
36 | # XXX add -V vendor class and option parsing per kernel |
37 | @@ -91,9 +110,27 @@ |
38 | echo "No carrier detected" |
39 | return 1 |
40 | fi |
41 | - echo "Starting dhcp for interface $netif" |
42 | - dhclient "$@" -1 -q -cf /etc/dhclient.conf -pf /tmp/dhclient.$netif.pid -lf /tmp/dhclient.$netif.lease $netif \ |
43 | - || echo "dhcp failed" |
44 | + |
45 | + case $DHCP_PROG_NAME in |
46 | + dhclient) |
47 | + opts="$@ -1 -q" |
48 | + opts+=" -cf /etc/dhclient.conf" |
49 | + opts+=" -pf /tmp/$DHCP_PROG_NAME.$netif.pid" |
50 | + opts+=" -lf /tmp/$DHCP_PROG_NAME.$netif.lease" |
51 | + ;; |
52 | + |
53 | + dhcpcd) |
54 | + opts="$@ -q" |
55 | + ;; |
56 | + |
57 | + udhcpc) |
58 | + opts="-q" |
59 | + opts+=" -p /tmp/$DHCP_PROG_NAME.$netif.pid" |
60 | + ;; |
61 | + esac |
62 | + |
63 | + echo "Starting dhcp ($DHCP_PROG_NAME) for interface $netif" |
64 | + $DHCP_PROG $opts $DHCP_START $netif || echo "dhcp failed" |
65 | } |
66 | |
67 | load_ipv6() { |
68 | diff -Naur dracut-034/modules.d/40network/kill-dhcpcd.sh dracut-034-udhcpc/modules.d/40network/kill-dhcpcd.sh |
69 | --- dracut-034/modules.d/40network/kill-dhcpcd.sh 1970-01-01 00:00:00.000000000 +0000 |
70 | +++ dracut-034-udhcpc/modules.d/40network/kill-dhcpcd.sh 2014-01-20 12:11:59.659000000 +0000 |
71 | @@ -0,0 +1,17 @@ |
72 | +#!/bin/sh |
73 | +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- |
74 | +# ex: ts=8 sw=4 sts=4 et filetype=sh |
75 | + |
76 | +for f in /run/dhcpcd.*.pid /run/dhcpcd.pif; do |
77 | + [ -e $f ] || continue |
78 | + read PID < $f; |
79 | + kill $PID >/dev/null 2>&1 |
80 | +done |
81 | + |
82 | +sleep 0.1 |
83 | + |
84 | +for f in /tmp/dhcpcd.*.pid /run/dhcpcd.pid; do |
85 | + [ -e $f ] || continue |
86 | + read PID < $f; |
87 | + kill -9 $PID >/dev/null 2>&1 |
88 | +done |
89 | diff -Naur dracut-034/modules.d/40network/kill-udhpc.sh dracut-034-udhcpc/modules.d/40network/kill-udhpc.sh |
90 | --- dracut-034/modules.d/40network/kill-udhpc.sh 1970-01-01 00:00:00.000000000 +0000 |
91 | +++ dracut-034-udhcpc/modules.d/40network/kill-udhpc.sh 2014-01-20 12:12:44.515000000 +0000 |
92 | @@ -0,0 +1,17 @@ |
93 | +#!/bin/sh |
94 | +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- |
95 | +# ex: ts=8 sw=4 sts=4 et filetype=sh |
96 | + |
97 | +for f in /tmp/udhcpc.*.pid; do |
98 | + [ -e $f ] || continue |
99 | + read PID < $f; |
100 | + kill $PID >/dev/null 2>&1 |
101 | +done |
102 | + |
103 | +sleep 0.1 |
104 | + |
105 | +for f in /tmp/udhcpc.*.pid; do |
106 | + [ -e $f ] || continue |
107 | + read PID < $f; |
108 | + kill -9 $PID >/dev/null 2>&1 |
109 | +done |
110 | diff -Naur dracut-034/modules.d/40network/module-setup.sh dracut-034-udhcpc/modules.d/40network/module-setup.sh |
111 | --- dracut-034/modules.d/40network/module-setup.sh 2013-10-08 07:55:26.000000000 +0000 |
112 | +++ dracut-034-udhcpc/modules.d/40network/module-setup.sh 2014-01-20 12:23:21.421000000 +0000 |
113 | @@ -4,8 +4,9 @@ |
114 | |
115 | check() { |
116 | local _program |
117 | + . /etc/conf.d/network |
118 | |
119 | - for _program in ip arping dhclient ; do |
120 | + for _program in ip ifconfig route arping $DEFAULT_DHCP_PROG ; do |
121 | if ! type -P $_program >/dev/null; then |
122 | derror "Could not find program \"$_program\" required by network." |
123 | return 1 |
124 | @@ -69,16 +70,20 @@ |
125 | |
126 | install() { |
127 | local _arch _i _dir |
128 | - inst_multiple ip arping dhclient sed |
129 | + local _dhcp_prog_name |
130 | + local _file |
131 | + . /etc/conf.d/network |
132 | + _dhcp_prog_name="${DEFAULT_DHCP_PROG##*/}" |
133 | + |
134 | + inst_multiple ip arping $_dhcp_prog_name sed |
135 | + inst_multiple ifconfig route |
136 | inst_multiple -o ping ping6 |
137 | inst_multiple -o brctl |
138 | inst_multiple -o teamd teamdctl teamnl |
139 | inst_simple /etc/libnl/classid |
140 | inst_script "$moddir/ifup.sh" "/sbin/ifup" |
141 | inst_script "$moddir/netroot.sh" "/sbin/netroot" |
142 | - inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script" |
143 | inst_simple "$moddir/net-lib.sh" "/lib/net-lib.sh" |
144 | - inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf" |
145 | inst_hook pre-udev 50 "$moddir/ifname-genrules.sh" |
146 | inst_hook pre-udev 60 "$moddir/net-genrules.sh" |
147 | inst_hook cmdline 91 "$moddir/dhcp-root.sh" |
148 | @@ -89,7 +94,28 @@ |
149 | inst_hook cmdline 97 "$moddir/parse-bridge.sh" |
150 | inst_hook cmdline 98 "$moddir/parse-ip-opts.sh" |
151 | inst_hook cmdline 99 "$moddir/parse-ifname.sh" |
152 | - inst_hook cleanup 10 "$moddir/kill-dhclient.sh" |
153 | + case $_dhcp_prog_name in |
154 | + dhclient) |
155 | + inst_script "$moddir/dhclient-script.sh" "/sbin/dhclient-script" |
156 | + inst_simple "$moddir/dhclient.conf" "/etc/dhclient.conf" |
157 | + inst_hook cleanup 10 "$moddir/kill-dhclient.sh" |
158 | + ;; |
159 | + |
160 | + udhcpc) |
161 | + inst_script /usr/share/udhcpc/default.script |
162 | + inst_hook cleanup 10 "$moddir/kill-udhcpc.sh" |
163 | + ;; |
164 | + |
165 | + dhcpcd) |
166 | + inst_simple /etc/dhcpcd.conf |
167 | + inst_script -o /usr/lib/dhcpcd/dhcpcd-run-hooks |
168 | + for _file in $(find /usr/lib/dhcpcd/dhcpcd-hooks -type f); do |
169 | + inst_simple -o $_file |
170 | + done |
171 | + inst_hook cleanup 10 "$moddir/kill-dhcpcd.sh" |
172 | + ;; |
173 | + esac |
174 | + inst_simple /etc/conf.d/network |
175 | |
176 | _arch=$(uname -m) |
177 | |
178 | diff -Naur dracut-034/modules.d/40network/net-lib.sh dracut-034-udhcpc/modules.d/40network/net-lib.sh |
179 | --- dracut-034/modules.d/40network/net-lib.sh 2014-01-20 12:05:21.542000000 +0000 |
180 | +++ dracut-034-udhcpc/modules.d/40network/net-lib.sh 2014-01-20 12:24:31.383000000 +0000 |
181 | @@ -95,6 +95,8 @@ |
182 | [ -e /tmp/net.$netif.hostname ] && . /tmp/net.$netif.hostname |
183 | [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override |
184 | [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts |
185 | + [ -e /tmp/udhcpc.$netif.dhcpopts ] && . /tmp/udhcpc.$netif.dhcpopts |
186 | + [ -e /tmp/dhcpcd.$netif.dhcpopts ] && . /tmp/dhcpcd.$netif.dhcpopts |
187 | # set up resolv.conf |
188 | [ -e /tmp/net.$netif.resolv.conf ] && \ |
189 | cp -f /tmp/net.$netif.resolv.conf /etc/resolv.conf |
190 | @@ -142,6 +144,15 @@ |
191 | for f in /tmp/dhclient.$i.*; do |
192 | [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/dhclient.} |
193 | done |
194 | + for f in /tmp/udhcpc.$i.*; do |
195 | + [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/udhcpc.} |
196 | + done |
197 | + for f in /run/dhcpcd.$i.*; do |
198 | + [ -f $f ] && cp -f $f /tmp/net.${f#/run/dhcpcd.} |
199 | + done |
200 | + for f in /var/lib/dhcpcd/dhcpcd.$i.*; do |
201 | + [ -f $f ] && cp -f $f /tmp/net.${f#/var/lib/dhcpcd/dhcpcd.} |
202 | + done |
203 | done |
204 | echo $IFACES > /tmp/.net.ifaces.new |
205 | mv /tmp/.net.ifaces.new /tmp/net.ifaces |
206 | diff -Naur dracut-034/modules.d/40network/netroot.sh dracut-034-udhcpc/modules.d/40network/netroot.sh |
207 | --- dracut-034/modules.d/40network/netroot.sh 2013-10-08 07:55:26.000000000 +0000 |
208 | +++ dracut-034-udhcpc/modules.d/40network/netroot.sh 2014-01-20 12:24:57.335000000 +0000 |
209 | @@ -38,6 +38,8 @@ |
210 | if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then |
211 | # Load dhcp options |
212 | [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts |
213 | + [ -e /tmp/udhcpc.$netif.dhcpopts ] && . /tmp/udhcpc.$netif.dhcpopts |
214 | + [ -e /tmp/dhcpcd.$netif.dhcpopts ] && . /tmp/dhcpcd.$netif.dhcpopts |
215 | |
216 | # If we have a specific bootdev with no dhcpoptions or empty root-path, |
217 | # we die. Otherwise we just warn |