1 |
commit: 4255ba175bd7c3ccadc5bc894d00ccb844467067 |
2 |
Author: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Jan 9 00:24:03 2012 +0000 |
4 |
Commit: Robin H. Johnson <robbat2 <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Jan 9 00:24:10 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=4255ba17 |
7 |
|
8 |
net: net.lo, lots of scripts |
9 |
|
10 |
The program function in depend blocks is now able to search paths by |
11 |
itself. If passed multiple arguments or multiple calls, at least one of |
12 |
the arguments passed must be a program or a shell builtin (eg ip built |
13 |
into busybox). If a qualified path is specified, only that path will be |
14 |
checked, otherwise it will be checked as a builtin, then $PATH will be |
15 |
checked for the named binary (via type). |
16 |
|
17 |
Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org> |
18 |
|
19 |
--- |
20 |
init.d/net.lo.in | 40 ++++++++++++++++++++++++++-------------- |
21 |
net/br2684ctl.sh | 13 ++----------- |
22 |
net/bridge.sh | 2 +- |
23 |
net/ethtool.sh | 5 +---- |
24 |
net/ip6to4.sh | 1 + |
25 |
net/iproute2.sh | 5 +---- |
26 |
net/macchanger.sh | 1 + |
27 |
net/macvlan.sh | 5 +---- |
28 |
net/tuntap.sh | 1 + |
29 |
net/vlan.sh | 5 +---- |
30 |
10 files changed, 36 insertions(+), 42 deletions(-) |
31 |
|
32 |
diff --git a/init.d/net.lo.in b/init.d/net.lo.in |
33 |
index de393bd..2913561 100644 |
34 |
--- a/init.d/net.lo.in |
35 |
+++ b/init.d/net.lo.in |
36 |
@@ -172,7 +172,9 @@ _configure_variables() |
37 |
_which() |
38 |
{ |
39 |
local i OIFS |
40 |
+ # Empty |
41 |
[ -z "$1" ] && return |
42 |
+ # check paths |
43 |
OIFS="$IFS" |
44 |
IFS=: |
45 |
for i in $PATH ; do |
46 |
@@ -181,6 +183,22 @@ _which() |
47 |
IFS=$OIFS |
48 |
} |
49 |
|
50 |
+# Like _which, but also consider shell builtins, and multiple alternatives |
51 |
+_program_available() |
52 |
+{ |
53 |
+ [ -z "$1" ] && return 0 |
54 |
+ local x= |
55 |
+ for x; do |
56 |
+ case "${x}" in |
57 |
+ /*) [ -x "${x}" ] && break;; |
58 |
+ *) type "${x}" >/dev/null 2>&1 && break;; |
59 |
+ esac |
60 |
+ unset x |
61 |
+ done |
62 |
+ [ -n "${x}" ] && echo $x && return 0 |
63 |
+ return 1 |
64 |
+} |
65 |
+ |
66 |
_show_address() |
67 |
{ |
68 |
einfo "received address $(_get_inet_address "${IFACE}")" |
69 |
@@ -323,11 +341,10 @@ _load_modules() |
70 |
|
71 |
eval set -- \$module_${i}_program |
72 |
if [ -n "$1" ]; then |
73 |
- x= |
74 |
- for x; do |
75 |
- [ -x "${x}" ] && break |
76 |
- done |
77 |
- [ -x "${x}" ] || continue |
78 |
+ if ! _program_available "$@" >/dev/null; then |
79 |
+ vewarn "Skipping module $mod due to missing program: $@" |
80 |
+ continue |
81 |
+ fi |
82 |
fi |
83 |
if ${starting}; then |
84 |
eval set -- \$module_${i}_program_start |
85 |
@@ -335,15 +352,10 @@ _load_modules() |
86 |
eval set -- \$module_${i}_program_stop |
87 |
fi |
88 |
if [ -n "$1" ]; then |
89 |
- x= |
90 |
- for x; do |
91 |
- case "${x}" in |
92 |
- /*) [ -x "${x}" ] && break;; |
93 |
- *) type "${x}" >/dev/null 2>&1 && break;; |
94 |
- esac |
95 |
- unset x |
96 |
- done |
97 |
- [ -n "${x}" ] || continue |
98 |
+ if ! _program_available "$@" >/dev/null; then |
99 |
+ vewarn "Skipping module $mod due to missing program: $@" |
100 |
+ continue |
101 |
+ fi |
102 |
fi |
103 |
|
104 |
eval provides=\$module_${i}_provide |
105 |
|
106 |
diff --git a/net/br2684ctl.sh b/net/br2684ctl.sh |
107 |
index d605579..b3f6119 100644 |
108 |
--- a/net/br2684ctl.sh |
109 |
+++ b/net/br2684ctl.sh |
110 |
@@ -1,19 +1,10 @@ |
111 |
# Copyright (c) 2007-2008 Roy Marples <roy@×××××××.name> |
112 |
# Released under the 2-clause BSD license. |
113 |
|
114 |
-_br2684ctl() |
115 |
-{ |
116 |
- if [ -x /usr/sbin/br2684ctl ]; then |
117 |
- echo /usr/sbin/br2684ctl |
118 |
- else |
119 |
- echo /sbin/br2684ctl |
120 |
- fi |
121 |
-} |
122 |
- |
123 |
br2684ctl_depend() |
124 |
{ |
125 |
before ppp |
126 |
- program start $(_br2684ctl) |
127 |
+ program start br2684ctl |
128 |
} |
129 |
|
130 |
_config_vars="$_config_vars bridge bridge_add brctl" |
131 |
@@ -42,7 +33,7 @@ br2684ctl_pre_start() |
132 |
esac |
133 |
|
134 |
einfo "Starting RFC 2684 Bridge control on ${IFACE}" |
135 |
- start-stop-daemon --start --exec $(_br2684ctl) --background \ |
136 |
+ start-stop-daemon --start --exec $(_which br2684ctl) --background \ |
137 |
--make-pidfile --pidfile "/var/run/br2684ctl-${IFACE}.pid" \ |
138 |
-- -c "${IFACE#nas*}" ${opts} |
139 |
eend $? |
140 |
|
141 |
diff --git a/net/bridge.sh b/net/bridge.sh |
142 |
index 7b80ec0..4f3618a 100644 |
143 |
--- a/net/bridge.sh |
144 |
+++ b/net/bridge.sh |
145 |
@@ -4,7 +4,7 @@ |
146 |
bridge_depend() |
147 |
{ |
148 |
before interface macnet |
149 |
- program /sbin/brctl |
150 |
+ program brctl |
151 |
} |
152 |
|
153 |
_config_vars="$_config_vars bridge bridge_add brctl" |
154 |
|
155 |
diff --git a/net/ethtool.sh b/net/ethtool.sh |
156 |
index ba5719d..4e10409 100644 |
157 |
--- a/net/ethtool.sh |
158 |
+++ b/net/ethtool.sh |
159 |
@@ -3,10 +3,7 @@ |
160 |
|
161 |
ethtool_depend() |
162 |
{ |
163 |
- local x |
164 |
- x=$(_which ethtool) |
165 |
- [ -z "$x" ] && return 1 |
166 |
- program $x |
167 |
+ program ethtool |
168 |
before interface |
169 |
} |
170 |
|
171 |
|
172 |
diff --git a/net/ip6to4.sh b/net/ip6to4.sh |
173 |
index 959a2a0..51b3858 100644 |
174 |
--- a/net/ip6to4.sh |
175 |
+++ b/net/ip6to4.sh |
176 |
@@ -6,6 +6,7 @@ _config_vars="$_config_vars link suffix relay" |
177 |
ip6to4_depend() |
178 |
{ |
179 |
after interface |
180 |
+ program ip |
181 |
} |
182 |
|
183 |
ip6to4_pre_start() |
184 |
|
185 |
diff --git a/net/iproute2.sh b/net/iproute2.sh |
186 |
index 16d9a60..9b89352 100644 |
187 |
--- a/net/iproute2.sh |
188 |
+++ b/net/iproute2.sh |
189 |
@@ -3,10 +3,7 @@ |
190 |
|
191 |
iproute2_depend() |
192 |
{ |
193 |
- local x |
194 |
- x=$(_which ip) |
195 |
- [ -z "$x" ] && return 1 |
196 |
- program $x |
197 |
+ program ip |
198 |
provide interface |
199 |
after ifconfig |
200 |
} |
201 |
|
202 |
diff --git a/net/macchanger.sh b/net/macchanger.sh |
203 |
index ad41309..4e535ec 100644 |
204 |
--- a/net/macchanger.sh |
205 |
+++ b/net/macchanger.sh |
206 |
@@ -4,6 +4,7 @@ |
207 |
macchanger_depend() |
208 |
{ |
209 |
before macnet |
210 |
+ # no program 'macchanger', as we have partial functionality without it |
211 |
} |
212 |
|
213 |
_config_vars="$_config_vars mac" |
214 |
|
215 |
diff --git a/net/macvlan.sh b/net/macvlan.sh |
216 |
index ccb28ea..86a659c 100644 |
217 |
--- a/net/macvlan.sh |
218 |
+++ b/net/macvlan.sh |
219 |
@@ -5,10 +5,7 @@ |
220 |
|
221 |
macvlan_depend() |
222 |
{ |
223 |
- local x |
224 |
- x=$(_which ip) |
225 |
- [ -z "${X}" ] && return 1 |
226 |
- program $x |
227 |
+ program ip |
228 |
after interface |
229 |
before dhcp macchanger |
230 |
} |
231 |
|
232 |
diff --git a/net/tuntap.sh b/net/tuntap.sh |
233 |
index 679b097..d0f24c5 100644 |
234 |
--- a/net/tuntap.sh |
235 |
+++ b/net/tuntap.sh |
236 |
@@ -4,6 +4,7 @@ |
237 |
tuntap_depend() |
238 |
{ |
239 |
before bridge interface macchanger |
240 |
+ program ip openvpn tunctl |
241 |
} |
242 |
|
243 |
_config_vars="$_config_vars iproute2 openvpn tunctl" |
244 |
|
245 |
diff --git a/net/vlan.sh b/net/vlan.sh |
246 |
index ec30dd6..ff63dfd 100644 |
247 |
--- a/net/vlan.sh |
248 |
+++ b/net/vlan.sh |
249 |
@@ -3,10 +3,7 @@ |
250 |
|
251 |
vlan_depend() |
252 |
{ |
253 |
- local x |
254 |
- x=$(_which ip) |
255 |
- [ -z "$x" ] && return 1 |
256 |
- program $x |
257 |
+ program ip |
258 |
after interface |
259 |
before dhcp |
260 |
} |