1 |
Author: grobian |
2 |
Date: 2011-03-31 14:11:17 +0000 (Thu, 31 Mar 2011) |
3 |
New Revision: 1682 |
4 |
|
5 |
Added: |
6 |
trunk/baselayout-prefix/ |
7 |
trunk/baselayout-prefix/ChangeLog |
8 |
trunk/baselayout-prefix/bin/ |
9 |
trunk/baselayout-prefix/bin/rc-status |
10 |
trunk/baselayout-prefix/etc/ |
11 |
trunk/baselayout-prefix/etc/conf.d/ |
12 |
trunk/baselayout-prefix/etc/conf.d/bootmisc |
13 |
trunk/baselayout-prefix/etc/conf.d/clock |
14 |
trunk/baselayout-prefix/etc/conf.d/consolefont |
15 |
trunk/baselayout-prefix/etc/conf.d/env_whitelist |
16 |
trunk/baselayout-prefix/etc/conf.d/hostname |
17 |
trunk/baselayout-prefix/etc/conf.d/keymaps |
18 |
trunk/baselayout-prefix/etc/conf.d/local.start |
19 |
trunk/baselayout-prefix/etc/conf.d/local.stop |
20 |
trunk/baselayout-prefix/etc/conf.d/net |
21 |
trunk/baselayout-prefix/etc/conf.d/net.example |
22 |
trunk/baselayout-prefix/etc/conf.d/rc |
23 |
trunk/baselayout-prefix/etc/conf.d/wireless.example |
24 |
trunk/baselayout-prefix/etc/env.d/ |
25 |
trunk/baselayout-prefix/etc/env.d/00basic |
26 |
trunk/baselayout-prefix/etc/filesystems |
27 |
trunk/baselayout-prefix/etc/fstab |
28 |
trunk/baselayout-prefix/etc/group |
29 |
trunk/baselayout-prefix/etc/hosts |
30 |
trunk/baselayout-prefix/etc/inputrc |
31 |
trunk/baselayout-prefix/etc/issue |
32 |
trunk/baselayout-prefix/etc/issue.devfix |
33 |
trunk/baselayout-prefix/etc/issue.logo |
34 |
trunk/baselayout-prefix/etc/modules.autoload.d/ |
35 |
trunk/baselayout-prefix/etc/modules.autoload.d/kernel-2.4 |
36 |
trunk/baselayout-prefix/etc/modules.autoload.d/kernel-2.6 |
37 |
trunk/baselayout-prefix/etc/modules.d/ |
38 |
trunk/baselayout-prefix/etc/modules.d/aliases |
39 |
trunk/baselayout-prefix/etc/modules.d/i386 |
40 |
trunk/baselayout-prefix/etc/networks |
41 |
trunk/baselayout-prefix/etc/passwd |
42 |
trunk/baselayout-prefix/etc/profile |
43 |
trunk/baselayout-prefix/etc/protocols |
44 |
trunk/baselayout-prefix/etc/rc.conf |
45 |
trunk/baselayout-prefix/etc/services |
46 |
trunk/baselayout-prefix/etc/shadow |
47 |
trunk/baselayout-prefix/etc/shells |
48 |
trunk/baselayout-prefix/etc/sysctl.conf |
49 |
trunk/baselayout-prefix/init.d/ |
50 |
trunk/baselayout-prefix/init.d/bootmisc |
51 |
trunk/baselayout-prefix/init.d/checkfs |
52 |
trunk/baselayout-prefix/init.d/checkroot |
53 |
trunk/baselayout-prefix/init.d/clock |
54 |
trunk/baselayout-prefix/init.d/consolefont |
55 |
trunk/baselayout-prefix/init.d/halt.sh |
56 |
trunk/baselayout-prefix/init.d/hostname |
57 |
trunk/baselayout-prefix/init.d/keymaps |
58 |
trunk/baselayout-prefix/init.d/local |
59 |
trunk/baselayout-prefix/init.d/localmount |
60 |
trunk/baselayout-prefix/init.d/modules |
61 |
trunk/baselayout-prefix/init.d/net.eth0 |
62 |
trunk/baselayout-prefix/init.d/net.lo |
63 |
trunk/baselayout-prefix/init.d/netmount |
64 |
trunk/baselayout-prefix/init.d/numlock |
65 |
trunk/baselayout-prefix/init.d/reboot.sh |
66 |
trunk/baselayout-prefix/init.d/rmnologin |
67 |
trunk/baselayout-prefix/init.d/shutdown.sh |
68 |
trunk/baselayout-prefix/init.d/urandom |
69 |
trunk/baselayout-prefix/lib/ |
70 |
trunk/baselayout-prefix/lib/rcscripts/ |
71 |
trunk/baselayout-prefix/lib/rcscripts/net/ |
72 |
trunk/baselayout-prefix/lib/rcscripts/net/adsl.sh |
73 |
trunk/baselayout-prefix/lib/rcscripts/net/apipa.sh |
74 |
trunk/baselayout-prefix/lib/rcscripts/net/arping.sh |
75 |
trunk/baselayout-prefix/lib/rcscripts/net/bonding.sh |
76 |
trunk/baselayout-prefix/lib/rcscripts/net/br2684ctl.sh |
77 |
trunk/baselayout-prefix/lib/rcscripts/net/bridge.sh |
78 |
trunk/baselayout-prefix/lib/rcscripts/net/ccwgroup.sh |
79 |
trunk/baselayout-prefix/lib/rcscripts/net/clip.sh |
80 |
trunk/baselayout-prefix/lib/rcscripts/net/dhclient.sh |
81 |
trunk/baselayout-prefix/lib/rcscripts/net/dhcpcd.sh |
82 |
trunk/baselayout-prefix/lib/rcscripts/net/essidnet.sh |
83 |
trunk/baselayout-prefix/lib/rcscripts/net/ifconfig.sh |
84 |
trunk/baselayout-prefix/lib/rcscripts/net/ifplugd.sh |
85 |
trunk/baselayout-prefix/lib/rcscripts/net/ip6to4.sh |
86 |
trunk/baselayout-prefix/lib/rcscripts/net/ipppd.sh |
87 |
trunk/baselayout-prefix/lib/rcscripts/net/iproute2.sh |
88 |
trunk/baselayout-prefix/lib/rcscripts/net/iptunnel.sh |
89 |
trunk/baselayout-prefix/lib/rcscripts/net/iwconfig.sh |
90 |
trunk/baselayout-prefix/lib/rcscripts/net/macchanger.sh |
91 |
trunk/baselayout-prefix/lib/rcscripts/net/macnet.sh |
92 |
trunk/baselayout-prefix/lib/rcscripts/net/netplugd.sh |
93 |
trunk/baselayout-prefix/lib/rcscripts/net/pppd.sh |
94 |
trunk/baselayout-prefix/lib/rcscripts/net/pump.sh |
95 |
trunk/baselayout-prefix/lib/rcscripts/net/rename.sh |
96 |
trunk/baselayout-prefix/lib/rcscripts/net/system.sh |
97 |
trunk/baselayout-prefix/lib/rcscripts/net/tuntap.sh |
98 |
trunk/baselayout-prefix/lib/rcscripts/net/udhcpc.sh |
99 |
trunk/baselayout-prefix/lib/rcscripts/net/vlan.sh |
100 |
trunk/baselayout-prefix/lib/rcscripts/net/wpa_supplicant.sh |
101 |
trunk/baselayout-prefix/man/ |
102 |
trunk/baselayout-prefix/man/MAKEDEV.8 |
103 |
trunk/baselayout-prefix/man/consoletype.1 |
104 |
trunk/baselayout-prefix/man/modules-update.8 |
105 |
trunk/baselayout-prefix/man/modules.autoload.5 |
106 |
trunk/baselayout-prefix/man/rc-status.8 |
107 |
trunk/baselayout-prefix/man/rc-update.8 |
108 |
trunk/baselayout-prefix/man/start-stop-daemon.8 |
109 |
trunk/baselayout-prefix/rc-lists/ |
110 |
trunk/baselayout-prefix/rc-lists/boot |
111 |
trunk/baselayout-prefix/rc-lists/default |
112 |
trunk/baselayout-prefix/rc-lists/nonetwork |
113 |
trunk/baselayout-prefix/rc-lists/single |
114 |
trunk/baselayout-prefix/sbin/ |
115 |
trunk/baselayout-prefix/sbin/MAKEDEV |
116 |
trunk/baselayout-prefix/sbin/MAKEDEV-gentoo.patch |
117 |
trunk/baselayout-prefix/sbin/depscan.sh |
118 |
trunk/baselayout-prefix/sbin/env-update.sh |
119 |
trunk/baselayout-prefix/sbin/functions.sh |
120 |
trunk/baselayout-prefix/sbin/modules-update |
121 |
trunk/baselayout-prefix/sbin/rc |
122 |
trunk/baselayout-prefix/sbin/rc-daemon.sh |
123 |
trunk/baselayout-prefix/sbin/rc-help.sh |
124 |
trunk/baselayout-prefix/sbin/rc-services.sh |
125 |
trunk/baselayout-prefix/sbin/rc-update |
126 |
trunk/baselayout-prefix/sbin/runscript.sh |
127 |
trunk/baselayout-prefix/src/ |
128 |
trunk/baselayout-prefix/src/Makefile |
129 |
trunk/baselayout-prefix/src/awk/ |
130 |
trunk/baselayout-prefix/src/awk/cachedepends.awk |
131 |
trunk/baselayout-prefix/src/awk/functions.awk |
132 |
trunk/baselayout-prefix/src/awk/gendepends.awk |
133 |
trunk/baselayout-prefix/src/awk/genenviron.awk |
134 |
trunk/baselayout-prefix/src/consoletype.c |
135 |
trunk/baselayout-prefix/src/core/ |
136 |
trunk/baselayout-prefix/src/core/ChangeLog |
137 |
trunk/baselayout-prefix/src/core/Makefile |
138 |
trunk/baselayout-prefix/src/core/README |
139 |
trunk/baselayout-prefix/src/core/debug.h |
140 |
trunk/baselayout-prefix/src/core/depend.c |
141 |
trunk/baselayout-prefix/src/core/depend.h |
142 |
trunk/baselayout-prefix/src/core/depscan.c |
143 |
trunk/baselayout-prefix/src/core/list.h |
144 |
trunk/baselayout-prefix/src/core/misc.c |
145 |
trunk/baselayout-prefix/src/core/misc.h |
146 |
trunk/baselayout-prefix/src/core/parse.c |
147 |
trunk/baselayout-prefix/src/core/parse.h |
148 |
trunk/baselayout-prefix/src/core/simple-regex.c |
149 |
trunk/baselayout-prefix/src/core/simple-regex.h |
150 |
trunk/baselayout-prefix/src/core/test-regex.c |
151 |
trunk/baselayout-prefix/src/env_whitelist |
152 |
trunk/baselayout-prefix/src/filefuncs/ |
153 |
trunk/baselayout-prefix/src/filefuncs/Makefile |
154 |
trunk/baselayout-prefix/src/filefuncs/filefuncs.c |
155 |
trunk/baselayout-prefix/src/headers.h |
156 |
trunk/baselayout-prefix/src/runscript.c |
157 |
trunk/baselayout-prefix/src/start-stop-daemon.c |
158 |
Log: |
159 |
Add original code base from baselayout-1.12.5 |
160 |
|
161 |
Added: trunk/baselayout-prefix/ChangeLog |
162 |
=================================================================== |
163 |
--- trunk/baselayout-prefix/ChangeLog (rev 0) |
164 |
+++ trunk/baselayout-prefix/ChangeLog 2011-03-31 14:11:17 UTC (rev 1682) |
165 |
@@ -0,0 +1,5278 @@ |
166 |
+# ChangeLog for Gentoo System Intialization ("rc") scripts |
167 |
+# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2 |
168 |
+ |
169 |
+ 06 Sep 2006; Roy Marples <uberlord@g.o>: |
170 |
+ |
171 |
+ Fix PPPoA usage, #144194 thanks to Giampaolo Tomassoni. |
172 |
+ |
173 |
+ iproute2 netlink check has been moved to the ebuild. |
174 |
+ |
175 |
+ When stopping a ppp link, don't remove the IP address, #145034. |
176 |
+ |
177 |
+ 05 Sep 2006; Roy Marples <uberlord@g.o>: |
178 |
+ |
179 |
+ wpa_supplicant packet socket checks have been moved to the ebuild. |
180 |
+ |
181 |
+ 21 Aug 2006; Roy Marples <uberlord@g.o>: |
182 |
+ |
183 |
+ Each dhcp client now supports global options - ie dhcpcd="-a" |
184 |
+ |
185 |
+ Classical IP over ATM support has been added, #108153 thanks to |
186 |
+ Giampaolo Tomassoni. Note that he will not support the module and no |
187 |
+ Gentoo devs have the hardware so any bugs reported may take time to fix. |
188 |
+ |
189 |
+ 18 Aug 2006; Roy Marples <uberlord@g.o>: |
190 |
+ |
191 |
+ Don't stop services that are depended on by coldplugged services. |
192 |
+ |
193 |
+ 17 Aug 2006; Roy Marples <uberlord@g.o>: |
194 |
+ |
195 |
+ Document ppp plugin options, #144194. |
196 |
+ |
197 |
+ Allow RC_NEED_$iface to work in the same was as RC_NEED. |
198 |
+ |
199 |
+ 16 Aug 2006; Roy Marples <uberlord@g.o>: |
200 |
+ |
201 |
+ Fix typo's in net.example, #144144 thanks to Christian 'Opfer' Faulhammer. |
202 |
+ |
203 |
+ /sys/class/net/$iface/wireless means it's a wireless device too in |
204 |
+ iwconfig.sh and wpa_supplicant.sh |
205 |
+ |
206 |
+ 15 Aug 2006; Roy Marples <uberlord@g.o>: |
207 |
+ |
208 |
+ Fix start-stop-daemon using the --name option |
209 |
+ #143951 thanks to Dustin J. Mitchell |
210 |
+ |
211 |
+ Support old gateway variable with iproute2. |
212 |
+ arpinging of available address can be disabled with |
213 |
+ modules=( "!arping" ) |
214 |
+ |
215 |
+ 14 Aug 2006; Roy Marples <uberlord@g.o>: |
216 |
+ |
217 |
+ Only send a process the TERM signal once, #141832 |
218 |
+ |
219 |
+ Set frequency, channel and ap after ESSID, #143716 thanks to damage. |
220 |
+ |
221 |
+ 13 Aug 2006; Roy Marples <uberlord@g.o>: |
222 |
+ |
223 |
+ Remove silly dhcpcd version check. Drop -o from dhcpcd options as |
224 |
+ all dhcpcd versions in portage have been patches to not bring the interface |
225 |
+ down and future versions may not support that option as they won't bring |
226 |
+ the interface down at all. |
227 |
+ |
228 |
+ Fix frequency parsing and add channel parsing to iwconfig, #143698 |
229 |
+ |
230 |
+ Start dhclient on the right interface, #130670 thanks to Petr Svoboda. |
231 |
+ |
232 |
+ 04 Aug 2006; Roy Marples <uberlord@g.o>: |
233 |
+ |
234 |
+ Add bootchart suppport, #74425 and #141114. Thanks to Paul Pacheco. |
235 |
+ |
236 |
+* baselayout-1.12.4 (02 Aug 2006) |
237 |
+ |
238 |
+ 02 Aug 2006; Roy Marples <uberlord@g.o>: |
239 |
+ |
240 |
+ Updated tarball.sh to make clean before making the tarball, bug #142457 |
241 |
+ |
242 |
+* baselayout-1.12.2 (01 Aug 2006) |
243 |
+ |
244 |
+ 26 Jul 2006; Roy Marples <uberlord@g.o>: |
245 |
+ |
246 |
+ wpa_supplicant now launches even when wireless radio has been killed |
247 |
+ as if the user enables it then it will associate and work without the |
248 |
+ user having to restart the interface. |
249 |
+ |
250 |
+ 20 Jul 2006; Roy Marples <uberlord@g.o>: |
251 |
+ |
252 |
+ Enable RC_NEED="foo" and RC_USE="bar" in /etc/conf.d/${SERVICE} |
253 |
+ so that users can overlay service dependencies with their own. |
254 |
+ Bug #140865 |
255 |
+ |
256 |
+ 18 Jul 2006; Roy Marples <uberlord@g.o>: |
257 |
+ |
258 |
+ Report services scheduled to be started by another service as |
259 |
+ started OK for splash. |
260 |
+ |
261 |
+ 12 Jul 2006; Roy Marples <uberlord@g.o>: |
262 |
+ |
263 |
+ Add bootmisc as a CRITICAL_SERVICE as too many init scripts don't |
264 |
+ depend on it, which means that /var/run and others could get cleaned after |
265 |
+ daemons write important things there - like pidfiles - when using parallel |
266 |
+ startup. |
267 |
+ |
268 |
+ 10 Jul 2006; Roy Marples <uberlord@g.o>: |
269 |
+ |
270 |
+ Fixed some internal net dependencies with >1 active net service |
271 |
+ Services can now be scheduled on any inactive services. |
272 |
+ |
273 |
+ 27 Jun 2006; Roy Marples <uberlord@g.o>: |
274 |
+ |
275 |
+ Document that depend_eth0() only works in conf.d/net and |
276 |
+ not conf.d/net.$profile, #137727. |
277 |
+ |
278 |
+ 23 Jun 2006; Roy Marples <uberlord@g.o>: |
279 |
+ |
280 |
+ Fix rc-status broken link reporting properly, #137656 |
281 |
+ |
282 |
+ 19 Jun 2006; Roy Marples <uberlord@g.o>: |
283 |
+ |
284 |
+ Preliminary support for dscape ieee80211 stack devices. |
285 |
+ |
286 |
+ 18 Jun 2006; Roy Marples <uberlord@g.o>: |
287 |
+ |
288 |
+ vlan id's can now be treated as individual interfaces via init scripts |
289 |
+ provided they depend on the real interface, #137029 |
290 |
+ |
291 |
+ 15 Jun 2006; Roy Marples <uberlord@g.o>: |
292 |
+ |
293 |
+ runscript.sh now supports the --verbose flag setting RC_VERBOSE="yes" |
294 |
+ When RC_VERBOSE="yes" and RC_PARALLEL_STARTUP="yes" and there is no |
295 |
+ exclusive lock (ie, init script not started via rc) then we don't hide |
296 |
+ init script output by setting RC_QUIET_STDOUT, #136034. |
297 |
+ |
298 |
+ 14 Jun 2006; Roy Marples <uberlord@g.o>: |
299 |
+ |
300 |
+ {start,stop}_volumes moved to rc and halt.sh respectively. |
301 |
+ |
302 |
+ net services are now depended upon more correctly. |
303 |
+ |
304 |
+ wireless cards now get their txpower set to auto before starting. |
305 |
+ |
306 |
+ Fix "before net" dependencies, #135872 thanks to Oldrich Jedlicka. |
307 |
+ |
308 |
+ pppd.sh now uses passwordfd instead of very nasty regex stuff, |
309 |
+ thanks to Oldrich Jedlicka, Alin Nastac and me :), #134337 |
310 |
+ |
311 |
+ 12 Jun 2006; Roy Marples <uberlord@g.o>: |
312 |
+ |
313 |
+ We now have a Makefile to install our scripts. |
314 |
+ |
315 |
+ 06 Jun 2006; Roy Marples <uberlord@g.o>: |
316 |
+ |
317 |
+ shutdown.sh now uses the INIT_HALT variable correctly, #135740 |
318 |
+ thanks to Steve Moerk. |
319 |
+ |
320 |
+* baselayout-1.12.1 (05 Jun 2006) |
321 |
+ |
322 |
+ 05 Jun 2006; Roy Marples <uberlord@g.o>: |
323 |
+ |
324 |
+ Restore the man user/group, #113298 thanks to Chris Gianelloni. |
325 |
+ |
326 |
+ Fix typo in /sbin/rc, #135323 thanks to Ed Catmur. |
327 |
+ |
328 |
+ rc now stops services again, #135340. |
329 |
+ |
330 |
+ depscan.sh now tries to touch files in with future mtimes so that |
331 |
+ users only see the clock skew message once, #135212. |
332 |
+ |
333 |
+ Show help when rc-update is called without arguments, #133434. |
334 |
+ |
335 |
+ Ensure that an empty NET_FS_LIST doesn't cause localmount to error, |
336 |
+ #132928 thanks to Dominik Buerkle. |
337 |
+ |
338 |
+ 02 Jun 2006; Roy Marples <uberlord@g.o>: |
339 |
+ |
340 |
+ Allow LC_* and LANG vars through to runscript.sh by default. |
341 |
+ |
342 |
+ net.lo now comes after bootmisc, #135118 thanks to Oldrich Jedlicka. |
343 |
+ |
344 |
+ arping.sh now has MAC address support, #134253 thanks to Oldrich Jedlicka. |
345 |
+ |
346 |
+ pppd.sh now updates secret files with a blank password, #134337 |
347 |
+ |
348 |
+ Remove swapon call from /sbin/rc as localmount already calls it, |
349 |
+ #47932 and also a partial fix for #134489 |
350 |
+ |
351 |
+ 30 May 2006; Roy Marples <uberlord@g.o>: |
352 |
+ |
353 |
+ Allow users to specify netplugd options. |
354 |
+ |
355 |
+ Really fix is_xenU_sys, #134571 thanks to Stefan Hellermann. |
356 |
+ |
357 |
+ 24 May 2006; Roy Marples <uberlord@g.o>: |
358 |
+ |
359 |
+ Ensure that we call halt.sh in a new shell with LC_ALL=C so that we don't |
360 |
+ load any locale information which may stop us unmounting /usr, #128848 |
361 |
+ and #133090. |
362 |
+ |
363 |
+ Don't set clock for OpenVZ systems, #133265 thanks to Kir Kolyshkin. |
364 |
+ |
365 |
+ Don't remount / in checkroot for unionfs /, #129975 thanks to Daniel. |
366 |
+ |
367 |
+ Don't stop net interfaces / is unionfs and a branch is network mounted. |
368 |
+ |
369 |
+* baselayout-1.12.0 (23 May 2006) |
370 |
+ |
371 |
+ 23 May 2006; Roy Marples <uberlord@g.o>: |
372 |
+ |
373 |
+ halt.sh can now deal with unionfs a bit better, #99682. |
374 |
+ |
375 |
+ 16 May 2006; Roy Marples <uberlord@g.o>: |
376 |
+ |
377 |
+ Always report Xen domU domains correctly, #107976. |
378 |
+ |
379 |
+ 15 May 2006; Roy Marples <uberlord@g.o>: |
380 |
+ |
381 |
+ Always test for space at the end of the bridge name. |
382 |
+ |
383 |
+ 14 May 2006; Roy Marples <uberlord@g.o>: |
384 |
+ |
385 |
+ Don't stop coldplugged services when changing runlevels, #113264. |
386 |
+ |
387 |
+ Only report inactive start once. |
388 |
+ |
389 |
+ 07 May 2006; Roy Marples <uberlord@g.o>: |
390 |
+ |
391 |
+ Fix logic in br2684ctl.sh as reported by Alin Nastac, #132549. |
392 |
+ |
393 |
+ 05 May 2006; Mike Frysinger <vapier@g.o>: |
394 |
+ |
395 |
+ Fix typo s/veend/vewend/ in functions.sh as reported by Yoshino #132262. |
396 |
+ |
397 |
+ 05 May 2006; Roy Marples <uberlord@g.o>: |
398 |
+ |
399 |
+ If a device initiated service is in the default runlevel then we no |
400 |
+ longer start it in the boot runlevel. |
401 |
+ |
402 |
+ 04 May 2006; Roy Marples <uberlord@g.o>: |
403 |
+ |
404 |
+ RC_COLDPLUG is now just a yes|no setting and the service list allowed |
405 |
+ is now in RC_PLUG_SERVICES. |
406 |
+ Added RC_HOTPLUG setting similar to RC_COLDPLUG. |
407 |
+ |
408 |
+* baselayout-1.12.0_pre19 (02 May 2006) |
409 |
+ |
410 |
+ 01 May 2006; Roy Marples <uberlord@g.o>: |
411 |
+ |
412 |
+ /proc/net/wireless may not have whitespace after $iface: |
413 |
+ wpa_supplicant no longer requires ctrl_interface set. |
414 |
+ Thanks to kelmo for those ideas. |
415 |
+ |
416 |
+ 28 Apr 2006; Mike Frysinger <vapier@g.o>: |
417 |
+ |
418 |
+ Tweak is_older_than than so it skips checking the timestamps on directories, |
419 |
+ just the files in the directory. |
420 |
+ |
421 |
+ Rewrite modules-update to make it readable and usuable without old modutils. |
422 |
+ |
423 |
+ 24 Apr 2006; Roy Marples <uberlord@g.o>: |
424 |
+ |
425 |
+ revert the -k2 addition to sort in halt.sh as we only echo the second |
426 |
+ key to sort, #131001. |
427 |
+ |
428 |
+* baselayout-1.12.0_pre18 (22 Apr 2006) |
429 |
+ |
430 |
+ 22 Apr 2006; Mike Frysinger <vapier@g.o>: |
431 |
+ |
432 |
+ Touchup fuser arguments in halt.sh so we dont have to pipe to /dev/null. |
433 |
+ |
434 |
+ 22 Apr 2006; Roy Marples <uberlord@g.o>: |
435 |
+ |
436 |
+ udhcpc module now requires udhcp-0.9.9_pre20041216-r3 or newer with |
437 |
+ the --env command option. |
438 |
+ |
439 |
+ 21 Apr 2006; Roy Marples <uberlord@g.o>: |
440 |
+ |
441 |
+ br2684 module should now work correctly. |
442 |
+ Document usage of br2684 module. |
443 |
+ |
444 |
+ move /lib/rcscripts/net.modules.d to /lib/rcscripts/net |
445 |
+ |
446 |
+ 18 Apr 2006; Roy Marples <uberlord@g.o>: |
447 |
+ |
448 |
+ start-stop-daemon only removes the daemon stopping from the daemon |
449 |
+ started list, #130166. |
450 |
+ |
451 |
+ 15 Apr 2006; Roy Marples <uberlord@g.o>: |
452 |
+ |
453 |
+ net services are now calculated properly in trace_dependencies. |
454 |
+ |
455 |
+ arping.sh now tests if the interface exists or not. |
456 |
+ |
457 |
+ 12 Apr 2006; Roy Marples <uberlord@g.o>: |
458 |
+ |
459 |
+ vlans can now be configured with their own interface scripts, which |
460 |
+ means that they can now be renamed, #128283. |
461 |
+ Thanks to Jonathan deBoer. |
462 |
+ |
463 |
+ 11 Apr 2006; Roy Marples <uberlord@g.o>: |
464 |
+ |
465 |
+ udhcpc.sh now works with the -q|--quit option again, #129437. |
466 |
+ |
467 |
+ 09 Apr 2006; Roy Marples <uberlord@g.o>: |
468 |
+ |
469 |
+ RC_COLDPLUG now controls if we add coldplugged services to the boot |
470 |
+ runlevel or not, #129331. |
471 |
+ |
472 |
+ The ccwgroup module now really works! |
473 |
+ |
474 |
+* baselayout-1.12.0_pre17 (08 Apr 2006) |
475 |
+ |
476 |
+ 07 Apr 2006; Roy Marples <uberlord@g.o>: |
477 |
+ |
478 |
+ net modules now apply their own metric if they are activated, which makes |
479 |
+ for a much easier and less mesy calculation. |
480 |
+ |
481 |
+ 05 Apr 2006; Roy Marples <uberlord@g.o>: |
482 |
+ |
483 |
+ runscript.sh now stores the fact that it failed to to /dev/.rcsysinit |
484 |
+ existing in the directory /dev/.rcboot. rc adds services in |
485 |
+ /dev/.rcboot to the boot list and then rm -f's that directory. This |
486 |
+ solves the issue of udev-089 forcing coldplug removal. |
487 |
+ |
488 |
+ 03 Apr 2006; Roy Marples <uberlord@g.o>: |
489 |
+ |
490 |
+ rc-status doesn't report broken symlinks when querying all levels, |
491 |
+ #113755 again. |
492 |
+ |
493 |
+ All net modules how have a .sh suffix to indicate that they are shell |
494 |
+ scripts as not everyone uses vim. |
495 |
+ |
496 |
+ runscript.sh now has a --nodeps option so that no depends are checked |
497 |
+ when starting and stopping a service. |
498 |
+ |
499 |
+ net.lo and system modules now support resolvconf instead of using our |
500 |
+ own internal system. |
501 |
+ |
502 |
+ DHCP and PPP clients no longer have helper scripts. As such they don't |
503 |
+ change service status at all. Moved helpers.d/functions back into net.lo |
504 |
+ |
505 |
+ Moved {get,save}_options from functions.sh to rc-services.sh |
506 |
+ |
507 |
+ Removed whole load of crud from hostname init script, fixes #38172 again |
508 |
+ and #122794. Also, it's no longer a critical service as defined by rc. |
509 |
+ |
510 |
+ Added net modules for ccwgroup (s390 qeth ethernet) and br2684ctl |
511 |
+ (speedtouch usb). |
512 |
+ |
513 |
+ Removed xargs and find from all net scripts as /usr maybe net mounted, |
514 |
+ #107260. |
515 |
+ |
516 |
+ Punted the domainname script. Functionality has been in conf.d/net so you |
517 |
+ can do this. |
518 |
+ dns_domain_lo="foo" |
519 |
+ nis_domain_lo="bar" |
520 |
+ |
521 |
+ ppd module now checks to see if link exists if prefixed with /, #126916. |
522 |
+ |
523 |
+ 14 Mar 2006; Roy Marples <uberlord@g.o>: |
524 |
+ |
525 |
+ Allow services that depend on net to be stopped/started in post |
526 |
+ up/down functions when the net service is started by rc. |
527 |
+ |
528 |
+ 13 Mar 2006; Roy Marples <uberlord@g.o>: |
529 |
+ |
530 |
+ Allow more than 1 inactive dependant service to start us when it is |
531 |
+ started, #125819 thanks to Arnuad Fabre. |
532 |
+ |
533 |
+ 12 Mar 2006; Roy Marples <uberlord@g.o>: |
534 |
+ |
535 |
+ iwconfig now strips duplicate mac addresses from scan results which means |
536 |
+ we only try and connect to ad-hoc networks once. |
537 |
+ |
538 |
+ 10 Mar 2006; Roy Marples <uberlord@g.o>: |
539 |
+ |
540 |
+ iwconfig now reports mode in scan results |
541 |
+ |
542 |
+ net script modules variables function has been moved into module_expose |
543 |
+ and removed from module_depend to be more correct. |
544 |
+ |
545 |
+ net script modules have had #!/bin/bash removed from the top and now |
546 |
+ set vim fs=sh to be more correct. |
547 |
+ |
548 |
+ 02 Mar 2006; Roy Marples <uberlord@g.o>: |
549 |
+ |
550 |
+ $myservice is now deprecated for init scripts. |
551 |
+ $SVCNAME should be used instead and is read-only so it cannot be |
552 |
+ clobbered. |
553 |
+ |
554 |
+ Several variables in global scope that provided functions rely on, |
555 |
+ such as BOOTLEVEL, SOFTLEVEL and svcdir are now read only for init |
556 |
+ scripts. |
557 |
+ |
558 |
+ depscan.sh now accepts the --svcdir option so that svcdir can now be |
559 |
+ specified as the variable is marked readonly in functions.sh. Splash |
560 |
+ programs will have to be updated. |
561 |
+ |
562 |
+ 24 Feb 2006; Roy Marples <uberlord@g.o>: |
563 |
+ |
564 |
+ Misc STYLE and quoting issues fixes in net scripts. |
565 |
+ |
566 |
+ dhclient and udhcpc now work with RFC violating space separated |
567 |
+ domain names in /etc/resolv.conf - they get appended to the search |
568 |
+ option if it's not specified. |
569 |
+ |
570 |
+ punted clean_pidfile and process_finished functions and as |
571 |
+ start-stop-daemon as provided by rc-daemon.sh now provides |
572 |
+ the same thing, just better. |
573 |
+ |
574 |
+ We now send extra configuration to dhclient via stdin. |
575 |
+ This means we don't have to edit /etc/dhcp/dhclient.conf anymore |
576 |
+ or warn users about script settings. Requires net-misc/dhcp-3.0.3-r5. |
577 |
+ |
578 |
+ 22 Feb 2006; Roy Marples <uberlord@g.o>: |
579 |
+ |
580 |
+ Ensure that ifplugd, netplugd and wpa_supplicant timeouts really are |
581 |
+ infinite when requested. Thanks to embobo. |
582 |
+ |
583 |
+ 17 Feb 2006; Roy Marples <uberlord@g.o>: |
584 |
+ |
585 |
+ Fixed typo in functions, #123136 thanks to Alexander Danilov. |
586 |
+ |
587 |
+* baselayout-1.12.0_pre16 (16 Feb 2006) |
588 |
+ |
589 |
+ 15 Feb 2006; Roy Marples <uberlord@g.o>: |
590 |
+ |
591 |
+ tuntap now works if openvpn is installed, #122452. |
592 |
+ |
593 |
+ 14 Feb 2006; Roy Marples <uberlord@g.o>: |
594 |
+ |
595 |
+ ip rules setup has been documented in net.example, #107628. |
596 |
+ |
597 |
+ pppd should now be fully re-entrant, #122396. |
598 |
+ |
599 |
+ 08 Feb 2006; Roy Marples <uberlord@g.o>: |
600 |
+ |
601 |
+ New module ip6to4 that creates tunnels with IPv6 addresses based off |
602 |
+ global IPv4 addresses on a specified interface, #122015. |
603 |
+ Thanks to Antti Mäkelä for testing and ideas. |
604 |
+ |
605 |
+ 07 Feb 2006; Roy Marples <uberlord@g.o>: |
606 |
+ |
607 |
+ Always ensure that end_service is called, #119233 again. |
608 |
+ |
609 |
+ You can now specify a maxfail value for pppd (default 0), #115346. |
610 |
+ |
611 |
+ net.lo now depends on isapnp to work with older NICs, #121539. |
612 |
+ |
613 |
+ chat commands in pppd are now re-quoted, #121665. |
614 |
+ |
615 |
+ wpa_supplicant now looks for config files in order |
616 |
+ /etc/wpa_supplicant/wpa_supplicant-$iface.conf |
617 |
+ /etc/wpa_supplicant/wpa_supplicant.conf |
618 |
+ /etc/wpa_supplicant.conf |
619 |
+ and for these wpa_cli scripts |
620 |
+ /etc/wpa_supplicant/wpa_cli.sh |
621 |
+ /sbin/wpa_cli.action |
622 |
+ |
623 |
+ 25 Jan 2006; Roy Marples <uberlord@g.o>: |
624 |
+ |
625 |
+ New variable RC_ULIMIT applies ulimit commands before starting a service. |
626 |
+ This should be configured in /etc/conf.d/foo for service foo, but can also |
627 |
+ be configured in /etc/conf.d/rc on a global basis. |
628 |
+ RC_DAEMON now works in a similar way, instead of RC_DAEMON_foo. |
629 |
+ Fixes, #120151. |
630 |
+ |
631 |
+ 24 Jan 2006; Roy Marples <uberlord@g.o>: |
632 |
+ |
633 |
+ Dependant services are restarted correctly when the restarted |
634 |
+ service is started and not inactive, #120154. |
635 |
+ |
636 |
+ 21 Jan 2006; Roy Marples <uberlord@g.o>: |
637 |
+ |
638 |
+ Ensure that CRITICAL_SERVICES are in the boot runlevel, #117912. |
639 |
+ |
640 |
+* baselayout-1.12.0_pre15 (20 Jan 2006) |
641 |
+ |
642 |
+ 20 Jan 2006; Roy Marples <uberlord@g.o>: |
643 |
+ |
644 |
+ Fix quoting in iwconfig, #119629. |
645 |
+ Fix process pid selection in rc-daemon.sh, #119631. |
646 |
+ Both of the above thanks to Dominik Buerkle. |
647 |
+ |
648 |
+ init scripts no longer run during the sysinit runlevel, #118419. |
649 |
+ Thanks to Greg KH and the Linux Hotplug mailing list for advice. |
650 |
+ |
651 |
+ 19 Jan 2006; Roy Marples <uberlord@g.o>: |
652 |
+ |
653 |
+ Give a better error message when no valid DHCP client is installed. |
654 |
+ |
655 |
+ 18 Jan 2006; Roy Marples <uberlord@g.o>: |
656 |
+ |
657 |
+ Services should not get stuck in rc anymore, #119233, #119242. |
658 |
+ |
659 |
+ We only hotplug net.* scripts on interfaces that are marked as ethernet. |
660 |
+ |
661 |
+ 16 Jan 2006; Roy Marples <uberlord@g.o>: |
662 |
+ |
663 |
+ Renamed restart in $svcdir to scheduled as it makes much more sense. |
664 |
+ |
665 |
+ Interfaces names with a dot in them now work. |
666 |
+ |
667 |
+ 14 Jan 2006; Roy Marples <uberlord@g.o>: |
668 |
+ |
669 |
+ Changed runscript.sh to store it's services to restart like rc. |
670 |
+ |
671 |
+* baselayout-1.12.0_pre14 (13 Jan 2006) |
672 |
+ |
673 |
+ 13 Jan 2006; Roy Marples <uberlord@g.o>: |
674 |
+ |
675 |
+ Added warning to modules.autoload.d files stating that it's a bad idea |
676 |
+ to put modules there that trigger hotplug events which in turn start |
677 |
+ services, #118419. |
678 |
+ |
679 |
+ Services that need a service which is inactive at boot are now scheduled |
680 |
+ to start when the inactive service starts, #118801. |
681 |
+ |
682 |
+ 12 Jan 2006; Roy Marples <uberlord@g.o>: |
683 |
+ |
684 |
+ Interactive start is now controllable by RC_INTERACTIVE="yes" and will |
685 |
+ probe to see if we can go interactive. |
686 |
+ |
687 |
+ 11 Jan 2006; Roy Marples <uberlord@g.o>: |
688 |
+ |
689 |
+ runscript.sh now traps interrupt signals and rolls back its status to what |
690 |
+ it was when before it started. |
691 |
+ |
692 |
+ bonding module now supports space seperated and array variables, #118590. |
693 |
+ |
694 |
+ start-stop-daemon now waits for upto 1 second if it returns 0 and we |
695 |
+ don't have a valid process. |
696 |
+ |
697 |
+ A more user friendly message is reported when an interface does not exist. |
698 |
+ |
699 |
+ 10 Jan 2006; Roy Marples <uberlord@g.o>: |
700 |
+ |
701 |
+ Removed runlevel dependancies from runscript.sh as they're now in rc. |
702 |
+ |
703 |
+ runscript.sh now has much better locking, #118418. |
704 |
+ |
705 |
+ We now store services to restart when we end up as inactive from a restart |
706 |
+ or we were stopped with IN_BACKGROUND=true, #112088. |
707 |
+ |
708 |
+ We no longer stop and start services already running on runlevel change if |
709 |
+ they're in the runlevel we're changing too. |
710 |
+ |
711 |
+ We can now wait_sevice on services started outside of rc. |
712 |
+ |
713 |
+ rc-status now reports "Could not locate" instead of "Could not local", |
714 |
+ thanks to Christian Heim. |
715 |
+ |
716 |
+ 09 Jan 2006; Roy Marples <uberlord@g.o>: |
717 |
+ |
718 |
+ Ensure that specific configuration is loaded after net, #118368. |
719 |
+ |
720 |
+ iwconfig now supports multiple iwconfig_* and iwpriv_* statements and is |
721 |
+ also configurable for specific ESSIDs. This allows use to use the inbuilt |
722 |
+ WPA support in the rt2500 driver. |
723 |
+ |
724 |
+ module-loader now loads interface specific configuration files, #118366. |
725 |
+ |
726 |
+ 07 Jan 2006; Roy Marples <uberlord@g.o>: |
727 |
+ |
728 |
+ Save a few CPU cycles by storing add_suffix in variable. |
729 |
+ |
730 |
+ 06 Jan 2006; Roy Marples <uberlord@g.o>: |
731 |
+ |
732 |
+ Use ${DEFAULTLEVEL} if ${SOFTLEVEL} is boot, shutdown, reboot or single |
733 |
+ in add_suffix. |
734 |
+ |
735 |
+ Sync style changes in functions.sh |
736 |
+ |
737 |
+ Critical services now load a suffixed config and fail gracefully. |
738 |
+ |
739 |
+ 05 Jan 2006; Roy Marples <uberlord@g.o>: |
740 |
+ |
741 |
+ iproute deletes addresses again, fixes #117799. |
742 |
+ |
743 |
+ dhclient now supports dhclient-enter-hooks, #117763. |
744 |
+ |
745 |
+* baselayout-1.12.0_pre13 (04 Jan 2006) |
746 |
+ |
747 |
+ 03 Jan 2006; Roy Marples <uberlord@g.o>: |
748 |
+ |
749 |
+ net scripts now work with bash-3.1-r2, #116352. |
750 |
+ |
751 |
+ 02 Jan 2006; Roy Marples <uberlord@g.o>: |
752 |
+ |
753 |
+ Interfaces can be dynamically added to bridges again, #117406. |
754 |
+ Updated copyright to 2006. |
755 |
+ |
756 |
+ 29 Dec 2005; Roy Marples <uberlord@g.o>: |
757 |
+ |
758 |
+ Support old gateway var again for ifconfig, #116761. |
759 |
+ |
760 |
+ 21 Dec 2005; Roy Marples <uberlord@g.o>: |
761 |
+ |
762 |
+ Add new variable RC_DOWN_INTERFACE and documentation so that interfaces |
763 |
+ are kept up for Wake On LAN support, #113880. |
764 |
+ |
765 |
+* baselayout-1.12.0_pre12 (20 Dec 2005) |
766 |
+ |
767 |
+ 20 Dec 2005; Roy Marples <uberlord@g.o>: |
768 |
+ |
769 |
+ Ensure that tty has keyboard and stty reports icanon before enabling |
770 |
+ interactive rc, #112161. |
771 |
+ |
772 |
+ 15 Dec 2005; Roy Marples <uberlord@g.o>: |
773 |
+ |
774 |
+ When setting ad-hoc or master modes, set the mode before anything else, |
775 |
+ #115664 thanks to Oldrich Jedlicka. |
776 |
+ |
777 |
+ 14 Dec 2005; Roy Marples <uberlord@g.o>: |
778 |
+ |
779 |
+ Add great big warning in documentation advising people not to use the |
780 |
+ IPv6 examples if they don't have IPv6 enabled in their kernel, #115396. |
781 |
+ |
782 |
+ 09 Dec 2005; Roy Marples <uberlord@g.o>: |
783 |
+ |
784 |
+ Remove nasty undocumented backgrounding as we now support |
785 |
+ ifplugd, netplug and wpa_supplicant-0.4.x which do much better jobs. |
786 |
+ |
787 |
+ 06 Dec 2005; Roy Marples <uberlord@g.o>: |
788 |
+ |
789 |
+ ppp documentation updated, #114551. |
790 |
+ |
791 |
+ 05 Dec 2005; Roy Marples <uberlord@g.o>: |
792 |
+ |
793 |
+ Fix dhcp options, #114519. |
794 |
+ |
795 |
+ 28 Nov 2005; Roy Marples <uberlord@g.o>: |
796 |
+ |
797 |
+ Fixed fallback_routes, #113776. |
798 |
+ Fixed variable array references, #113661. |
799 |
+ Fixed iwconfig mode selection, #113677 - thanks to Tuan Van. |
800 |
+ Fixed iproute2 is_up check, #113672 - thanks to Georgi Georgiev. |
801 |
+ Added information about the "broken" status as reported by rc-status to |
802 |
+ its output, #113755. |
803 |
+ |
804 |
+ 24 Nov 2005; Roy Marples <uberlord@g.o>: |
805 |
+ |
806 |
+ ifconfig routes now work with metrics and older configs again |
807 |
+ #113378 and #113406. |
808 |
+ |
809 |
+ arping now works with multiple gateways, #113402. |
810 |
+ |
811 |
+ pppd module now updates an emply secrets file, #113431. |
812 |
+ |
813 |
+ use ${svclib} instead of hardcoding /lib/rcscripts. |
814 |
+ |
815 |
+* baselayout-1.12.0_pre11 (23 Nov 2005) |
816 |
+ |
817 |
+ 23 Nov 2005; Roy Marples <uberlord@g.o>: |
818 |
+ |
819 |
+ RC_KILL_CHILDREN now defaults to "no". This stops ssh children being |
820 |
+ killed when a network interface is restarted. |
821 |
+ |
822 |
+ macchanger now ensures the interface is down before attempting to change |
823 |
+ the mac address, #112333. |
824 |
+ |
825 |
+ 22 Nov 2005; Roy Marples <uberlord@g.o>: |
826 |
+ |
827 |
+ Stop ifplugd and netplugd from operating on bonded and vlan interfaces. |
828 |
+ |
829 |
+ 21 Nov 2005; Roy Marples <uberlord@g.o>: |
830 |
+ |
831 |
+ Fix wpa_suppicant error when auth is IEEE 802.1X (NO WPA) #112938. |
832 |
+ |
833 |
+ 18 Nov 2005; Roy Marples <uberlord@g.o>: |
834 |
+ |
835 |
+ Changed from eval foo=\"\$config_$ifvar\" to foo=config_$ivar; foo=$!foo |
836 |
+ This is to avoid using the eval statement to extract user configured vars. |
837 |
+ |
838 |
+ Enhanced pppd module so that it obeys metric routes, does not mess |
839 |
+ with the system resolv.conf and works with updetach a bit better, #112049. |
840 |
+ |
841 |
+ Fixed pointotpoint, #112757 thanks to Felix Braun. |
842 |
+ |
843 |
+ 10 Nov 2005; Martin Schlemmer <azarah@g.o>: |
844 |
+ |
845 |
+ Fix for bug #104288. Update to modules-update from trunk. |
846 |
+ |
847 |
+ 10 Nov 2005; Roy Marples <uberlord@g.o>: |
848 |
+ |
849 |
+ Fix WEP for forced AP's, #112031 |
850 |
+ |
851 |
+ Change pppd behaviour for updetach, #112049 |
852 |
+ |
853 |
+ Fix "Device foo not found" error when stopping an interface and the |
854 |
+ interface does not physically exist. |
855 |
+ |
856 |
+ 09 Nov 2005; Roy Marples <uberlord@g.o>: |
857 |
+ |
858 |
+ ifplugd, netplug and wpa_supplicant now background automatically |
859 |
+ instead of waiting to see if the interface was configured OK |
860 |
+ |
861 |
+* baselayout-1.12.0_pre10 (08 Nov 2005) |
862 |
+ |
863 |
+ 08 Nov 2005; Roy Marples <uberlord@g.o>: |
864 |
+ |
865 |
+ punted serial from rc-lists/boot as it's no longer provided by baselayout |
866 |
+ |
867 |
+ 08 Nov 2005; Martin Schlemmer <azarah@g.o>: |
868 |
+ |
869 |
+ Backport changes needed for udev/devfs addons. |
870 |
+ |
871 |
+ 31 Oct 2005; Roy Marples <uberlord@g.o>: |
872 |
+ |
873 |
+ Replace the bubble-esq sort routine with a tsort based one for |
874 |
+ loading modules. This means that we are much faster than before :) |
875 |
+ |
876 |
+ Fix ifconfig with multiple IP addresses, #110956 |
877 |
+ |
878 |
+ 19 Oct 2005; Roy Marples <uberlord@g.o>: |
879 |
+ |
880 |
+ rc-daemon.sh now kills children correctly. |
881 |
+ |
882 |
+ 18 Oct 2005; Roy Marples <uberlord@g.o>: |
883 |
+ |
884 |
+ You can now specify a custom wpa_supplicant configuration file. |
885 |
+ wpa_supplicant now works on more than one interface. |
886 |
+ |
887 |
+ 17 Oct 2005; Roy Marples <uberlord@g.o>: |
888 |
+ |
889 |
+ wpa_supplicant now works on wired interfaces, and can work with |
890 |
+ ifplugd and netplug too. |
891 |
+ |
892 |
+ 16 Oct 2005; Roy Marples <uberlord@g.o>: |
893 |
+ |
894 |
+ Fixed typo in dhcpcd-wrapper so the new resolv.conf gets created |
895 |
+ in /var/lib/net-scripts and not the current directory. Thanks to |
896 |
+ Mark-Dominik Bürkle for the patch. |
897 |
+ |
898 |
+ 13 Oct 2005; Roy Marples <uberlord@g.o>: |
899 |
+ |
900 |
+ Fix test_service_state() so it always returns 1 when it's not in that |
901 |
+ state. |
902 |
+ |
903 |
+ 12 Oct 2005; Roy Marples <uberlord@g.o>: |
904 |
+ |
905 |
+ Changed number of preferred modules from 3 to 4 in net.lo, #108960. |
906 |
+ |
907 |
+* baselayout-1.12.0_pre9 (11 Oct 2005) |
908 |
+ |
909 |
+ 11 Oct 2005; Roy Marples <uberlord@g.o>: |
910 |
+ |
911 |
+ arping now dis-regards 0.0.0.0 and 0 addresses, #108737. |
912 |
+ |
913 |
+ dhcpcd now allows the user to configure the -c script option, #108345. |
914 |
+ |
915 |
+ bash doesn't handle floats, so we eumlate it. Fixes the issue |
916 |
+ where some daemons didn't stop, #107492. Thanks to Giampaolo Tomassoni. |
917 |
+ |
918 |
+ 09 Oct 2005; Roy Marples <uberlord@g.o>: |
919 |
+ |
920 |
+ Fix chroot handling and enable custom env vars for start-stop-daemon |
921 |
+ binary #101642, thanks to Quequero. |
922 |
+ |
923 |
+ 07 Oct 2005; Roy Marples <uberlord@g.o>: |
924 |
+ |
925 |
+ Fix some vlan/bridge/tap/neplugd/ifplugd interdependencies #107406. |
926 |
+ |
927 |
+ 06 Oct 2005; Roy Marples <uberlord@g.o>: |
928 |
+ |
929 |
+ Fixup IPv6 documentation and support, #108143. |
930 |
+ |
931 |
+ 16 Sep 2005; Roy Marples <uberlord@g.o>: |
932 |
+ |
933 |
+ iwconfig and wpa_supplicant now check to see if /proc/net/wireless exists |
934 |
+ before checking for extensions, #106036 |
935 |
+ |
936 |
+ 14 Sep 2005; Roy Marples <uberlord@g.o>: |
937 |
+ |
938 |
+ netplug module renamed to netplugd for consistency |
939 |
+ |
940 |
+ pppd module added, #53954 thanks to Alin Nastac |
941 |
+ |
942 |
+ 13 Sep 2005; Roy Marples <uberlord@g.o>: |
943 |
+ |
944 |
+ Changed net.lo depend from isdn4linux to isdn, #102846 |
945 |
+ |
946 |
+ 12 Sep 2005; Roy Marples <uberlord@g.o>: |
947 |
+ |
948 |
+ Set essid before mode for ad-hoc/master configurations, #105452 |
949 |
+ |
950 |
+ Fixed force_any associate order option, #99256 |
951 |
+ |
952 |
+ 08 Sep 2005; Roy Marples <uberlord@g.o>: |
953 |
+ |
954 |
+ Added ifplugd module, but we prefer netplug by default |
955 |
+ |
956 |
+ 07 Sep 2005; Roy Marples <uberlord@g.o>: |
957 |
+ |
958 |
+ replace the apipa module with a generic arping module which can now |
959 |
+ do gateway detection and apply a configuration for it as well as the |
960 |
+ apipa stuff |
961 |
+ |
962 |
+ updated env_whitelist so that nothing is allowed by default |
963 |
+ |
964 |
+ system module now runs through pre instead of post and is run by |
965 |
+ lo as well, so dns_ options can be configured for it |
966 |
+ |
967 |
+ netplug and wpa_supplicant understand negative timeouts to be defined |
968 |
+ as "return immediately and don't wait for success" |
969 |
+ |
970 |
+ dns options and sortlist now get merged in resolv.conf too |
971 |
+ |
972 |
+ bridge error message regarding the kernel module should work with |
973 |
+ newer versions of bridge-utils |
974 |
+ |
975 |
+ 06 Sep 2005; Roy Marples <uberlord@g.o>: |
976 |
+ |
977 |
+ dns_*, nis_* and ntp_* options now work globally too, but are overridden |
978 |
+ by specific interface/essid/mac ones. |
979 |
+ |
980 |
+ dhcpcd and pump now support the "options" and "sortlist" directives too, |
981 |
+ #104870 |
982 |
+ |
983 |
+ 05 Sep 2005; Roy Marples <uberlord@g.o>: |
984 |
+ |
985 |
+ Added resolv.conf options for "options" and "sortlist" directives, #104870 |
986 |
+ |
987 |
+ dns_search_path_eth0 renamed to dns_search_eth0 so that all the dns_ |
988 |
+ variables match their resolv.conf counterpart. |
989 |
+ |
990 |
+ 04 Sep 2005; Martin Schlemmer <azarah@g.o>: |
991 |
+ |
992 |
+ Do not unmount /usr, but rather remount it ro, else we run into issues |
993 |
+ with systems that have locales enabled, as the fuser call in halt.sh tries |
994 |
+ to kill bash (due to it using /usr/lib/locale/*). |
995 |
+ |
996 |
+ 03 Sep 2005; Martin Schlemmer <azarah@g.o>: |
997 |
+ |
998 |
+ Add warning about having LANG in env_whitelist, add TERM to system |
999 |
+ env_whitelist, set argv[0] to '/bin/bash' and not 'runscript'. |
1000 |
+ |
1001 |
+ 02 Sep 2005; Roy Marples <uberlord@g.o>: |
1002 |
+ |
1003 |
+ Fixed netplug from stopping on the wrong interface |
1004 |
+ |
1005 |
+* baselayout-1.12.0_pre8 (02 Sep 2005) |
1006 |
+ |
1007 |
+ 02 Sep 2005; Martin Schlemmer <azarah@g.o>: |
1008 |
+ |
1009 |
+ Split the enviroment whitelist for runscript into a system and user part. |
1010 |
+ Update it to use LIBDIR so that we can set 'lib' or 'lib64'. |
1011 |
+ |
1012 |
+ 02 Sep 2005; Roy Marples <uberlord@g.o>: |
1013 |
+ |
1014 |
+ netplug module added + documentation for it. |
1015 |
+ |
1016 |
+ We also set MTU in the pre_start of ifconfig/iproute2 incase a DHCP |
1017 |
+ client or similar needs it. |
1018 |
+ |
1019 |
+ 01 Sep 2005; Roy Marples <uberlord@g.o>: |
1020 |
+ |
1021 |
+ Altered iproute2 to use the same lo logic as ifconfig below |
1022 |
+ |
1023 |
+ Fixed ifconfig bringing lo up and then working out aliases, bug #104415 |
1024 |
+ |
1025 |
+ 31 Aug 2005; Martin Schlemmer <azarah@g.o>: |
1026 |
+ |
1027 |
+ Add the initial stuff for filtering of env variables for the rc-system. |
1028 |
+ |
1029 |
+ Use /sbin/functions.sh instead of /etc/init.d/functions.sh. |
1030 |
+ |
1031 |
+ Fix for the 'local starts and stops unneeded' issue when calling /sbin/rc |
1032 |
+ in some cases. |
1033 |
+ |
1034 |
+* baselayout-1.12.0_pre7 (31 Aug 2005) |
1035 |
+ |
1036 |
+ 31 Aug 2005; Roy Marples <uberlord@g.o>: |
1037 |
+ |
1038 |
+ service status requests (either by /etc/init.d/foo status or rc-status) |
1039 |
+ now update the service status by checking daemons and/or pidfiles to check |
1040 |
+ if they are still running or not. To update the status in your own code, |
1041 |
+ source "${svclib}/sh/rc-daemon.sh" and call |
1042 |
+ update_service_status "${service}" |
1043 |
+ |
1044 |
+ Trimmed $Header$ from a few files |
1045 |
+ |
1046 |
+ 30 Aug 2005; Roy Marples <uberlord@g.o>: |
1047 |
+ |
1048 |
+ iwconfig fixed for scanned ad-hoc networks |
1049 |
+ we now prefer managed over ad-hoc when processing scan results |
1050 |
+ |
1051 |
+ iwconfig associate_test_quality now works. Fixes #103579 thanks to |
1052 |
+ Harald Schioeberg |
1053 |
+ |
1054 |
+ iproute2 now understands ifconfig style netmask routes |
1055 |
+ |
1056 |
+ fixed IPv6 address problems in ifconfig and iproute2 modules |
1057 |
+ |
1058 |
+ 24 Aug 2005; Roy Marples <uberlord@g.o>: |
1059 |
+ |
1060 |
+ rc-daemon now handles --signal correct - fixes #103182 |
1061 |
+ |
1062 |
+ 19 Aug 2005; Roy Marples <uberlord@g.o>: |
1063 |
+ |
1064 |
+ dhcpcd now reports the correct needed version |
1065 |
+ |
1066 |
+ iwconfig and wpa_supplicant have better tests for wireless interface |
1067 |
+ which fixes the "lan wlan" problem |
1068 |
+ |
1069 |
+* baselayout-1.12.0_pre6 (18 Aug 2005) |
1070 |
+ |
1071 |
+ 18 Aug 2005; Roy Marples <uberlord@g.o>: |
1072 |
+ |
1073 |
+ RC_AUTO_INTERFACE defaults to NO - but we still default to DHCP |
1074 |
+ |
1075 |
+ consoletype is now cached. This has the benefit of being very slightly |
1076 |
+ faster and you now get coloured text for parallel startup |
1077 |
+ |
1078 |
+ Parallel startup also does parallel shutdown as well |
1079 |
+ |
1080 |
+ You're now warned if you're using a deprecated conf.d/net syntax |
1081 |
+ |
1082 |
+ 15 Aug 2005; Roy Marples <uberlord@g.o>: |
1083 |
+ |
1084 |
+ iproute2 now understands the old iface_xxx syntax, but this only works |
1085 |
+ if ifconfig (from net-tools) is installed |
1086 |
+ |
1087 |
+ 14 Aug 2005; Roy Marples <uberlord@g.o>: |
1088 |
+ |
1089 |
+ fallback_route_eth0 now works again |
1090 |
+ |
1091 |
+ Implemented interactive startup - fixes #5353 |
1092 |
+ Thanks to Paul Pacheco for the patch |
1093 |
+ |
1094 |
+ 13 Aug 2005; Roy Marples <uberlord@g.o>: |
1095 |
+ |
1096 |
+ Parallel startup races should now be fixed |
1097 |
+ |
1098 |
+ iwconfig now scans for mode so you can prefer ad-hoc networks |
1099 |
+ |
1100 |
+ 12 Aug 2005; Roy Marples <uberlord@g.o>: |
1101 |
+ |
1102 |
+ RC_AUTO_INTERFACE now defaults to no - we no longer mess with /etc unless |
1103 |
+ told too |
1104 |
+ |
1105 |
+ tuntap no longer complains about ${devnull} |
1106 |
+ |
1107 |
+ We now merge resolv.conf and ntp.conf from active interfaces |
1108 |
+ |
1109 |
+ 11 Aug 2005; Roy Marples <uberlord@g.o>: |
1110 |
+ |
1111 |
+ Add support for --pid ${pidfile} and --pidfile=${pidfile} in rc-daemon.sh |
1112 |
+ |
1113 |
+ Remove tail from depdir() in /sbin/modules-update |
1114 |
+ |
1115 |
+* baselayout-1.12.0_pre5 (11 Aug 2005) |
1116 |
+ |
1117 |
+ 08 Aug 2005; Roy Marples <uberlord@g.o>: |
1118 |
+ |
1119 |
+ Add failup/faildown user functions when an interface fails to come up/go |
1120 |
+ down. Fixes bug #101087. |
1121 |
+ |
1122 |
+ 06 Aug 2005; Martin Schlemmer <azarah@g.o>: |
1123 |
+ |
1124 |
+ Revert 'mtime' changes to depscan.sh, and just make it warn if it detects |
1125 |
+ that there are files with mtime in the future. |
1126 |
+ |
1127 |
+ 06 Aug 2005; Martin Schlemmer <azarah@g.o>: |
1128 |
+ |
1129 |
+ Enhance gendepends.awk to check more than one level of dependencies. Also |
1130 |
+ break checking of NEED/USE/BEFORE/AFTER into more stages, so that we can |
1131 |
+ but sure that all NEED's will override the rest, that USE will override |
1132 |
+ BEFORE/AFTER, and also check both the resolved and unresolved trees. |
1133 |
+ |
1134 |
+ Also test if RUNLEVEL is '1' besides 'S', fixing 'init 1'. |
1135 |
+ |
1136 |
+ Hack init.d/clock to wait for /dev/rtc if compiled as a module ... hopefully |
1137 |
+ udev will get sorted soon. |
1138 |
+ |
1139 |
+ Try a workaround for the "mtime in future" issues we have with depscan.sh. |
1140 |
+ |
1141 |
+* baselayout-1.12.0_pre4 (05 Aug 2005) |
1142 |
+ |
1143 |
+ 05 Aug 2005; Roy Marples <uberlord@g.o>: |
1144 |
+ |
1145 |
+ Rationalise if/then/else login in runscript.sh svc_start() and svc_stop() |
1146 |
+ |
1147 |
+ Fixed a few quoting issues in iwconfig |
1148 |
+ Use return values instead of capturing stderr output for iwconfig commands |
1149 |
+ |
1150 |
+ Added # vim:ts=4 to all net-script files and re-indented |
1151 |
+ |
1152 |
+ ${svcdir}/dep{cache,tree} are now chmodded 0644 so users can read them |
1153 |
+ |
1154 |
+ 04 Aug 2005; Martin Schlemmer <azarah@g.o>: |
1155 |
+ |
1156 |
+ Update /sbin/rc to actually use init's single level, and also to launch |
1157 |
+ sulogin, bug #66834. |
1158 |
+ |
1159 |
+ Fix a typo and some logic issues in new trace_dependencies(). |
1160 |
+ |
1161 |
+ Whitespace cleanups in new trace_dependencies(). |
1162 |
+ |
1163 |
+ Fix my own logic issue in new trace_dependencies(). |
1164 |
+ |
1165 |
+ 04 Aug 2005; Roy Marples <uberlord@g.o>: |
1166 |
+ |
1167 |
+ interface state directories are now created with -m 0755 to ensure that |
1168 |
+ everyone can read them |
1169 |
+ |
1170 |
+ rc-daemon.sh now supports multiple cmds - partial fix for #98745 |
1171 |
+ |
1172 |
+ trace_dependencies gets a re-write (again) to try and solve the hanging |
1173 |
+ issues that many people are reporting |
1174 |
+ |
1175 |
+ More anal about RHS quoting |
1176 |
+ |
1177 |
+ 02 Aug 2005; Roy Marples <uberlord@g.o>: |
1178 |
+ |
1179 |
+ 0 timeout now means infinite for wpa_supplicant and iwconfig wrt #90443 |
1180 |
+ |
1181 |
+ iwconfig no longer downs and ups the interface after a scan - instead we |
1182 |
+ set essid any just before doing it |
1183 |
+ |
1184 |
+ 01 Aug 2005; Roy Marples <uberlord@g.o>: |
1185 |
+ |
1186 |
+ dhclient now has to be told it can edit dhclient.conf instead of assuming |
1187 |
+ it. Final fix to #100745. |
1188 |
+ |
1189 |
+ Tweaked module depends to fix order when no dhcp client is found. |
1190 |
+ |
1191 |
+ rc-daemon now works with mysql - fixes #100982, thanks to bju from the |
1192 |
+ forums. |
1193 |
+ |
1194 |
+ We now only link /etc/{resolv,ntp,yp}.conf when the file exists. |
1195 |
+ We now link back everything in the state dir except for .sv files. |
1196 |
+ |
1197 |
+ 30 Jul 2005; Roy Marples <uberlord@g.o>: |
1198 |
+ |
1199 |
+ Fixed associate_order "forcepreferred" #100799, thanks to Benoit Boissinot. |
1200 |
+ |
1201 |
+ 29 Jul 2005; Roy Marples <uberlord@g.o>: |
1202 |
+ |
1203 |
+ Fixed dhclient sending hostname #100745, thanks to Benoit Boissinot. |
1204 |
+ |
1205 |
+* baselayout-1.12.0_pre3 (29 Jul 2005) |
1206 |
+ |
1207 |
+ 26 Jul 2005; Martin Schlemmer <azarah@g.o>: |
1208 |
+ |
1209 |
+ Remove the "parallel" depend stuff from the awk backend. |
1210 |
+ |
1211 |
+ Remove the "parallel" depend stuff from the help. |
1212 |
+ |
1213 |
+ 26 Jul 2005; Roy Marples <uberlord@g.o>: |
1214 |
+ |
1215 |
+ Removed the "parallel" depend for init scripts and related functions. |
1216 |
+ The RC_PARALLEL_STARTUP works well for all - no need for init scripts to |
1217 |
+ state if they parallel or not. |
1218 |
+ |
1219 |
+ Removed loops from trace_dependencies for a nice speed boost. |
1220 |
+ |
1221 |
+ Fixed failure in runscript.sh to proceed when a non needed dependency |
1222 |
+ (ie use, after, before) failed to start. |
1223 |
+ |
1224 |
+ 25 Jul 2005; Martin Schlemmer <azarah@g.o>: |
1225 |
+ |
1226 |
+ If we do not have net services, check both boot and current runlevel for |
1227 |
+ net services in trace_dependencies(). Sort services and make sure they |
1228 |
+ are unique. |
1229 |
+ |
1230 |
+ Fix the adding of dependencies to properly add netservices as 'net'. |
1231 |
+ |
1232 |
+ 25 Jul 2005; Roy Marples <uberlord@g.o>: |
1233 |
+ |
1234 |
+ trace_dependencies no longer clobbers the net service. |
1235 |
+ |
1236 |
+ RC_AUTO_INTERFACE no longer symlinks /etc/{resolv,ntp,yp}.conf when no. |
1237 |
+ |
1238 |
+ 25 Jul 2005; Martin Schlemmer <azarah@g.o>: |
1239 |
+ |
1240 |
+ Do not restart dependencies on runlevel change if the service that needs |
1241 |
+ them are in the next runlevel. |
1242 |
+ |
1243 |
+* baselayout-1.12.0_pre2 (22 Jul 2005) |
1244 |
+ |
1245 |
+ 22 Jul 2005; Roy Marples <uberlord@g.o>: |
1246 |
+ |
1247 |
+ When a service is stopped, the IN_BACKGROUND variable is cleared |
1248 |
+ before any dependencies are stopped so they are not marked inactive. |
1249 |
+ The IN_BACKGROUND variable is then restored so the parent script can be |
1250 |
+ marked inactive. |
1251 |
+ |
1252 |
+ 21 Jul 2005; Mike Frysinger <vapier@g.o>: |
1253 |
+ |
1254 |
+ Change the -l option to tar to --one-file-system #99775. |
1255 |
+ |
1256 |
+ Add a --debug option to depscan.sh. |
1257 |
+ |
1258 |
+ 21 Jul 2005; Martin Schlemmer <azarah@g.o>: |
1259 |
+ |
1260 |
+ Fix hangs in bootup, bug #99663. |
1261 |
+ |
1262 |
+ 21 Jul 2005; Roy Marples <uberlord@g.o>: |
1263 |
+ |
1264 |
+ dhclient now sets the hostname correctly. |
1265 |
+ |
1266 |
+ Fixed some start/stop/restart logic for #99663. |
1267 |
+ |
1268 |
+ Stopped rc-status from checking failed and broken which no longer apply. |
1269 |
+ |
1270 |
+ 20 Jul 2005; Mike Frysinger <vapier@g.o>: |
1271 |
+ |
1272 |
+ Make sure the X11 dirs are always created in /tmp #99679 by Marc Ballarin. |
1273 |
+ |
1274 |
+ 20 Jul 2005; Roy Marples <uberlord@g.o>: |
1275 |
+ |
1276 |
+ Fixed <wpa_supplicant-0.4 support |
1277 |
+ |
1278 |
+ Removed trailing tab from local.start - fixes #99624 |
1279 |
+ |
1280 |
+ Moved RC_AUTO_INTERFACE definition to /etc/conf.d/rc |
1281 |
+ |
1282 |
+ 19 Jul 2005; Mike Frysinger <vapier@g.o>: |
1283 |
+ |
1284 |
+ Punt the cyrus/mysql/slocate/vpopmail users/groups to the |
1285 |
+ respective ebuilds. |
1286 |
+ |
1287 |
+ Removed trailing tab from local.start - fixes #99624 |
1288 |
+ |
1289 |
+ 19 Jul 2005; Roy Marples <uberlord@g.o>: |
1290 |
+ |
1291 |
+ ${ESSID} and ${ESSIDVAR} are now available in predown() - fixes #99106 |
1292 |
+ |
1293 |
+ 18 Jul 2005; Roy Marples <uberlord@g.o>: |
1294 |
+ |
1295 |
+ Changed wpa-supplicant to wpa_supplicant when reporting that it is not |
1296 |
+ installed. Fixes #99381 |
1297 |
+ |
1298 |
+ Fixed some startup problems caused by a mixture of inactive + |
1299 |
+ begin_service/end_service functions. |
1300 |
+ |
1301 |
+ 16 Jul 2005; Martin Schlemmer <azarah@g.o>: |
1302 |
+ |
1303 |
+ Add Darwin support for start-stop-daemon, bug #82421. |
1304 |
+ |
1305 |
+ 15 Jul 2005; Martin Schlemmer <azarah@g.o>: |
1306 |
+ |
1307 |
+ Do not run depmod in modules-update if System.map is missing, bug #59188. |
1308 |
+ |
1309 |
+* baselayout-1.12.0_pre1 (14 Jul 2005) |
1310 |
+ |
1311 |
+ 13 Jul 2005; Roy Marples <uberlord@g.o>: |
1312 |
+ |
1313 |
+ pump-0.8.21-r4 now creates ntp.conf by itself so the ntp.conf creation |
1314 |
+ code has been removed from the pump module and helper. |
1315 |
+ |
1316 |
+ Moved wpa_supplicant and iwconfig et all from /usr/sbin to /sbin |
1317 |
+ |
1318 |
+ 12 Jul 2005; Roy Marples <uberlord@g.o>: |
1319 |
+ |
1320 |
+ Added dhcp_eth0="nogateway" option, generic to all dhcp clients. |
1321 |
+ Fixes #98466 |
1322 |
+ |
1323 |
+ 11 Jul 2005; Martin Schlemmer <azarah@g.o>: |
1324 |
+ |
1325 |
+ Add fix -r to unmount to be -n .. bug #98667, thanks to Patrick McLean. |
1326 |
+ |
1327 |
+ 11 Jul 2005; Roy Marples <uberlord@g.o>: |
1328 |
+ |
1329 |
+ udhcpc/dhclient helpers no longer flush IPv6 addresses - fixes #98539 |
1330 |
+ |
1331 |
+ wpa_supplicant now marks service as stopped when using wpa_supplicant-0.4.x |
1332 |
+ and we have associated but failed to configure in the background. |
1333 |
+ |
1334 |
+ 09 Jul 2005; Mike Frysinger <vapier@g.o>: |
1335 |
+ |
1336 |
+ Only remount the / filesystem readonly if it isn't already and don't |
1337 |
+ screw around with net filesystems #98405 in init.d/checkroot. |
1338 |
+ |
1339 |
+ Add support for completely wiping out /tmp and in general clean up |
1340 |
+ the bootmisc file #56592. |
1341 |
+ |
1342 |
+ Add back in support for mounting usbfs under usbgid #35860. |
1343 |
+ |
1344 |
+ 09 Jul 2005; Martin Schlemmer <azarah@g.o>: |
1345 |
+ |
1346 |
+ Add workaround for evms device names and 'RC_DEVICE_TARBALL="yes"'. Patch |
1347 |
+ by Olaf Niermann, bug #95799. |
1348 |
+ |
1349 |
+ 07 Jul 2005; Roy Marples <uberlord@g.o>: |
1350 |
+ |
1351 |
+ Added "nosendhost" dhcp option so users can request not to send their |
1352 |
+ machines hostname by default. Fixes #98132 - Patch by Eli. |
1353 |
+ |
1354 |
+ 04 Jul 2005; Roy Marples <uberlord@g.o>: |
1355 |
+ |
1356 |
+ Added a rename module to rename interfaces based on MAC address |
1357 |
+ (preferred) or current name. Fixes #76328 |
1358 |
+ |
1359 |
+ 03 Jul 2005; Roy Marples <uberlord@g.o>: |
1360 |
+ |
1361 |
+ Fixed module depends in net.lo |
1362 |
+ |
1363 |
+ Remove the "no net scripts in boot runlevel" restriction as we now |
1364 |
+ have a hotplug policy setup instead |
1365 |
+ |
1366 |
+ 02 Jul 2005; Roy Marples <uberlord@g.o>: |
1367 |
+ |
1368 |
+ net.lo no longer needs find or diff |
1369 |
+ |
1370 |
+ 01 Jul 2005; Roy Marples <uberlord@g.o>: |
1371 |
+ |
1372 |
+ Minor tweaks to all dhcp modules - basically better quoting so that |
1373 |
+ the eval ${dhcpclient} calls work better |
1374 |
+ |
1375 |
+ pump can now be backgrounded |
1376 |
+ |
1377 |
+ Tweaked the dhcp helpers so that more code is shared |
1378 |
+ |
1379 |
+ A few tweaks to runscript.sh and rc-services.sh to avoid races |
1380 |
+ |
1381 |
+ bootmisc now cleans /var/lib/net-scripts/state/* |
1382 |
+ |
1383 |
+ 30 Jun 2005; Roy Marples <uberlord@g.o>: |
1384 |
+ |
1385 |
+ pump can now use route metrics and store it's configs in |
1386 |
+ /var/lib/net-scripts/state/${iface} |
1387 |
+ |
1388 |
+ 29 Jun 2005; Roy Marples <uberlord@g.o>: |
1389 |
+ |
1390 |
+ dhclient now parses dhclient_eth0 for -cf parameter to set ${cffile} |
1391 |
+ dhclient now strips lines starting with script and send host-name |
1392 |
+ from ${cffile} and adds send host-name "${HOSTNAME}"; at the top |
1393 |
+ To stop this behaviour, add dhclient_edit_config="no" to /etc/conf.d/net |
1394 |
+ Fixes #96322 |
1395 |
+ |
1396 |
+ Removed killing udhcpc hard as it now dies nicely |
1397 |
+ |
1398 |
+ wireless.runlevel now works |
1399 |
+ |
1400 |
+ 28 Jun 2005; Mike Frysinger <vapier@g.o>: |
1401 |
+ |
1402 |
+ Add davfs to the net list #97283 by Erik Grinaker. |
1403 |
+ |
1404 |
+ 28 Jun 2005; Roy Marples <uberlord@g.o>: |
1405 |
+ |
1406 |
+ wpa_supplicant now respects the background=no option if |
1407 |
+ wpa_suppliant>=0.4.0 is installed |
1408 |
+ |
1409 |
+ fixed network dependencies some more |
1410 |
+ |
1411 |
+ You can now restart a script marked starting/inactive |
1412 |
+ |
1413 |
+ Documented the use of the RC_USE_CONFIG_PROFILE variable in conf.d/rc |
1414 |
+ |
1415 |
+ udhcpc now removes stale pidfiles and parses for -(h|H) instead of |
1416 |
+ just --hostname |
1417 |
+ |
1418 |
+ 24 Jun 2005; Roy Marples <uberlord@g.o>: |
1419 |
+ |
1420 |
+ udhcpc now doesn't send hostname if it's set at the default of localhost |
1421 |
+ |
1422 |
+ net.lo will not take down the interface if it does not exist and starting |
1423 |
+ failed to work |
1424 |
+ |
1425 |
+ 21 Jun 2005; Roy Marples <uberlord@g.o>: |
1426 |
+ |
1427 |
+ interfaces can now dynamically add themselves to a bridge using |
1428 |
+ bridge_add_eth0="br0" - they are dynamically removed as well. Fixes #93321 |
1429 |
+ |
1430 |
+ 20 Jun 2005; Roy Marples <uberlord@g.o>: |
1431 |
+ |
1432 |
+ ifconfig now reports correct MAC address |
1433 |
+ |
1434 |
+ ifconfig and iproute2 now support mtu_eth0 option |
1435 |
+ |
1436 |
+ net.lo attemts to arping the requested address when RC_AUTO_INTERFACE==yes |
1437 |
+ |
1438 |
+ iwconfig and wpa_supplicant now check rk_kill if available and produce a |
1439 |
+ suitable error if rf is killed #56430 |
1440 |
+ |
1441 |
+ added hotplug policy check for interface name #78495 |
1442 |
+ |
1443 |
+ 19 Jun 2005; Mike Frysinger <vapier@g.o>: |
1444 |
+ |
1445 |
+ Make sure /proc/cmdline is readable before using it in get_bootconfig() |
1446 |
+ in /sbin/functions.sh. |
1447 |
+ |
1448 |
+ 17 Jun 2005; Roy Marples <uberlord@g.o>: |
1449 |
+ |
1450 |
+ Fixed VLAN documentation for working with eth0.1 style names #95121 |
1451 |
+ |
1452 |
+ tarball.sh now works with svn |
1453 |
+ |
1454 |
+ dhclient and udhcpc now report any errors to stdout |
1455 |
+ |
1456 |
+ RC_DEVICE_TARBALL now defaults to "no" |
1457 |
+ |
1458 |
+ STYLE updates to all modules |
1459 |
+ |
1460 |
+ 16 Jun 2005; Mike Frysinger <vapier@g.o>: |
1461 |
+ |
1462 |
+ Add lmtp as an alias to the 2003 tcp port #96190. |
1463 |
+ |
1464 |
+ Add support for Xen to clock init.d #96240 by Christopher G. Stach II. |
1465 |
+ |
1466 |
+ When we mount readonly, make sure we don't attempt the same mountpoint |
1467 |
+ twice #96259 by Toralf Förster. |
1468 |
+ |
1469 |
+ 14 Jun 2005; Roy Marples <uberlord@g.o>: |
1470 |
+ |
1471 |
+ dhclient now calls /etc/dhcp/dhclient-exit-hooks when it exits |
1472 |
+ fixes #96000 |
1473 |
+ |
1474 |
+ 13 Jun 2005; Roy Marples <uberlord@g.o>: |
1475 |
+ |
1476 |
+ /etc/{resolv,ntp,yp}.conf now link to /var/lib/net-scripts |
1477 |
+ |
1478 |
+ 13 Jun 2005; Mike Frysinger <vapier@g.o>: |
1479 |
+ |
1480 |
+ Remove etc/ppp since the ppp package provides this stuff. |
1481 |
+ |
1482 |
+ 05 Jun 2005; Mike Frysinger <vapier@g.o>: |
1483 |
+ |
1484 |
+ Run sysctl in quiet mode so we don't force errors to /dev/null. |
1485 |
+ |
1486 |
+ 02 Jun 2005; Roy Marples <uberlord@g.o>: |
1487 |
+ |
1488 |
+ dhcp helper module fixes |
1489 |
+ |
1490 |
+ dhcpcd-backgrounder renamed to dhcpcd-wrapper |
1491 |
+ |
1492 |
+ dhcpcd-wrapper applies dns_search_domains_* to /etc/resolv.conf |
1493 |
+ fixes #94027 when used with dhcpcd-1.3.22_p4-r10 |
1494 |
+ |
1495 |
+ dhcpcd module now applies route metric if possible |
1496 |
+ |
1497 |
+ 01 Jun 2005; Roy Marples <uberlord@g.o>: |
1498 |
+ |
1499 |
+ removed cruft from net-scripts functions helper as rc-services.sh can |
1500 |
+ now be sourced by our dhcp helpers without causing errors. |
1501 |
+ |
1502 |
+ system module now creates it's temporary files in /tmp instead of /etc |
1503 |
+ |
1504 |
+ 31 May 2005; Mike Frysinger <vapier@g.o>: |
1505 |
+ |
1506 |
+ Add support for bootlogging (via blogd in showconsole package). |
1507 |
+ |
1508 |
+ Rewrite the modules.autoload code in init.d/modules to work off the |
1509 |
+ current arbitrary kernel version #35872. |
1510 |
+ |
1511 |
+ 29 May 2005; Mike Frysinger <vapier@g.o>: |
1512 |
+ |
1513 |
+ Make sure we quote EDITOR in /etc/profile #94412 by Stanislav Brabec. |
1514 |
+ |
1515 |
+ 27 May 2005; Roy Marples <uberlord@g.o>: |
1516 |
+ |
1517 |
+ Added macnet module (like essidnet but for mac addresses) |
1518 |
+ Regresses macchanger one version |
1519 |
+ Tweaked module depends for macnet |
1520 |
+ dhcp helper now uses macnet |
1521 |
+ |
1522 |
+ is_net_fs now works with what $1 was mounted as, not would it would |
1523 |
+ be remounted as - fixes #53104 |
1524 |
+ |
1525 |
+ 26 May 2005; Roy Marples <uberlord@g.o>: |
1526 |
+ |
1527 |
+ report ${myservice} instead of $0 when disallowing net scripts to work in |
1528 |
+ the boot runlevel - fixes #91534 |
1529 |
+ |
1530 |
+ You can now configure all options via the MAC address of your network card |
1531 |
+ and the MAC address of AP you connect to like so |
1532 |
+ config_001122334455=( "192.168.0.2/24 brd +") |
1533 |
+ Fixes the last part of #52975 |
1534 |
+ |
1535 |
+ The old way of configuring for the MAC address of the AP is no longer |
1536 |
+ supported |
1537 |
+ |
1538 |
+ 25 May 2005; Mike Frysinger <vapier@g.o>: |
1539 |
+ |
1540 |
+ Add gfs to the NET_FS_LIST #93911 by Thomas Rasch. |
1541 |
+ |
1542 |
+ 25 May 2005; Roy Marples <uberlord@g.o>: |
1543 |
+ |
1544 |
+ networking now expands configuration parameters - fixes #91564 |
1545 |
+ so config_eth0=( "192.168.{1..3}.{1..3}/24 brd +" ) expands into |
1546 |
+ config_eth0=( |
1547 |
+ "192.168.1.1/24 brd +" |
1548 |
+ "192.168.1.2/24 brd +" |
1549 |
+ "192.168.1.3/24 brd +" |
1550 |
+ "192.168.2.1/24 brd +" |
1551 |
+ "192.168.2.2/24 brd +" |
1552 |
+ "192.168.2.3/24 brd +" |
1553 |
+ "192.168.3.1/24 brd +" |
1554 |
+ "192.168.3.2/24 brd +" |
1555 |
+ "192.168.3.3/24 brd +" |
1556 |
+ ) |
1557 |
+ |
1558 |
+ updated ESSID variables example in wireless.example - fixes #92469 |
1559 |
+ |
1560 |
+ 21 May 2005; Martin Schlemmer <azarah@g.o>: |
1561 |
+ |
1562 |
+ Quiet down valid_i() if ${svcdir}/softlevel do not yet exist, try #2. |
1563 |
+ |
1564 |
+ 20 May 2005; Roy Marples <uberlord@g.o>: |
1565 |
+ |
1566 |
+ fix ifconfig to understand CIDR addresses - bug #93237 |
1567 |
+ iproute2 now works out broadcast addresses |
1568 |
+ |
1569 |
+ added #!/bin/bash or #!/bin/sh to modules and helpers so they now get |
1570 |
+ nice syntax highlighting and indenting |
1571 |
+ |
1572 |
+ 20 May 2005; Martin Schlemmer <azarah@g.o>: |
1573 |
+ |
1574 |
+ Fixup sbin/{depscan.sh,modules-update} to use is_older_than() for mtime |
1575 |
+ logic. Some small tweaks regarding 2.6 systems and modules-update. |
1576 |
+ |
1577 |
+ 19 May 2005; Roy Marples <uberlord@g.o>: |
1578 |
+ |
1579 |
+ Merged Paul Pacheco's parallel startup #69854 and modules update |
1580 |
+ #55329 patches |
1581 |
+ |
1582 |
+ If RC_PARALLEL_STARTUP==yes then we no longer output einfo/ebegin |
1583 |
+ messages as they don't line up on screen correctly - instead we output |
1584 |
+ service ${myservice} starting/started/stopping/stopped/failed |
1585 |
+ |
1586 |
+ 17 May 2005; Mike Frysinger <vapier@g.o>: |
1587 |
+ |
1588 |
+ Make sure /dev is mounted with exec since many video drivers need to |
1589 |
+ mmap() device nodes in there with exec access #92921 by Lachlan Pease. |
1590 |
+ |
1591 |
+ 16 May 2005; Mike Frysinger <vapier@g.o>: |
1592 |
+ |
1593 |
+ If halt/reboot failed, try to force it as a fallback. |
1594 |
+ |
1595 |
+ Add RC_FORCE_AUTO setting so people can try to minimize amount of |
1596 |
+ user interaction required for booting. |
1597 |
+ |
1598 |
+ Move nsswitch.conf to glibc. |
1599 |
+ |
1600 |
+ 15 May 2005; Roy Marples <uberlord@g.o>: |
1601 |
+ |
1602 |
+ udhcpc and dhclient now select the best interface when one goes down |
1603 |
+ |
1604 |
+ 14 May 2005; Mike Frysinger <vapier@g.o>: |
1605 |
+ |
1606 |
+ Make sure /dev is mounted with sane permissions #87745 by Jordan. |
1607 |
+ |
1608 |
+ When we search /etc/fstab for /, make sure we handle mounts that have |
1609 |
+ UUID/LABEL info in them #90603 by Alessandro Sappia. |
1610 |
+ |
1611 |
+ Simplify rc-script error checking so we don't need a tempfile and so |
1612 |
+ non-root users can run /etc/init.d/status #85892 by Stuart Shelton. |
1613 |
+ |
1614 |
+ Add a sanity check for devs who write bad scripts and call exit #85298. |
1615 |
+ |
1616 |
+ Run irqbalance after /var is rw #85304 by Miroslaw Mieszczak. |
1617 |
+ |
1618 |
+ Redo the addon code to prepare for profiling support #74425. |
1619 |
+ |
1620 |
+ 12 May 2005; Mike Frysinger <vapier@g.o>: |
1621 |
+ |
1622 |
+ Move pam files out of baselayout and into packages #92387. |
1623 |
+ |
1624 |
+ 10 May 2005; Martin Schlemmer <azarah@g.o>: |
1625 |
+ |
1626 |
+ Really fix trace_dependencies() to handle net.* services properly. |
1627 |
+ |
1628 |
+ Quiet down valid_i() if ${svcdir}/softlevel do not yet exist. |
1629 |
+ |
1630 |
+ 10 May 2005; Martin Schlemmer <azarah@g.o>: |
1631 |
+ |
1632 |
+ Fix get_service_index() being off by one. Fix trace_dependencies() to also |
1633 |
+ take "net" into regard if its a net_service. This fixes two problems, first |
1634 |
+ shutdown should bring services down that uses net before the net.* services, |
1635 |
+ and secondly '/etc/init.d/net.eth0 needsme', etc should now work properly. |
1636 |
+ All changes to sbin/rc-services.sh. |
1637 |
+ |
1638 |
+ 03 May 2005; Roy Marples <uberlord@g.o>: |
1639 |
+ |
1640 |
+ changed default indentation to 2 spaces to match rcscripts in functions.sh |
1641 |
+ |
1642 |
+ wpa_supplicant now stops wpa_cli before wpa_supplicant to fix a potential |
1643 |
+ future error |
1644 |
+ |
1645 |
+ 02 May 2005; Roy Marples <uberlord@g.o>: |
1646 |
+ |
1647 |
+ Fix user function hooks for echoing to stdout and protecting our vars |
1648 |
+ |
1649 |
+ 30 Apr 2005; Martin Schlemmer <azarah@g.o>: |
1650 |
+ |
1651 |
+ Do not create the udev devices.tar.bz2 if we do not have write permissions |
1652 |
+ for /. Request by Donnie (spyderous) for boxes with / on NFS. |
1653 |
+ |
1654 |
+ 30 Apr 2005; Martin Schlemmer <azarah@g.o>: |
1655 |
+ |
1656 |
+ Fixor column/color logic for when used in portage. |
1657 |
+ |
1658 |
+ 29 Apr 2005; Mike Frysinger <vapier@g.o>: |
1659 |
+ |
1660 |
+ Move crypto-loop to util-linux and skel bash files to bash. |
1661 |
+ |
1662 |
+ 28 Apr 2005; Mike Frysinger <vapier@g.o>: |
1663 |
+ |
1664 |
+ Export the 'service name' for init scripts #86348. |
1665 |
+ |
1666 |
+ 28 Apr 2005; Martin Schlemmer <azarah@g.o>: |
1667 |
+ |
1668 |
+ If no /etc/modules.conf exist, do not 'touch' it, but create a new |
1669 |
+ file with the 'modules-update header' in it to get modules-update |
1670 |
+ to do the right thing (regen), and not just quit (init.d/modules). |
1671 |
+ |
1672 |
+ 27 Apr 2005; Mike Frysinger <vapier@g.o>: |
1673 |
+ |
1674 |
+ Ignore trailing comments in module files #88553. |
1675 |
+ |
1676 |
+ 26 Apr 2005; Mike Frysinger <vapier@g.o>: |
1677 |
+ |
1678 |
+ Sync special var's with portage's env-update.sh and ours #88819. |
1679 |
+ |
1680 |
+ 26 Apr 2005; Roy Marples <uberlord@g.o>: |
1681 |
+ |
1682 |
+ wpa_supplicant now supports wpa_supplicant-0.4.0 |
1683 |
+ |
1684 |
+ iwconfig downs and ups the interface after a scan |
1685 |
+ |
1686 |
+ 25 Apr 2005; Roy Marples <uberlord@g.o>: |
1687 |
+ |
1688 |
+ iproute2 now handles mtu the same way as ifconfig - fixes #90242 |
1689 |
+ |
1690 |
+ net.lo no longer errors when using postdown and postup functions |
1691 |
+ |
1692 |
+ 22 Apr 2005; Roy Marples <uberlord@g.o>: |
1693 |
+ |
1694 |
+ Address network routes now get metrics applied as well |
1695 |
+ (ie a route automatically added when an address is added) |
1696 |
+ |
1697 |
+ net.lo no longer errors when exlcuding modules who are installed |
1698 |
+ |
1699 |
+* rc-scripts 1.7.1 (19 Apr 2005) |
1700 |
+ |
1701 |
+ 18 Apr 2005; Roy Marples <uberlord@g.o>: |
1702 |
+ |
1703 |
+ Changed "sed -ne" to "sed -n -e" for portability. |
1704 |
+ |
1705 |
+ Added auto_interface (default yes). |
1706 |
+ if auto_interface is yes then we |
1707 |
+ *) default to dhcp |
1708 |
+ *) automatically calculate a metric (this may need work) |
1709 |
+ *) select the best interface based on metric |
1710 |
+ (restore resolv.conf, ntp.conf and yp.conf we have saved) |
1711 |
+ otherwise we |
1712 |
+ *) default to null |
1713 |
+ |
1714 |
+ wpa_supplicant no longer kills itself when we're not stopping the interface |
1715 |
+ it's running on. |
1716 |
+ |
1717 |
+ wpa_supplicant now uses wpa_monitor (yet to be released) if available. |
1718 |
+ |
1719 |
+ Added a new module called system which enables the definition of domain |
1720 |
+ name, dns servers, ntp servers, nis domain and nis servers per interface. |
1721 |
+ essidnet and dhcp helpers have been re-coded around this module. |
1722 |
+ |
1723 |
+ 15 Apr 2005; Chris Gianelloni <wolf31o2@g.o> -bin/bashlogin, |
1724 |
+ -sbin/livecd-functions.sh: |
1725 |
+ Removed sbin/livecd-functions.sh and bin/bashlogin as they are only used in |
1726 |
+ release building, and they have been moved to livecd-tools. |
1727 |
+ |
1728 |
+ 14 Apr 2005; Martin Schlemmer <azarah@g.o>: |
1729 |
+ |
1730 |
+ Do not kill udevd in /sbin/rc, as it is apparently evil. |
1731 |
+ |
1732 |
+ 14 Apr 2005; Roy Marples <uberlord@g.o>: |
1733 |
+ |
1734 |
+ Fixed ifconfig and iproute2 erroring from new lo code - fixes #88006 |
1735 |
+ |
1736 |
+ If /proc/net/netlink does not exist then iproute2 will fail the |
1737 |
+ check_installed function with an appropriate error - Thanks to |
1738 |
+ Jeremy Huddleston for the patch. |
1739 |
+ |
1740 |
+ If /proc/net/packet does not exist then wpa_supplicant will fail |
1741 |
+ check_installed function with an appropriate error |
1742 |
+ |
1743 |
+ Background fixes for net.lo, udhcpc and wpa_supplicant |
1744 |
+ |
1745 |
+ 11 Apr 2005; Roy Marples <uberlord@g.o>: |
1746 |
+ |
1747 |
+ removed ${devnull} from net.lo and net-script modules |
1748 |
+ updated all modules not to re-direct stderr where appropriate |
1749 |
+ |
1750 |
+ iwconfig and wpa_supplicant now save their current ESSID via save_options |
1751 |
+ and reload it in their pre_stops so that ${ESSID} and ${ESSIDVAR} can be |
1752 |
+ used in users custom postdown functions |
1753 |
+ |
1754 |
+ wpa_supplicant now calls iwconfig_defaults and iwconfig_user_config |
1755 |
+ if available - fixes #88703 |
1756 |
+ |
1757 |
+ 09 Apr 2005; Mike Frysinger <vapier@g.o>: |
1758 |
+ |
1759 |
+ Have the 'status' function return 0/1 based upon the status of the |
1760 |
+ init script #88319 by Josh Nichols. |
1761 |
+ |
1762 |
+ 08 Apr 2005; Roy Marples <uberlord@g.o>: |
1763 |
+ |
1764 |
+ added a bash_variable to functions.sh which converts the given string |
1765 |
+ into a variable that bash can use - fixes #88175 |
1766 |
+ |
1767 |
+ net scripts can only launch if we're not in ${BOOTLEVEL} - fixes #78495 |
1768 |
+ |
1769 |
+ 01 Apr 2005; Roy Marples <uberlord@g.o>: |
1770 |
+ |
1771 |
+ RC_DAEMON_syslog_ng allows syslog-ng to be started with the specified |
1772 |
+ launcher - like valgrind or strace. Handy for debugging/auditing. |
1773 |
+ Thanks to Rob Holland for the idea. |
1774 |
+ |
1775 |
+ Stopped setting ESSID in predown functions in iwconfig and wpa_supplicant |
1776 |
+ as there is no guarantee that the current ESSID is the one we started with |
1777 |
+ Also, we may not have an ESSID at all... |
1778 |
+ |
1779 |
+ 23 Mar 2005; Roy Marples <uberlord@××××××.ord>: |
1780 |
+ |
1781 |
+ bridge stops removing IP addresses from bridge ports. |
1782 |
+ iwconfig no longer tries to get an ESSID from non-wireless interfaces. |
1783 |
+ ifconfig no longer errors when deleting addresses on a non-existant |
1784 |
+ interface. |
1785 |
+ |
1786 |
+ 23 Mar 2005; Martin Schlemmer <azarah@g.o>: |
1787 |
+ |
1788 |
+ Get modules-update to clean up after itself if we on a 2.6 kernel without |
1789 |
+ modules.conf. |
1790 |
+ |
1791 |
+ 22 Mar 2005; Roy Marples <uberlord@g.o>: |
1792 |
+ |
1793 |
+ revamped rc-services.sh for STYLE updates and code rationalisation. |
1794 |
+ |
1795 |
+ 21 Mar 2005; Roy Marples <uberlord@g.o>: |
1796 |
+ |
1797 |
+ udhcpc now checks for custom hostname correctly |
1798 |
+ |
1799 |
+ 21 Mar 2005; Martin Schlemmer <azarah@g.o>: |
1800 |
+ |
1801 |
+ Fix tracing for current service as list_depend_trace() was removed. |
1802 |
+ Fix mylevel not being set if valid_iuse(), etc is called from /sbin/rc. |
1803 |
+ |
1804 |
+ 20 Mar 2005; Martin Schlemmer <azarah@g.o>: |
1805 |
+ |
1806 |
+ Take sort_services function from bug #70009, and fix the removing of a |
1807 |
+ service from a array properly by using unset. Use this instead of the |
1808 |
+ trace_* stuff, and fixup shutdown order. |
1809 |
+ |
1810 |
+ 19 Mar 2005; Mike Frysinger <vapier@g.o>: |
1811 |
+ |
1812 |
+ Make sure we mount svcdir with 0755 and not 0644 #85888. |
1813 |
+ |
1814 |
+ 15 Mar 2005; Martin Schlemmer <azarah@g.o>: |
1815 |
+ |
1816 |
+ Export myservice when starting critical services, as its needed by |
1817 |
+ some of the addons (dmcrypt for example). |
1818 |
+ |
1819 |
+ 12 Mar 2005; Mike Frysinger <vapier@g.o>: |
1820 |
+ |
1821 |
+ When shutting down, pass -h to halt too #84654 by Dmitry Karasik. |
1822 |
+ |
1823 |
+ 11 Mar 2005; Roy Marples <uberlord@g.o>: |
1824 |
+ |
1825 |
+ Prepend rc-daemon.sh functions with rc_ to avoid name conflicts |
1826 |
+ |
1827 |
+ 11 Mar 2005; Martin Schlemmer <azarah@g.o>: |
1828 |
+ |
1829 |
+ Make sure the last test in init.d/modules do not bork the return |
1830 |
+ value of the script if not true. |
1831 |
+ |
1832 |
+ 10 Mar 2005; Mike Frysinger <vapier@g.o>: |
1833 |
+ |
1834 |
+ Add udev/selinux support by Chris PeBenito #84337. |
1835 |
+ |
1836 |
+ 10 Mar 2005; Martin Schlemmer <azarah@g.o>: |
1837 |
+ |
1838 |
+ The system() stuff in *depends.awk should be dosystem(). |
1839 |
+ |
1840 |
+* rc-scripts 1.7.0 (10 Mar 2005) |
1841 |
+ |
1842 |
+ 09 Mar 2005; Roy Marples <uberlord@g.o>: |
1843 |
+ |
1844 |
+ changed from $( cat ${file} ) to $( < ${file ) in net-scripts |
1845 |
+ |
1846 |
+ fixed ChangeLog corruption |
1847 |
+ |
1848 |
+ rc-daemon.sh now works with the env program |
1849 |
+ |
1850 |
+ 08 Mar 2005; Roy Marples <uberlord@g.o>: |
1851 |
+ |
1852 |
+ rc-services.sh now does a /sbin/depscan.sh -u if we have not got |
1853 |
+ our deptree loaded |
1854 |
+ |
1855 |
+ removed net_start/stop function from net.lo, bridge and bonding |
1856 |
+ |
1857 |
+ net.lo now supports depend() per interface like so |
1858 |
+ depend_br0() { need net.eth0 net.eth1 } |
1859 |
+ |
1860 |
+ 04 Mar 2005; Roy Marples <uberlord@g.o>: |
1861 |
+ |
1862 |
+ applied STYLE updates to rc-status |
1863 |
+ |
1864 |
+ rc-status now uses find correctly for -maxdepth which fixes #84055 |
1865 |
+ |
1866 |
+ 03 Mar 2005; Roy Marples <uberlord@g.o>: |
1867 |
+ |
1868 |
+ iwconfig now defaults the transmit key to 1 |
1869 |
+ bridging and bonding modules now start an interface if it's not |
1870 |
+ marked as started |
1871 |
+ |
1872 |
+ 02 Mar 2005; Roy Marples <uberlord@g.o>: |
1873 |
+ |
1874 |
+ net_service() now returns 1 for non net-services |
1875 |
+ fixes bug #83352 |
1876 |
+ |
1877 |
+ 02 Mar 2005; Aron Griffis <agriffis@g.o>: |
1878 |
+ |
1879 |
+ Add requote() to functions.sh to help rc-daemon.sh |
1880 |
+ |
1881 |
+ 01 Mar 2005; Martin Schlemmer <azarah@g.o>: |
1882 |
+ |
1883 |
+ Fix braindead logic in init.d/checkfs ([[ -z $CDBOOT ]] &&, not -n). |
1884 |
+ |
1885 |
+ 01 Mar 2005; Roy Marples <uberlord@g.o> |
1886 |
+ |
1887 |
+ rc-daemon.sh now provides a working wrapper for start-stop-daemon |
1888 |
+ fixes bug #7198 |
1889 |
+ |
1890 |
+ removed ps calls from net scripts |
1891 |
+ |
1892 |
+ 25 Feb 2005; Chris Gianelloni <wolf31o2@g.o> |
1893 |
+ |
1894 |
+ Updated livecd-functions.sh to match what we are using on the LiveCD. |
1895 |
+ |
1896 |
+ 25 Feb 2005; Martin Schlemmer <azarah@g.o>: |
1897 |
+ |
1898 |
+ Style updates for init.d/halt.sh. |
1899 |
+ |
1900 |
+ Only run pam_console_apply if we are actually using pam_console. |
1901 |
+ |
1902 |
+ Fix init.d/checkfs, init.d/localmount and init.d/halt.sh to call |
1903 |
+ start_addon, stop_addon, start_volumes and stop_volumes. |
1904 |
+ |
1905 |
+ 24 Feb 2005; Martin Schlemmer <azarah@g.o>: |
1906 |
+ |
1907 |
+ Update /sbin/modules-update to work without modprobe.old (modutils) for |
1908 |
+ 2.6 kernels. |
1909 |
+ |
1910 |
+ Update /etc/init.d/modules so that it will only touch modules.conf if we |
1911 |
+ have a <= 2.4 kernel, or have /sbin/modprobe.old. |
1912 |
+ |
1913 |
+ 23 Feb 2005; Martin Schlemmer <azarah@g.o>: |
1914 |
+ |
1915 |
+ Remove RAID/LVM/EVMS2/dm-crypt from checkfs and localmount, and |
1916 |
+ add needed {start,stop}-volumes() and {start,stop}-addons(). |
1917 |
+ |
1918 |
+ Add use tempory file for deptree, bug #48303, thanks to patch from |
1919 |
+ Stefan Hoefer <stefan@××××××.ch>. |
1920 |
+ |
1921 |
+ Add {start,stop}-volumes() to /sbin/functions.sh, as well as |
1922 |
+ RC_VOLUME_ORDER to /etc/conf.d/rc. |
1923 |
+ |
1924 |
+ 21 Feb 2005; Mike Frysinger <vapier@g.o>: |
1925 |
+ |
1926 |
+ Move the serial init.d to the setserial package. |
1927 |
+ |
1928 |
+ Create a rc-status.8 manpage #81917. |
1929 |
+ |
1930 |
+ 11 Feb 2005; Mike Frysinger <vapier@g.o>: |
1931 |
+ |
1932 |
+ Add UPS kill fixes for halt.sh by Lee Weisz / Remy Blank #46440. |
1933 |
+ |
1934 |
+ Define a few more {for,back}ward-word bindings in inputrc to fix up |
1935 |
+ the different GUI terminals #53770 by Arturo Alberto Busleiman. |
1936 |
+ |
1937 |
+ 10 Feb 2005; Roy Marples <uberlord@g.o>: |
1938 |
+ |
1939 |
+ net.lo now supports fallback_route - fixes #75676 |
1940 |
+ due to bash limitations, only one fallback route is supported |
1941 |
+ |
1942 |
+ cleaned up dhcp helper |
1943 |
+ |
1944 |
+ iproute now appends routes instead of adding them - this allows multiple |
1945 |
+ default routes |
1946 |
+ |
1947 |
+ RC_STRICT_NET_CHECKING now supports the none "option" which means |
1948 |
+ that the net service is always up |
1949 |
+ |
1950 |
+ 31 Jan 2005; Mike Frysinger <vapier@g.o>: |
1951 |
+ |
1952 |
+ Punt the PROTOCOL variable from rc.conf since nothing uses it. |
1953 |
+ |
1954 |
+ Punt the consolefont related variables from rc.conf since they've |
1955 |
+ been moved to conf.d/consolefont. |
1956 |
+ |
1957 |
+ Import some VServer support from #55973. For now, just add the |
1958 |
+ detection function to functions.sh and support in init.d/clock. |
1959 |
+ |
1960 |
+ 07 Feb 2005; Martin Schlemmer <azarah@g.o>: |
1961 |
+ |
1962 |
+ Fix /sbin/functions.sh not to run stty during 'emerge depend'. |
1963 |
+ |
1964 |
+ 07 Feb 2005; Roy Marples <uberlord@g.o>: |
1965 |
+ |
1966 |
+ netmask2cidr now works correctly - fixes #81119 |
1967 |
+ Thanks to Benoit Boissinot for the patch |
1968 |
+ |
1969 |
+ 06 Feb 2005; Mike Frysinger <vapier@g.o>: |
1970 |
+ |
1971 |
+ Remove the apache user and let apache ebuilds handle it #77738. |
1972 |
+ |
1973 |
+ 04 Feb 2005; Roy Marples <uberlord@g.o>: |
1974 |
+ |
1975 |
+ It's now possible to configure addresses and routes for the loopback |
1976 |
+ interface if required - however you cannot override our defaults |
1977 |
+ |
1978 |
+ wpa_supplicant and iwconfig now loop for 5 seconds if essid is |
1979 |
+ not returned straight away |
1980 |
+ |
1981 |
+ 31 Jan 2005; Mike Frysinger <vapier@g.o>: |
1982 |
+ |
1983 |
+ Fix the test for device-mapper in checkfs #80206. |
1984 |
+ |
1985 |
+ Change home of man to /usr/share/man. |
1986 |
+ |
1987 |
+* rc-scripts 1.6.9 (30 Jan 2004) |
1988 |
+ |
1989 |
+ 30 Jan 2005; Mike Frysinger <vapier@g.o>: |
1990 |
+ |
1991 |
+ Use clock, don't need it. Not everyone has a RTC #78997. |
1992 |
+ |
1993 |
+ Rewrite the KV_* functions to use pure bash rather than awk #75836. |
1994 |
+ |
1995 |
+ Don't use 'none' when mounting virtual filesystems since `umount` can |
1996 |
+ produce some pretty vague output #78684. Fixed sbin/rc and etc/fstab |
1997 |
+ and etc/halt.sh to handle the new format. |
1998 |
+ |
1999 |
+ modules-update.8 touchups by Benno Schulenberg #77582. |
2000 |
+ |
2001 |
+ Don't symlink /etc/filesystems since it is an user config file #74176. |
2002 |
+ |
2003 |
+ Punt the 'guest' user #74737. |
2004 |
+ |
2005 |
+ Add support for loopback dm-crypt by Dylan Carlson #73598 and for gpg |
2006 |
+ dm-crypt by Lars Strojny #75659. |
2007 |
+ |
2008 |
+ Update crypto-loop to newer util-linux #40874 by jochen / Jürgen Hötzel |
2009 |
+ |
2010 |
+ 27 Jan 2005; Roy Marples <uberlord@g.o>: |
2011 |
+ |
2012 |
+ removed udhcpc-* and dhclient-* helper modules and replaced them with a |
2013 |
+ generic dhcp module which caters for all interfaces and dhcp clients that |
2014 |
+ need it. |
2015 |
+ We now prefer iproute2 over ifconfig if both are installed. |
2016 |
+ |
2017 |
+ 24 Jan 2005; Roy Marples <uberlord@g.o>: |
2018 |
+ |
2019 |
+ replaced awk commands with sed equivalents in net-scripts to make us |
2020 |
+ more portable |
2021 |
+ STYLE fixes to many net-scripts modules |
2022 |
+ Removed hardcoded Version and replaced with cvs $Header: |
2023 |
+ |
2024 |
+ 17 Jan 2005; Roy Marples <uberlord@g.o>: |
2025 |
+ |
2026 |
+ net.lo changed logic to read "only fail if no configuration parameters |
2027 |
+ work, bring interface down and abort". Fixes #78092 |
2028 |
+ all modules should now check interface existance correctly - fixes #76385 |
2029 |
+ wpa_supplicant now works with EAP - fixes #78367 |
2030 |
+ |
2031 |
+ 13 Jan 2005; Roy Marples <uberlord@g.o>: |
2032 |
+ |
2033 |
+ wpa_supplicant forces ctrl_interface to /var/run/wpa_supplicant |
2034 |
+ and removes stale directories |
2035 |
+ clean_pidfile function no longer errors on empty pidfiles |
2036 |
+ net dependancies corrected in runscript.sh - fixes #77839 |
2037 |
+ allow pure IPv6 addresses - fixes #73844 |
2038 |
+ |
2039 |
+ 12 Jan 2005; Roy Marples <uberlord@g.o>: |
2040 |
+ |
2041 |
+ net.lo now ignores dot files when loading modules |
2042 |
+ ipppd module now stops correctly - fixes #73067 again |
2043 |
+ |
2044 |
+ 11 Jan 2005; Roy Marples <uberlord@g.o>: |
2045 |
+ |
2046 |
+ added "noop" config parameter which means take no action if the interface |
2047 |
+ is up and has an address configured, otherwise continue |
2048 |
+ addresses are now removed when starting an interface - fixes #77111 |
2049 |
+ |
2050 |
+ 06 Jan 2005; Roy Marples <uberlord@g.o>: |
2051 |
+ |
2052 |
+ ifconfig, udhcpc-ifconfig now deletes addresses using 0.0.0.0 for uclibc |
2053 |
+ - fixes #76846 |
2054 |
+ |
2055 |
+ 04 Jan 2005; Roy Marples <uberlord@g.o>: |
2056 |
+ |
2057 |
+ bridge now marks interfaces as UP - fixes #75354 |
2058 |
+ bridge, net.lo, iwconfig touched up to match new STYLE |
2059 |
+ net.lo tests the return value of modprobe - fixes #76385 |
2060 |
+ iwconfig now sets enc keys through an eval statement - fixes #76601 |
2061 |
+ updated wireless.example for whitespace in keys |
2062 |
+ iwconfig now accepts mode "auto" and defaults to it |
2063 |
+ |
2064 |
+ 30 Dec 2004; Mike Frysinger <vapier@g.o>: |
2065 |
+ |
2066 |
+ Touch up rc-update to match our new STYLE. Also tweak the help |
2067 |
+ to fit in the standard console. |
2068 |
+ |
2069 |
+ 23 Dec 2004; Mike Frysinger <vapier@g.o>: |
2070 |
+ |
2071 |
+ Merge a bunch of BSD fixes into our .c files. |
2072 |
+ |
2073 |
+ 18 Dec 2004; Roy Marples <uberlord@g.o>: |
2074 |
+ |
2075 |
+ iwconfig now sets ESSIDVAR for master/ad-hoc modes - fixes #74802 |
2076 |
+ |
2077 |
+ 17 Dec 2004; Roy Marples <uberlord@g.o>: |
2078 |
+ |
2079 |
+ wpa_supplicant - fixed file location for wpa_cli and association test |
2080 |
+ as it they changed in wpa_supplicant-0.3.x |
2081 |
+ wpa_supplicant now brings the interface up before launching - fixes #74637 |
2082 |
+ |
2083 |
+* rc-scripts 1.6.8 (15 Dec 2004) |
2084 |
+ |
2085 |
+ 15 Dec 2004; Mike Frysinger <vapier@g.o>: |
2086 |
+ |
2087 |
+ start_critical_service in /sbin/rc should rely on $1 instead of |
2088 |
+ the external variable $x for the service name. #74425 |
2089 |
+ |
2090 |
+ 15 Dec 2004; Roy Marples <uberlord@g.o>: |
2091 |
+ |
2092 |
+ rc-status now reports stopping status |
2093 |
+ Updated documentation to point non-usb linux-wlan-ng users to use |
2094 |
+ hostap-driver instead |
2095 |
+ |
2096 |
+ 13 Dec 2004; Martin Schlemmer <azarah@g.o>: |
2097 |
+ |
2098 |
+ Tweak init.d/halt.sh to support new text based udev_db ('udevinfo -d' do |
2099 |
+ not work anymore, and there is no space after '(S|N):'). Also check if |
2100 |
+ devices.tar.bz2 is empty before trying to create it, bug #71143. |
2101 |
+ |
2102 |
+ 12 Dec 2004; Mike Frysinger <vapier@g.o>: |
2103 |
+ |
2104 |
+ Tweak get_mount_fstab to only print the first mount point found and then |
2105 |
+ spit warning messages for extra matches. Also add support for RC_USE_FSTAB |
2106 |
+ so normal users don't have to worry about a broken /etc/fstab. |
2107 |
+ |
2108 |
+ Add an additional sanity check to the udev tarball usage. Don't try to |
2109 |
+ unpack an empty or non-existant tarball. |
2110 |
+ |
2111 |
+ Tweak the 'static' description so users know they can use it to make |
2112 |
+ /sbin/rc ignore /dev completely. |
2113 |
+ |
2114 |
+ 12 Dec 2004; Martin Schlemmer <azarah@g.o>: |
2115 |
+ |
2116 |
+ Add suport for using /sbin/udevsend from new udev-048 as hotplug multiplexer. |
2117 |
+ |
2118 |
+ 12 Dec 2004; Roy Marples <uberlord@g.o>: |
2119 |
+ |
2120 |
+ fixed installed typo in net.lo - fixes #74152. Thanks to Federico Galassi |
2121 |
+ |
2122 |
+ dhcpcd and udhcpc now run via the eval statement so quotes can be used |
2123 |
+ in options. Fixes #74053 - thanks to Evan Buswell |
2124 |
+ |
2125 |
+ 09 Dec 2004; Roy Marples <uberlord@g.o>: |
2126 |
+ |
2127 |
+ fixed net.lo getting vlan config |
2128 |
+ rc doesn't stop hotplugged devices when system is booting - fixes #61594 |
2129 |
+ thanks to Andreas Sundebo for the fix |
2130 |
+ rc-status now reports stopping |
2131 |
+ |
2132 |
+ 08 Dec 2004; Roy Marples <uberlord@g.o>: |
2133 |
+ |
2134 |
+ iwconfig now unsets wireless config and downs interface when backgrounding |
2135 |
+ fails |
2136 |
+ wpa_supplicant now supports backgrounding |
2137 |
+ removed is_in_fstab function and replaced with get_mount_fstab which |
2138 |
+ returns a mount command based on the contents of fstab. Resolves bugs |
2139 |
+ #70044 and #73762 |
2140 |
+ |
2141 |
+ 07 Dec 2004; Roy Marples <uberlord@g.o>: |
2142 |
+ |
2143 |
+ essidnet - fixed setting up search domains |
2144 |
+ ifconfig now reads the old gateway variable correctly - fixes #73641 |
2145 |
+ iwconfig now supports backgrounding |
2146 |
+ ifconfig and iproute2 now support function interface_set_mac_address |
2147 |
+ macchanger no longer depends on macchanger if configuring a specific |
2148 |
+ mac address |
2149 |
+ |
2150 |
+ fix depstop for net-services when system is booting - should fix #61594 |
2151 |
+ added service_stopped function to make reading code easier and trying |
2152 |
+ to avoid race conditions |
2153 |
+ |
2154 |
+ 06 Dec 2004; Roy Marples <uberlord@g.o>: |
2155 |
+ |
2156 |
+ macchanger defaults to setting the interface down, and then trying |
2157 |
+ with it up - fixes #71929 |
2158 |
+ macchanger converts mac_${IFACE} to lowercase - fixes #73549 |
2159 |
+ iproute2 now configures the interface up everytime we add an address |
2160 |
+ removed "need interface" from all modules depends as net.lo requires |
2161 |
+ interface anyway |
2162 |
+ removed hardcoded ath0 in wpa_supplicant |
2163 |
+ |
2164 |
+ added rc-script statuses "starting", "stopping" and "inactive" |
2165 |
+ dhcpcd, udhcpc and dhclient now support backgrounding - fixes #52975 |
2166 |
+ |
2167 |
+ 05 Dec 2004; Roy Marples <uberlord@g.o>: |
2168 |
+ |
2169 |
+ dhclient now kill it's process if it failed to get a lease on startup |
2170 |
+ all dhclient responses are now handled correctly |
2171 |
+ |
2172 |
+ 04 Dec 2004; Roy Marples <uberlord@g.o>: |
2173 |
+ |
2174 |
+ fixed dhclient-ifconfig to look for dhclient-udhcpc-wrapper in the correct |
2175 |
+ place and changed hardcoded eth1 to ${interface} in udhcpc-ifconfig. |
2176 |
+ Fixes #73327 - thanks to Benoit Boissinot |
2177 |
+ |
2178 |
+ essidnet gets the essid itself instead of relying on ${ESSID} |
2179 |
+ wpa_supplicant module added |
2180 |
+ config-system now creates files as .tmp instead of .new and loads |
2181 |
+ the wpa_supplicant module if needed |
2182 |
+ ifconfig now addes aliases to devices other than eth0 |
2183 |
+ dhcpcd, dhclient, pump and udhcpc now expose the dhcp_${IFACE} variable |
2184 |
+ instead of the old peer_dns_${IFACE}, peer_ntp_${IFACE}, peer_nis_${IFACE} |
2185 |
+ ones |
2186 |
+ |
2187 |
+ removed modules use dependancy in net.lo and added installed |
2188 |
+ - this allows use to provide "virtual" modules which are only "installed" |
2189 |
+ when other depended modules are installed |
2190 |
+ |
2191 |
+* rc-scripts 1.6.7 (03 Dec 2004) |
2192 |
+ |
2193 |
+ 03 Dec 2004; Mike Frysinger <vapier@g.o>: |
2194 |
+ |
2195 |
+ Simply filesystem unmounting in halt.sh. Based upon work by Georg Sauthoff |
2196 |
+ #68697. Also clean up the filesystem remounting readonly. As a last |
2197 |
+ resort to filesystems which won't remount readonly, we try to unmount them |
2198 |
+ with the force/readonly options. Idea from #70349. |
2199 |
+ |
2200 |
+ 03 Dec 2004; Roy Marples <uberlord@g.o>: |
2201 |
+ |
2202 |
+ Fixed config-system for only changing hostname when needed |
2203 |
+ udhcpc and dhclient now restore saved configs when stopping and work |
2204 |
+ with non-infinite leases |
2205 |
+ Moved generic dhcp options into a space seperated string |
2206 |
+ udhcpc now caches it's IP address and requests it the next time it starts |
2207 |
+ if the address is not released |
2208 |
+ udhcpc and dhclient no longer flush interfaces if we don't need too |
2209 |
+ ipppd module now looks for ipppd in /usr/sbin - fixes #73067 |
2210 |
+ |
2211 |
+ 02 Dec 2004; Mike Frysinger <vapier@g.o>: |
2212 |
+ |
2213 |
+ Merge time checking function (is_older_than) to help simplify config |
2214 |
+ file update checking. Used for now in env-update.sh #71285. Function |
2215 |
+ written by Paul Pacheco #55329. |
2216 |
+ |
2217 |
+ 02 Dec 2004; Roy Marples <uberlord@g.o>: |
2218 |
+ |
2219 |
+ Added option dhcp_release to specify if we release the DHCP lease or not |
2220 |
+ defaults to no |
2221 |
+ Changed variables peer_* to dhcp_* |
2222 |
+ dhclient and udhcpc now specify a pidfile |
2223 |
+ Fixed iwconfig report if iwgetid does not support --channel |
2224 |
+ |
2225 |
+ 01 Dec 2004; Mike Frysinger <vapier@g.o>: |
2226 |
+ |
2227 |
+ Refix and clean up the netmount script to kill processes #64034. |
2228 |
+ |
2229 |
+ 01 Dec 2004; Roy Marples <uberlord@g.o>: |
2230 |
+ |
2231 |
+ Documentation fixes regarding iwconfig and linux-wlan-ng |
2232 |
+ Fixed bonding deps per bug #71419 |
2233 |
+ |
2234 |
+ 30 Nov 2004; Mike Frysinger <vapier@g.o>: |
2235 |
+ |
2236 |
+ Fix the UML/coLinux check in init.d/clock #72937. |
2237 |
+ |
2238 |
+ Allow the user to override the default mount options via /etc/fstab |
2239 |
+ for all the mounts. Added a 'is_in_fstab' function to see if the |
2240 |
+ user has defined the mount, and if not, fall back to the hardcoded |
2241 |
+ stuff from before. This also lets us get rid of $RC_DEVICE_FS #70044. |
2242 |
+ |
2243 |
+ 26 Nov 2004; Roy Marples <uberlord@g.o>: |
2244 |
+ |
2245 |
+ Fixed up address detection in apipa |
2246 |
+ net.lo now checks for duplicate static IPv4 addresses before assigning |
2247 |
+ iwconfig now supports preassociate and postassociate user hooks |
2248 |
+ net.example - changed $1 to ${IFACE} in examples |
2249 |
+ clarified lack of linux-wlan-ng support |
2250 |
+ |
2251 |
+ 24 Nov 2004; Mike Frysinger <vapier@g.o>: |
2252 |
+ |
2253 |
+ Allow users to specify charset option to dumpkeys when using unicode |
2254 |
+ in conf.d/keymaps #72225. Also move all the init.d/keymap specific |
2255 |
+ options out of rc.conf and into conf.d/keymaps and add some config |
2256 |
+ checks to init.d/keymaps like the clock/hostname init.d scripts. |
2257 |
+ |
2258 |
+ Make sure /etc/rc.conf overrides conf.d files when starting up |
2259 |
+ critical services. Should help out with transition from rc.conf. |
2260 |
+ |
2261 |
+ 24 Nov 2004; Roy Marples <uberlord@g.o>: |
2262 |
+ |
2263 |
+ Ensure all net-scripts modules depend on interface_variable function |
2264 |
+ where applicable |
2265 |
+ Fixed adsl stopping - #68934. Thanks to Andreas Kauer |
2266 |
+ |
2267 |
+ 23 Nov 2004; Roy Marples <uberlord@g.o>: |
2268 |
+ |
2269 |
+ iproute2 does not need to create dummy interfaces for aliases |
2270 |
+ unlike ifconfig so we no longer do this |
2271 |
+ We now bring down all aliases and addresses properly |
2272 |
+ Split off some functions from net.lo into helpers.d/functions |
2273 |
+ so that our DHCP helper scripts can use them too :) |
2274 |
+ Deprecated interface specific setup in favour of a generic config |
2275 |
+ macchanger brings interface up now - fixes #71929 |
2276 |
+ DHCP over VLAN now works - fixes #71860 |
2277 |
+ Disabled modified function checking as it's far too expensive on CPU |
2278 |
+ and still isn't 100% reliable |
2279 |
+ When specifing a module that isn't emerged, you now get an error |
2280 |
+ telling you what to emerge |
2281 |
+ Removed -p option from the diff call used for function removal |
2282 |
+ Removed rp_filter setting - fixes first part of bug #71971 |
2283 |
+ Added sysctl.conf settings relating to rp_filter to sysctl.conf |
2284 |
+ - fixes last part of bug #71971 |
2285 |
+ Fixed pump exporing ntp servers |
2286 |
+ implemented MODULES_DIR so we can change directory we load from on the fly |
2287 |
+ fixed variables for vlans in most modules |
2288 |
+ |
2289 |
+ 19 Nov 2004; Aron Grffis <agriffis@g.o>: |
2290 |
+ |
2291 |
+ Remove crap "ll" and "d" aliases from skel .bashrc |
2292 |
+ |
2293 |
+ 19 Nov 2004; Roy Marples <uberlord@g.o>: |
2294 |
+ |
2295 |
+ tests for hostname (none) when sending hostname via dhcpcd, udhpc or pump |
2296 |
+ udhcpc now does correct signal handling so we can release leases and |
2297 |
+ terminate cleanly |
2298 |
+ Improved pump process detection |
2299 |
+ Rewrote udhcpc helper scripts around udhcpc and wrapped dhclient to udhcpc |
2300 |
+ scripts. This makes things much saner as udhcpc is much saner - also fixed |
2301 |
+ essidnet and ipv6 local link for them. |
2302 |
+ removed iproute2 udhcpc reliance on the "bc" command |
2303 |
+ |
2304 |
+ 17 Nov 2004; Roy Marples <uberlord@g.o>: |
2305 |
+ |
2306 |
+ Fixed invalid variable handling in bonding and vlan - bug #71419 |
2307 |
+ apipa now brings the interface up before testing if address exists |
2308 |
+ Updated bonding documentation - bug #71419 |
2309 |
+ Fixed iproute2 adding addresses for vlans - bug #71419 |
2310 |
+ ifconfig handle inet6 routing automatically - bug #33310 |
2311 |
+ ifconfig - fixed old gateway + gateway in routes conflict |
2312 |
+ iproute2 cleaned up some functions |
2313 |
+ |
2314 |
+ 16 Nov 2004; Roy Marples <uberlord@g.o>: |
2315 |
+ |
2316 |
+ We no longer default a fallback to APIPA when no config is given |
2317 |
+ net.example fleshed out a bit more for dhcpcd - fixes #60845 |
2318 |
+ Improved forced module handling a touch |
2319 |
+ modules_sort and modules_check_user in net.lo buffer _provides, |
2320 |
+ _before and _after in arrays to avoid shelling out |
2321 |
+ |
2322 |
+ 15 Nov 2004; Mike Frysinger <vapier@g.o>: |
2323 |
+ |
2324 |
+ Add a check to clock init.d to make sure users dont try to set |
2325 |
+ config their clock in rc.conf anymore. |
2326 |
+ |
2327 |
+ Redo hostname/domainname scripts to use files in /etc/conf.d/ |
2328 |
+ instead of creating files in /etc/. Allows for controlling things |
2329 |
+ like the behavior of setting the 'domain' in resolv.conf since users |
2330 |
+ may not always understand exactly what's going on. |
2331 |
+ |
2332 |
+ Stop referring to conf.d/basic as a global rc config option. That |
2333 |
+ file hasn't been used in a long time and has since been replaced |
2334 |
+ with env.d/00basic. Updated sbin/runscript.sh, etc/profile, |
2335 |
+ sbin/rc-help.sh, and src/awk/cachedepends.awk. |
2336 |
+ |
2337 |
+ Run `find | xargs` instead of `find -exec`. Much better performance |
2338 |
+ this way, and busybox friendly #59732. |
2339 |
+ |
2340 |
+ 15 Nov 2004; Roy Marples <uberlord@g.o>: |
2341 |
+ |
2342 |
+ Split modules_load into smaller more managable functions in net.lo |
2343 |
+ Added modules_force option to net.lo with a big phat warning in |
2344 |
+ net.example about it potentially breaking networking |
2345 |
+ Added searchdomains_ESSID option to essidnet |
2346 |
+ Stopped the domain setting from putting the same entry in search |
2347 |
+ in config-system and essidnet |
2348 |
+ Removed second warning in net.lo when configuration not set |
2349 |
+ Documented APIPA module in net.example |
2350 |
+ Added kernel checking for vlan - fixes #70829 |
2351 |
+ Added kernel checking for bonding, bridging and tuntap |
2352 |
+ Added iproute2 support to the APIPA module |
2353 |
+ |
2354 |
+ 13 Nov 2004; Mike Frysinger <vapier@g.o>: |
2355 |
+ |
2356 |
+ Update the svcdir mounting #69595. Instead of mounting in /mnt |
2357 |
+ and then bind mounting to $svcdir, we mount the ramdisk on $svcidr. |
2358 |
+ |
2359 |
+ 12 Nov 2004; Roy Marples <uberlord@g.o>: |
2360 |
+ |
2361 |
+ Added arping duplicate address detection to net.lo |
2362 |
+ Created Automatic Private IP Addressing (APIPA) module |
2363 |
+ |
2364 |
+ Added dependancy checking to ipppd |
2365 |
+ Bonding is now started pre instead of post |
2366 |
+ Fixed iface variable in dhcp modules for vlans |
2367 |
+ Changed get_device to interface_device |
2368 |
+ Changed get_type to interface_type |
2369 |
+ Added vlan configuration options and documented them in net.example |
2370 |
+ Fixed bridge configuration handling |
2371 |
+ Removed _get_vlans from iproute2 and ifconfig as vlan now does it itself |
2372 |
+ |
2373 |
+ 11 Nov 2004; Roy Marples <uberlord@g.o>: |
2374 |
+ |
2375 |
+ Fixed category of rp-pppoe to net-dialup error when requesting ADSL |
2376 |
+ Improved inet6 address deletion and detection in iproute2 |
2377 |
+ Improved gateway logic in ifconfig |
2378 |
+ Changed all wireless reporting functions to use iwgetid instead of |
2379 |
+ parsing iwconfig output except for essid |
2380 |
+ |
2381 |
+* rc-scripts 1.6.6 (08 Nov 2004) |
2382 |
+ |
2383 |
+ 08 Nov 2004; Roy Marples <uberlord@g.o>: |
2384 |
+ |
2385 |
+ Added options to configure bridge |
2386 |
+ Added bridge configuration example to net.example |
2387 |
+ Added missing required function interface_exists to iptunnel check_depends |
2388 |
+ |
2389 |
+ 07 Nov 2004; Aron Griffis <agriffis@g.o>: |
2390 |
+ |
2391 |
+ Fix shell scripting errors that would result in |
2392 |
+ /sbin/functions.sh: line 166: [: too many arguments. |
2393 |
+ |
2394 |
+ 05 Nov 2004; Roy Marples <uberlord@g.o>: |
2395 |
+ |
2396 |
+ net-scripts/net.modules.d/bridge |
2397 |
+ - fixed destroying a bridge if no ports were added |
2398 |
+ - starts interfaces if they don't exist - fixed bug #65153 |
2399 |
+ |
2400 |
+ net-scrips/net.modules.d/bonding |
2401 |
+ - starts interfaces if they don't exist |
2402 |
+ |
2403 |
+ net-scripts/init.d/net.lo |
2404 |
+ - added net_start() function to start depandant ifaces |
2405 |
+ so that bridge br0 can active tun0 which net.tun0 has to create |
2406 |
+ - added use dependany on wlan incase we're using linux-wlan-ng drivers |
2407 |
+ fixes bug #64978 |
2408 |
+ - moved start() to run_start() and stop() to run_stop() |
2409 |
+ created run() and new start()/stop() functions |
2410 |
+ this is so that we have one single entry point to localise variables |
2411 |
+ and to remove any added functions loaded by our modules |
2412 |
+ - removed redundant interface_exists() as it's provided by |
2413 |
+ ifconfig and/or iproute2 |
2414 |
+ |
2415 |
+ net-scripts/net.modules.d/ifconfig and iproute2 |
2416 |
+ - added ifconfig_tunnel and iproute2_tunnel functions |
2417 |
+ |
2418 |
+ addred gre/ipip tunnel support via the the tunnel module |
2419 |
+ - fixes bug #50765 |
2420 |
+ |
2421 |
+ 04 Nov 2004; Roy Marples <uberlord@g.o>: |
2422 |
+ |
2423 |
+ net-scripts/net.modules.d/pump |
2424 |
+ - fixed setting ntp servers |
2425 |
+ |
2426 |
+ net-scripts/net.modules.d/dhcpcd |
2427 |
+ - fixed stopping function |
2428 |
+ |
2429 |
+ net-scripts/net.modules.d/bonding |
2430 |
+ - fixed module to actually work with the interface |
2431 |
+ |
2432 |
+ net-scripts/init.d/net.lo |
2433 |
+ - we remove all added functions when restarting an interface |
2434 |
+ this relies on the diff command being available |
2435 |
+ |
2436 |
+ added isdn support via the new ipppd module - fixes bug #69035 |
2437 |
+ |
2438 |
+ net-scripts/conf.d/net.example |
2439 |
+ - added sample isdn setup |
2440 |
+ |
2441 |
+ net-scripts/conf.d/wireless.example |
2442 |
+ - added better descriptions to the _sleep variables |
2443 |
+ |
2444 |
+ Fixed boolean logic error when testing is_net_up in /sbin/runscript.sh |
2445 |
+ - fixed bug #70022 |
2446 |
+ |
2447 |
+ net.lo - added get_type function to return the type of the interface |
2448 |
+ - eth, ippp, etc |
2449 |
+ |
2450 |
+ ipppd, tuntap |
2451 |
+ - start() moved to pre_start() and we now test by type |
2452 |
+ this means you no longer need ifconfig_ippp0=( "isdn" "dhcp" ) |
2453 |
+ as ippp0 is always an isdn device |
2454 |
+ |
2455 |
+ bridge - fixed stop function and moved start() to pre_start() |
2456 |
+ and automatically start if the variable bridge_${iface} exists |
2457 |
+ |
2458 |
+ net.example - fixed up documentation for changed behaviour above |
2459 |
+ |
2460 |
+ 03 Nov 2004; Mike Frysinger <vapier@g.o>: |
2461 |
+ |
2462 |
+ When launching critical services in /sbin/rc, make sure we source |
2463 |
+ the conf.d file (if it exists). Resolves #69956. |
2464 |
+ |
2465 |
+ 03 Nov 2004; Roy Marples <uberlord@g.o>: |
2466 |
+ |
2467 |
+ net-scripts/init.d/net.lo |
2468 |
+ - fixed !module when it's not installed |
2469 |
+ - we can now specify null inet addresses in the config |
2470 |
+ this allows a pure inet6 setup |
2471 |
+ - shutdown lo the same way we bring it up |
2472 |
+ |
2473 |
+ net-scripts/net.modules.d/ifconfig |
2474 |
+ - changed IPv6 to inet6 in output of adding inet6 addresses |
2475 |
+ - just output inet6 address removed, not eth0 del foo |
2476 |
+ |
2477 |
+ net-scripts/net.modules.d/iproute2 |
2478 |
+ - fix deletion of non-link addresses - fixes bug #65417 (again) |
2479 |
+ - handle inet6 addresses like ifconfig - fixes more bug #65417 |
2480 |
+ |
2481 |
+ net-scripts/conf.d/net.example |
2482 |
+ - noted that inet6 addresses do not create aliases |
2483 |
+ - added examples of assigning inet6 addresses |
2484 |
+ |
2485 |
+ net-scripts/net.modules.d/iwconfig |
2486 |
+ - improve error message when card does not support scanning |
2487 |
+ |
2488 |
+ net-scripts/conf.d/wireless.example |
2489 |
+ - fixed comment regarding preferred_aps not working with cards that don't |
2490 |
+ support scanning |
2491 |
+ |
2492 |
+ 02 Nov 2004; Roy Marples <uberlord@g.o>: |
2493 |
+ |
2494 |
+ net-scripts/conf.d/net.example |
2495 |
+ - added bridging and tuntap examples |
2496 |
+ |
2497 |
+ net-scripts/init.d/net.lo |
2498 |
+ - modprobe ${IFACE} when ${IFACE} does not exist |
2499 |
+ |
2500 |
+ net-scripts/net.modules.d/ifconfig |
2501 |
+ - fixed interface existance check |
2502 |
+ |
2503 |
+ net-scripts/net.modules.d |
2504 |
+ ifconfig & iproute2 |
2505 |
+ - added boolean to interface_exists to report if it exists or not |
2506 |
+ - added checks to see if the interface exists or not when starting |
2507 |
+ |
2508 |
+ dhcpcd |
2509 |
+ - removed debug line |
2510 |
+ |
2511 |
+ bonding, dhclient, dhcpcd, essidnet, macchanger, pump, udhcpc |
2512 |
+ - added checks to see if the interface exists or not when starting |
2513 |
+ |
2514 |
+ tuntap |
2515 |
+ - added checks to see if the interface exists or not when stopping |
2516 |
+ |
2517 |
+ 01 Nov 2004; Mike Frysinger <vapier@g.o>: |
2518 |
+ |
2519 |
+ Dump the error message that hwclock returns since it tends to be |
2520 |
+ quite useful. Modified init.d/clock. |
2521 |
+ |
2522 |
+ Fix error in functions.sh [ -z "$@" ] -> [[ -z "$@" ]] #69789. |
2523 |
+ |
2524 |
+ Don't create /dev/sndstat link anymore in populate_udev per #69635. |
2525 |
+ |
2526 |
+ 01 Nov 2004; Roy Marples <uberlord@g.o>: |
2527 |
+ |
2528 |
+ net-scripts/init.d/net.lo: |
2529 |
+ - modules specified by interface config now error if they are not loaded |
2530 |
+ - moved interface check to after preup incase user preup loads drivers |
2531 |
+ - modules can be explicitly not used by prefixing them with a ! |
2532 |
+ however, they are still available to other modules |
2533 |
+ fixes bugs #68908, #69027 |
2534 |
+ - remove check to see if interface exists |
2535 |
+ - modules may setup new interfaces and still require config |
2536 |
+ so we have a new label counter in iface_start |
2537 |
+ - removed the check to see if a class wrapping already exists |
2538 |
+ this fixes the bug where ifconfig and iproute2 are installed, but |
2539 |
+ ifconfig is asked for and the interface is restarted. |
2540 |
+ - added check to see if the configured module is loaded |
2541 |
+ and installed or not in iface_start |
2542 |
+ - add dependancy on isdn4linux - fixes bug #69035 |
2543 |
+ - interface_exists moved to iproute and ifconfig |
2544 |
+ |
2545 |
+ net-scripts/net.modules.d |
2546 |
+ - Split wireless module into iwconfig and essidnet modules |
2547 |
+ - Added tuntap and bridge modules, fixes bug #55394, #30688 |
2548 |
+ |
2549 |
+ net-scripts/init.d/iwconfig: |
2550 |
+ - wep mode is now reported |
2551 |
+ - removed post_stop function so we keep existing config |
2552 |
+ - added pre_stop to set the ESSID variable |
2553 |
+ - changed to veinfo/vewarn where appropriate |
2554 |
+ - check if interface exists otherwise abort gracefully |
2555 |
+ - no longer deletes addresses as we now avoid |
2556 |
+ ipv6 local addresses in detecting if interface has an addresses or not |
2557 |
+ |
2558 |
+ net-scripts/init.d/ifconfig: |
2559 |
+ - added flag enable/disable function |
2560 |
+ - scope:link inet6 addresses are ignored when testing is_up and |
2561 |
+ del_addresses - fixes bug #65417 |
2562 |
+ |
2563 |
+ net-scripts/init.d/iproute2: |
2564 |
+ - added flag enable/disable function |
2565 |
+ - scope:link inet6 addresses are ignored when testing is_up and |
2566 |
+ del_addresses - fixes bug #65417 |
2567 |
+ |
2568 |
+ net-scripts/init.d/macchanger: |
2569 |
+ - fixed detecting whether the change worked or not, fixes bug #68893 |
2570 |
+ |
2571 |
+ net-scripts/init.d/vlan: |
2572 |
+ - fixed old config problem |
2573 |
+ |
2574 |
+ 31 Oct 2004; Martin Schlemmer <azarah@g.o>: |
2575 |
+ |
2576 |
+ Do not delete depscan and envupdate caches on reboot, as this should |
2577 |
+ improve bootup times - works nicely with the '-u' parameters of both. |
2578 |
+ Also move the '-u' parameter test of depscan.sh after the directory |
2579 |
+ exist test, else ${svcdir}/started/, etc do not exist. Modified both |
2580 |
+ /sbin/rc and /sbin/depscan.sh for this. |
2581 |
+ |
2582 |
+ Move things around in /sbin/functions.sh to have all functions above. |
2583 |
+ |
2584 |
+ Add the 'lo' option to RC_NET_STRICT_CHECKING to resolve bug #29225. |
2585 |
+ |
2586 |
+ 28 Oct 2004; Martin Schlemmer <azarah@g.o>: |
2587 |
+ |
2588 |
+ Only add files not managed by udev to device tarball, bug #57110. |
2589 |
+ |
2590 |
+ 28 Oct 2004; Mike Frysinger <vapier@g.o>: |
2591 |
+ |
2592 |
+ Revert pam_console_apply udev check in bootmisc/halt.sh since |
2593 |
+ the bug is with pam_console_apply and not udev/pam. |
2594 |
+ |
2595 |
+ Use ${EUID} instead of $(id -u) to help out BSD in runscript.sh. |
2596 |
+ |
2597 |
+ Allow users to select ramfs instead of default tmpfs for mounting |
2598 |
+ on /dev with udev #69091. |
2599 |
+ |
2600 |
+ Add issue.devfix which would be auto copied to /etc/issue if |
2601 |
+ /sbin/rc detects the user is missing /dev/null or /dev/console. |
2602 |
+ Includes a simple explanation/fix for what's wrong. |
2603 |
+ |
2604 |
+ Make sure the clock init script runs after checkroot/modules/localmount |
2605 |
+ so that timestamps are synchronized asap #68133 / #70008. |
2606 |
+ |
2607 |
+ Accept '-nc' as a short option to '--nocolor' #64736. |
2608 |
+ |
2609 |
+ 26 Oct 2004; Mike Frysinger <vapier@g.o>: |
2610 |
+ |
2611 |
+ Don't use -A with fsck to respect the fs_passno since it'll try |
2612 |
+ to fsck all filesystems, not just the ones specified. Instead, |
2613 |
+ awk /etc/fstab to review the passno field in checkroot #68822. |
2614 |
+ |
2615 |
+ Add support for 'gentoo=forcefsck' boot option in checkroot. |
2616 |
+ |
2617 |
+ Make sure we run devfsd in /sbin/rc even when /dev has been |
2618 |
+ automounted by the kernel #68795. |
2619 |
+ |
2620 |
+ Don't generate the device tarball in halt.sh with livecds #68469. |
2621 |
+ |
2622 |
+ 25 Oct 2004; Aron Griffis <agriffis@g.o>: |
2623 |
+ |
2624 |
+ net-scripts/net.modules.d/ifconfig: |
2625 |
+ - Simplify ifconfig_is_up() |
2626 |
+ - Fix ifconfig_get_aliases_rev() to actually work... you can't |
2627 |
+ specify an interface name to ifconfig if you want to see the |
2628 |
+ aliases. |
2629 |
+ - Workaround a couple ifconfig bugs dealing with aliases |
2630 |
+ - Correct a return status in ifconfig_interface_del_addresses() |
2631 |
+ - ifconfig_iface_stop() is bool, not void; fix the comments |
2632 |
+ |
2633 |
+ net-scripts/net.modules.d/iproute2: |
2634 |
+ - iproute2_iface_stop() is bool, not void. Fix the code so it |
2635 |
+ returns meaningful values |
2636 |
+ |
2637 |
+ net-scripts/init.d/net.lo: |
2638 |
+ - Fix preferred (ifconfig/dhcpcd) module loading so it doesn't |
2639 |
+ barf when a preferred module is either (1) missing from |
2640 |
+ net.modules.d or (2) not available due to missing dependencies |
2641 |
+ - When loading all modules in order to stop an interface, only use |
2642 |
+ the first available to satisfy each class wrapper |
2643 |
+ |
2644 |
+ 24 Oct 2004; Aron Griffis <agriffis@g.o>: |
2645 |
+ |
2646 |
+ Include livecd patch that was applied to baselayout-1.9.4-r6 |
2647 |
+ to use agetty instead of mingetty |
2648 |
+ |
2649 |
+ 24 Oct 2004; Mike Frysinger <vapier@g.o>: |
2650 |
+ |
2651 |
+ Mount tmpfs instead of ramfs on /dev when using udev systems. |
2652 |
+ The problem with ramfs is that it has no size limitations so |
2653 |
+ one could easily take down their machine by accident #68653. |
2654 |
+ |
2655 |
+* rc-scripts 1.6.3 (23 Oct 2004) |
2656 |
+ |
2657 |
+ 22 Oct 2004; Aron Griffis <agriffis@g.o>: |
2658 |
+ |
2659 |
+ Add support for user_eth0 in the adsl module and in net.example. |
2660 |
+ This means that most users won't need to edit pppoe.conf at all |
2661 |
+ |
2662 |
+ 21 Oct 2004; Aron Griffis <agriffis@g.o>: |
2663 |
+ |
2664 |
+ Remove old etc/conf.d/net and try to clarify instructions in |
2665 |
+ net-scripts/conf.d/net.example. Add example for ADSL |
2666 |
+ |
2667 |
+ 21 Oct 2004; Mike Frysinger <vapier@g.o>: |
2668 |
+ |
2669 |
+ Merge all of the UML checks into one function, is_uml_sys(), |
2670 |
+ which is now in functions.sh. |
2671 |
+ |
2672 |
+ 18 Oct 2004; Aron Griffis <agriffis@g.o>: |
2673 |
+ |
2674 |
+ Add v-e-commands (veinfo, vbegin, etc) to sbin/functions.sh that |
2675 |
+ depend on RC_VERBOSE which defaults to no. Add --verbose to args |
2676 |
+ understood by runscript.sh. |
2677 |
+ |
2678 |
+ In net.lo, use veinfo and friends when loading modules since this |
2679 |
+ information is confusing to users. |
2680 |
+ |
2681 |
+ In net.lo, always load global "modules" setting in following |
2682 |
+ "modules_iface" since this is a little easier for users to |
2683 |
+ understand. |
2684 |
+ |
2685 |
+ In net.lo, use eindent for output of pre/post scripts |
2686 |
+ |
2687 |
+ 18 Oct 2004; Mike Frysinger <vapier@g.o>: |
2688 |
+ |
2689 |
+ Add shfs to our list of net filesystems #61452. Also add afs/nfs4. |
2690 |
+ |
2691 |
+ Add a '-u' parameter to depscan.sh to allow for updates only when |
2692 |
+ the config files have changed. With /sbin/rc using this, we speed |
2693 |
+ up bootup by only regenerating the cache when need be #67976. Also |
2694 |
+ add a '-u' parameter to env-update.sh for same reasons. |
2695 |
+ |
2696 |
+ Don't run depscan.sh in rc-update anymore since the cache files don't |
2697 |
+ depend on runlevels (which is all that rc-update modifies). |
2698 |
+ |
2699 |
+ Add unicode support to keymaps/consolefont #32111 and UML support #29707. |
2700 |
+ |
2701 |
+ Add checks to many filesystem operations in the eventuality that the |
2702 |
+ filesystems are mounted read only. |
2703 |
+ |
2704 |
+ 16 Oct 2004; Mike Frysinger <vapier@g.o>: |
2705 |
+ |
2706 |
+ Update the default fstab /dev/shm mount to include the nodev, nosuid, |
2707 |
+ and noexec mount flags. No reason for the filesystem to have those. |
2708 |
+ |
2709 |
+ Cleaned up the clock init script. Moved the clock options out of |
2710 |
+ rc.conf and into its own conf.d/clock file. Added support for the |
2711 |
+ weird Alpha consoles SRM/ARC since they need special config options. |
2712 |
+ Also made the syncing of system clock to hardware clock at shutdown |
2713 |
+ optional (with the default being off) #15834. Don't try to set the |
2714 |
+ clock if running inside a coLinux environment #52870. |
2715 |
+ |
2716 |
+ Update default PATH ordering to try to follow default behavior in |
2717 |
+ other distro's and because it's logical that /usr/local should |
2718 |
+ override /usr which should override /. Fixes #12531. |
2719 |
+ |
2720 |
+ Move devfs stuff out of baselayout and into the devfsd package. |
2721 |
+ |
2722 |
+ Don't run /sbin/pam_console_apply -r if using udev on /dev #50315. |
2723 |
+ |
2724 |
+ 14 Oct 2004; Aron Griffis <agriffis@g.o>: |
2725 |
+ |
2726 |
+ Fix rc-status to work with new COLS code. |
2727 |
+ |
2728 |
+ 14 Oct 2004; Mike Frysinger <vapier@g.o>: |
2729 |
+ |
2730 |
+ Allow users to mount ramfs/tmpfs/ramdisk as their svcdir and |
2731 |
+ stop assuming ramfs==ramdisk #64079. |
2732 |
+ |
2733 |
+ 13 Oct 2004; Mike Frysinger <vapier@g.o>: |
2734 |
+ |
2735 |
+ Rework the code for managing /dev to make it more flexible for |
2736 |
+ users. Some don't want to use devfs/udev but rather just create |
2737 |
+ their own nodes. Handles some issues with #44906 / #67276. |
2738 |
+ |
2739 |
+ Move the utmp clearing code out of bootmisc and into /sbin/rc. |
2740 |
+ The utmp log must be cleared while in the initial boot level |
2741 |
+ (meaning inside /sbin/rc) because as soon as rc exists, init |
2742 |
+ writes a 'boot' record (`who -b`) which would normally be lost |
2743 |
+ when the bootmisc init.d script is run #61727. |
2744 |
+ |
2745 |
+ 13 Oct 2004; Aron Griffis <agriffis@g.o>: |
2746 |
+ |
2747 |
+ Cosmetic fixes for starting loopback interface |
2748 |
+ |
2749 |
+ SpanKY doesn't like the dots... disable them by default, but you |
2750 |
+ can set RC_DOT_PATTERN=' .' in /etc/conf.d/rc to get them back |
2751 |
+ |
2752 |
+* rc-scripts 1.6.2 (13 Oct 2004) |
2753 |
+ |
2754 |
+ 13 Oct 2004; Aron Griffis <agriffis@g.o>: |
2755 |
+ |
2756 |
+ Install net.modules.d to /lib/rcscripts instead of /etc so we |
2757 |
+ don't have to deal with CONFIG_PROTECT |
2758 |
+ |
2759 |
+ Fix diff code in modules_load so it can identify which functions |
2760 |
+ have been modified |
2761 |
+ |
2762 |
+ Fix fallback mechanism in iface_start so that it works correctly |
2763 |
+ and doesn't report a bogus error message when trying the fallback |
2764 |
+ |
2765 |
+ Get rid of need_begin trickery in iface_stop |
2766 |
+ |
2767 |
+ Simplify eend processing in dhcp modules |
2768 |
+ |
2769 |
+ Implement eindent, eoutdent, esetdent in functions.sh and adjust |
2770 |
+ net-scripts to use them. |
2771 |
+ |
2772 |
+ Re-write einfo, ewarn, eerror, ebegin, eend, ewend to use |
2773 |
+ RC_INDENTATION and to work better on serial terminals |
2774 |
+ |
2775 |
+ Remove conf.d/net.ppp0 since that is provided by net-dialup/ppp |
2776 |
+ |
2777 |
+ 12 Oct 2004; Aron Griffis <agriffis@g.o>: |
2778 |
+ |
2779 |
+ Fix ipaddr_fallback in net-scripts/conf.d/net.example |
2780 |
+ |
2781 |
+ 09 Oct 2004; Aron Griffis <agriffis@g.o>: |
2782 |
+ |
2783 |
+ Remove init.d/net.eth0 net.lo and net.ppp0. The first two are |
2784 |
+ provided now by net-scripts and net.ppp0 is shipped in |
2785 |
+ net-dialup/ppp |
2786 |
+ |
2787 |
+ Create NET_FS_LIST and is_net_fs in functions.sh and use them in |
2788 |
+ checkroot, localmount, netmount, net.example, and net.lo |
2789 |
+ |
2790 |
+ 09 Oct 2004; Mike Frysinger <vapier@g.o>: |
2791 |
+ |
2792 |
+ If the hostname has already been set via the kernel/dhcp, don't |
2793 |
+ force it to 'localhost'. Used in netboot/terminal setups #38172. |
2794 |
+ |
2795 |
+ Add domainname to default boot runlevel list #47041. |
2796 |
+ |
2797 |
+ 08 Oct 2004; Mike Frysinger <vapier@g.o>: |
2798 |
+ |
2799 |
+ Make sure that when we try to mount /sys, we do so with -n (tigger). |
2800 |
+ |
2801 |
+ Add some examples for nfs to sysctl.conf #66575. |
2802 |
+ |
2803 |
+ 06 Oct 2004; Aron Griffis <agriffis@g.o>: |
2804 |
+ |
2805 |
+ Update to net-scripts 1.0.2 from Roy |
2806 |
+ ------------------------------------ |
2807 |
+ - wireless module: replaced preferred_only var with |
2808 |
+ associate_order this makes more sense now as we have changed the |
2809 |
+ possible values |
2810 |
+ - wireless module: added patch from Daniel Zappala we should call |
2811 |
+ wireless_get_essid everywhere now |
2812 |
+ - wireless module: don't declare ESSID local in |
2813 |
+ wireless_configure(). This allows ESSID to be tested in the |
2814 |
+ user defined postup() function |
2815 |
+ - wireless module: test type != "NOT READY!" instead of testing = |
2816 |
+ IEEE. this resolves problems with intel and ra-tech drivers |
2817 |
+ - net.lo start() now errors when the interface does not exist |
2818 |
+ - dhcpcd, dhclient, udhcpc and pump now expose peer_* vars this |
2819 |
+ enables wireless to map them from peer_dns_ESSID |
2820 |
+ - config-system helper now loads wireless module to remap |
2821 |
+ variables from ESSID this allows udhcpc and dhclient to use |
2822 |
+ remapped wireless vars |
2823 |
+ - fixed dhcpcd and pump modules using peer_* vars |
2824 |
+ - wireless aborts after 5 seconds if it cannot report a valid |
2825 |
+ ESSID this fixes a potential infinite loop problem |
2826 |
+ - wireless_setup_iface() renamed to wireless_map_essid_vars() this |
2827 |
+ avoids confusion about what the function actually does |
2828 |
+ |
2829 |
+ 06 Oct 2004; Mike Frysinger <vapier@g.o>: |
2830 |
+ |
2831 |
+ Change the default net.ipv4.conf.default.rp_filter setting to 1 |
2832 |
+ in sysctl.conf since it shouldn't be harmful in anyway. Redhat |
2833 |
+ does the same. |
2834 |
+ |
2835 |
+ 05 Oct 2004; Aron Griffis <agriffis@g.o>: |
2836 |
+ |
2837 |
+ Get rid of getcols() in sbin/functions.sh. Use COLUMNS when |
2838 |
+ possible and otherwise clean up the COLS code. Fix the "emerge |
2839 |
+ depend" detection code to use RC_ENDCOL="no" |
2840 |
+ |
2841 |
+ 05 Oct 2004; Mike Frysinger <vapier@g.o>: |
2842 |
+ |
2843 |
+ Changed behavior of the domainname init.d script. It will now |
2844 |
+ override any settings obtained via dhcp/whatever. See #48277. |
2845 |
+ |
2846 |
+ Updated bootmisc to dump the output of `dmesg` to /var/log/dmesg. |
2847 |
+ This way users have an 'after-boot' log of their dmesg saved |
2848 |
+ somewhere useful #55421. |
2849 |
+ |
2850 |
+ Added the 'eend' back to depscan.sh since the script starts with a |
2851 |
+ call to 'ebegin' #59694. |
2852 |
+ |
2853 |
+ Add selinux update from Chris PeBenito for src/runscript.c #64019. |
2854 |
+ |
2855 |
+ Add more quoting to rc-help.sh to fix some non-critical errors. |
2856 |
+ Make rc-help.sh respect the value of RC_NOCOLOR. Allow RC_NOCOLOR |
2857 |
+ in functions.sh to be set via the environment. |
2858 |
+ |
2859 |
+ Flesh out the default sysctl.conf with comments and more examples |
2860 |
+ since our previous one was pretty sparse #59993. |
2861 |
+ |
2862 |
+ Change calls to `uniq` to `sort -u` in checkroot/halt.sh. This way |
2863 |
+ we only require sort in / and not both #36453. |
2864 |
+ |
2865 |
+ 04 Oct 2004; Mike Frysinger <vapier@g.o>: |
2866 |
+ |
2867 |
+ More (I mean a LOT more) services. This takes care of #44458, |
2868 |
+ #52881 #55939 #58997 #66166 #66297. Gleaned many from the IANA |
2869 |
+ list/Fedora/FreeBSD/Debian. |
2870 |
+ |
2871 |
+ Change the test for /proc/cmdline from -e to -r. On grsecurity |
2872 |
+ based systems for example, the file may exist, but not be readable |
2873 |
+ by non-root users (patch by Ned Ludd). |
2874 |
+ |
2875 |
+ 03 Oct 2004; Mike Frysinger <vapier@g.o>: |
2876 |
+ |
2877 |
+ Add support for NFSv4 from #25106 to the netmount script. Don't |
2878 |
+ try to fsck / if the root is a remote filesystem (like NFS) #36624. |
2879 |
+ |
2880 |
+ Update the fs_passno values in the default fstab to match the |
2881 |
+ settings suggested by the manpage #37314. Make checkroot respect |
2882 |
+ a fs_passno setting of 0 when dealing with / #39212. Change |
2883 |
+ default / filesystem type to ext3 instead of xfs #42670. |
2884 |
+ |
2885 |
+ Re-order the arguments to mount to match POSIX requirements #66225. |
2886 |
+ |
2887 |
+ Don't pipe swapon in localmount to /dev/null and ignore return |
2888 |
+ codes anymore. A swapon that works shows no output #39834. |
2889 |
+ |
2890 |
+ 02 Oct 2004; Mike Frysinger <vapier@g.o>: |
2891 |
+ |
2892 |
+ Break up the COL/COLOR code properly this time. Not all serial |
2893 |
+ consoles can handle adjusting to the end of the line, so let's not |
2894 |
+ bother running stty at all anymore. This should fix up #32453. |
2895 |
+ |
2896 |
+ 30 Sep 2004; Mike Frysinger <vapier@g.o>: |
2897 |
+ |
2898 |
+ Disable cryptfs by default in the conf.d file. Also cleanup |
2899 |
+ the output generated in localmount/checkfs/halt.sh for dm-crypt. |
2900 |
+ Add an extra check so that cryptfs is only run when the conf.d |
2901 |
+ file exists as well as /bin/cryptsetup. |
2902 |
+ |
2903 |
+ 29 Sep 2004; Mike Frysinger <vapier@g.o>: |
2904 |
+ |
2905 |
+ Let glibc install nscd since different versions of glibc will |
2906 |
+ need to be handled differently. See #43076 by Rui Malheiro. |
2907 |
+ |
2908 |
+ 29 Sep 2004; Aron Griffis <agriffis@g.o>: |
2909 |
+ |
2910 |
+ Prefer ~/.dir_colors over /etc/DIR_COLORS when it exists #64489 |
2911 |
+ |
2912 |
+ 27 Sep 2004; Aron Griffis <agriffis@g.o>: |
2913 |
+ |
2914 |
+ Clear the screen in .bash_logout #32330 |
2915 |
+ |
2916 |
+* rc-scripts 1.6.1 (27 Sep 2004) |
2917 |
+ |
2918 |
+ 27 Sep 2004; Aron Griffis <agriffis@g.o>: |
2919 |
+ |
2920 |
+ Update dm-crypt to work with multi-line configuration files. |
2921 |
+ Also don't set status in a subshell; it was being lost before. |
2922 |
+ |
2923 |
+ 23 Sep 2004; Mike Frysinger <vapier@g.o>: |
2924 |
+ |
2925 |
+ Rework the logic behind the $COLS code. It should not depend |
2926 |
+ on whether color is enabled. Also add a check for negative |
2927 |
+ values (like when using a serial console). |
2928 |
+ |
2929 |
+* rc-scripts 1.6.0 (15 Sep 2004) |
2930 |
+ |
2931 |
+ 15 Sep 2004; Aron Griffis <agriffis@g.o>: |
2932 |
+ |
2933 |
+ Fix bug 64034: simplify netmount script's stop function so that |
2934 |
+ mountpoints containing spaces work correctly |
2935 |
+ |
2936 |
+ Update tarball.sh to use net-scripts |
2937 |
+ |
2938 |
+ 14 Sep 2004; Aron Griffis <agriffis@g.o>: |
2939 |
+ |
2940 |
+ Commit dm-crypt enablement patch from Tigger (Rob Holland) in |
2941 |
+ bug 43146 |
2942 |
+ |
2943 |
+* rc-scripts 1.5.3 (18 Aug 2004) |
2944 |
+ |
2945 |
+ 18 Aug 2004; Aron Griffis <agriffis@g.o>: |
2946 |
+ |
2947 |
+ Fix bug 60719 (request for better error messages from runscript) |
2948 |
+ by allowing errors to show on the screen when they're encountered |
2949 |
+ in wrap_rcscript |
2950 |
+ |
2951 |
+ Apply Spock's bootsplash patch from bug 45784. This moves most of |
2952 |
+ the splash functionality out of baselayout. |
2953 |
+ |
2954 |
+ 13 Aug 2004; Aron Griffis <agriffis@g.o>: |
2955 |
+ |
2956 |
+ Don't export PS1. Continuation of bug 26951, comments 60-62. |
2957 |
+ |
2958 |
+* rc-scripts 1.5.2 (02 Aug 2004) |
2959 |
+ |
2960 |
+ 02 Aug 2004; Aron Griffis <agriffis@g.o>: |
2961 |
+ |
2962 |
+ Related to bug 38955, don't set INPUTRC. Instead patch bash so |
2963 |
+ that it looks for /etc/inputrc automatically if ~/.inputrc is |
2964 |
+ missing. This is better than using INPUTRC since that will |
2965 |
+ override even after the user creates ~/.inputrc. |
2966 |
+ |
2967 |
+ Fix bug 54275: Don't set INFODIR. The correct variable used by |
2968 |
+ texinfo is INFOPATH, which is already set in 00basic. Setting |
2969 |
+ INFODIR is useless, and breaks a NetBSD cross compile from Gentoo |
2970 |
+ |
2971 |
+ 01 Aug 2004; Aron Griffis <agriffis@g.o>: |
2972 |
+ |
2973 |
+ Fix bug 58805: net.eth0 should use bridge so that bridge |
2974 |
+ interfaces are configured prior to net.br0 running |
2975 |
+ |
2976 |
+ Fix bug 56856: Get rid of net.rej and integrate missing stuff to |
2977 |
+ conf.d/net |
2978 |
+ |
2979 |
+ Apply half of spock's patch in bug 45784: Check for |
2980 |
+ conf.d/bootsplash instead of conf.d/bootsplash.conf |
2981 |
+ |
2982 |
+ Fix bug 51351: Quote parsed output of /proc/filesystems to handle |
2983 |
+ octal sequences in mountpoint such as encoded spaces (\040) |
2984 |
+ |
2985 |
+ Fix bug 46680: Add cifs support to localmount and netmount. |
2986 |
+ Thanks to Ronald Moesbergen for the patches |
2987 |
+ |
2988 |
+ 21 Jul 2004; Aron Griffis <agriffis@g.o>: |
2989 |
+ |
2990 |
+ Fix bug 26952: Use /etc/bash/bashrc to setup PS1, testing $- to |
2991 |
+ determine if shell is interactive. The new system-wide bashrc is |
2992 |
+ installed by bash-2.05b-r10 |
2993 |
+ |
2994 |
+ 19 Jul 2004; Aron Griffis <agriffis@g.o>: |
2995 |
+ |
2996 |
+ Fix bug 38743: strip leading and trailing spaces from variable |
2997 |
+ values in genenviron.awk. Thanks to Marius Mauch for the patch. |
2998 |
+ |
2999 |
+ 09 Jul 2004; Aron Griffis <agriffis@g.o>: |
3000 |
+ |
3001 |
+ Fix bug 55576: swap words "start" and "stop" in runscript.sh error |
3002 |
+ message |
3003 |
+ |
3004 |
+* rc-scripts 1.5.1 (28 Jun 2004) |
3005 |
+ |
3006 |
+ 28 Jun 2004; Aron Griffis <agriffis@g.o>: |
3007 |
+ |
3008 |
+ Fix dhcp in iface_start_ifconfig: It was re-using the variable |
3009 |
+ ${i} which would result in the following error: |
3010 |
+ /sbin/runscript.sh: line 441: ((: 16.141.88.153: syntax error |
3011 |
+ in expression (error token is ".141.88.153") |
3012 |
+ |
3013 |
+ Use vlan_IFACE instead of iface_IFACE_vlans in net.eth0 for more |
3014 |
+ consistent vlan configuration. Thanks to robbat2 in bug 55394 |
3015 |
+ (not fully resolved) |
3016 |
+ |
3017 |
+ Add example for checking if root filesystem is NFS-mounted via |
3018 |
+ predown function in conf.d/net for bug 53104. This might be |
3019 |
+ better integrated at some point into net.eth0 |
3020 |
+ |
3021 |
+* rc-scripts 1.5.0 (26 Jun 2004) |
3022 |
+ |
3023 |
+ 26 Jun 2004; Aron Griffis <agriffis@g.o>: |
3024 |
+ |
3025 |
+ Fix bug 47659: support iproute2-style configuration. Thanks to |
3026 |
+ Dean Bailey for some fantastic patches, including documentation |
3027 |
+ for conf.d/net. This is a pretty huge re-write of net.eth0 |
3028 |
+ |
3029 |
+ Fix bug 34607: provide examples for in conf.d/net for preup, |
3030 |
+ postup, predown, postdown functions. Also pay attention to return |
3031 |
+ value from predown function (previously ignored) |
3032 |
+ |
3033 |
+ 15 Jun 2004; Aron Griffis <agriffis@g.o>: |
3034 |
+ |
3035 |
+ Fix bug 25975: support adsl in net.eth0. Thanks to Patrick McLean |
3036 |
+ for the initial pass at the code. |
3037 |
+ |
3038 |
+ Fix bug 34140: add --servicelist option to rc-status. Thanks to |
3039 |
+ Eldad Zack for the patch. |
3040 |
+ |
3041 |
+ Fix bug 37418: fix order of LVM and RAID in checkfs. Thanks to |
3042 |
+ Raimondo Giammanco for the patch. |
3043 |
+ |
3044 |
+* rc-scripts 1.4.16 (06 Jun 2004) |
3045 |
+ |
3046 |
+ 06 Jun 2004; Aron Griffis <agriffis@g.o>: |
3047 |
+ |
3048 |
+ Only call generate-modprobe.conf with --assume-kernel if |
3049 |
+ modules-update was called with --assume-kernel. This means that |
3050 |
+ only catalyst has the dependency on module-init-tools, not |
3051 |
+ everybody with the newer baselayout |
3052 |
+ |
3053 |
+* rc-scripts 1.4.15 (21 May 2004) |
3054 |
+ |
3055 |
+ 21 May 2004; Aron Grifis <agriffis@g.o>: |
3056 |
+ |
3057 |
+ Fix bug 51570: typo on line 161 of /sbin/livecd-functions.sh |
3058 |
+ |
3059 |
+ Fix bug 51626: wrong variable declaration at top of |
3060 |
+ get_bootparam() in /sbin/functions.sh |
3061 |
+ |
3062 |
+* rc-scripts 1.4.14 (17 May 2004) |
3063 |
+ |
3064 |
+ 17 May 2004; Aron Griffis <agriffis@g.o>: |
3065 |
+ |
3066 |
+ Bump version to 1.4.14 to push out gmsoft's fix for hppa console |
3067 |
+ on ttyB0 |
3068 |
+ |
3069 |
+* rc-scripts 1.4.13 (15 May 2004) |
3070 |
+ |
3071 |
+ 15 May 2004; Aron Griffis <agriffis@g.o>: |
3072 |
+ |
3073 |
+ Bump version to 1.4.13 to push out Gustavo's livecd serial console |
3074 |
+ fixes for sparc and hppa. |
3075 |
+ |
3076 |
+* rc-scripts 1.4.12 (07 May 2004) |
3077 |
+ |
3078 |
+ 10 May 2004; Aron Griffis <agriffis@g.o>: |
3079 |
+ |
3080 |
+ Bump version to 1.4.12 to release these critical bug fixes |
3081 |
+ |
3082 |
+ Fix bug 50434: The new version of start-stop-daemon changes |
3083 |
+ directory to / by default unless --chdir is specified. Revert |
3084 |
+ this behavior to maintain working directory. This fixes openvpn |
3085 |
+ startup (probably among other things). Thanks to Sven Wegener for |
3086 |
+ the patch. |
3087 |
+ |
3088 |
+ Fix bug 50448: Four days ago I changed bash loops to use the wrong |
3089 |
+ conditional syntax in net.eth0. Thanks to Sven Wegener for |
3090 |
+ pointing out the problem and providing a patch. |
3091 |
+ |
3092 |
+* rc-scripts 1.4.11 (07 May 2004) |
3093 |
+ |
3094 |
+ 07 May 2004; Aron Griffis <agriffis@g.o>: |
3095 |
+ |
3096 |
+ Fix bug 20597: Skip RCS files when updating modules |
3097 |
+ |
3098 |
+ Fix bug 49926: Add a --assume-kernel flag to modules-update. This |
3099 |
+ requires a companion patch in module-init-tools-3.0-r2 to handle |
3100 |
+ the same flag in generate-modprobe.conf; this dependency won't be |
3101 |
+ handled in the baselayout ebuild since it only affects livecd |
3102 |
+ building. |
3103 |
+ |
3104 |
+ 06 May 2004; Aron Griffis <agriffis@g.o>: |
3105 |
+ |
3106 |
+ In net.eth0, fix many instances of loops like "for ((i = 0; i < |
3107 |
+ 100; i = i + 1))". The problem here is that the middle comparison |
3108 |
+ is being interpreted as a bash conditional, which means that it's |
3109 |
+ doing string comparison by default. It needs to be "i -lt 100" |
3110 |
+ |
3111 |
+ Fix bug 34827: net.eth0 breaks when localized because the ifconfig |
3112 |
+ output changes. Wrap ifconfig in a function that overrides |
3113 |
+ LC_ALL=C |
3114 |
+ |
3115 |
+ Fix bug 48305: Provide a new network configuration variable |
3116 |
+ ifconfig_fallback_eth0 which allows one to specify a fallback |
3117 |
+ configuration in case DHCP fails. |
3118 |
+ |
3119 |
+ Fix bug 50246: Give root an invalid password ("*" in /etc/shadow) |
3120 |
+ in the default baselayout. This prevents the first reboot after |
3121 |
+ installation from having a blank password. |
3122 |
+ |
3123 |
+ 05 May 2004; Aron Griffis <agriffis@g.o>: |
3124 |
+ |
3125 |
+ Fix bug 48595: Make sure $(id -u) is zero (root user) when running |
3126 |
+ init scripts to avoid a lot of error messages. |
3127 |
+ |
3128 |
+ Replace many lines of awk with two lines of grep in |
3129 |
+ init.d/localmount |
3130 |
+ |
3131 |
+ Fix bug 44316: Use 0644 instead of 0640 for resolv.conf in net.ppp0 |
3132 |
+ |
3133 |
+ 03 May 2004; Aron Griffis <agriffis@g.o>: |
3134 |
+ |
3135 |
+ Update to version 1.10.20 of Debian's start-stop-daemon (contained |
3136 |
+ in dpkg at http://packages.debian.org/testing/base/dpkg). This |
3137 |
+ fixes bug 22686 (start-stop-daemon in baselayout doesn't allow |
3138 |
+ altered nicelevel). |
3139 |
+ |
3140 |
+* rc-scripts 1.4.10 (25 Apr 2004) |
3141 |
+ |
3142 |
+ 25 Apr 2004; Aron Griffis <agriffis@g.o>: |
3143 |
+ |
3144 |
+ Fix typos in sbin/rc: "try try mount" and "mount ... & >/dev/null" |
3145 |
+ Also removed the errstr double-checking since the need for that is |
3146 |
+ alleviated by these typo fixes. |
3147 |
+ |
3148 |
+ 23 Apr 2004; Aron Griffis <agriffis@g.o>: |
3149 |
+ |
3150 |
+ Fix bug 48629 (/sbin/rc fixups for udev) with patch from GregKH |
3151 |
+ |
3152 |
+ Fix bug 40987 (gentoo should be able to boot with an empty /dev) |
3153 |
+ with patch from Spanky. The patch avoids redirection to /dev/null |
3154 |
+ when it doesn't exist; this was breaking /sbin/rc. |
3155 |
+ |
3156 |
+* rc-scripts 1.4.9 (15 Apr 2004) |
3157 |
+ |
3158 |
+ 15 Apr 2004; Aron Griffis <agriffis@g.o>: |
3159 |
+ |
3160 |
+ Fix bug 47111 (severe depcache problems) with tons of help from |
3161 |
+ dswhite42 and the rest of the crew in that bug. Thanks guys! |
3162 |
+ |
3163 |
+* rc-scripts 1.4.8 (14 Apr 2004) |
3164 |
+ |
3165 |
+ 14 Apr 2004; Aron Griffis <agriffis@g.o>: |
3166 |
+ |
3167 |
+ Fix bug 47623 (error removing inet6 addresses) with patch provided |
3168 |
+ by Vlad Yasevich. |
3169 |
+ |
3170 |
+* rc-scripts 1.4.7 (12 Apr 2004) |
3171 |
+ |
3172 |
+ 12 Apr 2004; Aron Griffis <agriffis@g.o>: |
3173 |
+ |
3174 |
+ Fix bug 47218 (net.eth0 broken for vlans) with patch provided by |
3175 |
+ Andy Dustman. Fix bug 47250 (depscan.sh fails to create |
3176 |
+ /var/lib/init.d/* directories) with patch from Terje Bergström |
3177 |
+ |
3178 |
+* rc-scripts 1.4.6 (08 Apr 2004) |
3179 |
+ |
3180 |
+ 08 Apr 2004; Aron Griffis <agriffis@g.o>: |
3181 |
+ |
3182 |
+ Update patch from Gustavoz; -ln /bin/bash should have been -nl /bin/bash |
3183 |
+ |
3184 |
+* rc-scripts 1.4.5 (08 Apr 2004) |
3185 |
+ |
3186 |
+ 08 Apr 2004; Aron Griffis <agriffis@g.o>: |
3187 |
+ |
3188 |
+ Patch init.d/checkroot to list / (root) only once in mtab; see bug 38360. |
3189 |
+ Patch from Gustavoz to livecd-functions.sh to run bash instead of login on |
3190 |
+ serial consoles, necessary due to scrambled root passwords. |
3191 |
+ |
3192 |
+* rc-scripts 1.4.4 (07 Apr 2004) |
3193 |
+ |
3194 |
+ 07 Apr 2004; Aron Griffis <agriffis@g.o>: |
3195 |
+ |
3196 |
+ Patch from Gustavoz for Sparc console: Fetch LIVECD_CONSOLE from dmesg |
3197 |
+ output. Also support 4800 baud correctly. |
3198 |
+ |
3199 |
+ 16 Mar 2004; Aron Griffis <agriffis@g.o>: |
3200 |
+ |
3201 |
+ The changes in this commit pertain primarily to |
3202 |
+ http://bugs.gentoo.org/show_bug.cgi?id=19695 |
3203 |
+ http://bugs.gentoo.org/show_bug.cgi?id=35736 |
3204 |
+ |
3205 |
+ Specify routes as an array per interface, for example: |
3206 |
+ routes_eth0=( |
3207 |
+ "-net 10.1.0.0 netmask 255.255.0.0 gw 10.0.0.5" |
3208 |
+ "-net 10.2.0.0 netmask 255.255.0.0 gw 10.0.0.6" |
3209 |
+ "-host 10.3.0.1 dev eth0" |
3210 |
+ ) |
3211 |
+ |
3212 |
+ You can optionally use the gateway variable or just put the default route |
3213 |
+ in the routes variable. The following two are REDUNDANT: |
3214 |
+ |
3215 |
+ routes_eth0=( "default gw 10.0.0.5" ) |
3216 |
+ gateway="eth0/10.0.0.5" |
3217 |
+ |
3218 |
+ Old configuration variables in /etc/conf.d/net are fully supported and |
3219 |
+ used transparently if ifconfig_eth0 is missing. In other words, this new |
3220 |
+ script is fully backward-compatible. However you can get rid of |
3221 |
+ iface_eth0, alias_eth0, broadcast_eth0 and netmask_eth0 if you want by |
3222 |
+ using the new syntax: |
3223 |
+ |
3224 |
+ ifconfig_eth0=( |
3225 |
+ "10.0.0.6 broadcast 10.0.255.255 netmask 255.255.0.0" |
3226 |
+ "192.168.1.1 netmask 255.255.255.0" |
3227 |
+ "123.456.789.1" |
3228 |
+ ) |
3229 |
+ |
3230 |
+ Full backward compatibility so no danger to screwing up users relying on |
3231 |
+ existing /etc/conf.d/net setup |
3232 |
+ |
3233 |
+ NET_DEBUG can be set in the environment for copious debugging output |
3234 |
+ |
3235 |
+ Deprecate [ ] in favor of [[ ]] which has fewer quoting issues and |
3236 |
+ better functionality (and is even slightly faster) |
3237 |
+ |
3238 |
+ Properly localize all variables, including variables returned by |
3239 |
+ setup_vars |
3240 |
+ |
3241 |
+ Allow full options for every ifconfig command, both base address and |
3242 |
+ aliases via ifconfig_eth0, replacing the convoluted and less-functional |
3243 |
+ iface_eth0, alias_eth0, broadcast_eth0, netmask_eth0 |
3244 |
+ |
3245 |
+ Provide full support for static routes via routes_eth0 |
3246 |
+ |
3247 |
+ Fix potential quoting problems in setup_vars by using better eval syntax |
3248 |
+ instead of eval echo |
3249 |
+ |
3250 |
+ Display IP addresses while configuring, both DHCP-retrieved and |
3251 |
+ statically set addresses |
3252 |
+ |
3253 |
+ Collapse redundant caching of $? since eend returns $? again |
3254 |
+ |
3255 |
+ Report when keeping kernel configuration for an interface along with IP |
3256 |
+ address gleaned |
3257 |
+ |
3258 |
+ Don't reset the default gateway if it is already set correctly |
3259 |
+ |
3260 |
+ Don't bind default gateway to particular interface when /sbin/route is |
3261 |
+ called so that it can survive if there is more than one interface on the |
3262 |
+ required subnet. (Old behavior can be obtained by setting |
3263 |
+ routes_eth0="default gw 1.2.3.4 dev eth0" if you really want it) |
3264 |
+ |
3265 |
+ Don't bomb if default gateway can't be set since that doesn't |
3266 |
+ necessarily mean that the interface configuration is invalid. |
3267 |
+ (Old behavior was completely broken, but commented section |
3268 |
+ demonstrates how to do it right if necessary) |
3269 |
+ |
3270 |
+ iface_stop no longer relies on configuration in /etc/conf.d/net AT ALL. |
3271 |
+ This is very good because it means you can put new configuration in |
3272 |
+ /etc/conf.d/net, then restart the interface and the old configuration will |
3273 |
+ be properly shut down. |
3274 |
+ |
3275 |
+ iface_stop reports when it is releasing the DHCP lease |
3276 |
+ |
3277 |
+* rc-scripts 1.4.3.13p1 (26 Feb 2004) |
3278 |
+ |
3279 |
+ 26 Feb 2004; Martin Schlemmer <azarah@g.o>: |
3280 |
+ |
3281 |
+ Remove /etc/DIR_COLORS, as coreutils provides it now. |
3282 |
+ |
3283 |
+ Add RC_DEVICE_TARBALL to /etc/conf.d/rc to control use of device tarball. |
3284 |
+ Also modified /sbin/rc and /etc/init.d/halt.sh for this. |
3285 |
+ |
3286 |
+ Start udevd if present. |
3287 |
+ |
3288 |
+ Small fix to sbin/rc-services.sh related to mtime checking and 'net' |
3289 |
+ virtual service - it had no mtime generated, so check_mtime() failed |
3290 |
+ for it ... |
3291 |
+ |
3292 |
+ 25 Feb 2004; Martin Schlemmer <azarah@g.o>: |
3293 |
+ |
3294 |
+ Update to enable checking of mtimes on rc-scripts, and auto running |
3295 |
+ depscan.sh if needed. Also try to run depscan.sh when RC_GOT_DEPTREE_INFO |
3296 |
+ is not set instead of just erroring. |
3297 |
+ |
3298 |
+ 19 Feb 2004; Martin Schlemmer <azarah@g.o>: |
3299 |
+ |
3300 |
+ Fix irda type-o in /sbin/MAKEDEV, thanks to Tobias Sager <moixa@×××.ch>. |
3301 |
+ |
3302 |
+ Fix type-o in /etc/initrc, bug #41666 (Tom Vergote <bugzilla@××××××××××.be>). |
3303 |
+ |
3304 |
+ 15 Feb 2004; Martin Schlemmer <azarah@g.o>: |
3305 |
+ |
3306 |
+ Add RC_TTY_NUMBER to /etc/conf.d/rc to configure how many tty devices |
3307 |
+ are used in scripts such as consolefonts, numlock, etc. This should |
3308 |
+ close bug #39863. |
3309 |
+ |
3310 |
+ Fix type-o in /etc/init.d/consolefont, bug #40938, thanks to patch from |
3311 |
+ Cory Tusar <ctusar@××××××××.net>. |
3312 |
+ |
3313 |
+ 09 Feb 2004; Martin Schlemmer <azarah@g.o>: |
3314 |
+ |
3315 |
+ Add SELinux modifications to /sbin/runscript. This allows runscript to |
3316 |
+ make sure it is running in the right domain. Patch done by |
3317 |
+ Chris PeBenito <pebenito@g.o>. |
3318 |
+ |
3319 |
+* rc-scripts 1.4.3.13 (08 Feb 2004) |
3320 |
+ |
3321 |
+ 08 Feb 2004; Martin Schlemmer <azarah@g.o>: |
3322 |
+ |
3323 |
+ Fix wrong logic in /etc/init.d/halt.sh which did not umount all mounts |
3324 |
+ _but_ /mnt/cdrom and /mnt/livecd. |
3325 |
+ |
3326 |
+ Update /etc/init.d/consolefont to use newer kbd. Should also close |
3327 |
+ bug #39864. |
3328 |
+ |
3329 |
+ Fix /sbin/depscan.sh, /sbin/functions.sh and /sbin/rc to use mkdir rather |
3330 |
+ than install, as newer versions of install is located in /usr/bin. This |
3331 |
+ closes bug #39648. |
3332 |
+ |
3333 |
+ 06 Feb 2004; Martin Schlemmer <azarah@g.o>: |
3334 |
+ |
3335 |
+ Tweak livecd support changes and add some more to hopefully sort out |
3336 |
+ last issues, with help from Brad House <brad_mssw@g.o>. |
3337 |
+ |
3338 |
+ Add code to generate /dev/fd, /dev/std* and /dev/core to /sbin/rc, |
3339 |
+ bug #37349. |
3340 |
+ |
3341 |
+* rc-scripts 1.4.3.12p3 (21 Jan 2004) |
3342 |
+ |
3343 |
+ 19 Jan 2004; Martin Schlemmer <azarah@g.o>: |
3344 |
+ |
3345 |
+ Add /sbin/livecd-functions.sh from Brad House <brad_mssw@g.o> |
3346 |
+ for livecd support. Add bits to /sbin/rc to support it. |
3347 |
+ |
3348 |
+ 06 Jan 2004; Martin Schlemmer <azarah@g.o>: |
3349 |
+ |
3350 |
+ Fix type-o in /etc/init.d/checkfs, bug #37113. |
3351 |
+ |
3352 |
+ 29 Dec 2003; Martin Schlemmer <azarah@g.o>: |
3353 |
+ |
3354 |
+ Update /sbin/depscan.sh, /sbin/env-update.sh, src/awk/cachedepends.awk, |
3355 |
+ src/awk/gendepends.awk and src/awk/genenviron.awk to use ENVIRON rather |
3356 |
+ then gawk -v. Also add some tests to see if we got the environment |
3357 |
+ variables. |
3358 |
+ |
3359 |
+ 28 Dec 2003; Martin Schlemmer <azarah@g.o>: |
3360 |
+ |
3361 |
+ Fix /sbin/rc to mount /dev/pts with gid=5 and mode=0620, bug #36088. |
3362 |
+ |
3363 |
+* rc-scripts 1.4.3.12p2 (27 Dec 2003) |
3364 |
+ |
3365 |
+ 26 Dec 2003; Martin Schlemmer <azarah@g.o>: |
3366 |
+ |
3367 |
+ Update code to generate /dev from /sys. Add UDEV_NO_SLEEP=1 for |
3368 |
+ hack to not make udev sleep - its not needed as these entries |
3369 |
+ are already present, and not a hotplug event. |
3370 |
+ |
3371 |
+ Update /etc/init.d/{consolefont,numlock} to work with udev managed |
3372 |
+ /dev that have devfs layout. |
3373 |
+ |
3374 |
+ 14 Dec 2003; Martin Schlemmer <azarah@g.o>: |
3375 |
+ |
3376 |
+ Fix type-o in /sbin/rc, bug #34837. |
3377 |
+ |
3378 |
+* rc-scripts 1.4.3.12p1 (26 Nov 2003) |
3379 |
+ |
3380 |
+ 26 Nov 2003; Martin Schlemmer <azarah@g.o>: |
3381 |
+ |
3382 |
+ Fix /etc/init.d/halt.sh to reset pam_console permissions, else |
3383 |
+ the next bootup might be done with some non-root nodes which cause |
3384 |
+ some odd issues. |
3385 |
+ |
3386 |
+ Add code to generate /dev from sysfs entries - not much it currently |
3387 |
+ support but block/tty devices, but it is a start for when we have |
3388 |
+ full sysfs support in all drivers. |
3389 |
+ |
3390 |
+ Revert carrier detection check, as there is currently too many |
3391 |
+ issues with it, bug #33272. |
3392 |
+ |
3393 |
+ Make sure we mount already mounted mount (done in /sbin/rc) with |
3394 |
+ correct permissions, etc, bug #33764. Modified /etc/init.d/checkroot |
3395 |
+ for this. |
3396 |
+ |
3397 |
+ 16 Nov 2003; Martin Schlemmer <azarah@g.o>: |
3398 |
+ |
3399 |
+ Fix carrier detection - we need to do a 'ifconfig $IFACE up' else |
3400 |
+ some drivers do not set the IFF_RUNNING bit, bug #33272, thanks to |
3401 |
+ Jason Rhinelander <jason-gentoo@××××××××××××××××.com> for the fix. |
3402 |
+ |
3403 |
+ 15 Nov 2003; Martin Schlemmer <azarah@g.o>: |
3404 |
+ |
3405 |
+ Add a warning to cachedepends.awk if a rc-script's name ends in |
3406 |
+ '.sh', bug #33134. Add better error checking to /sbin/depscan.sh. |
3407 |
+ |
3408 |
+ Fix /etc/init.d/halt.sh to not try and remount virtual devices, |
3409 |
+ also do a few cleanups. Closes bug #33271. |
3410 |
+ |
3411 |
+* rc-scripts 1.4.3.12 (11 Nov 2003) |
3412 |
+ |
3413 |
+ 11 Nov 2003; Martin Schlemmer <azarah@g.o>: |
3414 |
+ |
3415 |
+ Add carrier detection to /etc/init.d/net.eth0 closing bug #25480; |
3416 |
+ patch by Jordan Ritter <jpr5+gentoo@×××××××××.com>. |
3417 |
+ |
3418 |
+ Add extra checks for critical directories to /sbin/rc. |
3419 |
+ |
3420 |
+ 04 Nov 2003; Martin Schlemmer <azarah@g.o>: |
3421 |
+ |
3422 |
+ Update /bin/rc-status giving a working '-u' parameter, bug #32417. |
3423 |
+ Fix by Michael Frysinger <vapier@g.o>. |
3424 |
+ |
3425 |
+ 31 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3426 |
+ |
3427 |
+ Add support for --tty switch added to setfont and remove consolechars |
3428 |
+ support; modified /etc/init.d/consolefont for this. Also remove |
3429 |
+ consoletools support from /etc/init.d/keymaps. |
3430 |
+ |
3431 |
+ 29 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3432 |
+ |
3433 |
+ We should still use /sbin/udev as hotplug agent if /sbin/hotplug do |
3434 |
+ not exist. Updated /sbin/rc for this. |
3435 |
+ |
3436 |
+ Add a fix to /etc/init.d/keymaps for bug #32111 (we should not have |
3437 |
+ '-u' in the call to loadkeys when using unicode). |
3438 |
+ |
3439 |
+ We should not use '-' in variable names for bash, bug #31184, thanks |
3440 |
+ to Andreas Simon <yuipx@×××.net>. Updated /sbin/MAKEDEV. |
3441 |
+ |
3442 |
+ 27 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3443 |
+ |
3444 |
+ Fix return code checking of fsck in /etc/init.d/checkfs, bug #31349. |
3445 |
+ |
3446 |
+ 26 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3447 |
+ |
3448 |
+ The unmount stuff in /etc/init.d/halt.sh was flawed, in the fact that |
3449 |
+ it called 'umount -t no<insert_fs_here>', which resulted in /proc, etc |
3450 |
+ unmounted anyhow. Change it to remount the last filesystems readonly |
3451 |
+ without trying to unmount any. This fixes a few cases where reboot |
3452 |
+ would halt due to unmounted /proc, etc. |
3453 |
+ |
3454 |
+ This change set fixes two things: |
3455 |
+ 1) In exporting all functions/variables in functions.sh, rc-services.sh |
3456 |
+ and rc-daemon.sh, we created an overly large environment, and also |
3457 |
+ broke stuff like glftpd. Do not do this, and hope whatever caused |
3458 |
+ the issues previously is fixed in the meantime. This should close |
3459 |
+ bugs #25754 and #31794. |
3460 |
+ 2) gendepend.awk used to generate deptree with functions called |
3461 |
+ depinfo_<scriptname> which set appropriate variables when called. |
3462 |
+ This broke if the scriptname contained characters that is not valid |
3463 |
+ for bash variable names. Changed things to use an array fixing this. |
3464 |
+ This closes bug #24092. |
3465 |
+ |
3466 |
+ Change /sbin/rc again to not set the hotplug agent to /sbin/udev, as |
3467 |
+ /sbin/hotplug will call udev as well. |
3468 |
+ |
3469 |
+ Fix a logic error in /lib/rcscripts/sh/rc-services.sh that cause the |
3470 |
+ get_dep_info() function to skip the last entry in the RC_DEPEND_TREE |
3471 |
+ array (in my case 'net'). |
3472 |
+ |
3473 |
+ We did not handle the 'net' dependency properly in valid_iuse() and |
3474 |
+ valid_iafter(). Fix this in /lib/rcscripts/sh/rc-services.sh, closing |
3475 |
+ bugs #30327 and #31950. |
3476 |
+ |
3477 |
+ Change an occurance of /etc/modutils in modules-update.8 to |
3478 |
+ /etc/modules.d/ closing bug #31171. |
3479 |
+ |
3480 |
+ 19 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3481 |
+ |
3482 |
+ More bootsplash fixes, bug #21019 (comment #21). |
3483 |
+ |
3484 |
+ Remove the killall5 stuff from /etc/init.d/halt.sh, as it messes with |
3485 |
+ bootsplash. Add support to kill processes still using non-critical |
3486 |
+ mounts with fuser though. |
3487 |
+ |
3488 |
+ 17 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3489 |
+ |
3490 |
+ Bootsplash fixes from Michael Aichler <micha@×××××××.net>, (comment #15 |
3491 |
+ and #16 from bug #21019). |
3492 |
+ |
3493 |
+ Bootsplash coded did not play nice with boot profiles, so I fixed that |
3494 |
+ as well. Some other style tweaks. |
3495 |
+ |
3496 |
+ Fix /sbin/MAKEDEV to use 'user:group' form, and not depriciated '.'. |
3497 |
+ Also changed the permissions on tty's, ibcs and scanner devices |
3498 |
+ to 0660. |
3499 |
+ |
3500 |
+* rc-scripts 1.4.3.11p2 (14 Sep 2003) |
3501 |
+ |
3502 |
+ 14 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3503 |
+ |
3504 |
+ Revert previous changes, and substitute it for the bootsplash patches |
3505 |
+ from Michael Aichler <micha@×××××××.net>, bug #21019. His www pages |
3506 |
+ can be reached at: |
3507 |
+ |
3508 |
+ http://www.aichler.net/gentoo/bootsplash/ |
3509 |
+ |
3510 |
+ I should note that the bootsplash stuff is not 100% tested. |
3511 |
+ |
3512 |
+ |
3513 |
+* rc-scripts 1.4.3.11p1 (14 Sep 2003) |
3514 |
+ |
3515 |
+ 14 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3516 |
+ |
3517 |
+ Initial bootsplash patch as from LiveCD's. |
3518 |
+ |
3519 |
+ Add more tty's to /etc/init.d/numlock, bug #28252. |
3520 |
+ |
3521 |
+* rc-scripts 1.4.3.11 (14 Sep 2003) |
3522 |
+ |
3523 |
+ 14 Oct 2003; Martin Schlemmer <azarah@g.o>: |
3524 |
+ |
3525 |
+ Add initial udev support. Modified /sbin/rc and /etc/init.d/halt.sh. |
3526 |
+ Resolves bug #27527. |
3527 |
+ |
3528 |
+ Add squid to /etc/services, bug #30995. Other cleanups from rac. |
3529 |
+ |
3530 |
+ Add patch from Kumba <kumba@g.o> to MAKEDEV to not allow |
3531 |
+ running while pwd is root (/). |
3532 |
+ |
3533 |
+ Add 'after hotplug' to /etc/init.d/consolefont, bug #30856. |
3534 |
+ |
3535 |
+ Add entry for floppy in /etc/fstab, bug #30574. |
3536 |
+ |
3537 |
+ Remove changing group of /tmp/.{X,ICE}-unix, as it it not needed, |
3538 |
+ bug #28861. |
3539 |
+ |
3540 |
+ Apply a patch from Mike Frysinger <vapier@g.o> for rc-status. |
3541 |
+ It now will work with runlevels named with any characters (other than |
3542 |
+ ones found in default bash IFS). It also adds a few sanity/error |
3543 |
+ checks, bug #26432. |
3544 |
+ |
3545 |
+ Change /etc/inputrc to have PageUp/PageDown search through bash |
3546 |
+ history again, bug #26036. |
3547 |
+ |
3548 |
+ 14 Sep 2003; Martin Schlemmer <azarah@g.o>: |
3549 |
+ |
3550 |
+ Change update-modules to modules-update in manpage, bug #28101. |
3551 |
+ |
3552 |
+* rc-scripts 1.4.3.10p1 (08 Sep 2003) |
3553 |
+ |
3554 |
+ 08 Sep 2003; Martin Schlemmer <azarah@g.o>: |
3555 |
+ |
3556 |
+ Change the '-k' switch to dhcpcd to '-z' in /etc/init.d/net.eth0. |
3557 |
+ |
3558 |
+ 12 Aug 2003; Martin Schlemmer <azarah@g.o>: |
3559 |
+ |
3560 |
+ Add missing 'local x' to filter_environ() (bug #26429), thanks to |
3561 |
+ Mark Wagner <mark@×××××××.net>. Modified rc-services.sh for this. |
3562 |
+ |
3563 |
+ 11 Aug 2003; Martin Schlemmer <azarah@g.o>: |
3564 |
+ |
3565 |
+ Modify /etc/init.d/modules not to print the autoloading stuff if |
3566 |
+ no modules should be loaded (resolving bug #26288), per request from |
3567 |
+ Michael Frysinger <vapier@g.o>. |
3568 |
+ |
3569 |
+ Fix get_bootparam() in /sbin/functions.sh to check for existance of |
3570 |
+ the /proc/cmdline proc entry. |
3571 |
+ |
3572 |
+ 10 Aug 2003; Martin Schlemmer <azarah@g.o>: |
3573 |
+ |
3574 |
+ Modify /etc/init.d/halt.sh to first kill, and then deactivate swap on |
3575 |
+ request of Luke-Jr <luke-jr@g.o>. It should be ok now, as the |
3576 |
+ whole way of devfs handling changed long ago already. |
3577 |
+ |
3578 |
+ Fix /etc/init.d/halt.sh to unmount the mount point and not the device. |
3579 |
+ Also change it to 'mount -d' to detach the loop device. Patch by |
3580 |
+ Kalin KOZHUHAROV <kalin@××××××××.net>, bug #26256. |
3581 |
+ |
3582 |
+ Fix /etc/init.d/consolefont to not error out if CONSOLEFONT in rc.conf |
3583 |
+ is not set, bug #26278 (noted by Michael Frysinger <vapier@g.o>). |
3584 |
+ |
3585 |
+* rc-scripts 1.4.3.10 (04 Aug 2003) |
3586 |
+ |
3587 |
+ 04 Aug 2003; Martin Schlemmer <azarah@g.o>: |
3588 |
+ |
3589 |
+ Add /bin/rc-status and 'show' support to /sbin/rc-update (long overdue), |
3590 |
+ bug #4222, thanks to Sean E Russell <ser@××××××××××××××××.com>, |
3591 |
+ Michael Frysinger <vapier@g.o> (/bin/rc-status) and for the 'show' |
3592 |
+ stuff to /sbin/rc-update, Max Kalika <max@g.o>. |
3593 |
+ |
3594 |
+ Fixed modules-update to only do the /etc/modprobe.conf generation if we |
3595 |
+ are actually running a 2.5+ kernel. |
3596 |
+ |
3597 |
+ Add pop3 entries to /etc/services, bug #25501. |
3598 |
+ |
3599 |
+ Add a switch for devfsd startup to /etc/conf.d/rc, fix /sbin/rc to check |
3600 |
+ RC_DEVFSD_STARTUP. Closes bug #24361, thanks to patches from |
3601 |
+ Kurt V. Hindenburg <khindenburg@××××××××××××.net>. |
3602 |
+ |
3603 |
+ Add LVM2 support thanks to Max Kalika <max@g.o> (bug #21908). |
3604 |
+ |
3605 |
+ Add IPV6 versions of localhost and co in /etc/hosts, bug #25859. |
3606 |
+ |
3607 |
+ Fix type-o in /sbin/rc-update, bug #25854. |
3608 |
+ |
3609 |
+ 29 Jul 2003; Martin Schlemmer <azarah@g.o>: |
3610 |
+ |
3611 |
+ Tweak /etc/init.d/check{root,fs} to set retval after each fsck call, |
3612 |
+ and not the whole block. Tweak check checkroot to reboot if need be |
3613 |
+ (This is with sufficient warning and message). Tweak checkfs to not |
3614 |
+ drop to a sulogin if return code 2 or 3 is given - as we did not |
3615 |
+ mount the filesystems yet, we should not need to reboot ... bug #25398. |
3616 |
+ |
3617 |
+ Add '-T' option to fsck (/etc/init.d/check{root,fs} - requested by |
3618 |
+ Michael Frysinger <vapier@g.o>. |
3619 |
+ |
3620 |
+ 28 Jul 2003; Martin Schlemmer <azarah@g.o>: |
3621 |
+ |
3622 |
+ Rework changes for the Adelie project to support boot config profiles |
3623 |
+ better. Added support for /etc/runlevels/LEVEL/.fake to specify which |
3624 |
+ runlevels should be marked started or stopped without executing the |
3625 |
+ script. Renamed the /etc/runlevels/LEVEL/critical to ".critical" for |
3626 |
+ more uniformity. Modified /sbin/rc, /sbin/functions.sh, /sbin/runscript.sh |
3627 |
+ for this. |
3628 |
+ |
3629 |
+ Add better support for services that provide the "logger" virtual. We |
3630 |
+ should really start the logger earlier, and stop it as late as possible. |
3631 |
+ Modified /sbin/rc, /lib/rcscripts/sh/rc-services.sh and gendepends.awk |
3632 |
+ for this. |
3633 |
+ |
3634 |
+ Fix .../boot/... paths hardcoded in /lib/rcscripts/sh/rc-services.sh, |
3635 |
+ thanks to Jean-Francois Richard <jean-francois@×××××××.name>. |
3636 |
+ |
3637 |
+ Replace the Suse /etc/inputrc with a non copyrighted one, bug #24918. |
3638 |
+ |
3639 |
+ 23 Jul 2003; Martin Schlemmer <azarah@g.o>: |
3640 |
+ |
3641 |
+ From Jean-Francois Richard <jean-francois@×××××××.name> and |
3642 |
+ Olivier Crete <tester@g.o> from the Adelie project: |
3643 |
+ |
3644 |
+ The last four patches are the "adaptation" of our previous patches to |
3645 |
+ the new "no-tmpfs" init system in Gentoo. Since we were using quite |
3646 |
+ different scripts for the boot runlevel (no "checkroot" for example) and |
3647 |
+ that the new system hardcodes some of the boot services, we had to find |
3648 |
+ a simple yet elegant solution. |
3649 |
+ |
3650 |
+ We chose to make init scripts read "/etc/runlevels/LEVEL/critical" to |
3651 |
+ know what are the boot runlevel services. If this file is not present, |
3652 |
+ it uses the Gentoo hardcoded defaults. |
3653 |
+ |
3654 |
+ This touches /sbin/rc, /sbin/functions.sh, /sbin/runscript.sh and |
3655 |
+ /etc/init.d/halt.sh. |
3656 |
+ |
3657 |
+ I just changed the behaviour of 'softlevel' kernel command line argument |
3658 |
+ to not only add a suffix and some other cleanups. |
3659 |
+ |
3660 |
+ Add support for irqbalance. |
3661 |
+ |
3662 |
+ 22 Jul 2003; Martin Schlemmer <azarah@g.o>: |
3663 |
+ |
3664 |
+ Fix the /dev/root entry in /etc/mtab, bug #24916. |
3665 |
+ |
3666 |
+ Add EVMS2 support, thanks to Mike Javorski <mike_javorski@×××××××.com>, |
3667 |
+ bug #24064. |
3668 |
+ |
3669 |
+* rc-scripts 1.4.3.9 (17 Jul 2003) |
3670 |
+ |
3671 |
+ 17 Jul 2003; Martin Schlemmer <azarah@g.o>: |
3672 |
+ |
3673 |
+ Add vlan support to /etc/init.d/net.eth0, bug #15588, thanks to |
3674 |
+ Andy Dustman <andy-gentoo.54e552@×××××××.net>. |
3675 |
+ |
3676 |
+ Add 'TERM=Eterm' to /etc/DIR_COLORS, bug #23423. |
3677 |
+ |
3678 |
+ Add mdadm support to /etc/init.d/checkfs, bug #23437, many thanks |
3679 |
+ to Wes Kurdziolek <wkurdzio@××××××.org>. |
3680 |
+ |
3681 |
+ Rather use 'uname -r' to get kernel version, as else we need sysctl. |
3682 |
+ This closes bug #23923, modified /etc/init.d/modules. |
3683 |
+ |
3684 |
+ Fix a type-o in /etc/fstab, bug #23308. |
3685 |
+ |
3686 |
+ Add support for the new 'O' agetty option to display the DNS domainname |
3687 |
+ in the issue file thanks to Marius Mauch <genone@××××××.de>, bug #22275. |
3688 |
+ Updated /etc/issue and /etc/issue.logo for this. |
3689 |
+ |
3690 |
+ 16 Jul 2003; Martin Schlemmer <azarah@g.o>: |
3691 |
+ |
3692 |
+ Add aliases for add/del to /sbin/rc-update closing bug #24317, thanks |
3693 |
+ to Antonio Dolcetta <zagarna@×××××.com>. |
3694 |
+ |
3695 |
+ Fix /etc/init.d/net.eth0 to not set rp_filter if already set via |
3696 |
+ /etc/sysctl.conf, bug #24235 - thanks jochen <jochen.eisinger@×××.de>. |
3697 |
+ |
3698 |
+ Fix /sbin/runscript.sh and /lib/rcscripts/awk/cachedepend.awk to work |
3699 |
+ with symlinks in /etc/init.d/, closing bug #24228. |
3700 |
+ |
3701 |
+ Fix /etc/init.d/clock to work with UML, closing bug #24225 thanks to |
3702 |
+ John Mylchreest <johnm@g.o>. |
3703 |
+ |
3704 |
+ Fix hardcoded color escape sequence in /sbin/rc, closing bug #24109, |
3705 |
+ thanks to splite <splite-gentoo@××××××××××××××××.edu>. |
3706 |
+ |
3707 |
+ Fix /sbin/functions.sh to disable color printing if NOCOLOR is set to |
3708 |
+ "true" in /etc/make.conf, closing bug #24107. |
3709 |
+ |
3710 |
+ Fix /etc/init.d/keymaps to be more non-x86 friendly, and also allow |
3711 |
+ more keymaps to be specified in /etc/rc.conf, bug #24084. |
3712 |
+ |
3713 |
+ 15 Jul 2003; Martin Schlemmer <azarah@g.o>: |
3714 |
+ |
3715 |
+ Add /bin/csh to /etc/shells. |
3716 |
+ |
3717 |
+ Add new protocols to /etc/services, thanks Rajiv Aaron Manglani |
3718 |
+ <rajiv@g.o>. |
3719 |
+ |
3720 |
+ 23 Jun 2003; Martin Schlemmer <azarah@g.o>: |
3721 |
+ |
3722 |
+ Cleanups for bug #21438 from bug #22637, thanks to |
3723 |
+ Christian Strauf <christian.strauf@×××.de> and Ian Abbott <ian@××××××.org>. |
3724 |
+ |
3725 |
+ 22 Jun 2003; Martin Schlemmer <azarah@g.o>: |
3726 |
+ |
3727 |
+ Really commit fix for bug #21438 to CVS. |
3728 |
+ |
3729 |
+ 21 May 2003; Martin Schlemmer <azarah@g.o>: |
3730 |
+ |
3731 |
+ Call /proc mount with explicit options to fix issues where user |
3732 |
+ have 'bind' mounts for /proc in fstab as well, bug #21068. |
3733 |
+ |
3734 |
+ Fix /etc/init.d/bootmisc to check for /sbin/env-update.sh, bug #21384, |
3735 |
+ reported by Gunnlaugur Thor Briem <gthb@××.is>. |
3736 |
+ |
3737 |
+ Add 'before bootmisc' to /etc/init.d/domainname, as we need to start |
3738 |
+ it before 'env-update.sh' gets run by /etc/init.d/bootmisc. |
3739 |
+ |
3740 |
+* rc-scripts 1.4.3.8p1 (21 May 2003) |
3741 |
+ |
3742 |
+ 21 May 2003; Martin Schlemmer <azarah@g.o>: |
3743 |
+ |
3744 |
+ Last fix I did not use the modified 'myservice', but used $1 again, |
3745 |
+ causing the network dependencies to bork. I did not notice this |
3746 |
+ as I have net.eth0 in default runlevel. |
3747 |
+ |
3748 |
+* rc-scripts 1.4.3.8 (20 May 2003) |
3749 |
+ |
3750 |
+ 20 May 2003; Martin Schlemmer <azarah@g.o>: |
3751 |
+ |
3752 |
+ A '-' in a bash variable is not valid as well. Fix gendepend.awk and |
3753 |
+ rc-service.sh to handle this, thanks to YAMAKURA Makoto |
3754 |
+ <makoto@×××××××××××.jp>. |
3755 |
+ |
3756 |
+ Move /etc/issue to /etc/issue.logo, and have /etc/issue only print info |
3757 |
+ about the host it is running on. |
3758 |
+ |
3759 |
+ 18 May 2003; Martin Schlemmer <azarah@g.o>: |
3760 |
+ |
3761 |
+ Do not let devfsd handle /dev/log's permission management, as it breaks |
3762 |
+ selinux. Modified /etc/devfsd.conf, changes submited by Chris PeBenito |
3763 |
+ <pebenito@g.o>. |
3764 |
+ |
3765 |
+ Fix type-o in /etc/init.d/net.ppp0, and add local ip-up/ip-down support. |
3766 |
+ |
3767 |
+ 14 May 2003; Martin Schlemmer <azarah@g.o>: |
3768 |
+ |
3769 |
+ We should not export the RC_GOT_* variables, as it breaks on some systems, |
3770 |
+ thanks to J?rg Gollnick <gentoo-bugs@××××××××××××××.de>, bug #20851. |
3771 |
+ |
3772 |
+ From C. Brewer <killian@g.o>: |
3773 |
+ - Add hide-password to the connect cmd-line of /etc/init.d/net.ppp0, which is |
3774 |
+ suppose to be default, but why take chances? |
3775 |
+ - Also, echoing chmod 640 in the resolv.conf two-step at the end to solve the |
3776 |
+ kppp complaint. |
3777 |
+ |
3778 |
+ 13 May 2003; Martin Schlemmer <azarah@g.o>: |
3779 |
+ |
3780 |
+ For the network functions, the dependency code tried to create a funcion |
3781 |
+ with a '.' in the name, causing the network rc-scripts to not have any |
3782 |
+ dependencies. This should fix bug #20849 's order issue, thanks to |
3783 |
+ YAMAKURA Makoto <makoto@×××××××××××.jp> for noticing. |
3784 |
+ |
3785 |
+ Fix query_{before,after} to also check 'net' if 'service2' is a network |
3786 |
+ service. |
3787 |
+ |
3788 |
+ 12 May 2003; Martin Schlemmer <azarah@g.o>: |
3789 |
+ |
3790 |
+ More cleanups: |
3791 |
+ - Move the broken stuff from symlinks to a DB entry in ${svcdir}/deptree. |
3792 |
+ Updated /sbin/runscript.sh, /sbin/rc-services.sh and gendepend.awk for |
3793 |
+ this. |
3794 |
+ - Add functions for more common tasks in /sbin/runscript.sh to |
3795 |
+ /sbin/rc-services.sh. |
3796 |
+ - Move 'consoletype' to /sbin. |
3797 |
+ - Rename /sbin/rc-envupdate.sh to /sbin/env-update.sh; updated |
3798 |
+ /etc/init.d/bootmisc for this. |
3799 |
+ - Move rc-services.sh, rc-daemon.sh and rc-help.sh to /lib/rcscripts/sh. |
3800 |
+ - Improve detection of circular depends ... modified gendepend.awk for this. |
3801 |
+ |
3802 |
+* rc-scripts 1.4.3.7 (11 May 2003) |
3803 |
+ |
3804 |
+ 11 May 2003; Martin Schlemmer <azarah@g.o>: |
3805 |
+ |
3806 |
+ Too many things to remember, so here is changes of note: |
3807 |
+ - More changes to gendepend.awk. This basically modifies it to not use |
3808 |
+ symlinks in $svcdir/{need,use,before,after,provide} anymore, but rather |
3809 |
+ create a file that can be sourced. Seems to speedup things nicely. |
3810 |
+ - Add /sbin/rc-services.sh. This is basically a module to get dependency |
3811 |
+ info from the new $svcdir/deptree, and some other new service functions. |
3812 |
+ - Modify the whole works to *only* source all needed files once. This |
3813 |
+ includes /sbin/{functions.sh,rc-services.sh,rc-daemon.sh}. Also |
3814 |
+ rc-services.sh will only source $svcdir/deptree once. /sbin/runscript.sh |
3815 |
+ is sourced more than once (actually each time a service is started or |
3816 |
+ stopped, but is is cut down much). Also seems to speed things up again. |
3817 |
+ - Fix a long outstanding bug in gendepend.awk that caused the 'net' |
3818 |
+ dependency to not be actually used in shutdown, causing the services |
3819 |
+ needing it to be stoped before net.* services. |
3820 |
+ - Add the RC_PARALLEL_STARTUP variable, with schedule_service_startup() to |
3821 |
+ /sbin/rc-services.sh and /etc/conf.d/rc. This is experimental parallel |
3822 |
+ startup of services, and seems to work nicely. Only issues to date is |
3823 |
+ that printing of messages is not synced, and a race very intermittantly |
3824 |
+ that causes a service to be started when it was already scheduled. |
3825 |
+ - Add a new dependency type 'parallel' that can be used to control if a |
3826 |
+ service can be started in paralled or not. Possible arguments is "yes" |
3827 |
+ or "no"; if it is not present, it is considered as "yes": |
3828 |
+ |
3829 |
+ depend() { |
3830 |
+ parallel yes|no |
3831 |
+ } |
3832 |
+ |
3833 |
+ Modified cachedepend.awk, gendepend.awk and /sbin/rc-services.sh. |
3834 |
+ - Fix the 'single' runlevel to actually work properly, and without a |
3835 |
+ /etc/runlevels/single directory. |
3836 |
+ - Remove the BOOT variable, and update /sbin/rc to set SOFTLEVEL properly. |
3837 |
+ Fix /etc/init.d/{checkroot,bootmisc} to use SOFTLEVEL instead of BOOT. |
3838 |
+ |
3839 |
+ 08 May 2003; Martin Schlemmer <azarah@g.o>: |
3840 |
+ |
3841 |
+ Major rework of /lib/rcscript/awk/gendepend.awk, cleaning it up nicely, |
3842 |
+ and adding more sanity checks. |
3843 |
+ |
3844 |
+ 04 May 2003; Martin Schlemmer <azarah@g.o>: |
3845 |
+ |
3846 |
+ Revert /etc/init.d/hostname the way it was, as it should be the user's |
3847 |
+ choice if he want to have a FQDN in there or not, bug #14946. |
3848 |
+ |
3849 |
+ Add /etc/init.d/domainname for those that want to use it. |
3850 |
+ |
3851 |
+ 29 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3852 |
+ |
3853 |
+ Change the root check back the way it was, else it breaks with non bash |
3854 |
+ shells; modified /etc/profile. |
3855 |
+ |
3856 |
+ 29 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3857 |
+ |
3858 |
+ Change test in /etc/profile for root to '[ "$EUID" -eq 0 ]', bug #20140. |
3859 |
+ |
3860 |
+ 27 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3861 |
+ |
3862 |
+ Add various patches from Rachel Holmes <rach@×××.net>: |
3863 |
+ |
3864 |
+ Dropped use of 'cat' in bash scripts, '$(<$file)' is there for that |
3865 |
+ purpose. Modified: |
3866 |
+ |
3867 |
+ /etc/init.d/net.ppp0 |
3868 |
+ /etc/init.d/nscd |
3869 |
+ /sbin/functions.sh |
3870 |
+ /sbin/rc |
3871 |
+ /sbin/rc-daemon.sh |
3872 |
+ /sbin/rc-envupdate.sh.bash |
3873 |
+ /sbin/runscript.sh |
3874 |
+ |
3875 |
+ Exchanged some gratuitous use of awk for grep. Awk is a little resource |
3876 |
+ hungry just for a simple test. (I [azarah] did not apply the changes to |
3877 |
+ tests for 'devfs', as having 'usbdevfs' in the equation will break |
3878 |
+ things). Modified /sbin/rc for this. |
3879 |
+ |
3880 |
+ Gentoo enforces having /proc, so uname -r is a little redundant when the |
3881 |
+ information is available without an external command. Modified: |
3882 |
+ |
3883 |
+ /etc/init.d/modules |
3884 |
+ /etc/init.d/serial |
3885 |
+ /sbin/functions.sh |
3886 |
+ /sbin/modules-update |
3887 |
+ |
3888 |
+ Changed 'id -u' commands to use $EUID in bash executed scripts, same |
3889 |
+ result no extra command. Modified: |
3890 |
+ |
3891 |
+ /sbin/rc-envupdate.sh |
3892 |
+ /sbin/rc-envupdate.sh.bash |
3893 |
+ /sbin/rc-update |
3894 |
+ |
3895 |
+ Removed all the cat sections, and the separate echo sections. The output |
3896 |
+ is _exactly_ the same, minus some spare spaces that have been removed. |
3897 |
+ Fourfold speed increase in the (granted flimsy) tests I have done. |
3898 |
+ Modified /sbin/rc-help.sh for this. |
3899 |
+ |
3900 |
+ Final remaining 'cat' commands removed, in favour of using bash's internal |
3901 |
+ '$(< )' or 'echo'. Use of echo leads the way to future support for bash's |
3902 |
+ i18n anyway. Modified: |
3903 |
+ |
3904 |
+ /sbin/rc |
3905 |
+ /sbin/rc-envupdate.sh |
3906 |
+ /sbin/rc-envupdate.sh.bash |
3907 |
+ |
3908 |
+ |
3909 |
+ |
3910 |
+* rc-scripts 1.4.3.6 (27 Apr 2003) |
3911 |
+ |
3912 |
+ 27 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3913 |
+ |
3914 |
+ Add a 'save' function /etc/init.d/clock, bug #19685. |
3915 |
+ |
3916 |
+ Add a slocate group to /etc/group, bug #19604. |
3917 |
+ |
3918 |
+ Do not stop a network service if we do not reboot on runlevel change, |
3919 |
+ as it could have been started by the user or hotplug. This should |
3920 |
+ address bug #12763; modified /sbin/rc for this. |
3921 |
+ |
3922 |
+ Fix /etc/init.d/hostname to set only the hostname, and not the NIS |
3923 |
+ domainname. |
3924 |
+ |
3925 |
+ Fix /etc/init.d/keymaps to be able to set the extended keymap in rc.conf. |
3926 |
+ This should close bug #16884. |
3927 |
+ |
3928 |
+ Fix /etc/profile to be /bin/sh compadible, bug #18918. |
3929 |
+ |
3930 |
+ Change the swap comments in /sbin/rc to "Activating (possible) swap" to |
3931 |
+ be more 'generic' ? Only try to disable swap if any devices/files was |
3932 |
+ activated. This should close bug #19089. |
3933 |
+ |
3934 |
+ Fix /etc/init.d/checkroot to only remount / rw if not set explicitly to |
3935 |
+ rw in /etc/fstab, bug #19158. |
3936 |
+ |
3937 |
+ 24 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3938 |
+ |
3939 |
+ Fix /etc/init.d/net.ppp0 to do the right thing if stopped was called, |
3940 |
+ but the ppp link was already down, bug #15333. |
3941 |
+ |
3942 |
+ 12 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3943 |
+ |
3944 |
+ Fix type-o in /etc/init.d/consolefont (line 38 should be 'retval=$?'). |
3945 |
+ Thanks to Matt Taylor <liverbugg@××××.com> (comment #6, bug #18344). |
3946 |
+ |
3947 |
+ From linux-2.5.68, we need to mount devpts on /dev/pts again ... |
3948 |
+ updated /sbin/rc for this. |
3949 |
+ |
3950 |
+ 11 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3951 |
+ |
3952 |
+ Fix errors on sourcing /etc/profile if EDITOR is not set, bug #18995. |
3953 |
+ |
3954 |
+ 10 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3955 |
+ |
3956 |
+ Make checking in unmount more strict, fixing bug #19007. |
3957 |
+ |
3958 |
+ 09 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3959 |
+ |
3960 |
+ Add one more check to genenviron.awk, to spot cases where there is a |
3961 |
+ space between the variable and the '='. |
3962 |
+ |
3963 |
+ 08 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3964 |
+ |
3965 |
+ Fix interactive shell not to have coloured prompt when used as a |
3966 |
+ dumb client, bug #18886. Fix was inspired by patch from |
3967 |
+ Matthew Kennedy <mkennedy@g.o>. |
3968 |
+ |
3969 |
+* rc-scripts 1.4.3.5 (06 Apr 2003) |
3970 |
+ |
3971 |
+ 06 Apr 2003; Martin Schlemmer <azarah@g.o>: |
3972 |
+ |
3973 |
+ Hopefully get the serial support sane again. Added /bin/consoletype |
3974 |
+ from Redhat to check for serial console. This should resolve bug |
3975 |
+ #18329 partly. |
3976 |
+ |
3977 |
+ Add the --nocolor option to suppress the use of colors. |
3978 |
+ |
3979 |
+ Change the 'status' option to return true if the service is running, |
3980 |
+ and false if stopped. This is only if the '--quiet' flag was also |
3981 |
+ given. |
3982 |
+ |
3983 |
+ Change the start and stop options not to output or return false if |
3984 |
+ the '--quiet' flag was given. |
3985 |
+ |
3986 |
+ Redirect stderr for consolechars in /etc/init.d/consolefont to /dev/null |
3987 |
+ as well, fixing bug #18344. |
3988 |
+ |
3989 |
+ Optimize $EDITOR extraction in /etc/profile closing bug #18614, thanks to |
3990 |
+ Aron Griffis <agriffis@g.o>. |
3991 |
+ |
3992 |
+ Set HALT to 'shutdown' or 'reboot' depending on if we are shutting down |
3993 |
+ or rebooting. |
3994 |
+ |
3995 |
+ 30 Mar 2003; Martin Schlemmer <azarah@g.o>: |
3996 |
+ |
3997 |
+ Fix bug #18329 ... $COLS was not setup properly for serial console. |
3998 |
+ |
3999 |
+ 24 Mar 2003; Martin Schlemmer <azarah@g.o>: |
4000 |
+ |
4001 |
+ Optimize USB fs stuff in /etc/init.d/localmount to use less cats etc. |
4002 |
+ Fix a problem where it might not have mounted the USB fs when usbcore |
4003 |
+ was compiled as module, and the kernel did not mount it by the time |
4004 |
+ the script was started. Get it to rather check what filesystems is |
4005 |
+ supported when deciding if it should use 'usbdevfs' or 'usbfs', as |
4006 |
+ later 2.4 kernels now also support the newer 'usbfs'. |
4007 |
+ |
4008 |
+ Optimize RAID stuff in /etc/init.d/checkfs a bit. |
4009 |
+ |
4010 |
+ 16 Mar 2003; Martin Schlemmer <azarah@g.o>: |
4011 |
+ |
4012 |
+ Update sbin/rc-envupdate.sh.bash for bug #17549. |
4013 |
+ |
4014 |
+* rc-scripts 1.4.3.4 (16 Mar 2003) |
4015 |
+ |
4016 |
+ 16 Mar 2003; Martin Schlemmer <azarah@g.o>: |
4017 |
+ |
4018 |
+ Add /etc/issue done by a Polish ascii-artists, v|rus with some slight |
4019 |
+ modifications (purple and display hostname, etc). Closes bug #16806. |
4020 |
+ |
4021 |
+ Add 'use hotplug' to /etc/init.d/net.eth0, to get cardbus hardware to |
4022 |
+ work properly. Closes bug #17348. |
4023 |
+ |
4024 |
+ Add update from Wout Mertens <wmertens@g.o> to speedup shutdown |
4025 |
+ of dhcp interfaces, closing bug #17378. This modified /etc/init.d/net.eth0. |
4026 |
+ |
4027 |
+ 11 Mar 2003; Martin Schlemmer <azarah@g.o>: |
4028 |
+ |
4029 |
+ Fix usage of /usr/bin/cut in /sbin/functions.sh, thanks Brandon Low |
4030 |
+ <lostlogic@g.o>! |
4031 |
+ |
4032 |
+ 10 Mar 2003; Martin Schlemmer <azarah@g.o>: |
4033 |
+ |
4034 |
+ Add sysfs support for 2.5 kernels (mounted to /sys). Updated /sbin/rc |
4035 |
+ and /etc/init.d/halt.sh for this. |
4036 |
+ |
4037 |
+ Update /etc/fstab to correctly mount /proc with: |
4038 |
+ |
4039 |
+ mount -t proc none /proc |
4040 |
+ |
4041 |
+ Do the same for /dev/shm: |
4042 |
+ |
4043 |
+ mount -t tmpfs none /dev/shm |
4044 |
+ |
4045 |
+ Fix a typeo in /etc/init.d/checkroot that caused 'umount -a' to output |
4046 |
+ noise if we exited a recovery console. |
4047 |
+ |
4048 |
+ Fix /etc/init.d/hostname using /usr/bin/cut, closing bug #17175, thanks |
4049 |
+ to Bobby Bingham <uhmmmm@×××××××××××.com> for noticing this. |
4050 |
+ |
4051 |
+ Bring down default gateway before adding new one .. this fixes issues |
4052 |
+ where eth0/whatever was brought up by kernel. Changed /etc/init.d/net.eth0 |
4053 |
+ for this, closing bug #17164. Thanks to nth <y.lesaint@××××.fr> for the |
4054 |
+ fix. |
4055 |
+ |
4056 |
+ Fix /etc/init.d/modules to call modprobe with -q .. this fix issues where |
4057 |
+ it fails for module-init-tools if the module is already loaded. This |
4058 |
+ closes bug #17163, thanks to nth <y.lesaint@××××.fr>. |
4059 |
+ |
4060 |
+* rc-scripts 1.4.3.3 (09 Mar 2003) |
4061 |
+ |
4062 |
+ 09 Mar 2003; Martin Schlemmer <azarah@g.o>: |
4063 |
+ |
4064 |
+ Fix /etc/init.d/netmount not to unmount / on nfs/whatever, bug #16274. |
4065 |
+ |
4066 |
+ Fix net.eth0 not to try and start an interface if already up. |
4067 |
+ |
4068 |
+ Update MAKEDEV from Debian to support more archs. This adds support |
4069 |
+ for 'arm', 'hppa' among others. URL: |
4070 |
+ |
4071 |
+ http://packages.debian.org/stable/base/makedev.html |
4072 |
+ |
4073 |
+ Add support to /etc/init.d/modules to use /etc/modules.autoload/kernel-2.4 |
4074 |
+ if we are using a 2.4 kernel, and /etc/modules.autoload/kernel-2.5 if we |
4075 |
+ are using a 2.5 kernel ... bug #17109. |
4076 |
+ |
4077 |
+ 02 Mar 2003; Martin Schlemmer <azarah@g.o>: |
4078 |
+ |
4079 |
+ Update /etc/init.d/hostname to only set the hostname to whatever is before |
4080 |
+ the first '.', and then set the domainname to the rest, closing bug #14946. |
4081 |
+ |
4082 |
+ 28 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4083 |
+ |
4084 |
+ Merge some of the optimizations from Graham Forest <vladimir@g.o>. |
4085 |
+ |
4086 |
+ Fix spelling of dependency and some other spelling/grammer issues. |
4087 |
+ Thanks goes to Kerin Millar <kerin@×××××××××××××××.net> and |
4088 |
+ Mike Frysinger <vapier@g.o>, bug #15498. |
4089 |
+ |
4090 |
+ Change $svcdir to '/var/lib/init.d' to be more FHS compliant, bug #15192. |
4091 |
+ |
4092 |
+ Add 'Eterm' to /etc/skel/.bashrc, closing bug #14662. |
4093 |
+ |
4094 |
+ Adjust comments about PROTOCOLS in /etc/rc.conf to try and prevent |
4095 |
+ bug #14556. |
4096 |
+ |
4097 |
+ 27 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4098 |
+ |
4099 |
+ Finally fix /etc/init.d/halt.sh to unmount non critical mounts properly. |
4100 |
+ |
4101 |
+ 20 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4102 |
+ |
4103 |
+ Kill /dev/ttyp0 error at boot by changing test in /etc/init.d/modules |
4104 |
+ to 'test -c /dev/ttyp0 &> /dev/null'. |
4105 |
+ |
4106 |
+ 18 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4107 |
+ |
4108 |
+ Update /sbin/modules-update to generate /etc/modprobe.devfs from |
4109 |
+ /etc/modules.devfs. This along with the devfs-hack.patch in the latest |
4110 |
+ module-init-tools-0.9.9 should get rid of many of the warnings/errors |
4111 |
+ with devfs, and makes it work a bit better. |
4112 |
+ |
4113 |
+ 17 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4114 |
+ |
4115 |
+ Fix /etc/inputrc for dvorak keyboard layout, bug #2599 again. |
4116 |
+ |
4117 |
+ 16 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4118 |
+ |
4119 |
+ Fix the 'source /etc/profile.env' to be '. /etc/profile' to have ksh |
4120 |
+ support. This resolves bug #14994. |
4121 |
+ |
4122 |
+ Move EDITOR to /etc/rc.conf. Also update /etc/profile to set EDITOR |
4123 |
+ according to /etc/rc.conf. |
4124 |
+ |
4125 |
+ Update /etc/init.d/checkfs to fix bug #14282. It did not exclude comments, |
4126 |
+ and used 'basename' which is located in /usr/bin. |
4127 |
+ |
4128 |
+ 13 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4129 |
+ |
4130 |
+ Merge changes from Nick Jones <carpaski@g.o> to not run stty if |
4131 |
+ used in portage. Fix the NOCOLOR stuff. Updated /sbin/functions.sh for |
4132 |
+ this. |
4133 |
+ |
4134 |
+ 06 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4135 |
+ |
4136 |
+ Update src/awk/genenviron.awk to properly set the environment for each |
4137 |
+ rc-script's depend() function by sourcing required config files. |
4138 |
+ |
4139 |
+ 05 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4140 |
+ |
4141 |
+ Fix /sbin/rc-envupdate.sh to use $svcdir to set SVCDIR. This is thanks |
4142 |
+ to Max Kalika <alkern23@×××××.com>, bug #15050. |
4143 |
+ |
4144 |
+ 03 Feb 2003; Martin Schlemmer <azarah@g.o>: |
4145 |
+ |
4146 |
+ Fix /sbin/modules-update to work with module-init-tools-0.9.9. |
4147 |
+ |
4148 |
+ 30 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4149 |
+ |
4150 |
+ Add 'use isapnp' to /etc/init.d/modules, closing bug #14677, thanks to |
4151 |
+ Hubert Hanghofer <hubert.hanghofer@××××××××××.at>. |
4152 |
+ |
4153 |
+ 27 Jan 2003; Donny Davies <woodchip@g.o>: |
4154 |
+ |
4155 |
+ Fix halt.sh by moving the nut UPS kill power stuff back into a function! |
4156 |
+ Add fix from the wonderful analysis of Toby Dickenson |
4157 |
+ <tdickenson@×××××××××××××××××.com> in #12947. |
4158 |
+ |
4159 |
+ 26 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4160 |
+ |
4161 |
+ Fix start-stop-daemon to check the call to nice() correctly for failure, |
4162 |
+ closing bug #14359, thanks to YAMAKURA Makoto <makoto@×××××××××××.jp>. |
4163 |
+ |
4164 |
+ Fix globbing $? when checking return value of fsck in /etc/init.d/checkroot |
4165 |
+ and /etc/init.d/checkfs. This closes bug #13320, thanks to good work from |
4166 |
+ Malcolm Scott <m@×××××××××.uk>. |
4167 |
+ |
4168 |
+ 21 Jan 2003; Mike Frysinger <vapier@g.o>: |
4169 |
+ |
4170 |
+ Updated /etc/rc.conf to add elogin/entrance support #13790. |
4171 |
+ |
4172 |
+ 21 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4173 |
+ |
4174 |
+ Update /etc/init.d/keymaps to enable unicode if required. This closes |
4175 |
+ bug #14306 thanks to Danny Milosavljevic <danny_milo@×××××.com>. |
4176 |
+ |
4177 |
+ 19 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4178 |
+ |
4179 |
+ Fix deadlock durning shutdown if tmpfs filesystems larger than free |
4180 |
+ memory, and swap gets deactivated, bug #13599. Updated /etc/init.d/halt.sh |
4181 |
+ for this. |
4182 |
+ |
4183 |
+ Merge in some fixes from Vapier <vapier@g.o> to /sbin/functions.sh. |
4184 |
+ This closes bug #13868. |
4185 |
+ |
4186 |
+ Always add "/bin:/sbin:/usr/bin:/usr/sbin" to PATH, as it fixes both |
4187 |
+ 'su -c foo' not finding start-stop-daemon (etc), and bug #14127. |
4188 |
+ |
4189 |
+ Add route for lo interface to /etc/init.d/net.lo, closing bug #14055. |
4190 |
+ |
4191 |
+ 15 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4192 |
+ |
4193 |
+ Clear $svcdir in /sbin/rc before we run depscan to make sure we do |
4194 |
+ not have stale entries left from hard reboot, thanks to pac1085 on |
4195 |
+ irc. |
4196 |
+ |
4197 |
+* rc-scripts 1.4.3.2 (15 Jan 2003) |
4198 |
+ |
4199 |
+ 15 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4200 |
+ |
4201 |
+ Truely fix bootup on seperate /var. |
4202 |
+ |
4203 |
+ Add some fixes and optimizations to /sbin/rc-update, thanks to |
4204 |
+ Daniel Robbins <drobbins@g.o>. |
4205 |
+ |
4206 |
+* rc-scripts 1.4.3.1 (15 Jan 2003) |
4207 |
+ |
4208 |
+ 15 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4209 |
+ |
4210 |
+ Fix bootup on seperate /var. |
4211 |
+ |
4212 |
+ 14 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4213 |
+ |
4214 |
+ Fix /etc/init.d/hostname and /etc/init.d/serial to close bug #13636. |
4215 |
+ |
4216 |
+ 07 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4217 |
+ |
4218 |
+ Fix /etc/init.d/keymaps to force linux keycodes for PPC, thanks |
4219 |
+ to Olaf Hering <gentoo@××××××.de>, bug #13193. |
4220 |
+ |
4221 |
+ Turn on -C option to fsck on for all calls to fsck. Updated scripts |
4222 |
+ /etc/init.d/checkroot and /etc/init.d/checkfs, closing bug #13321. |
4223 |
+ |
4224 |
+* rc-scripts 1.4.3.0 (07 Jan 2003) |
4225 |
+ |
4226 |
+ 07 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4227 |
+ |
4228 |
+ Too much to mention, but here are a few: |
4229 |
+ - Major rewrite of software RAID startup, based on Mandrake's, as |
4230 |
+ ours was pretty broken :( |
4231 |
+ - Redone /sbin/rc to work without the tmpfs/ramfs stat directory. |
4232 |
+ Much of /sbin/functions.sh and other scripts have been changed |
4233 |
+ to support this. |
4234 |
+ - Reworked /etc/inittab to support this. Also moved critical |
4235 |
+ mounting of local filesystems to 'sysinit' function of /sbin/rc. |
4236 |
+ - Move state directory to /var/state/init.d/ ($svcdir). |
4237 |
+ - Move Adelie node init to /sbin/functions.sh to try and simplify |
4238 |
+ /sbin/rc a bit. |
4239 |
+ - Updated Copyright dates to 2003. |
4240 |
+ |
4241 |
+* rc-scripts 1.4.2.8 (06 Jan 2003) |
4242 |
+ |
4243 |
+ 02 Jan 2003; Martin Schlemmer <azarah@g.o>: |
4244 |
+ |
4245 |
+ Fix src/awk/genenviron.awk to work with multiple 'need', 'use', etc |
4246 |
+ lines, as it seems users do not note the need to have them all on |
4247 |
+ one line .... |
4248 |
+ |
4249 |
+ Fix /sbin/runscript.sh to detect 'net.adsl', or any other net.* |
4250 |
+ script not ending on a digit. This closes bug #12887. |
4251 |
+ |
4252 |
+ Fix get_KV to also check micro version of kernel; add KV_to_int() |
4253 |
+ helper function for get_KV. Update /etc/init.d/localmount to work |
4254 |
+ with new get_KV ... |
4255 |
+ |
4256 |
+ 28 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4257 |
+ |
4258 |
+ Add support for generate-modprobe.conf or generating /etc/modprobe.conf |
4259 |
+ in the new sys-apps/module-init-tools. Note that you need version |
4260 |
+ 0.9.7 or later of sys-apps/module-init-tools. Updated |
4261 |
+ /sbin/modules-update for this. |
4262 |
+ |
4263 |
+ Change /etc/init.d/localmount to use 'usbfs' and not 'usbdevfs' if |
4264 |
+ we are running kernel 2.5 or later ... |
4265 |
+ |
4266 |
+ 26 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4267 |
+ |
4268 |
+ Add /etc/init.d/crypto-loop and /etc/conf.d/crypto-loop, a cool |
4269 |
+ rc-script to setup encrypted loopback devices. This was kindly |
4270 |
+ donated by Matthew Kennedy <mkennedy@g.o> (bug #11471). |
4271 |
+ |
4272 |
+ 25 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4273 |
+ |
4274 |
+ Fix src/awk/genenviron.awk stripping *all* '=', closing |
4275 |
+ bug #8901. |
4276 |
+ |
4277 |
+ Fix src/awk/genenviron.awk not seperating CONFIG_PROTECT with |
4278 |
+ spaces ... |
4279 |
+ |
4280 |
+* rc-scripts 1.4.2.7 (24 Dec 2002) |
4281 |
+ |
4282 |
+ 24 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4283 |
+ |
4284 |
+ Add a fix to /sbin/functions.sh for bug #12601. |
4285 |
+ |
4286 |
+ 22 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4287 |
+ |
4288 |
+ Add INFOPATH to /etc/env.d/00basic. |
4289 |
+ |
4290 |
+ Fix src/awk/genenviron.awk to get the order of the env.d files |
4291 |
+ correct. Also fix it to handle *all* the SPECIALS correctly. |
4292 |
+ This closes bug #12411. |
4293 |
+ |
4294 |
+* rc-scripts 1.4.2.6 (18 Dec 2002) |
4295 |
+ |
4296 |
+ 18 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4297 |
+ |
4298 |
+ Add mips changes to sbin/MAKEDEV. This should close bug #12329, |
4299 |
+ thanks to Nicholas Wourms <nwourms@××××××××.net>. |
4300 |
+ |
4301 |
+ Quote some tests in /sbin/rc-update to fix/avoid the problem |
4302 |
+ in bug # |
4303 |
+ |
4304 |
+ Fix awk regex in /etc/init.d/halt.sh to fix bug #11795. |
4305 |
+ |
4306 |
+ Update shell for postgres user, closing bug #12258. |
4307 |
+ |
4308 |
+ 11 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4309 |
+ |
4310 |
+ Fix src/awk/genenviron.awk not to add duplicate entries, closing |
4311 |
+ bug #8999. |
4312 |
+ |
4313 |
+* rc-scripts 1.4.2.5 (09 Dec 2002) |
4314 |
+ |
4315 |
+ 08 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4316 |
+ |
4317 |
+ Add another sync to /etc/init.d/halt.sh, closing bug 8173. |
4318 |
+ |
4319 |
+ Add smmsp uid and gid. Closes bug #8952. |
4320 |
+ |
4321 |
+ 04 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4322 |
+ |
4323 |
+ Setup colums, etc up properly for serial consoles in /sbin/functions.sh. |
4324 |
+ Closes bug #11557, thanks to Erik Scrafford <erik@×××××××××.org>. |
4325 |
+ |
4326 |
+ Add headers similar to that of portage-2.0.45 and up to the |
4327 |
+ generated profile files (/etc/{profile,csh}.env). Updated |
4328 |
+ src/awk/genenviron.awk for this. |
4329 |
+ |
4330 |
+ 01 Dec 2002; Martin Schlemmer <azarah@g.o>: |
4331 |
+ |
4332 |
+ Fix typeo in /etc/devfsd.conf, closing bug #11424, thanks to the |
4333 |
+ sharp eye of Techie2000 <Linux@×××××××××.com>. |
4334 |
+ |
4335 |
+ Rename /sbin/update-modules to /sbin/modules-update, closing |
4336 |
+ bug #11445. |
4337 |
+ |
4338 |
+ Nano moved from /usr/bin/nano to /bin/nano. Fix this in |
4339 |
+ /etc/env.d/00basic, bug #10916. |
4340 |
+ |
4341 |
+ 27 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4342 |
+ |
4343 |
+ Add more improvements to clustering code. This is from |
4344 |
+ Olivier Crete <crete@×××××××××××××××.ca>, bug #4151. |
4345 |
+ |
4346 |
+ 26 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4347 |
+ |
4348 |
+ Change default 'net' dependency behaviour to be more suited |
4349 |
+ for notebook users. Basically if at least one net.* service |
4350 |
+ beside net.lo start successfully, the 'net' dependency is |
4351 |
+ considered up. Server admin can set RC_NET_STRICT_CHECKING="yes" |
4352 |
+ in /etc/conf.d/rc to change this back to the old default. |
4353 |
+ This is the start to address bug #2706. |
4354 |
+ |
4355 |
+* rc-scripts 1.4.2.4 (26 Nov 2002) |
4356 |
+ |
4357 |
+ 26 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4358 |
+ |
4359 |
+ Initial merge of bits for Adelie Linux for SSI clusters. More |
4360 |
+ info at: |
4361 |
+ |
4362 |
+ http://www.cerca.umontreal.ca/hpc/en/projects/adelie/index.html |
4363 |
+ |
4364 |
+ 25 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4365 |
+ |
4366 |
+ One liner fix to src/awk/cachedepends.awk to once again fix |
4367 |
+ bug #7803. |
4368 |
+ |
4369 |
+ 18 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4370 |
+ |
4371 |
+ Add 'alias char-major-89 i2c-dev' to /etc/modules.d/aliases. |
4372 |
+ This should close bug #10891. |
4373 |
+ |
4374 |
+* rc-scripts 1.4.2.3 (18 Nov 2002) |
4375 |
+ |
4376 |
+ 18 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4377 |
+ |
4378 |
+ Add some more checks to src/awk/*. Fix error printing for |
4379 |
+ /sbin/depscan.sh. |
4380 |
+ |
4381 |
+ Link awk module with gcc and not with ld. This should fix |
4382 |
+ problems on sparc and alpha. Many thanks for this fix to |
4383 |
+ Stephan Jones <cretin@g.o>. |
4384 |
+ |
4385 |
+ Remove the copyright info from config files, thanks to |
4386 |
+ Matthew Kennedy <mkennedy@g.o>. |
4387 |
+ |
4388 |
+* rc-scripts 1.4.2.2 (18 Nov 2002) |
4389 |
+ |
4390 |
+ 18 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4391 |
+ |
4392 |
+ Add src/awk/genenviron.awk which is rc-envupdate.sh ported |
4393 |
+ to awk. This is also much faster than its bash version. |
4394 |
+ |
4395 |
+ Remove the 'Spider cat fix' from depscan.sh.bash, as it makes |
4396 |
+ things even slower on older boxes. Bug #10548. |
4397 |
+ |
4398 |
+ After a bored Vapier decided that he needed to update the |
4399 |
+ licenses of things in /etc :P, I did the rest. Hopefully |
4400 |
+ not too many people will nuke thier fstab :/ |
4401 |
+ |
4402 |
+* rc-scripts 1.4.2.1 (18 Nov 2002) |
4403 |
+ |
4404 |
+ 18 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4405 |
+ |
4406 |
+ Update src/awk/cachedepends.awk to find its own rc-scripts, |
4407 |
+ fixing the need for find which broke systems with /usr on |
4408 |
+ a different partition. |
4409 |
+ |
4410 |
+ 17 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4411 |
+ |
4412 |
+ Add some extra checks to src/awk/cachedepends.awk and |
4413 |
+ src/awk/gendepends.awk. |
4414 |
+ |
4415 |
+ Move some of the more generic functions in src/awk/gendepends.awk |
4416 |
+ to src/awk/functions.awk. |
4417 |
+ |
4418 |
+* rc-scripts 1.4.2 (17 Nov 2002) |
4419 |
+ |
4420 |
+ 17 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4421 |
+ |
4422 |
+ Add initial version of new depscan.sh. This uses awk scripts |
4423 |
+ to do the main work, giving about 10 times speed improvement on |
4424 |
+ slower machines. Updated /sbin/depscan.sh, src/filefuncts.c, |
4425 |
+ src/Makefile, src/awk/cachedepends.awk and src/awk/gendepends.awk |
4426 |
+ for this. This should close bug #10548. |
4427 |
+ |
4428 |
+* rc-scripts 1.4.1.2 (5 Nov 2002) |
4429 |
+ |
4430 |
+ 5 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4431 |
+ |
4432 |
+ Add UID/GID of 250 for Portage Fakeroot account. |
4433 |
+ |
4434 |
+ 4 Nov 2002; Martin Schlemmer <azarah@g.o>: |
4435 |
+ |
4436 |
+ Change /etc/init.d/clock to depend on localmount again, fixing |
4437 |
+ bug #10048. |
4438 |
+ |
4439 |
+ Get deps on logger sane again. I wanted to get the logger started |
4440 |
+ as early as possible, but clock for one breaks if /usr is mounted |
4441 |
+ on seperate partition. |
4442 |
+ |
4443 |
+ 29 Oct 2002; Martin Schlemmer <azarah@g.o>: |
4444 |
+ |
4445 |
+ Fix return in /etc/init.d/modules to return 0 if /proc/modules |
4446 |
+ do not exists. Closes bug #7738, comment #5. |
4447 |
+ |
4448 |
+* rc-scripts 1.4.1.1 (28 Oct 2002) |
4449 |
+ |
4450 |
+ 28 Oct 2002; Martin Schlemmer <azarah@g.o>: |
4451 |
+ |
4452 |
+ Fix /sbin/update-modules not to include backup files. Closes |
4453 |
+ bug #9707. |
4454 |
+ |
4455 |
+ 26 Oct 2002; Martin Schlemmer <azarah@g.o>: |
4456 |
+ |
4457 |
+ Fix update-modules borking if there are directories present |
4458 |
+ in /etc/modules.d/. Closes bug #9632. |
4459 |
+ |
4460 |
+ 17 Oct 2002; Martin Schlemmer <azarah@g.o>: |
4461 |
+ |
4462 |
+ Change deps on /etc/init.d/{clock,hostname,modules} not to |
4463 |
+ depend on localmount, but rather on checkroot, as all of them |
4464 |
+ just need / to be mounted. This should fix race conditions |
4465 |
+ because of checkfs dependency on modules. This should close |
4466 |
+ bug #9266. |
4467 |
+ |
4468 |
+* rc-scripts 1.4.1 (13 Oct 2002) |
4469 |
+ |
4470 |
+ 13 Oct 2002; Martin Schlemmer <azarah@g.o>: |
4471 |
+ |
4472 |
+ Create and fix permissions on /tmp/.{ICE,X11}-unix/. This |
4473 |
+ is additional measures for bug #8281. |
4474 |
+ |
4475 |
+ 12 Oct 2002; Martin Schlemmer <azarah@g.o>: |
4476 |
+ |
4477 |
+ Update /etc/init.d/net.eth0 to fix bug #8626. |
4478 |
+ |
4479 |
+ Fix /sbin/rc-update to check return code of "ln". This should |
4480 |
+ close bug #8867. |
4481 |
+ |
4482 |
+ 29 Sep 2002; Martin Schlemmer <azarah@g.o>: |
4483 |
+ |
4484 |
+ Fix indentation in /etc/inputrc. This should close |
4485 |
+ bug #8368. |
4486 |
+ |
4487 |
+ Add extended status functionality. Should close bug #2462. |
4488 |
+ |
4489 |
+ Add support for /sbin/rc-update to check if the rc-script |
4490 |
+ is executable or not. Thanks to widersacher@×××.net, closing |
4491 |
+ bug #8326. |
4492 |
+ |
4493 |
+ 25 Sep 2002; Martin Schlemmer <azarah@g.o>: |
4494 |
+ |
4495 |
+ Fix /etc/init.d/bootmisc not to kill pidfiles of running |
4496 |
+ daemons. Improve NGPT support in /sbin/rc a bit. |
4497 |
+ |
4498 |
+ 23 Sep 2002; Martin Schlemmer <azarah@g.o>: |
4499 |
+ |
4500 |
+ Fix my last screwup with /etc/init.d/net.ppp0. Basically |
4501 |
+ forgot to change a few DEVICE's to IFACE ... |
4502 |
+ |
4503 |
+ 22 Sep 2002; Martin Schlemmer <azarah@g.o>: |
4504 |
+ |
4505 |
+ NGPT support. |
4506 |
+ |
4507 |
+ 17 Sep 2002; Martin Schlemmer <azarah@g.o>: |
4508 |
+ |
4509 |
+ Did a small fix to /etc/init.d/net.eth0, thanks to |
4510 |
+ naanyaar2000@×××××.com, bug #7407. |
4511 |
+ |
4512 |
+ 16 Sep 2002; Martin Schlemmer <azarah@g.o>: |
4513 |
+ |
4514 |
+ Add the permission stuff for generic scsi when compiled as |
4515 |
+ module, thanks to Bauno <bauno@××××××.it>. |
4516 |
+ |
4517 |
+ Add support for /etc/devfs.d/ for additional devfs config |
4518 |
+ stuff .. idea from Denys Duchier <Denys.Duchier@×××××××××.de>. |
4519 |
+ |
4520 |
+ 11 Sep 2002; Martin Schlemmer <azarah@g.o>: |
4521 |
+ |
4522 |
+ Fix small type-o from last changes to /etc/init.d/netmount. |
4523 |
+ Should resolve bug #7803. |
4524 |
+ |
4525 |
+* rc-scripts 1.4.0 (7 Sep 2002) |
4526 |
+ |
4527 |
+ 7 Sep 2002; Martin Schlemmer <azarah@g.o>: |
4528 |
+ |
4529 |
+ Update /etc/init.d/net.eth0 to handle individual broadcast |
4530 |
+ and netmask for aliases. Should close bug #7407. |
4531 |
+ |
4532 |
+ Give /var/run/utmp and /var/log/wtmp the proper permissions |
4533 |
+ and ownership. First steps in fixing bug #7630. |
4534 |
+ |
4535 |
+ Change Raid stuff again in /etc/init.d/checkfs. |
4536 |
+ |
4537 |
+ 26 Aug 2002; Donny Davies <woodchip@g.o>: |
4538 |
+ |
4539 |
+ Give root a 'root' GECOS in /etc/passwd, was NULL before. |
4540 |
+ |
4541 |
+* rc-scripts 1.3.9 (25 Aug 2002) |
4542 |
+ |
4543 |
+ 25 Aug 2002; Martin Schlemmer <azarah@g.o>: |
4544 |
+ |
4545 |
+ Update /sbin/rc to fix some spelling/slang mistakes. Closes |
4546 |
+ bug #6887. |
4547 |
+ |
4548 |
+ Move /etc/init.d/net.ppp0 's config to /etc/conf.d/net.ppp0. |
4549 |
+ This closes bug #6378. |
4550 |
+ |
4551 |
+ Add IPv6 support to /etc/init.d/net.eth0. Closes bug #6175, |
4552 |
+ with many thanks to Asbjorn Sannes <ace@××××××.org>. |
4553 |
+ |
4554 |
+ 20 Aug 2002; Martin Schlemmer <azarah@g.o>: |
4555 |
+ |
4556 |
+ Update /etc/init.d/bootmisc to reset pam_console permissions. |
4557 |
+ |
4558 |
+ Update /etc/devfsd.conf to have the "pam_console_apply_devfsd.so" |
4559 |
+ line for getting devfs to work with pam_console. |
4560 |
+ |
4561 |
+ 12 Aug 2002; Martin Schlemmer <azarah@g.o>: |
4562 |
+ |
4563 |
+ Update /etc/init.d/keymaps to first load the windowkeys.inc then |
4564 |
+ the user selected one, fixing bug #6295. |
4565 |
+ |
4566 |
+ 11 Aug 2002; Martin Schlemmer <azarah@g.o>: |
4567 |
+ |
4568 |
+ Change the 'cat' in check_rcscript() to a single 'awk' in |
4569 |
+ /sbin/depscan.sh. This should fix broken pipe issues if the |
4570 |
+ loop exists too early. Resolves bug #5961. |
4571 |
+ |
4572 |
+ Fix software RAID startup/shutdown, bug #5310. Modified |
4573 |
+ /etc/init.d/checkfs and /etc/init.d/halt.sh for this. |
4574 |
+ |
4575 |
+* rc-scripts 1.3.8 (08 Aug 2002) |
4576 |
+ |
4577 |
+ 7 Aug 2002; Martin Schlemmer <azarah@g.o>: |
4578 |
+ |
4579 |
+ Move the color ls stuff to .bashrc. Fix bug #5250. |
4580 |
+ |
4581 |
+ 6 Aug 2002; Dan Armak <danarmak@g.o>: |
4582 |
+ |
4583 |
+ Correct the comments in rc.conf about the XSESSION variable: it should |
4584 |
+ be set to "kde-<version>" not "KDE". Closes bug #5948. |
4585 |
+ |
4586 |
+ 5 Aug 2002; Martin Schlemmer <azarah@g.o>: |
4587 |
+ |
4588 |
+ Fix the 'Usage' line in the help to return the correct options for |
4589 |
+ the script (/sbin/runscript.sh). Resolve bug #6029. |
4590 |
+ |
4591 |
+ 3 Aug 2002; Donny Davies <woodchip@g.o>: |
4592 |
+ |
4593 |
+ Added UPS shutdown support for nut to halt.sh. |
4594 |
+ Added nut user/group as uid/gid 84. |
4595 |
+ |
4596 |
+ 27 Jul 2002; Martin Schlemmer <azarah@g.o>: |
4597 |
+ |
4598 |
+ Updated /sbin/rc's way of checking for devfs support (now rather uses |
4599 |
+ awk, as it is more accurate). Closes bug #5458. |
4600 |
+ |
4601 |
+ Add the Redhat/Mandrake /forcefsck and /fastboot options to our checkroot |
4602 |
+ and checkfs. Updated /etc/init.d/{checkroot,checkfs,halt.sh} for this. |
4603 |
+ Thanks goes to Chris PeBenito (bug #5570). |
4604 |
+ |
4605 |
+ Changed most daemons to use /bin/false as shell. Should close bug #5388. |
4606 |
+ |
4607 |
+ 27 Jul 2002; Nicholas Jones <carpaski@g.o>: |
4608 |
+ |
4609 |
+ Added vpopmail user and group as 89:89 |
4610 |
+ |
4611 |
+ 22 Jul 2002; Martin Schlemmer <azarah@g.o>: |
4612 |
+ |
4613 |
+ Add the cyrus user to /etc/passwd. Resolves bug #4100. |
4614 |
+ |
4615 |
+ Some bugfixes and speed improvements to /sbin/depscan.sh after |
4616 |
+ last changes. |
4617 |
+ |
4618 |
+ Replace some cat/grep's in /sbin/rc-envupdate.sh with awk's to |
4619 |
+ get some speed improvements. |
4620 |
+ |
4621 |
+ 21 Jul 2002; Martin Schlemmer <azarah@g.o>: |
4622 |
+ |
4623 |
+ Fix LVM support in /etc/init.d/checkfs again, thanks to help from |
4624 |
+ Kyle Manna <nitro@g.o>. |
4625 |
+ |
4626 |
+ Add software RAID support to /etc/init.d/checkfs, thanks to |
4627 |
+ Daniel Ahlberg <aliz@g.o>. |
4628 |
+ |
4629 |
+ Update the cache_depend() funtion in /sbin/depscan.sh not to |
4630 |
+ quit on any "}", but only on the one matching the first "{". This |
4631 |
+ requires wc in /bin, so baselayout should depend on |
4632 |
+ >=sys-apps/textutils-2.0.19-r2 |
4633 |
+ |
4634 |
+ Update /etc/init.d/netmount to try and detect nfs mounts that should be |
4635 |
+ mounted automatically on boot. This requires awk in /bin, so baselayout |
4636 |
+ should depend on >=sys-apps/gawk-3.1.0-r3. |
4637 |
+ |
4638 |
+* rc-scripts 1.3.7 (17 Jul 2002) |
4639 |
+ |
4640 |
+ 17 Jul 2002; Martin Schlemmer <azarah@g.o>: |
4641 |
+ |
4642 |
+ Add logging functionality to the rc-scripts, thanks to Alexander Holler, |
4643 |
+ bug #4037 for the basic idea. Updated /sbin/functions.sh for this. |
4644 |
+ |
4645 |
+ 16 Jul 2002; Martin Schlemmer <azarah@g.o>: |
4646 |
+ |
4647 |
+ Add additional entries to /etc/services to support cyrus-imapd, thanks |
4648 |
+ to Nick Hadaway <raker@g.o>. |
4649 |
+ |
4650 |
+ Update /etc/init.d/consolefont to resolve bug #4968. This fixes a |
4651 |
+ problem with non 7bit ascii symbols. |
4652 |
+ |
4653 |
+ Updated /etc/init.d/checkfs to detect if lvm is already active. |
4654 |
+ This should resolve bug #3613. |
4655 |
+ |
4656 |
+ 5 Jun 2002; Martin Schlemmer <azarah@g.o>: |
4657 |
+ |
4658 |
+ Add "usb" group, gid 85. Move "sshd" user and group to 22. Move |
4659 |
+ "games" user and group to 35 |
4660 |
+ |
4661 |
+ 3 Jun 2002; Martin Schlemmer <azarah@g.o>: |
4662 |
+ |
4663 |
+ Update Copyright displayed at boot, thanks to Sascha Schwabbauer |
4664 |
+ (aka cybersystem). Updated /sbin/rc for this. |
4665 |
+ |
4666 |
+ 30 Jun 2002; Martin Schlemmer <azarah@g.o>: |
4667 |
+ |
4668 |
+ Update /etc/skel/.bashrc to update the window title of X terminals |
4669 |
+ that supports it. Closes bug #4232. |
4670 |
+ |
4671 |
+ 26 Jun 2002; Martin Schlemmer <azarah@g.o>: |
4672 |
+ |
4673 |
+ Add sshd user and group. Updated /etc/passwd and /etc/group for this. |
4674 |
+ |
4675 |
+ Update /etc/inputrc to resolve bug #2599. |
4676 |
+ |
4677 |
+ 20 Jun 2002; Martin Schlemmer <azarah@g.o>: |
4678 |
+ |
4679 |
+ Add /opt/bin to $PATH and $ROOTPATH, closing bug #3603. Modified |
4680 |
+ /etc/env.d/00basic for this. |
4681 |
+ |
4682 |
+ Add some new daemon stop and pid detection stuff to /sbin/functions.sh. |
4683 |
+ Nothing official, but I spent enough time on it not to want to loose it :) |
4684 |
+ |
4685 |
+ Fixed a bug in /sbin/functions.sh that caused rc-scripts run as cron jobs |
4686 |
+ to give output to stderr. This was caused by a call to "stty", which when |
4687 |
+ run without a attatched terminal, have this effect. Basically just pipe |
4688 |
+ stderr to /dev/null. |
4689 |
+ |
4690 |
+ 5 Jun 2002; Martin Schlemmer <azarah@g.o>: |
4691 |
+ |
4692 |
+ Add /usr/local/share/man to $MANPATH (/etc/env.d/00basic), resolving |
4693 |
+ bug #3363 |
4694 |
+ |
4695 |
+ 26 May 2002; Martin Schlemmer <azarah@g.o>: |
4696 |
+ |
4697 |
+ Update /etc/init.d/netmount not to try and mount NFS filesystems |
4698 |
+ if portmap was not started. This is to stop "hang" problems for |
4699 |
+ new users who do not add portmap to the default runlevel. See |
4700 |
+ bug #2555. |
4701 |
+ |
4702 |
+ Add the video4linux stuff to /etc/devfsd.conf. Resolves bug #2015. |
4703 |
+ |
4704 |
+ 19 May 2002; Martin Schlemmer <azarah@g.o>: |
4705 |
+ |
4706 |
+ Move $EDITOR from /etc/profile to /etc/env.d/00basic. |
4707 |
+ |
4708 |
+ 13 May 2002; Martin Schlemmer <azarah@g.o>: |
4709 |
+ |
4710 |
+ Change the homes of user "at" and "cron" in /etc/passwd, as |
4711 |
+ they moved to /var/spool/cron... |
4712 |
+ |
4713 |
+* rc-scripts 1.3.5 (12 May 2002) |
4714 |
+ |
4715 |
+ 12 May 2002; Martin Schlemmer <azarah@g.o>: |
4716 |
+ |
4717 |
+ Make slight modifications to /sbin/depscan.sh to improve speed (about |
4718 |
+ 1 second on a celeron 633). |
4719 |
+ |
4720 |
+ Finally fix /sbin/runscript.sh to properly handle interdependencies |
4721 |
+ between types need/use and before/after on runlevel change. I can |
4722 |
+ actually kick myself for previous implementations, as this fix simplifies |
4723 |
+ things a lot, and is almost 30 lines of code less! |
4724 |
+ |
4725 |
+ Change /etc/init.d/netmount not to fail if all mounts are not mounted. |
4726 |
+ It rather just exit with a warning, as I think most people have like |
4727 |
+ me mounts that are to boxes that are not always up. |
4728 |
+ |
4729 |
+ Resolve bug #2439 (should not use try with the dd command for ramdisk |
4730 |
+ stuff). Also increase the number of inodes used for the ramdisk to |
4731 |
+ fix "out of space" errors. Updated /sbin/rc for this. |
4732 |
+ |
4733 |
+ 10 May 2002; Martin Schlemmer <azarah@g.o>: |
4734 |
+ |
4735 |
+ Resolve bug #2505 ... /sbin/rc-envupdate.sh should not use |
4736 |
+ backup files to generate /etc/profile.env. |
4737 |
+ |
4738 |
+ Resolve bug #2489 and #2175. Modified /etc/init.d/net.eth0 |
4739 |
+ for this. |
4740 |
+ |
4741 |
+ 6 May 2002; Martin Schlemmer <azarah@g.o>: |
4742 |
+ |
4743 |
+ Fixed /sbin/rc-envupdate.sh to only use the $KDEDIR of the highest |
4744 |
+ /etc/env.d/ file. Same for $QTDIR. |
4745 |
+ |
4746 |
+ 5 May 2002; Martin Schlemmer <azarah@g.o>: |
4747 |
+ |
4748 |
+ Add /etc/DIR_COLORS as it is no longer shipped with fileutils, |
4749 |
+ and is needed for some fixes. |
4750 |
+ |
4751 |
+ 28 Apr 2002; Martin Schlemmer <azarah@g.o>: |
4752 |
+ |
4753 |
+ Update /etc/rc.conf to be more clear and state that you should |
4754 |
+ remove consolefont from startup if you do not use it. Should |
4755 |
+ resolve bug #2174. |
4756 |
+ |
4757 |
+ 26 Apr 2002; Donny Davies <woodchip@g.o> passwd, group : |
4758 |
+ |
4759 |
+ Added user/group apache with uid/gid 81. |
4760 |
+ |
4761 |
+ 25 Apr 2002; Martin Schlemmer <azarah@g.o>: |
4762 |
+ |
4763 |
+ Remove the "-net" from the line setting the default gateway |
4764 |
+ in /etc/init.d/net.eth0. Thanks to Peter W. Michaleas for |
4765 |
+ noting this. |
4766 |
+ |
4767 |
+ 24 Apr 2002; Donny Davies <woodchip@g.o> rc.conf : |
4768 |
+ |
4769 |
+ Remove NFSSERVER from rc.conf since it's now covered in /etc/conf.d/nfs |
4770 |
+ which is installed with the nfs-utils package. Also tidied up some |
4771 |
+ really old, leftover junk like the non-supported stuff from rc5. |
4772 |
+ Closes #1754. |
4773 |
+ |
4774 |
+ 23 Apr 2002; Martin Schlemmer <azarah@g.o>: |
4775 |
+ |
4776 |
+ Remove creation of /var/run/utmpx from bootmisc again. Seems |
4777 |
+ other people have wierd problems. |
4778 |
+ |
4779 |
+* rc-scripts 1.3.4 (21 Apr 2002) |
4780 |
+ |
4781 |
+ 21 Apr 2002; Martin Schlemmer <azarah@g.o>: |
4782 |
+ |
4783 |
+ Add /sbin/rc-envupdate.sh to speedup updating of /etc/profile.env, |
4784 |
+ and /etc/csh.env. Update /etc/init.d/bootmisc to use this. |
4785 |
+ |
4786 |
+ Implement the status commandline argument. Updated /sbin/runscript.sh |
4787 |
+ and /sbin/rc-help.sh for this. |
4788 |
+ |
4789 |
+ Fix /sbin/depscan.sh to honour NEED and USE overriding BEFORE |
4790 |
+ and AFTER. |
4791 |
+ |
4792 |
+ 12 Apr 2002; Martin Schlemmer <azarah@g.o>: |
4793 |
+ |
4794 |
+ Update /etc/init.d/bootmisc to create /var/run/utmpx. This |
4795 |
+ is needed, else /usr/bin/newgrp segfault. |
4796 |
+ |
4797 |
+ 11 Apr 2002; Martin Schlemmer <azarah@g.o>: |
4798 |
+ |
4799 |
+ Update /etc/skel/.bash_profile to make it tcsh compadible. |
4800 |
+ Thanks to Väinö Järvelä for this fix. |
4801 |
+ |
4802 |
+ Update /etc/profile to also set the PS? variables if $SHELL |
4803 |
+ is set to /bin/sh. This should make prompt colours in |
4804 |
+ bootstrap work again. |
4805 |
+ |
4806 |
+ Move LVM stuff to checkfs to ensure that they get fscked. |
4807 |
+ This resolves bug #1552. |
4808 |
+ |
4809 |
+* rc-scripts 1.3.3 (5 Apr 2002) |
4810 |
+ |
4811 |
+ 5 Apr 2002; Martin Schlemmer <azarah@g.o>: |
4812 |
+ |
4813 |
+ Move /etc/init.d/{depscan.sh,runscript.sh,functions.sh} to /sbin. |
4814 |
+ This is done to try and ensure system integrity. |
4815 |
+ |
4816 |
+ 1 Apr 2002; Martin Schlemmer <azarah@g.o>: |
4817 |
+ |
4818 |
+ Add quotes to the "export INPUTRC=/etc/inputrc" line to resolve bug #1391. |
4819 |
+ |
4820 |
+ Add a error message to /etc/init.d/consolefont, resolving bug #1415. |
4821 |
+ |
4822 |
+ Add a bash check to the code that sets the prompt, fixing bug #1078. |
4823 |
+ |
4824 |
+* rc-scripts 1.3.2 (24 Mar 2002) |
4825 |
+ |
4826 |
+ 24 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4827 |
+ |
4828 |
+ Resolve bug #1274. Updated /etc/init.d/hostname and /etc/init.d/bootmisc |
4829 |
+ for this. |
4830 |
+ |
4831 |
+ With the "before" and "after" stuff, recursion levels was getting too high, |
4832 |
+ and with some cases, things just plain did not work as it should. Reworked |
4833 |
+ things to to lower the levels of recursion and get the order right. Updated |
4834 |
+ /etc/init.d/runscript.sh for this. |
4835 |
+ |
4836 |
+ Fixed a problem in /sbin/rc and /etc/init.d/runscript.sh where |
4837 |
+ ${svcdir}/softlevel did not always exist, but runscript.sh tried to open it. |
4838 |
+ |
4839 |
+ Enhance --quiet support. Updated /etc/init.d/functions.sh for this. |
4840 |
+ |
4841 |
+ Remove /etc/pwdb.conf, as pwdb already install a copy of this. |
4842 |
+ |
4843 |
+ Remove /etc/pam.d/{rexec,rlogin,rsh} as pam already install this. |
4844 |
+ |
4845 |
+ Added $INPUTRC to /etc/profile, since too many people keep on bugging me, |
4846 |
+ and it seems it has fallen now to my discression. |
4847 |
+ |
4848 |
+* rc-scripts 1.3.1 (23 Mar 2002) |
4849 |
+ |
4850 |
+ 23 Mar 2002; Daniel Robbins <drobbins@g.o>: init.d/net.eth0: fix for |
4851 |
+ DHCP lease release from Jim Nutt. |
4852 |
+ |
4853 |
+ 23 Mar 2002; Daniel Robbins <drobbins@g.o>: rolling a new release |
4854 |
+ since there are a lot of important bug fixes in here that are needed. |
4855 |
+ |
4856 |
+ 23 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4857 |
+ |
4858 |
+ Resolve bug #1292. |
4859 |
+ |
4860 |
+ Remove the extra 'depmod -a' in /etc/init.d/modules, thanks to |
4861 |
+ Spidler. |
4862 |
+ |
4863 |
+ 21 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4864 |
+ |
4865 |
+ Update /sbin/rc to fix a 'cat mounts' instead of the correct |
4866 |
+ version, 'cat /proc/mounts'. |
4867 |
+ |
4868 |
+ 19 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4869 |
+ |
4870 |
+ Add initial support for the --quiet flag that suppress output. |
4871 |
+ |
4872 |
+ 18 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4873 |
+ |
4874 |
+ Remove the 'try' from 'try /etc/init.d/depscan.sh' in /sbin/rc |
4875 |
+ as not all errors by depscan.sh is critical. It should be |
4876 |
+ reworked to do better error handeling. |
4877 |
+ |
4878 |
+ 14 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4879 |
+ |
4880 |
+ Fix the GID and UID of nobody and nogroup in /etc/passwd and |
4881 |
+ /etc/group to match those of Debian, FBSD and others. Thanks |
4882 |
+ to those who reported it, and Woodchip for looking up the |
4883 |
+ proper values. |
4884 |
+ |
4885 |
+ Update /etc/init.d/net.eth0 to properly down DHCP interfaces. |
4886 |
+ This resolves bug #1150, thanks to Paul Fleischer. |
4887 |
+ |
4888 |
+ 11 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4889 |
+ |
4890 |
+ Updated /etc/init.d/functions.sh not to use /usr/bin/basename, |
4891 |
+ as some users have /usr on seperate partition which is not |
4892 |
+ mounted when depscan.sh is run the first time. |
4893 |
+ |
4894 |
+ Updated the checking for more than one service providing the |
4895 |
+ same virtual function in /etc/init.d/depscan.sh. It should |
4896 |
+ be working now, and this also fix a problem that when there is no |
4897 |
+ service providing a virtual, counter was used uninitialized. |
4898 |
+ |
4899 |
+* rc-scripts 1.3.0 (10 Mar 2002) |
4900 |
+ |
4901 |
+ 10 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4902 |
+ |
4903 |
+ Resolved bug #1021; updated /etc/init.d/consolefont for this. |
4904 |
+ |
4905 |
+ Resolved bug #1029; updated /etc/init.d/net.eth0 for this. |
4906 |
+ |
4907 |
+ Resolved bug #990; updated /etc/init.d/net.eth0, /etc/init.d/netmount |
4908 |
+ and /etc/init.d/localmount for this. |
4909 |
+ |
4910 |
+ Lots of form/syntax cleanups, most things should be more |
4911 |
+ consistant now. Fixed fail detection/return values of lots of |
4912 |
+ scripts. |
4913 |
+ |
4914 |
+ Lots of cleanup/fixes in the three main scripts behind our |
4915 |
+ rc-system, /sbin/rc, /etc/init.d/depscan.sh, /etc/init.d/runscript.sh |
4916 |
+ |
4917 |
+ Fix a bug regarding a invalid $PATH for portage if /etc/init.d/functions.sh |
4918 |
+ is sourced in a ebuild. |
4919 |
+ |
4920 |
+ Fix a bug that our rc-script wrapper introduced: Global variables |
4921 |
+ in scripts no longer worked. Updated /etc/init.d/runscript.sh for |
4922 |
+ this. |
4923 |
+ |
4924 |
+ Implemented more error checking for the main startup code in /sbin/rc. |
4925 |
+ Also fixed try() for mounting /proc (maybe all mount commands). |
4926 |
+ The function worked fine in a simulated test, but in real life failed |
4927 |
+ to detect a error when mounting /proc (remember to thank Grant for |
4928 |
+ his UserMode ebuilds, and Guide). |
4929 |
+ |
4930 |
+* rc-scripts 1.2.9 (6 Mar 2002) |
4931 |
+ |
4932 |
+ 6 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4933 |
+ |
4934 |
+ General form updates and some piping fixes. |
4935 |
+ |
4936 |
+ Updated /etc/inittab, /etc/init.d/xdm and /etc/X11/startDM.sh |
4937 |
+ to fix a problem where startDM.sh would be respawned repeatedly |
4938 |
+ if xdm was not in the default runlevel. |
4939 |
+ |
4940 |
+* rc-scripts 1.2.8 (4 Mar 2002) |
4941 |
+ |
4942 |
+ 4 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4943 |
+ |
4944 |
+ Add /etc/init.d/xdm, /etc/X11/startDM.sh and updated /etc/inittab |
4945 |
+ to fix the "dead key" problem we had with xdm/gdm/kdm. We should |
4946 |
+ move them to the xfree ebuild later on when things settles down. |
4947 |
+ |
4948 |
+ Added some sanity checks to /sbin/rc, /etc/init.d/runscripts.sh. |
4949 |
+ |
4950 |
+ Added a basic $PATH to /etc/init.d/functions.sh to fix a problem |
4951 |
+ where we had a invalid $PATH on boot in some cases. |
4952 |
+ |
4953 |
+ Updated /etc/init.d/keymap and /etc/init.d/consolefont to work with |
4954 |
+ the new sys-apps/kbd package. |
4955 |
+ |
4956 |
+* rc-scripts 1.2.7 (3 Mar 2002) |
4957 |
+ |
4958 |
+ 3 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4959 |
+ |
4960 |
+ Fixed the problem of rc-scripts trying to start/stop a service multiple |
4961 |
+ times if it fails to do so. Updated /etc/init.d/runscript.sh and /sbin/rc |
4962 |
+ for this. |
4963 |
+ |
4964 |
+ Fixing some variable declarations in /etc/init.d/runscript.sh caused |
4965 |
+ /etc/init.d/net.lo to fail on stop ($IFACE was set invalid). Fixed |
4966 |
+ this. |
4967 |
+ |
4968 |
+ Added caching of the "depend() { need foo; } " lines, and updated |
4969 |
+ /etc/init.d/depscan.sh to touch the actual files less. This should |
4970 |
+ speedup dependency caching a lot, especially on slow machines. |
4971 |
+ |
4972 |
+ Updated /etc/passwd to have users with no shell defined, use /bin/false |
4973 |
+ for security. |
4974 |
+ |
4975 |
+ Update /etc/fstab to mention /dev/shm since we dont mount it anymore. |
4976 |
+ |
4977 |
+ 1 Mar 2002; Martin Schlemmer <azarah@g.o>: |
4978 |
+ |
4979 |
+ Added a wrapper for sourcing the rc-scripts to eliminate syntax errors. |
4980 |
+ Thanks to Karl Trygve Kalleberg (aka karltk) for the idea. Updated |
4981 |
+ /etc/init.d/depscan.sh, /etc/init.d/functions.sh and |
4982 |
+ /etc/init.d/runscript.sh for this (added wrap_rcscript() function). |
4983 |
+ |
4984 |
+ Removed stopping of dependent services that have current service as |
4985 |
+ a 'use'dependency ... should be less confusing now. |
4986 |
+ Updated /etc/init.d/runscript.sh for this. |
4987 |
+ |
4988 |
+ 28 Feb 2002; Martin Schlemmer <azarah@g.o>: |
4989 |
+ |
4990 |
+ Add /etc/conf.d/local.start and /etc/conf.d/local.stop for adding any misc |
4991 |
+ programs to startup. This should pretty much have /etc/init.d/ static, |
4992 |
+ except for baselayout updates, etc. |
4993 |
+ |
4994 |
+ 27 Feb 2002; Martin Schlemmer <azarah@g.o>: |
4995 |
+ |
4996 |
+ In some wierd cases, a redundent /dev/.devfsd on a unmounted /dev can cause |
4997 |
+ problems. Fixed this in /sbin/rc. |
4998 |
+ |
4999 |
+ Added the patches from Grant Goodyear (aka g2boojum) to enable us to |
5000 |
+ use a ramdisk to store the contents of ${svcdir}. Updated /sbin/rc, |
5001 |
+ /etc/init.d/functions.sh and /etc/init.d/checkroot for this. |
5002 |
+ |
5003 |
+ 26 Feb 2002; Martin Schlemmer <azarah@g.o>: |
5004 |
+ |
5005 |
+ Fix my brain dead update of the 25th. It really should keep |
5006 |
+ "gentoo=nodevfs" in mind. Also added 'get_bootparam()' to help in |
5007 |
+ retrieving kernel options. Updated /etc/init.d/functions.sh, |
5008 |
+ /etc/init.d/checkroot and /sbin/rc for this. |
5009 |
+ |
5010 |
+ Updated /etc/init.d/consolefont to work without devfs as well. |
5011 |
+ |
5012 |
+ When rebooting or shutting down, a service should not fail to stop |
5013 |
+ if a service it depends on, fails. Updated /etc/init.d/runscript.sh |
5014 |
+ for this. |
5015 |
+ |
5016 |
+ 25 Feb 2002; Martin Schlemmer <azarah@g.o>: |
5017 |
+ |
5018 |
+ Added a check if /dev is mounted when creating entries for /etc/mtab. |
5019 |
+ This should solve a invalid entry or /dev being mounted even with |
5020 |
+ 'gentoo=nodevfs' option. Updated /etc/init.d/checkroot for this. |
5021 |
+ |
5022 |
+ 17 Feb 2002: Daniel Robbins <drobbins@g.o>: Made "xfs" the default |
5023 |
+ filesystem in /etc/fstab (from ReiserFS) and removed "notail" option (it's |
5024 |
+ just in a comment now) |
5025 |
+ |
5026 |
+ 17 Feb 2002: Martin Schlemmer (azarah@g.o): |
5027 |
+ |
5028 |
+ Mmore fixes to 'after' and 'before', updated /etc/init.d/runscript.sh for |
5029 |
+ this. This should fix services not getting started in the correct order |
5030 |
+ in a tight loop, services getting stopped out of order, and some other |
5031 |
+ sanity checks. Updated rc-script.sh for updated help. |
5032 |
+ |
5033 |
+ 15 Feb 2002: Martin Schlemmer (azarah@g.o): |
5034 |
+ |
5035 |
+ Update /etc/profile to resolve bug #588. Reimplemented things a bit, |
5036 |
+ and added the 'after' type. 'before' and 'after' will only work currently |
5037 |
+ for a change of runlevel. Updated /etc/init.d/depscan.sh, |
5038 |
+ /etc/init.d/runscript.sh and /sbin/rc for this. |
5039 |
+ |
5040 |
+ 13 Feb 2002: Martin Schlemmer (azarah@g.o): |
5041 |
+ |
5042 |
+ Add some more entries to /etc/devfsd.conf to make alsa users life |
5043 |
+ easier ... thanks Tod. |
5044 |
+ |
5045 |
+ 12 Feb 2002: Martin Schlemmer (azarah@g.o): |
5046 |
+ |
5047 |
+ Some more cleanups to /etc/init.d/depscan.sh and /etc/init.d/runscript.sh. |
5048 |
+ |
5049 |
+ Fixed some services not starting again when restarting a service. |
5050 |
+ Seems simple is still the best way. |
5051 |
+ |
5052 |
+ Fixed some other problems created with feature additions and cleanups. |
5053 |
+ |
5054 |
+ 11 Feb 2002: Martin Schlemmer (azarah@g.o): |
5055 |
+ |
5056 |
+ General cleanups to /etc/init.d/depscan.sh and /etc/init.d/runscript.sh. |
5057 |
+ |
5058 |
+ Added 'before *' to /etc/init.d/checkroot to make sure it gets |
5059 |
+ started first. |
5060 |
+ |
5061 |
+ Added 'use *' to /etc/init.d/local to make sure it gets started |
5062 |
+ last. |
5063 |
+ |
5064 |
+ 10 Feb 2002: Martin Schlemmer (azarah@g.o): |
5065 |
+ |
5066 |
+ Fixed /sbin/rc to stop a service on change of runlevel if it is |
5067 |
+ in 'use' by another service. |
5068 |
+ |
5069 |
+ Added the 'provide' depend type for creating virtual services. |
5070 |
+ Updated /etc/init.d/depscan.sh for this. |
5071 |
+ |
5072 |
+ Added the 'before' depend type. This is more for changing the |
5073 |
+ order services start in. Updated /etc/init.d/depscan.sh and |
5074 |
+ /etc/init.d/functions.sh for this. |
5075 |
+ |
5076 |
+ Updated /etc/init.d/depscan.sh to work with '*' as argument for |
5077 |
+ dependency types. This can be used with 'use' and 'before' to |
5078 |
+ start a script last or first respectively. |
5079 |
+ |
5080 |
+ Added save_options() and get_options() to /etc/init.d/functions.sh |
5081 |
+ for saving misc settings between startup/shutdown. Updated |
5082 |
+ /etc/init.d/net.eth0 to use these and properly down virtual |
5083 |
+ interfaces. |
5084 |
+ |
5085 |
+ 6 Feb 2002: Martin Schlemmer (azarah@g.o): |
5086 |
+ |
5087 |
+ Updated both /etc/init.d/bootmisc and /etc/init.d/keymaps to be quiet |
5088 |
+ on no errors. |
5089 |
+ |
5090 |
+* rc-scripts 1.2.6 (6 Feb 2002) |
5091 |
+ |
5092 |
+ 2 Feb 2002: Martin Schlemmer (azarah@g.o): |
5093 |
+ |
5094 |
+ Updated /etc/net.eth0 to specify the gateway device via the $gateway |
5095 |
+ variable (something like gateway="eth0/192.168.0.1"). |
5096 |
+ |
5097 |
+ 2 Feb 2002: Martin Schlemmer (azarah@g.o): |
5098 |
+ |
5099 |
+ Added rc-script /etc/init.d/numlock, for enabling numlock at boot. |
5100 |
+ |
5101 |
+ 29 Jan 2002: Martin Schlemmer (azarah@g.o): |
5102 |
+ |
5103 |
+ Hopefully the last fix to /etc/init.d/netmount to umount cleanly. This fix |
5104 |
+ implements a retry if not successful the first time, and will kill |
5105 |
+ processess using the mount. Also small type-o fix to /etc/init.d/halt.sh. |
5106 |
+ |
5107 |
+ 27 Jan 2002: Donny Davies (woodchip@g.o): security fix to |
5108 |
+ /etc/pam.d/sshd,login,chsh: added pam_shells.so to the stack. |
5109 |
+ Fixed /etc/passwd,group for user/group mysql. |
5110 |
+ |
5111 |
+ 27 Jan 2002: Martin Schlemmer (azarah@g.o): added charset |
5112 |
+ map file support to /etc/init.d/consolefont and the setting to |
5113 |
+ /etc/rc.conf. |
5114 |
+ |
5115 |
+ 25 Jan 2002: Martin Schlemmer (azarah@g.o): fixed dircolors |
5116 |
+ in skel files to support both versions of dircolors. |
5117 |
+ |
5118 |
+ 23 Jan 2002: Martin Schlemmer (azarah@g.o): fixed bug |
5119 |
+ in the restart stuff of /etc/init.d/runscript.sh that caused |
5120 |
+ a restart of a 'net' service not to restart services again |
5121 |
+ that depended on it. |
5122 |
+ |
5123 |
+* rc-scripts 1.2.5 (20 Jan 2002) |
5124 |
+ |
5125 |
+ 20 Jan 2002: Martin Schlemmer (azarah@g.o): updated |
5126 |
+ /etc/init.d/net.eth0 to 'use' pcmcia. |
5127 |
+ |
5128 |
+ 8 Jan 2002: Martin Schlemmer (azarah@g.o): added '--sh' to |
5129 |
+ the dircolors command in /etc/skel/.bash_profile to handle cases |
5130 |
+ where bash do not export $SHELL. |
5131 |
+ |
5132 |
+ 6 Jan 2002: Martin Schlemmer (azarah@g.o): updated |
5133 |
+ /etc/init.d/runscripts.sh, /etc/init.d/net.eth0, /etc/conf.d/net and |
5134 |
+ removed /etc/init.d/net.eth0-dhcp to reflect a new 'bsd-ish' config |
5135 |
+ scheme for the net.eth* scripts. |
5136 |
+ |
5137 |
+ 6 Jan 2002: Donny Davies (woodchip@g.o): Removed email address |
5138 |
+ from manpages; no need for that.. |
5139 |
+ |
5140 |
+ 5 Jan 2002: Martin Schlemmer (azarah@g.o): fix type-o in |
5141 |
+ /etc/devfsd.conf; had 'dvd' in the cdrw stuff. |
5142 |
+ |
5143 |
+* rc-scripts 1.2.4 (30 Dec 2001) |
5144 |
+ |
5145 |
+ 30 Dec 2001: Daniel Robbins (drobbins@g.o): Changed default umask |
5146 |
+ back to 022 as it should be. |
5147 |
+ |
5148 |
+ 30 Dec 2001; Martin Schlemmer (azarah@g.o): Updated |
5149 |
+ /etc/init.d/checkfs to return 0 if the fs was successfully repaired. |
5150 |
+ |
5151 |
+ 29 Dec 2001; Donny Davies (woodchip@g.o): |
5152 |
+ sort -t: -k3,3 -n /etc/passwd,group. Ahhhh :)) |
5153 |
+ |
5154 |
+ 28 Dec 2001; Martin Schlemmer (azarah@g.o); |
5155 |
+ |
5156 |
+ Updated /etc/init.d/depscan.sh to store info about missing dependencies |
5157 |
+ of type 'need' in ${svcdir}/broken. Also updated /etc/init.d/runscript.sh |
5158 |
+ to use this when starting a script ('need' dependencies is critical for |
5159 |
+ startup). Added the broken() function to /etc/init.d/runscript.sh |
5160 |
+ to list the missing dependencies. |
5161 |
+ |
5162 |
+ Updated /etc/init.d/runscript.sh for svc_start() to have better error |
5163 |
+ checking. |
5164 |
+ |
5165 |
+ Updated /etc/init.d/functions.sh with ewend(), which is the same as |
5166 |
+ eend(), but print a warning on error, not a error. Updated |
5167 |
+ /etc/init.d/checkroot and /etc/init.d/checkfs to use this function. |
5168 |
+ |
5169 |
+ 27 Dec 2001; Martin Schlemmer (azarah@g.o); |
5170 |
+ |
5171 |
+ Update /sbin/runscript.c to run /etc/init.d/rc-help.sh if no arguments |
5172 |
+ is passed to a rc-script. |
5173 |
+ |
5174 |
+ Added /etc/init.d/rc-help.sh, simple script that prints out help for |
5175 |
+ the rc-scripts. |
5176 |
+ |
5177 |
+ 25 Dec 2001; Martin Schlemmer (azarah@g.o); |
5178 |
+ |
5179 |
+ Update /etc/init.d/shutdown.sh and /etc/init.d/reboot.sh not to force the |
5180 |
+ halt and reboot. This fixes a problem where / was not unmounted properly |
5181 |
+ in some cases. |
5182 |
+ |
5183 |
+ 24 Dec 2001; Martin Schlemmer (azarah@g.o): |
5184 |
+ |
5185 |
+ Move $svcdir to to /etc/init.d/functions.sh, and update |
5186 |
+ /etc/init.d/runscript.sh and /etc/init.d/depscan.sh for this |
5187 |
+ |
5188 |
+ Modified /etc/init.d/runscript.sh to also restart the services that |
5189 |
+ depend on a service if that service is restarted. Enhanced the |
5190 |
+ restart function to be able to have custom restart() functions in |
5191 |
+ rc-scripts. The custom restart() have to use svc_stop() and |
5192 |
+ svc_start() to restart the service. |
5193 |
+ |
5194 |
+ Add a pause function to /etc/init.d/runscript.sh. It will basically |
5195 |
+ stop a service without stopping the services that depends on that |
5196 |
+ service. |
5197 |
+ |
5198 |
+ Add a pause function to /etc/init.d/runscript.sh. It will basically stop a |
5199 |
+ service without stopping the services that depends on that service. |
5200 |
+ |
5201 |
+* rc-scripts 1.2.3 (18 Dec 2001) |
5202 |
+ |
5203 |
+ 16 Dec 2001; Martin Schlemmer (azarah@g.o): |
5204 |
+ |
5205 |
+ Moved the stuff from /sbin/init (old) to /sbin/rc (basically drop the |
5206 |
+ init wrapper we used). |
5207 |
+ |
5208 |
+ Some cleanups: take out the shm resize comment; |
5209 |
+ |
5210 |
+ remove the $wrongmount; |
5211 |
+ |
5212 |
+ remove the mountshm() function and insert it directly |
5213 |
+ where needed; |
5214 |
+ |
5215 |
+ remove the setting of $PATH as /sbin/init already do |
5216 |
+ this for us. |
5217 |
+ |
5218 |
+ Added the if statement to detect if it is the first time the 'boot' |
5219 |
+ runlevel is executed (if [ "$RUNLEVEL" = "S" ] && [ "$argv1" = "boot" ]). |
5220 |
+ $RUNLEVEL is a env var set by /sbin/init. |
5221 |
+ |
5222 |
+ Also added functionality to detect if the kernel have DEVFS support |
5223 |
+ compiled in; seems new users thinks devfs is unstable and as they do |
5224 |
+ not always read the docs, it does not get compiled in ;/ Should |
5225 |
+ make live for us a bit easier. |
5226 |
+ |
5227 |
+ 14 Dec 2001; Martin Schlemmer (azarah@g.o): |
5228 |
+ |
5229 |
+ Fixed /sbin/rc to kill a cosmetic bug in the part that stops all |
5230 |
+ the unneeded services. |
5231 |
+ |
5232 |
+* rc-scripts 1.2.2 (8 Dec 2001) |
5233 |
+ |
5234 |
+ 10 Dec 2001; Added a localhost entry in /etc/hosts. |
5235 |
+ |
5236 |
+ 8 Dec 2001; Donny Davies (woodchip@g.o): Added start-stop-daemon.c |
5237 |
+ to rc-scripts/sbin source. Moved rc-scripts/init.d/runscript.c to |
5238 |
+ rc-scripts/sbin/runscript.c. Added manpage for start-stop-daemon. |
5239 |
+ Start-stop-daemon is moved here from sysvinit by the way. There is stuff |
5240 |
+ in this ChangeLog that needs to be removed! Like the changes to hosts, |
5241 |
+ profile. /etc/{passwd,group} have minor UID and GID type fixes for |
5242 |
+ users ftp, postgres, xfs. Tweaked tarball.sh to not include CVS |
5243 |
+ directories. |
5244 |
+ |
5245 |
+ 29 Nov 2001; Donny Davies (woodchip@g.o): Added a man directory |
5246 |
+ to rc-scripts. Checked in two manpages there, one for modules.autoload.5 |
5247 |
+ and one for update-modules.8. These were adapted from Debian. Updated |
5248 |
+ tarball.sh to include the new man directory. Updated baselayout to install |
5249 |
+ these manpages. Slightly tweak the /etc/modules.autoload comments. |
5250 |
+ |
5251 |
+ 28 Nov 2001; Martin Schlemmer (azarah@g.o): |
5252 |
+ |
5253 |
+ Updated /sbin/init to work correctly with the 'gentoo=nodevfs' option, |
5254 |
+ and cleaned out old code. |
5255 |
+ |
5256 |
+ Updated /etc/init.d/bootmisc with additional lock files to clean. |
5257 |
+ |
5258 |
+ 27 Nov 2001; Martin Schlemmer (azarah@g.o): |
5259 |
+ |
5260 |
+ Updated /etc/init.d/depscan.sh for a virtual 'use' depend, called 'logger' |
5261 |
+ that can be used for services that needs to have a logger started before |
5262 |
+ they are started. Updated /etc/conf.d/basic with $SYSLOGGER that is used |
5263 |
+ to define what loggers the 'logger' depend represent. |
5264 |
+ |
5265 |
+ 26 Nov 2001; Martin Schlemmer (azarah@g.o): |
5266 |
+ |
5267 |
+ Updated /etc/passwd and /etc/group with minor fixes to pass pwck |
5268 |
+ and grpck. |
5269 |
+ |
5270 |
+ 25 Nov 2001; Martin Schlemmer (azarah@g.o): |
5271 |
+ |
5272 |
+ Changed umask in /etc/profile for the user to 077 for security. |
5273 |
+ |
5274 |
+ Added a stop() function to /etc/init.d/clock. Also removed uneeded |
5275 |
+ 'source /etc/rc.conf' line. |
5276 |
+ |
5277 |
+ Updated /etc/init.d/hostname to set the hostname to 'localhost' if |
5278 |
+ /etc/hostname is invalid. |
5279 |
+ |
5280 |
+ Updated /sbin/init to move the entries in /lib/dev-state to /dev before |
5281 |
+ running devfsd, as it did still not save settings properly. Also removed |
5282 |
+ old /dev-state/compat stuff. |
5283 |
+ |
5284 |
+ 25 Nov 2001; ncsd, the name service cache daemon script, has been removed |
5285 |
+ from the default "default" runlevel. It still exists in the archive so that |
5286 |
+ users who want/need it can add it easily. |
5287 |
+ |
5288 |
+ 25 Nov 2001; Updated the /etc/fstab; removed usbdevfs (explicitly mounted), |
5289 |
+ removed notail from the ext2 boot partition, other cleanups. |
5290 |
+ |
5291 |
+ 25 Nov 2001; Fixed init.d/clock script to work in UTC mode. |
5292 |
+ |
5293 |
+ 24 Nov 2001; Martin Schlemmer (azarah@g.o): |
5294 |
+ |
5295 |
+ Added /etc/devfsd.conf and updated /sbin/init to use a new scheme for saving |
5296 |
+ /dev permissions. Also moved /dev-state to /lib/dev-state which is a more |
5297 |
+ standard location. |
5298 |
+ |
5299 |
+ Fixed a ugly bug in /etc/init.d/depscan.sh. If a service depended on |
5300 |
+ itself, calling depscan.sh or changing runlevels cause a tempory effect |
5301 |
+ similar to a 'mini fork bomb'. Afterwards the depends was broken, and |
5302 |
+ changing runlevels did not want to work. |
5303 |
+ |
5304 |
+ Updated /etc/init.d/halt.sh to terminate and display message for devfsd. |
5305 |
+ More cosmetic than anything else, but cant hurt with the new dev-state |
5306 |
+ scheme. |
5307 |
+ |
5308 |
+ Updated /sbin/init to set the console log level to 1, so that bootup |
5309 |
+ can be much cleaner. Also updated /etc/init.d/modules not to have |
5310 |
+ a logger in it 'use' depends, as it should not be needed anymore. |
5311 |
+ |
5312 |
+ Updated /sbin/rc to check if devfsd is still running between runlevel |
5313 |
+ changes. |
5314 |
+ |
5315 |
+ Updated /etc/init.d/modules to run update-modules. We want to be sure |
5316 |
+ /etc/modules.conf is updated when running depmod -a. |
5317 |
+ |
5318 |
+ Change ftp's uid to 21 in /etc/passwd (was the same as bind). Also |
5319 |
+ added a entry for xfs (X Font Server) in /etc/passwd and /etc/group. |
5320 |
+ |
5321 |
+ Added /etc/init.d/net.ppp0, /etc/conf.d/net.ppp0 and |
5322 |
+ /usr/lib/ppp/chat-default as part of my new pppd scripts. Also |
5323 |
+ updated tarball.sh to handle ppp/chat-default. |
5324 |
+ |
5325 |
+ Added /etc/skel/.bash* to make things cleaner. |
5326 |
+ |
5327 |
+ Other minor changes. |
5328 |
+ |
5329 |
+ 17 Nov 2001; Donny Davies (woodchip@g.o): Added /etc/shells file |
5330 |
+ to rc-scripts. Can remove it from sys-libs/shadow at the next release. |
5331 |
+ |
5332 |
+* rc-scripts 1.1.8 (15 Nov 2001) |
5333 |
+ |
5334 |
+ 16 Nov 2001; removed bogus "mountall.test" script. |
5335 |
+ |
5336 |
+ 15 Nov 2001; Martin Schlemmer (azarah@g.o): |
5337 |
+ |
5338 |
+ Updated init.d/{runscript.sh,depscan.sh}, sbin/rc to the new dep being |
5339 |
+ 'use' not 'uses', as it fits better with 'need' (not 'needs'). Also |
5340 |
+ removed unneeded for loop from init.d/depscan.sh, and other fixes. Updated |
5341 |
+ names of new functions in init.d/runscript.sh to better sounding ones. |
5342 |
+ Updated init.d/modules, init.d/netmount to use 'use'. Lots of other |
5343 |
+ fixes/cleanups. |
5344 |
+ |
5345 |
+ Removed try() out of init.d/runscript.sh (why was this here ?). |
5346 |
+ |
5347 |
+ 14 Nov 2001; Martin Schlemmer (azarah@g.o): |
5348 |
+ |
5349 |
+ Now init.d/bootmisc cleans /tmp. Also creates /etc/resolv.conf if it |
5350 |
+ doesn't exist. |
5351 |
+ |
5352 |
+ init.d/hostname: Added check for a valid /etc/hostname. |
5353 |
+ |
5354 |
+ init.d/keymaps: Added check for valid $KEYMAP. |
5355 |
+ |
5356 |
+ init.d/modules: Added sysklogd, metalog, syslog-ng as 'use' deps. This |
5357 |
+ should solve Woodchip's syslog+glue issue. We just have to change the |
5358 |
+ console loglevel for metalog and syslog-ng (sysklogd already updated) not to |
5359 |
+ output info and warnings, etc to the console, then boot will be much cleaner. |
5360 |
+ Also the install guide will need changing to add the loggers to 'boot' and |
5361 |
+ not 'default' runlevel. |
5362 |
+ |
5363 |
+ init.d/mountall.test: Hopefully updated to the new rc-scripts style. Is |
5364 |
+ this really needed (I cannot see that it is used anywhere ...)? |
5365 |
+ |
5366 |
+ 13 Nov 2001; Martin Schlemmer (azarah@g.o): |
5367 |
+ |
5368 |
+ Updated init.d/runscript.sh, init.d/depscan.sh and sbin/rc with a new depend |
5369 |
+ called 'uses'. It basically have the same usage as 'need', except that it |
5370 |
+ do not start services that is not in the current and 'boot' runlevels. |
5371 |
+ |
5372 |
+ Updated init.d/netmount to use the 'uses' depend. |
5373 |
+ |
5374 |
+ 11 Nov 2001; Martin Schlemmer (azarah@g.o): |
5375 |
+ |
5376 |
+ Fixed init.d/runscript.sh not to destroy the 'need' depends in |
5377 |
+ /${svcdir}/need. This caused subsequent starting and stopping of services |
5378 |
+ not to start depends. |
5379 |
+ |
5380 |
+ 7 Nov 2001; Martin Schlemmer (azarah@g.o): |
5381 |
+ |
5382 |
+ Fixed a problem in sbin/rc where the ${svcdir}/softscripts directory got |
5383 |
+ destroyed before stopping running services scheduled to be stopped. This |
5384 |
+ with the fact that $SOFTLEVEL was set too early, caused the services to be |
5385 |
+ stopped in the wrong order. |
5386 |
+ |
5387 |
+ 30 Oct 2001; Martin Schlemmer (azarah@g.o): |
5388 |
+ |
5389 |
+ Modified init.d/netmount to check if any network filesystems is mounted. |
5390 |
+ |
5391 |
+ 29 Oct 2001; init.d/netmount: umount -art doesn't seem to work, so I added |
5392 |
+ some awk and grep magic to find all remote filesystems and umount them. |
5393 |
+ |
5394 |
+ 29 Oct 2001; Martin Schlemmer (azarah@g.o): |
5395 |
+ |
5396 |
+ A fix for checkroot (missing "/"); it now actually checks the root |
5397 |
+ filesystem. Also, a localmount cleanliness fix. |
5398 |
+ |
5399 |
+* rc-scripts 1.1.7 (18 Oct 2001) |
5400 |
+ |
5401 |
+[old changelog format follows] |
5402 |
+ |
5403 |
+ *lots of scripts; woodchip |
5404 |
+ removed old rc5 scripts from cvs |
5405 |
+ |
5406 |
+ *init.d/runscript.sh; agriffis |
5407 |
+ Added support for rc.conf and home-grown functions |
5408 |
+ |
5409 |
+ *init.d/modules; |
5410 |
+ Now correctly looks at /etc/modules.autoload |
5411 |
+ |
5412 |
+rc-scripts-1.1.6, released 15 Sep 2001 |
5413 |
+====================================== |
5414 |
+ |
5415 |
+ *init.d/runscript.sh, others |
5416 |
+ Handling of "net" dependencies resolve to all net devices in |
5417 |
+ /etc/runlevels/boot and /etc/runlevels/[curr-runlevel]. INTERFACES |
5418 |
+ variable in /etc/rc.conf has been removed. |
5419 |
+ |
5420 |
+ *init.d/runscript.sh |
5421 |
+ New "zap" option for manually resetting the state of an initscript |
5422 |
+ to stopped. |
5423 |
+ |
5424 |
+ *init.d/{samba,sysklogd,sshd} |
5425 |
+ Removed from CVS; they live in their respective packages. |
5426 |
+ |
5427 |
+rc-scripts-1.1.5, released 02 Sep 2001 |
5428 |
+==================================== |
5429 |
+ |
5430 |
+ *sbin/rc-update |
5431 |
+ New version of the rc-update command for the new initscripts. Works |
5432 |
+ similarly to the old version, except this one updates our dependency |
5433 |
+ cache. |
5434 |
+ |
5435 |
+ *init.d/functions.sh |
5436 |
+ New and better looking informational message functions (einfo, einfon). |
5437 |
+ Brand new message functions (ewarn). |
5438 |
+ |
5439 |
+ *sbin/init, init.d/checkroot |
5440 |
+ We're going back to a /proc/mounts-based mtab symlink because it's |
5441 |
+ just plain better. Appropriate changes made. |
5442 |
+ |
5443 |
+# vim:expandtab |
5444 |
|
5445 |
Added: trunk/baselayout-prefix/bin/rc-status |
5446 |
=================================================================== |
5447 |
--- trunk/baselayout-prefix/bin/rc-status (rev 0) |
5448 |
+++ trunk/baselayout-prefix/bin/rc-status 2011-03-31 14:11:17 UTC (rev 1682) |
5449 |
@@ -0,0 +1,239 @@ |
5450 |
+#!/bin/bash |
5451 |
+################################################################################ |
5452 |
+# # |
5453 |
+# Author: Sean E. Russell <ser@××××××××××××××××.com> # |
5454 |
+# Version: 1.0 # |
5455 |
+# Date: Jun 26, 2002 # |
5456 |
+# Adaptation: Mike Frysinger [SpanKY] <vapier@g.o> # |
5457 |
+# Original code was in Ruby ... recoded into bash (at syntax level) # |
5458 |
+# # |
5459 |
+# This application displays information about the RC system used by Gentoo. # |
5460 |
+# In particular, it displays a tree-like format of a run level, showing # |
5461 |
+# all of the services that are installed at that level, and what each # |
5462 |
+# service's status is (running, stopped, etc.) # |
5463 |
+# # |
5464 |
+# -a can be used to display all runlevels # |
5465 |
+# -d can be used to display service dependancies # |
5466 |
+# -u will display all unassigned services # |
5467 |
+# -s will display all services # |
5468 |
+# -h will display help # |
5469 |
+# <runlevel> is used to choose the run level for which information is # |
5470 |
+# displayed # |
5471 |
+# # |
5472 |
+# By default, rc-status only displays information about the current # |
5473 |
+# runlevel; services installed and services running. # |
5474 |
+# # |
5475 |
+################################################################################ |
5476 |
+ |
5477 |
+# grab code from functions.sh so we don't have to reproduce it |
5478 |
+source /sbin/functions.sh |
5479 |
+runleveldir=/etc/runlevels |
5480 |
+ |
5481 |
+# grab settings from conf.d/rc |
5482 |
+source "${svclib}/sh/rc-daemon.sh" |
5483 |
+ |
5484 |
+################################################################################ |
5485 |
+# Parse command line options # |
5486 |
+################################################################################ |
5487 |
+do_opt() { |
5488 |
+ case $1 in |
5489 |
+ --all|-a) |
5490 |
+ ALL=true |
5491 |
+ ;; |
5492 |
+ --depend) |
5493 |
+ DEPEND=true |
5494 |
+ ;; |
5495 |
+ --unused|-u) |
5496 |
+ ALL=true |
5497 |
+ UNUSED=true |
5498 |
+ ;; |
5499 |
+ --list|-l) |
5500 |
+ ls -1 ${runleveldir} |
5501 |
+ exit 0 |
5502 |
+ ;; |
5503 |
+ --servicelist|-s) |
5504 |
+ ALL=true |
5505 |
+ SERVICELIST=true |
5506 |
+ ;; |
5507 |
+ --nocolor|-nc) |
5508 |
+ ;; |
5509 |
+ --help|-h|-*) |
5510 |
+ echo "USAGE: $0 [command | <runlevel>]" |
5511 |
+ echo |
5512 |
+ echo "Commands:" |
5513 |
+ echo " -a, --all Show services at all run levels" |
5514 |
+ echo " -l, --list Show list of run levels" |
5515 |
+ echo " -u, --unused Show services not assigned to any run level" |
5516 |
+ echo " -s, --servicelist Show service list" |
5517 |
+ echo " -nc,--nocolor Monochrome output only" |
5518 |
+ echo " <runlevel> Show services assigned to <runlevel>" |
5519 |
+ echo |
5520 |
+ echo "If no arguments are supplied, shows services for current run level." |
5521 |
+ exit 0 |
5522 |
+ ;; |
5523 |
+ *) |
5524 |
+ runlevel=$1 |
5525 |
+ ;; |
5526 |
+ esac |
5527 |
+} |
5528 |
+for opt in "$@" ; do |
5529 |
+ do_opt ${opt} |
5530 |
+ [[ -n $2 ]] && shift |
5531 |
+done |
5532 |
+ |
5533 |
+################################################################################ |
5534 |
+# Find the current runlevel being queried. This is either something supplied # |
5535 |
+# on the command line, or pulled from softlevel # |
5536 |
+################################################################################ |
5537 |
+if [[ -z ${runlevel} ]] ; then |
5538 |
+ if [[ -e ${svcdir}/softlevel ]] ; then |
5539 |
+ runlevel=$(<${svcdir}/softlevel) |
5540 |
+ else |
5541 |
+ ewarn "Could not locate current runlevel in ${svcdir}/softlevel" |
5542 |
+ if [[ -d ${runleveldir}/single ]] ; then |
5543 |
+ runlevel=single |
5544 |
+ elif [[ -d ${runleveldir}/default ]] ; then |
5545 |
+ runlevel=default |
5546 |
+ else |
5547 |
+ eerror "Your installation is probably broken ... please \`emerge baselayout\`" |
5548 |
+ exit 1 |
5549 |
+ fi |
5550 |
+ ewarn "Assuming current runlevel is '${runlevel}'" |
5551 |
+ fi |
5552 |
+fi |
5553 |
+if [[ ! -d ${runleveldir}/${runlevel} ]] ; then |
5554 |
+ eerror "${runlevel} is not a valid run level !" |
5555 |
+ eerror "Valid runlevels (obtained from \`rc-status --list\`):" |
5556 |
+ rc-status --list |
5557 |
+ exit 1 |
5558 |
+fi |
5559 |
+ |
5560 |
+################################################################################ |
5561 |
+# Build up a hash of the services associated with each run level. In the most # |
5562 |
+# trivial case, this is simply the current runlevel. If --all was specified, # |
5563 |
+# we gather information about all of the runlevels. If --unused was # |
5564 |
+# specified, we pull info about all of the services and filter for the ones # |
5565 |
+# that don't appear in any runlevel. # |
5566 |
+################################################################################ |
5567 |
+runlevelidxs=$(ls ${runleveldir}) |
5568 |
+declare -a runlevels |
5569 |
+# For each directory in /etc/runlevels, do ... |
5570 |
+arridx=0 |
5571 |
+for level in ${runlevelidxs} ; do |
5572 |
+ if [[ ${level} == ${runlevel} || -n ${ALL} ]] ; then |
5573 |
+ runlevels[${arridx}]=$(find ${runleveldir}/${level} -maxdepth 1 -type l -printf '%f ') |
5574 |
+ let "arridx += 1" |
5575 |
+ fi |
5576 |
+done |
5577 |
+ |
5578 |
+# In case --all was specified, get a list of all the services set up in |
5579 |
+# /etc/init.d; services can be added, but not enabled, and we need to |
5580 |
+# identify these 'orphan' services. |
5581 |
+in_list() { #$1=list $2=find |
5582 |
+ for ele in $1 ; do |
5583 |
+ if [[ ${ele} == $2 ]] ; then |
5584 |
+ echo 1 |
5585 |
+ return 0 |
5586 |
+ fi |
5587 |
+ done |
5588 |
+ echo 0 |
5589 |
+ return 0 |
5590 |
+} |
5591 |
+if [[ -n ${ALL} ]] ; then |
5592 |
+ unassigned= |
5593 |
+ allservices= |
5594 |
+ for service in $(ls -1 /etc/init.d | grep -v '\.sh$') ; do |
5595 |
+ if [[ $(in_list "${runlevels[*]}" "${service}") -eq 0 ]] ; then |
5596 |
+ unassigned="${unassigned} ${service}" |
5597 |
+ fi |
5598 |
+ allservices="${allservices} ${service}" |
5599 |
+ done |
5600 |
+ runlevelidxs="${runlevelidxs} UNASSIGNED" |
5601 |
+ runlevels[${arridx}]="${unassigned}" |
5602 |
+ runlevels[${arridx}+1]="${allservices}" |
5603 |
+fi |
5604 |
+ |
5605 |
+################################################################################ |
5606 |
+# Now collect information about the status of the various services; whether # |
5607 |
+# they're started, broken, or failed. Put all of this into arrays. # |
5608 |
+################################################################################ |
5609 |
+if [[ -x ${svcdir}/started ]]; then |
5610 |
+ started=$(ls ${svcdir}/started) |
5611 |
+ # If we're root then update service statuses incase any naughty daemons |
5612 |
+ # stopped running without our say so |
5613 |
+ if [[ ${EUID} == 0 ]]; then |
5614 |
+ for service in ${started}; do |
5615 |
+ update_service_status "${service}" |
5616 |
+ done |
5617 |
+ started=$(ls ${svcdir}/started) |
5618 |
+ fi |
5619 |
+fi |
5620 |
+[[ -x ${svcdir}/starting ]] && starting=$(ls ${svcdir}/starting) |
5621 |
+[[ -x ${svcdir}/inactive ]] && inactive=$(ls ${svcdir}/inactive) |
5622 |
+[[ -x ${svcdir}/stopping ]] && stopping=$(ls ${svcdir}/stopping) |
5623 |
+ |
5624 |
+################################################################################ |
5625 |
+# Now print out the information we've gathered. We do this by going through # |
5626 |
+# the hash of 'runlevels' information, and for each String key/Array value # |
5627 |
+# pair, print the runlevel; then for each service in that runlevel, print the # |
5628 |
+# service name and its status. # |
5629 |
+################################################################################ |
5630 |
+# Define a helper method for printing the status of a service; '[ xxx ]' |
5631 |
+print_msg() { |
5632 |
+ printf " %-$((COLS - 5 - ${#3}))s%s\n" "$1" "${BRACKET}[ $2$3 ${BRACKET}]${NORMAL}" |
5633 |
+} |
5634 |
+ |
5635 |
+# if --all wasnt specified, dont print everything |
5636 |
+[[ -z ${ALL} ]] && runlevelidxs=${runlevel} |
5637 |
+if [[ -z ${UNUSED} ]] ; then |
5638 |
+ if [[ -z ${SERVICELIST} ]] ; then |
5639 |
+ arridx=0 |
5640 |
+ else |
5641 |
+ runlevelidxs="all" |
5642 |
+ let "arridx += 1" |
5643 |
+ fi |
5644 |
+else |
5645 |
+ runlevelidxs="unused" |
5646 |
+fi |
5647 |
+ |
5648 |
+if [[ -f "/etc/runlevels/${BOOTLEVEL}/.critical" ]]; then |
5649 |
+ boot_crit= |
5650 |
+ for x in $(< "/etc/runlevels/${BOOTLEVEL}/.critical"); do |
5651 |
+ boot_crit="${boot_crit} ${x##*/}" |
5652 |
+ done |
5653 |
+else |
5654 |
+ boot_crit="checkroot hostname modules checkfs localmount clock" |
5655 |
+fi |
5656 |
+ |
5657 |
+broken="" |
5658 |
+for level in ${runlevelidxs} ; do |
5659 |
+ echo "Runlevel: ${HILITE}${level}${NORMAL}" |
5660 |
+ for service in ${runlevels[${arridx}]} ; do |
5661 |
+ if [[ -d "${runleveldir}/${level}" \ |
5662 |
+ && ! -e "${runleveldir}/${level}/${service}" ]] ; then |
5663 |
+ print_msg "${service}" "${BAD}" 'broken ' |
5664 |
+ broken="${broken} ${service}" |
5665 |
+ elif [[ -n ${stopping} && $(in_list "${stopping}" "${service}") -eq 1 ]] ; then |
5666 |
+ print_msg "${service}" "${BAD}" 'stopping' |
5667 |
+ elif [[ -n ${starting} && $(in_list "${starting}" "${service}") -eq 1 ]] ; then |
5668 |
+ print_msg "${service}" "${GOOD}" 'starting' |
5669 |
+ elif [[ -n ${inactive} && $(in_list "${inactive}" "${service}") -eq 1 ]] ; then |
5670 |
+ print_msg "${service}" "${WARN}" 'inactive' |
5671 |
+ elif [[ $(in_list "${started}" "${service}") -eq 1 ]] ; then |
5672 |
+ print_msg "${service}" "${GOOD}" 'started ' |
5673 |
+ else |
5674 |
+ print_msg "${service}" "${BAD}" 'stopped ' |
5675 |
+ fi |
5676 |
+ done |
5677 |
+ let "arridx += 1" |
5678 |
+ [ -n "${UNUSED}" ] && break |
5679 |
+done |
5680 |
+ |
5681 |
+if [[ -n ${broken} ]]; then |
5682 |
+ eerror "You have some broken symbolic links as reported by the broken" |
5683 |
+ eerror "status above. This can be fixed by removing the broken service" |
5684 |
+ eerror "from its runlevel and re-adding it back using rc-update." |
5685 |
+ exit 1 |
5686 |
+else |
5687 |
+ exit 0 |
5688 |
+fi |
5689 |
|
5690 |
|
5691 |
Property changes on: trunk/baselayout-prefix/bin/rc-status |
5692 |
___________________________________________________________________ |
5693 |
Added: svn:executable |
5694 |
+ * |
5695 |
|
5696 |
Added: trunk/baselayout-prefix/etc/conf.d/bootmisc |
5697 |
=================================================================== |
5698 |
--- trunk/baselayout-prefix/etc/conf.d/bootmisc (rev 0) |
5699 |
+++ trunk/baselayout-prefix/etc/conf.d/bootmisc 2011-03-31 14:11:17 UTC (rev 1682) |
5700 |
@@ -0,0 +1,12 @@ |
5701 |
+# /etc/conf.d/bootmisc |
5702 |
+ |
5703 |
+# Put a nologin file in /etc to prevent people from logging in before |
5704 |
+# system startup is complete |
5705 |
+ |
5706 |
+DELAYLOGIN="no" |
5707 |
+ |
5708 |
+ |
5709 |
+# Should we completely wipe out /tmp or just selectively remove known |
5710 |
+# locks / files / etc... ? |
5711 |
+ |
5712 |
+WIPE_TMP="no" |
5713 |
|
5714 |
Added: trunk/baselayout-prefix/etc/conf.d/clock |
5715 |
=================================================================== |
5716 |
--- trunk/baselayout-prefix/etc/conf.d/clock (rev 0) |
5717 |
+++ trunk/baselayout-prefix/etc/conf.d/clock 2011-03-31 14:11:17 UTC (rev 1682) |
5718 |
@@ -0,0 +1,27 @@ |
5719 |
+# /etc/conf.d/clock |
5720 |
+ |
5721 |
+# Set CLOCK to "UTC" if your system clock is set to UTC (also known as |
5722 |
+# Greenwich Mean Time). If your clock is set to the local time, then |
5723 |
+# set CLOCK to "local". Note that if you dual boot with Windows, then |
5724 |
+# you should set it to "local". |
5725 |
+ |
5726 |
+CLOCK="UTC" |
5727 |
+ |
5728 |
+# If you wish to pass any other arguments to hwclock during bootup, |
5729 |
+# you may do so here. |
5730 |
+ |
5731 |
+CLOCK_OPTS="" |
5732 |
+ |
5733 |
+# If you want to set the Hardware Clock to the current System Time |
5734 |
+# during shutdown, then say "yes" here. |
5735 |
+ |
5736 |
+CLOCK_SYSTOHC="no" |
5737 |
+ |
5738 |
+ |
5739 |
+### ALPHA SPECIFIC OPTIONS ### |
5740 |
+ |
5741 |
+# If your alpha uses the SRM console, set this to "yes". |
5742 |
+SRM="no" |
5743 |
+ |
5744 |
+# If your alpha uses the ARC console, set this to "yes". |
5745 |
+ARC="no" |
5746 |
|
5747 |
Added: trunk/baselayout-prefix/etc/conf.d/consolefont |
5748 |
=================================================================== |
5749 |
--- trunk/baselayout-prefix/etc/conf.d/consolefont (rev 0) |
5750 |
+++ trunk/baselayout-prefix/etc/conf.d/consolefont 2011-03-31 14:11:17 UTC (rev 1682) |
5751 |
@@ -0,0 +1,16 @@ |
5752 |
+# /etc/conf.d/consolefont |
5753 |
+ |
5754 |
+# CONSOLEFONT specifies the default font that you'd like Linux to use on the |
5755 |
+# console. You can find a good selection of fonts in /usr/share/consolefonts; |
5756 |
+# you shouldn't specify the trailing ".psf.gz", just the font name below. |
5757 |
+# To use the default console font, comment out the CONSOLEFONT setting below. |
5758 |
+# This setting is used by the /etc/init.d/consolefont script (NOTE: if you do |
5759 |
+# not want to use it, run "rc-update del consolefont" as root). |
5760 |
+ |
5761 |
+CONSOLEFONT="default8x16" |
5762 |
+ |
5763 |
+# CONSOLETRANSLATION is the charset map file to use. Leave commented to use |
5764 |
+# the default one. Have a look in /usr/share/consoletrans for a selection of |
5765 |
+# map files you can use. |
5766 |
+ |
5767 |
+#CONSOLETRANSLATION="8859-1_to_uni" |
5768 |
|
5769 |
Added: trunk/baselayout-prefix/etc/conf.d/env_whitelist |
5770 |
=================================================================== |
5771 |
--- trunk/baselayout-prefix/etc/conf.d/env_whitelist (rev 0) |
5772 |
+++ trunk/baselayout-prefix/etc/conf.d/env_whitelist 2011-03-31 14:11:17 UTC (rev 1682) |
5773 |
@@ -0,0 +1,6 @@ |
5774 |
+# /etc/conf.d/env_whitelist: Environment whitelist for rc-system |
5775 |
+ |
5776 |
+# Specify which variables are allowed to be passed from the environment to the |
5777 |
+# rc-system. If it is not set by the environment, then the variable will be |
5778 |
+# taken from /etc/profile.env - meaning, if you need to set LANG or such, |
5779 |
+# do it in a /etc/env.d/99myownstuff file for example, and run env-update. |
5780 |
|
5781 |
Added: trunk/baselayout-prefix/etc/conf.d/hostname |
5782 |
=================================================================== |
5783 |
--- trunk/baselayout-prefix/etc/conf.d/hostname (rev 0) |
5784 |
+++ trunk/baselayout-prefix/etc/conf.d/hostname 2011-03-31 14:11:17 UTC (rev 1682) |
5785 |
@@ -0,0 +1,4 @@ |
5786 |
+# /etc/conf.d/hostname |
5787 |
+ |
5788 |
+# Set to the hostname of this machine |
5789 |
+HOSTNAME="localhost" |
5790 |
|
5791 |
Added: trunk/baselayout-prefix/etc/conf.d/keymaps |
5792 |
=================================================================== |
5793 |
--- trunk/baselayout-prefix/etc/conf.d/keymaps (rev 0) |
5794 |
+++ trunk/baselayout-prefix/etc/conf.d/keymaps 2011-03-31 14:11:17 UTC (rev 1682) |
5795 |
@@ -0,0 +1,26 @@ |
5796 |
+# /etc/conf.d/keymaps |
5797 |
+ |
5798 |
+# Use KEYMAP to specify the default console keymap. There is a complete tree |
5799 |
+# of keymaps in /usr/share/keymaps to choose from. |
5800 |
+ |
5801 |
+KEYMAP="us" |
5802 |
+ |
5803 |
+ |
5804 |
+# Should we first load the 'windowkeys' console keymap? Most x86 users will |
5805 |
+# say "yes" here. Note that non-x86 users should leave it as "no". |
5806 |
+ |
5807 |
+SET_WINDOWKEYS="no" |
5808 |
+ |
5809 |
+ |
5810 |
+# The maps to load for extended keyboards. Most users will leave this as is. |
5811 |
+ |
5812 |
+EXTENDED_KEYMAPS="" |
5813 |
+#EXTENDED_KEYMAPS="backspace keypad euro" |
5814 |
+ |
5815 |
+ |
5816 |
+# Tell dumpkeys(1) to interpret character action codes to be |
5817 |
+# from the specified character set. |
5818 |
+# This only matters if you set UNICODE="yes" in /etc/rc.conf. |
5819 |
+# For a list of valid sets, run `dumpkeys --help` |
5820 |
+ |
5821 |
+DUMPKEYS_CHARSET="" |
5822 |
|
5823 |
Added: trunk/baselayout-prefix/etc/conf.d/local.start |
5824 |
=================================================================== |
5825 |
--- trunk/baselayout-prefix/etc/conf.d/local.start (rev 0) |
5826 |
+++ trunk/baselayout-prefix/etc/conf.d/local.start 2011-03-31 14:11:17 UTC (rev 1682) |
5827 |
@@ -0,0 +1,5 @@ |
5828 |
+# /etc/conf.d/local.start |
5829 |
+ |
5830 |
+# This is a good place to load any misc programs |
5831 |
+# on startup (use &>/dev/null to hide output) |
5832 |
+ |
5833 |
|
5834 |
Added: trunk/baselayout-prefix/etc/conf.d/local.stop |
5835 |
=================================================================== |
5836 |
--- trunk/baselayout-prefix/etc/conf.d/local.stop (rev 0) |
5837 |
+++ trunk/baselayout-prefix/etc/conf.d/local.stop 2011-03-31 14:11:17 UTC (rev 1682) |
5838 |
@@ -0,0 +1,8 @@ |
5839 |
+# /etc/conf.d/local.stop |
5840 |
+ |
5841 |
+# This is a good place to unload any misc. |
5842 |
+# programs you started above. |
5843 |
+# For example, if you are using OSS and have |
5844 |
+# "/usr/local/bin/soundon" above, put |
5845 |
+# "/usr/local/bin/soundoff" here. |
5846 |
+ |
5847 |
|
5848 |
Added: trunk/baselayout-prefix/etc/conf.d/net |
5849 |
=================================================================== |
5850 |
--- trunk/baselayout-prefix/etc/conf.d/net (rev 0) |
5851 |
+++ trunk/baselayout-prefix/etc/conf.d/net 2011-03-31 14:11:17 UTC (rev 1682) |
5852 |
@@ -0,0 +1,4 @@ |
5853 |
+# This blank configuration will automatically use DHCP for any net.* |
5854 |
+# scripts in /etc/init.d. To create a more complete configuration, |
5855 |
+# please review /etc/conf.d/net.example and save your configuration |
5856 |
+# in /etc/conf.d/net (this file :]!). |
5857 |
|
5858 |
Added: trunk/baselayout-prefix/etc/conf.d/net.example |
5859 |
=================================================================== |
5860 |
--- trunk/baselayout-prefix/etc/conf.d/net.example (rev 0) |
5861 |
+++ trunk/baselayout-prefix/etc/conf.d/net.example 2011-03-31 14:11:17 UTC (rev 1682) |
5862 |
@@ -0,0 +1,840 @@ |
5863 |
+############################################################################## |
5864 |
+# QUICK-START |
5865 |
+# |
5866 |
+# The quickest start is if you want to use DHCP. |
5867 |
+# In that case, everything should work out of the box, no configuration |
5868 |
+# necessary, though the startup script will warn you that you haven't |
5869 |
+# specified anything. |
5870 |
+ |
5871 |
+# WARNING :- some examples have a mixture of IPv4 (ie 192.168.0.1) and IPv6 |
5872 |
+# (ie 4321:0:1:2:3:4:567:89ab) internet addresses. They only work if you have |
5873 |
+# the relevant kernel option enabled. So if you don't have an IPv6 enabled |
5874 |
+# kernel then remove the IPv6 address from your config. |
5875 |
+ |
5876 |
+# If you want to use a static address or use DHCP explicitly, jump |
5877 |
+# down to the section labelled INTERFACE HANDLERS. |
5878 |
+# |
5879 |
+# If you want to do anything more fancy, you should take the time to |
5880 |
+# read through the rest of this file. |
5881 |
+ |
5882 |
+############################################################################## |
5883 |
+# MODULES |
5884 |
+# |
5885 |
+# We now support modular networking scripts which means we can easily |
5886 |
+# add support for new interface types and modules while keeping |
5887 |
+# compatability with existing ones. |
5888 |
+# |
5889 |
+# Modules load by default if the package they need is installed. If |
5890 |
+# you specify a module here that doesn't have it's package installed |
5891 |
+# then you get an error stating which package you need to install. |
5892 |
+# Ideally, you only use the modules setting when you have two or more |
5893 |
+# packages installed that supply the same service. |
5894 |
+# |
5895 |
+# In other words, you probably should DO NOTHING HERE... |
5896 |
+ |
5897 |
+# Prefer ifconfig over iproute2 |
5898 |
+#modules=( "ifconfig" ) |
5899 |
+ |
5900 |
+# You can also specify other modules for an interface |
5901 |
+# In this case we prefer udhcpc over dhcpcd |
5902 |
+#modules_eth0=( "udhcpc" ) |
5903 |
+ |
5904 |
+# You can also specify which modules not to use - for example you may be |
5905 |
+# using a supplicant or linux-wlan-ng to control wireless configuration but |
5906 |
+# you still want to configure network settings per ESSID associated with. |
5907 |
+#modules=( "!iwconfig" "!wpa_supplicant" ) |
5908 |
+# IMPORTANT: If you need the above, please disable modules in that order |
5909 |
+ |
5910 |
+ |
5911 |
+############################################################################## |
5912 |
+# INTERFACE HANDLERS |
5913 |
+# |
5914 |
+# We provide two interface handlers presently: ifconfig and iproute2. |
5915 |
+# You need one of these to do any kind of network configuration. |
5916 |
+# For ifconfig support, emerge sys-apps/net-tools |
5917 |
+# For iproute2 support, emerge sys-apps/iproute2 |
5918 |
+ |
5919 |
+# If you don't specify an interface then we prefer iproute2 if it's installed |
5920 |
+# To prefer ifconfig over iproute2 |
5921 |
+#modules=( "ifconfig" ) |
5922 |
+ |
5923 |
+# For a static configuration, use something like this |
5924 |
+# (They all do exactly the same thing btw) |
5925 |
+#config_eth0=( "192.168.0.2/24" ) |
5926 |
+#config_eth0=( "192.168.0.2 netmask 255.255.255.0" ) |
5927 |
+ |
5928 |
+# We can also specify a broadcast |
5929 |
+#config_eth0=( "192.168.0.2/24 brd 192.168.0.255" ) |
5930 |
+#config_eth0=( "192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255" ) |
5931 |
+ |
5932 |
+# If you need more than one address, you can use something like this |
5933 |
+# NOTE: ifconfig creates an aliased device for each extra IPv4 address |
5934 |
+# (eth0:1, eth0:2, etc) |
5935 |
+# iproute2 does not do this as there is no need to |
5936 |
+#config_eth0=( |
5937 |
+# "192.168.0.2/24" |
5938 |
+# "192.168.0.3/24" |
5939 |
+# "192.168.0.4/24" |
5940 |
+#) |
5941 |
+# Or you can use sequence expressions |
5942 |
+#config_eth0=( "192.168.0.{2..4}/24" ) |
5943 |
+# which does the same as above. Be careful though as if you use this and |
5944 |
+# fallbacks, you have to ensure that both end up with the same number of |
5945 |
+# values otherwise your fallback won't work correctly. |
5946 |
+ |
5947 |
+# You can also use IPv6 addresses |
5948 |
+# (you should always specify a prefix length with IPv6 here) |
5949 |
+#config_eth0=( |
5950 |
+# "192.168.0.2/24" |
5951 |
+# "4321:0:1:2:3:4:567:89ab/64" |
5952 |
+# "4321:0:1:2:3:4:567:89ac/64" |
5953 |
+#) |
5954 |
+ |
5955 |
+# If you wish to keep existing addresses + routing and the interface is up, |
5956 |
+# you can specify a noop (no operation). If the interface is down or there |
5957 |
+# are no addresses assigned, then we move onto the next step (default dhcp) |
5958 |
+# This is useful when configuring your interface with a kernel command line |
5959 |
+# or similar |
5960 |
+#config_eth0=( "noop" "192.168.0.2/24" ) |
5961 |
+ |
5962 |
+# If you don't want ANY address (only useful when calling for advanced stuff) |
5963 |
+#config_eth0=( "null" ) |
5964 |
+ |
5965 |
+# Here's how to do routing if you need it |
5966 |
+#routes_eth0=( |
5967 |
+# "default via 192.168.0.1" # IPv4 default route |
5968 |
+# "10.0.0.0/8 via 192.168.0.1" # IPv4 subnet route |
5969 |
+# "::/0" # IPv6 unicast |
5970 |
+#) |
5971 |
+ |
5972 |
+# If a specified module fails (like dhcp - see below), you can specify a |
5973 |
+# fallback like so |
5974 |
+#fallback_eth0=( "192.168.0.2 netmask 255.255.255.0" ) |
5975 |
+#fallback_route_eth0=( "default via 192.168.0.1" ) |
5976 |
+ |
5977 |
+# NOTE: fallback entry must match the entry location in config_eth0 |
5978 |
+# As such you can only have one fallback route. |
5979 |
+ |
5980 |
+# Some users may need to alter the MTU - here's how |
5981 |
+#mtu_eth0="1500" |
5982 |
+ |
5983 |
+############################################################################## |
5984 |
+# OPTIONAL MODULES |
5985 |
+ |
5986 |
+# INTERFACE RENAMING |
5987 |
+# There is no consistent device renaming scheme for Linux. |
5988 |
+# The preferred way of naming devices is via the kernel module directly or |
5989 |
+# by using udev (http://www.reactivated.net/udevrules.php) |
5990 |
+ |
5991 |
+# If you are unable to write udev rules, then we do provide a way of renaming |
5992 |
+# the interface based on it's MAC address, but it is not optimal. |
5993 |
+# Here is how to rename an interface whose MAC address is 00:11:22:33:44:55 |
5994 |
+# to foo1 |
5995 |
+#rename_001122334455="foo1" |
5996 |
+ |
5997 |
+# You can also do this based on current device name - although this is not |
5998 |
+# recommended. Here we rename eth1 to foo2. |
5999 |
+#rename_eth1="foo2" |
6000 |
+ |
6001 |
+#----------------------------------------------------------------------------- |
6002 |
+# WIRELESS (802.11 support) |
6003 |
+# Wireless can be provided by iwconfig or wpa_supplicant |
6004 |
+ |
6005 |
+# iwconfig |
6006 |
+# emerge net-wireless/wireless-tools |
6007 |
+# Wireless options are held in /etc/conf.d/wireless - but could be here too |
6008 |
+# Consult the sample file /etc/conf.d/wireless.example for instructions |
6009 |
+# iwconfig is the default |
6010 |
+ |
6011 |
+# wpa_supplicant |
6012 |
+# emerge net-wireless/wpa-supplicant |
6013 |
+# Wireless options are held in /etc/wpa_supplicant.conf |
6014 |
+# Consult the sample file /etc/wpa_supplicant.conf.example for instructions |
6015 |
+# To choose wpa_supplicant over iwconfig |
6016 |
+#modules=( "wpa_supplicant" ) |
6017 |
+# To configure wpa_supplicant |
6018 |
+#wpa_supplicant_eth0="-Dwext" # For generic wireless |
6019 |
+#wpa_supplicant_ath0="-Dmadwifi" # For Atheros based cards |
6020 |
+# Consult wpa_supplicant for more drivers |
6021 |
+# By default don't wait for wpa_suppliant to associate and authenticate. |
6022 |
+# If you would like to, so can specify how long in seconds |
6023 |
+#associate_timeout_eth0=60 |
6024 |
+# A value of 0 means wait forever. |
6025 |
+ |
6026 |
+# GENERIC WIRELESS OPTIONS |
6027 |
+# PLEASE READ THE INSTRUCTIONS IN /etc/conf.d/wireless.example FOR |
6028 |
+# HOW TO USE THIS ESSID VARIABLE |
6029 |
+# You can also override any settings found here per ESSID - which is very |
6030 |
+# handy if you use different networks a lot |
6031 |
+#config_ESSID=( "dhcp" ) |
6032 |
+#dhcpcd_ESSID="-t 5" |
6033 |
+ |
6034 |
+# Setting name/domain server causes /etc/resolv.conf to be overwritten |
6035 |
+# Note that if DHCP is used, and you want this to take precedence then |
6036 |
+# set dhcp_ESSID="nodns" |
6037 |
+#dns_servers_ESSID=( "192.168.0.1" "192.168.0.2" ) |
6038 |
+#dns_domain_ESSID="some.domain" |
6039 |
+#dns_search_ESSID="search.this.domain search.that.domain" |
6040 |
+# Please check the man page for resolv.conf for more information |
6041 |
+# as domain and search are mutually exclusive. |
6042 |
+ |
6043 |
+# You can also override any settings found here per MAC address of the AP |
6044 |
+# in case you use Access Points with the same ESSID but need different |
6045 |
+# networking configs. Below is an example - of course you use the same |
6046 |
+# method with other variables |
6047 |
+#mac_config_001122334455=( "dhcp" ) |
6048 |
+#mac_dhcpcd_001122334455="-t 10" |
6049 |
+#mac_dns_servers_001122334455=( "192.168.0.1" "192.168.0.2" ) |
6050 |
+ |
6051 |
+# When an interface has been associated with an Access Point, a global |
6052 |
+# variable called ESSID is set to the Access Point's ESSID for use in the |
6053 |
+# pre/post user functions below (although it's not available in preup as you |
6054 |
+# won't have associated then) |
6055 |
+ |
6056 |
+# If you're using anything else to configure wireless on your interface AND |
6057 |
+# you have installed any of the above packages, you need to disable them |
6058 |
+#modules=( "!iwconfig" "!wpa_supplicant" ) |
6059 |
+ |
6060 |
+#----------------------------------------------------------------------------- |
6061 |
+# DHCP |
6062 |
+# DHCP can be provided by dhclient, dhcpcd, pump or udhcpc. |
6063 |
+# |
6064 |
+# dhclient: emerge net-misc/dhcp |
6065 |
+# dhcpcd: emerge net-misc/dhcpcd |
6066 |
+# pump: emerge net-misc/pump |
6067 |
+# udhcpc: emerge net-misc/udhcp |
6068 |
+ |
6069 |
+# If you have more than one DHCP client installed, you need to specify which |
6070 |
+# one to use - otherwise we default to dhcpcd if available. |
6071 |
+#modules=( "dhclient" ) # to select dhclient over dhcpcd |
6072 |
+# |
6073 |
+# Notes: |
6074 |
+# - All clients send the current hostname to the DHCP server by default |
6075 |
+# - dhcpcd does not daemonize when the lease time is infinite |
6076 |
+# - udhcp-0.9.3-r3 and earlier do not support getting NTP servers |
6077 |
+# - pump does not support getting NIS servers |
6078 |
+# - DHCP tends to erase any existing device information - so add |
6079 |
+# static addresses after dhcp if you need them |
6080 |
+# - dhclient and udhcpc can set other resolv.conf options such as "option" |
6081 |
+# and "sortlist"- see the System module for more details |
6082 |
+ |
6083 |
+# Regardless of which DHCP client you prefer, you configure them the |
6084 |
+# same way using one of following depending on which interface modules |
6085 |
+# you're using. |
6086 |
+#config_eth0=( "dhcp" ) |
6087 |
+ |
6088 |
+# For passing custom options to dhcpcd use something like the following. This |
6089 |
+# example reduces the timeout for retrieving an address from 60 seconds (the |
6090 |
+# default) to 10 seconds. |
6091 |
+#dhcpcd_eth0="-t 10" |
6092 |
+ |
6093 |
+# dhclient, udhcpc and pump don't have many runtime options |
6094 |
+# You can pass options to them in a similar manner to dhcpcd though |
6095 |
+#dhclient_eth0="..." |
6096 |
+#udhcpc_eth0="..." |
6097 |
+#pump_eth0="..." |
6098 |
+ |
6099 |
+# GENERIC DHCP OPTIONS |
6100 |
+# Set generic DHCP options like so |
6101 |
+#dhcp_eth0="release nodns nontp nonis nogateway nosendhost" |
6102 |
+ |
6103 |
+# This tells the dhcp client to release it's lease when it stops, not to |
6104 |
+# overwrite dns, ntp and nis settings, not to set a default route and not to |
6105 |
+# send the current hostname to the dhcp server and when it starts. |
6106 |
+# You can use any combination of the above options - the default is not to |
6107 |
+# use any of them. |
6108 |
+ |
6109 |
+#----------------------------------------------------------------------------- |
6110 |
+# For APIPA support, emerge net-misc/iputils or net-analyzer/arping |
6111 |
+ |
6112 |
+# APIPA is a module that tries to find a free address in the range |
6113 |
+# 169.254.0.0-169.254.255.255 by arping a random address in that range on the |
6114 |
+# interface. If no reply is found then we assign that address to the interface |
6115 |
+ |
6116 |
+# This is only useful for LANs where there is no DHCP server and you don't |
6117 |
+# connect directly to the internet. |
6118 |
+#config_eth0=( "dhcp" ) |
6119 |
+#fallback_eth0=( "apipa" ) |
6120 |
+ |
6121 |
+#----------------------------------------------------------------------------- |
6122 |
+# ARPING Gateway configuration |
6123 |
+# and |
6124 |
+# Automatic Private IP Addressing (APIPA) |
6125 |
+# For arpingnet / apipa support, emerge net-misc/iputils or net-analyzer/arping |
6126 |
+# |
6127 |
+# This is a module that tries to find a gateway IP. If it exists then we use |
6128 |
+# that gateways configuration for our own. For the configuration variables |
6129 |
+# simply ensure that each octet is zero padded and the dots are removed. |
6130 |
+# Below is an example. |
6131 |
+# |
6132 |
+#gateways_eth0="192.168.0.1 10.0.0.1" |
6133 |
+#config_192168000001=( "192.168.0.2/24" ) |
6134 |
+#routes_192168000001=( "default via 192.168.0.1" ) |
6135 |
+#dns_servers_192168000001=( "192.168.0.1" ) |
6136 |
+#config_010000000001=( "10.0.0.254/8" ) |
6137 |
+#routes_010000000001=( "default via 10.0.0.1" ) |
6138 |
+#dns_servers_010000000001=( "10.0.0.1" ) |
6139 |
+ |
6140 |
+# We can also specify a specific MAC address for each gateway if different |
6141 |
+# networks have the same gateway. |
6142 |
+#gateways_eth0="192.168.0.1,00:11:22:AA:BB:CC 10.0.0.1,33:44:55:DD:EE:FF" |
6143 |
+#config_192168000001_001122AABBCC=( "192.168.0.2/24" ) |
6144 |
+#routes_192168000001_001122AABBCC=( "default via 192.168.0.1" ) |
6145 |
+#dns_servers_192168000001_001122AABBCC=( "192.168.0.1" ) |
6146 |
+#config_010000000001_334455DDEEFF=( "10.0.0.254/8" ) |
6147 |
+#routes_010000000001_334455DDEEFF=( "default via 10.0.0.1" ) |
6148 |
+#dns_servers_010000000001_334455DDEEFF=( "10.0.0.1" ) |
6149 |
+ |
6150 |
+# If we don't find any gateways (or there are none configured) then we try and |
6151 |
+# use APIPA to find a free address in the range 169.254.0.0-169.254.255.255 |
6152 |
+# by arping a random address in that range on the interface. If no reply is |
6153 |
+# found then we assign that address to the interface. |
6154 |
+ |
6155 |
+# This is only useful for LANs where there is no DHCP server. |
6156 |
+#config_eth0=( "arping" ) |
6157 |
+ |
6158 |
+# or if no DHCP server can be found |
6159 |
+#config_eth0=( "dhcp" ) |
6160 |
+#fallback_eth0=( "arping" ) |
6161 |
+ |
6162 |
+# NOTE: We default to sleeping for 1 second the first time we attempt an |
6163 |
+# arping to give the interface time to settle on the LAN. This appears to |
6164 |
+# be a good default for most instances, but if not you can alter it here. |
6165 |
+#arping_sleep=5 |
6166 |
+#arping_sleep_lan=7 |
6167 |
+ |
6168 |
+# NOTE: We default to waiting 3 seconds to get an arping response. You can |
6169 |
+# change the default wait like so. |
6170 |
+#arping_wait=3 |
6171 |
+#arping_wait_lan=2 |
6172 |
+ |
6173 |
+#----------------------------------------------------------------------------- |
6174 |
+# VLAN (802.1q support) |
6175 |
+# For VLAN support, emerge net-misc/vconfig |
6176 |
+ |
6177 |
+# Specify the VLAN numbers for the interface like so |
6178 |
+# Please ensure your VLAN IDs are NOT zero-padded |
6179 |
+#vlans_eth0="1 2" |
6180 |
+ |
6181 |
+# You may not want to assign an IP the the physical interface, but we still |
6182 |
+# need it up. |
6183 |
+#config_eth0=( "null" ) |
6184 |
+ |
6185 |
+# You can also configure the VLAN - see for vconfig man page for more details |
6186 |
+#vconfig_eth0=( "set_name_type VLAN_PLUS_VID_NO_PAD" ) |
6187 |
+#vconfig_vlan1=( "set_flag 1" "set_egress_map 2 6" ) |
6188 |
+#config_vlan1=( "172.16.3.1 netmask 255.255.254.0" ) |
6189 |
+#config_vlan2=( "172.16.2.1 netmask 255.255.254.0" ) |
6190 |
+ |
6191 |
+# NOTE: Vlans can be configured with a . in their interface names |
6192 |
+# When configuring vlans with this name type, you need to replace . with a _ |
6193 |
+#config_eth0.1=( "dhcp" ) - does not work |
6194 |
+#config_eth0_1=( "dhcp" ) - does work |
6195 |
+ |
6196 |
+# NOTE: Vlans are controlled by their physical interface and not per vlan |
6197 |
+# This means you do not need to create init scripts in /etc/init.d for each |
6198 |
+# vlan, you must need to create one for the physical interface. |
6199 |
+# If you wish to control the configuration of each vlan through a separate |
6200 |
+# script, or wish to rename the vlan interface to something that vconfig |
6201 |
+# cannot then you need to do this. |
6202 |
+#vlan_start_eth0="no" |
6203 |
+ |
6204 |
+# If you do the above then you may want to depend on eth0 like so |
6205 |
+# RC_NEED_vlan1="net.eth0" |
6206 |
+# NOTE: depend functions only work in /etc/conf.d/net |
6207 |
+# and not in profile configs such as /etc/conf.d/net.foo |
6208 |
+ |
6209 |
+#----------------------------------------------------------------------------- |
6210 |
+# Bonding |
6211 |
+# For link bonding/trunking emerge net-misc/ifenslave |
6212 |
+ |
6213 |
+# To bond interfaces together |
6214 |
+#slaves_bond0="eth0 eth1 eth2" |
6215 |
+#config_bond0=( "null" ) # You may not want to assign an IP the the bond |
6216 |
+ |
6217 |
+# If any of the slaves require extra configuration - for example wireless or |
6218 |
+# ppp devices - we need to depend function on the bonded interfaces |
6219 |
+#RC_NEED_bond0="net.eth0 net.eth1" |
6220 |
+ |
6221 |
+ |
6222 |
+#----------------------------------------------------------------------------- |
6223 |
+# Classical IP over ATM |
6224 |
+# For CLIP support emerge net-dialup/linux-atm |
6225 |
+ |
6226 |
+# Ensure that you have /etc/atmsigd.conf setup correctly |
6227 |
+# Now setup each clip interface like so |
6228 |
+#clip_atm0=( "peer_ip [if.]vpi.vci [opts]" ... ) |
6229 |
+# where "peer_ip" is the IP address of a PVC peer (in case of an ATM connection |
6230 |
+# with your ISP, your only peer is usually the ISP gateway closest to you), |
6231 |
+# "if" is the number of the ATM interface which will carry the PVC, "vpi.vci" |
6232 |
+# is the ATM VC address, and "opts" may optionally specify VC parameters like |
6233 |
+# qos, pcr, and the like (see "atmarp -s" for further reference). Please also |
6234 |
+# note quoting: it is meant to distinguish the VCs you want to create. You may, |
6235 |
+# in example, create an atm0 interface to more peers, like this: |
6236 |
+#clip_atm0=( "1.1.1.254 0.8.35" "1.1.1.253 1.8.35" ) |
6237 |
+ |
6238 |
+# By default, the PVC will use the LLC/SNAP encapsulation. If you rather need a |
6239 |
+# null encapsulation (aka "VC mode"), please add the keyword "null" to opts. |
6240 |
+ |
6241 |
+ |
6242 |
+#----------------------------------------------------------------------------- |
6243 |
+# PPP |
6244 |
+# For PPP support, emerge net-dialup/ppp |
6245 |
+# PPP is used for most dialup connections, including ADSL. |
6246 |
+# The older ADSL module is documented below, but you are encouraged to try |
6247 |
+# this module first. |
6248 |
+# |
6249 |
+# You need to create the PPP net script yourself. Make it like so |
6250 |
+#ln -s net.lo /etc/init.d/net.ppp0 |
6251 |
+# |
6252 |
+# We have to instruct ppp0 to actually use ppp |
6253 |
+#config_ppp0=( "ppp" ) |
6254 |
+# |
6255 |
+# Each PPP interface requires an interface to use as a "Link" |
6256 |
+#link_ppp0="/dev/ttyS0" # Most PPP links will use a serial port |
6257 |
+#link_ppp0="eth0" # PPPoE requires an ethernet interface |
6258 |
+#link_ppp0="[itf.]vpi.vci" # PPPoA requires the ATM VC's address |
6259 |
+#link_ppp0="/dev/null" # ISDN links should have this |
6260 |
+#link_ppp0="pty 'your_link_command'" # PPP links over ssh, rsh, etc |
6261 |
+# |
6262 |
+# Here you should specify what pppd plugins you want to use |
6263 |
+# Available plugins are: pppoe, pppoa, capi, dhcpc, minconn, radius, |
6264 |
+# radattr, radrealms and winbind |
6265 |
+#plugins_ppp0=( |
6266 |
+# "pppoe" # Required plugin for PPPoE |
6267 |
+# "pppoa vc-encaps" # Required plugin for PPPoA with an option |
6268 |
+# "capi" # Required plugin for ISDN |
6269 |
+#) |
6270 |
+# |
6271 |
+# PPP requires at least a username. You can optionally set a password here too |
6272 |
+# If you don't, then it will use the password specified in /etc/ppp/*-secrets |
6273 |
+# against the specified username |
6274 |
+#username_ppp0='user' |
6275 |
+#password_ppp0='password' |
6276 |
+# NOTE: You can set a blank password like so |
6277 |
+#password_ppp0= |
6278 |
+# |
6279 |
+# The PPP daemon has many options you can specify - although there are many |
6280 |
+# and may seem daunting, it is recommended that you read the pppd man page |
6281 |
+# before enabling any of them |
6282 |
+#pppd_ppp0=( |
6283 |
+# "maxfail 0" # WARNING: It's not recommended you use change this |
6284 |
+# # if you don't specify maxfail then we assume 0 |
6285 |
+# "updetach" # If not set, "/etc/init.d/net.ppp0 start" will return |
6286 |
+# # immediately, without waiting the link to come up |
6287 |
+# # for the first time. |
6288 |
+# # Do not use it for dial-on-demand links! |
6289 |
+# "debug" # Enables syslog debugging |
6290 |
+# "noauth" # Do not require the peer to authenticate itself |
6291 |
+# "defaultroute" # Make this PPP interface the default route |
6292 |
+# "usepeerdns" # Use the DNS settings provided by PPP |
6293 |
+# |
6294 |
+# On demand options |
6295 |
+# "demand" # Enable dial on demand |
6296 |
+# "idle 30" # Link goes down after 30 seconds of inactivity |
6297 |
+# "10.112.112.112:10.112.112.113" # Phony IP addresses |
6298 |
+# "ipcp-accept-remote" # Accept the peers idea of remote address |
6299 |
+# "ipcp-accept-local" # Accept the peers idea of local address |
6300 |
+# "holdoff 3" # Wait 3 seconds after link dies before re-starting |
6301 |
+# |
6302 |
+# Dead peer detection |
6303 |
+# "lcp-echo-interval 15" # Send a LCP echo every 15 seconds |
6304 |
+# "lcp-echo-failure 3" # Make peer dead after 3 consective |
6305 |
+# # echo-requests |
6306 |
+# |
6307 |
+# Compression options - use these to completely disable compression |
6308 |
+# noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp |
6309 |
+# |
6310 |
+# Dial-up settings |
6311 |
+# "lock" # Lock serial port |
6312 |
+# "115200" # Set the serial port baud rate |
6313 |
+# "modem crtscts" # Enable hardware flow control |
6314 |
+# "192.168.0.1:192.168.0.2" # Local and remote IP addresses |
6315 |
+#) |
6316 |
+# |
6317 |
+# Dial-up PPP users need to specify at least one telephone number |
6318 |
+#phone_number_ppp0=( "12345689" ) # Maximum 2 phone numbers are supported |
6319 |
+# They will also need a chat script - here's a good one |
6320 |
+#chat_ppp0=( |
6321 |
+# 'ABORT' 'BUSY' |
6322 |
+# 'ABORT' 'ERROR' |
6323 |
+# 'ABORT' 'NO ANSWER' |
6324 |
+# 'ABORT' 'NO CARRIER' |
6325 |
+# 'ABORT' 'NO DIALTONE' |
6326 |
+# 'ABORT' 'Invalid Login' |
6327 |
+# 'ABORT' 'Login incorrect' |
6328 |
+# 'TIMEOUT' '5' |
6329 |
+# '' 'ATZ' |
6330 |
+# 'OK' 'AT' # Put your modem initialization string here |
6331 |
+# 'OK' 'ATDT\T' |
6332 |
+# 'TIMEOUT' '60' |
6333 |
+# 'CONNECT' '' |
6334 |
+# 'TIMEOUT' '5' |
6335 |
+# '~--' '' |
6336 |
+#) |
6337 |
+ |
6338 |
+# If the link require extra configuration - for example wireless or |
6339 |
+# RFC 268 bridge - we need to depend on the bridge so they get |
6340 |
+# configured correctly. |
6341 |
+#RC_NEED_ppp0="net.nas0" |
6342 |
+ |
6343 |
+#----------------------------------------------------------------------------- |
6344 |
+# ADSL |
6345 |
+# For ADSL support, emerge net-dialup/rp-pppoe |
6346 |
+# WARNING: This ADSL module is being deprecated in favour of the PPP module |
6347 |
+# above. |
6348 |
+# You should make the following settings and also put your |
6349 |
+# username/password information in /etc/ppp/pap-secrets |
6350 |
+ |
6351 |
+# Configure the interface to use ADSL |
6352 |
+#config_eth0=( "adsl" ) |
6353 |
+ |
6354 |
+# You probably won't need to edit /etc/ppp/pppoe.conf if you set this |
6355 |
+#adsl_user_eth0="my-adsl-username" |
6356 |
+ |
6357 |
+#----------------------------------------------------------------------------- |
6358 |
+# ISDN |
6359 |
+# For ISDN support, emerge net-dialup/isdn4k-utils |
6360 |
+# You should make the following settings and also put your |
6361 |
+# username/password information in /etc/ppp/pap-secrets |
6362 |
+ |
6363 |
+# Configure the interface to use ISDN |
6364 |
+#config_ippp0=( "dhcp" ) |
6365 |
+# It's important to specify dhcp if you need it! |
6366 |
+#config_ippp0=( "192.168.0.1/24" ) |
6367 |
+# Otherwise, you can use a static IP |
6368 |
+ |
6369 |
+# NOTE: The interface name must be either ippp or isdn followed by a number |
6370 |
+ |
6371 |
+# You may need this option to set the default route |
6372 |
+#ipppd_eth0="defaultroute" |
6373 |
+ |
6374 |
+#----------------------------------------------------------------------------- |
6375 |
+# MAC changer |
6376 |
+# To set a specific MAC address |
6377 |
+#mac_eth0="00:11:22:33:44:55" |
6378 |
+ |
6379 |
+# For changing MAC addresses using the below, emerge net-analyzer/macchanger |
6380 |
+# - to randomize the last 3 bytes only |
6381 |
+#mac_eth0="random-ending" |
6382 |
+# - to randomize between the same physical type of connection (e.g. fibre, |
6383 |
+# copper, wireless) , all vendors |
6384 |
+#mac_eth0="random-samekind" |
6385 |
+# - to randomize between any physical type of connection (e.g. fibre, copper, |
6386 |
+# wireless) , all vendors |
6387 |
+#mac_eth0="random-anykind" |
6388 |
+# - full randomization - WARNING: some MAC addresses generated by this may NOT |
6389 |
+# act as expected |
6390 |
+#mac_eth0="random-full" |
6391 |
+# custom - passes all parameters directly to net-analyzer/macchanger |
6392 |
+#mac_eth0="some custom set of parameters" |
6393 |
+ |
6394 |
+# You can also set other options based on the MAC address of your network card |
6395 |
+# Handy if you use different docking stations with laptops |
6396 |
+#config_001122334455=( "dhcp" ) |
6397 |
+ |
6398 |
+#----------------------------------------------------------------------------- |
6399 |
+# TUN/TAP |
6400 |
+# For TUN/TAP support emerge net-misc/openvpn or sys-apps/usermode-utilities |
6401 |
+# |
6402 |
+# You must specify if we're a tun or tap device. Then you can give it any |
6403 |
+# name you like - such as vpn |
6404 |
+#tuntap_vpn="tun" |
6405 |
+#config_tun1=( "192.168.0.1/24") |
6406 |
+ |
6407 |
+# Or stick wit the generic names - like tap0 |
6408 |
+#tuntap_tap0="tap" |
6409 |
+#config_tap0=( "192.168.0.1/24") |
6410 |
+ |
6411 |
+# For passing custom options to tunctl use something like the following. This |
6412 |
+# example sets the owner to adm |
6413 |
+#tunctl_tun1="-u adm" |
6414 |
+# When using openvpn, there are no options |
6415 |
+ |
6416 |
+#----------------------------------------------------------------------------- |
6417 |
+# Bridging (802.1d) |
6418 |
+# For bridging support emerge net-misc/bridge-utils |
6419 |
+ |
6420 |
+# To add ports to bridge br0 |
6421 |
+#bridge_br0="eth0 eth1" |
6422 |
+# or dynamically add them when the interface comes up |
6423 |
+#bridge_add_eth0="br0" |
6424 |
+#bridge_add_eth1="br0" |
6425 |
+ |
6426 |
+# You need to configure the ports to null values so dhcp does not get started |
6427 |
+#config_eth0=( "null" ) |
6428 |
+#config_eth1=( "null" ) |
6429 |
+ |
6430 |
+# Finally give the bridge an address - dhcp or a static IP |
6431 |
+#config_br0=( "dhcp" ) # may not work when adding ports dynamically |
6432 |
+#config_br0=( "192.168.0.1/24" ) |
6433 |
+ |
6434 |
+# If any of the ports require extra configuration - for example wireless or |
6435 |
+# ppp devices - we need to depend on them like so. |
6436 |
+#RC_NEED_br0="net.eth0 net.eth1" |
6437 |
+ |
6438 |
+# Below is an example of configuring the bridge |
6439 |
+# Consult "man brctl" for more details |
6440 |
+#brctl_br0=( "setfd 0" "sethello 0" "stp off" ) |
6441 |
+ |
6442 |
+#----------------------------------------------------------------------------- |
6443 |
+# RFC 2684 Bridge Support |
6444 |
+# For RFC 2684 bridge support emerge net-misc/br2684ctl |
6445 |
+ |
6446 |
+# Interface names have to be of the form nas0, nas1, nas2, etc. |
6447 |
+# You have to specify a VPI and VCI for the interface like so |
6448 |
+#br2684ctl_nas0="-a 0.38" # UK VPI and VCI |
6449 |
+ |
6450 |
+# You may want to configure the encapsulation method as well by adding the -e |
6451 |
+# option to the command above (may need to be before the -a command) |
6452 |
+# -e 0 # LLC (default) |
6453 |
+# -e 1 # VC mux |
6454 |
+ |
6455 |
+# Then you can configure the interface as normal |
6456 |
+#config_nas0=( "192.168.0.1/24" ) |
6457 |
+ |
6458 |
+#----------------------------------------------------------------------------- |
6459 |
+# Tunnelling |
6460 |
+# WARNING: For tunnelling it is highly recommended that you |
6461 |
+# emerge sys-apps/iproute2 |
6462 |
+# |
6463 |
+# For GRE tunnels |
6464 |
+#iptunnel_vpn0="mode gre remote 207.170.82.1 key 0xffffffff ttl 255" |
6465 |
+ |
6466 |
+# For IPIP tunnels |
6467 |
+#iptunnel_vpn0="mode ipip remote 207.170.82.2 ttl 255" |
6468 |
+ |
6469 |
+# To configure the interface |
6470 |
+#config_vpn0=( "192.168.0.2 pointopoint 192.168.1.2" ) # ifconfig style |
6471 |
+#config_vpn0=( "192.168.0.2 peer 192.168.1.1" ) # iproute2 style |
6472 |
+ |
6473 |
+# 6to4 Tunnels allow IPv6 to work over IPv4 addresses, provided you |
6474 |
+# have a non-private address configured on an interface. |
6475 |
+# link_6to4="eth0" # Interface to base it's addresses on |
6476 |
+# config_6to4=( "ip6to4" ) |
6477 |
+# You may want to depend on eth0 like so |
6478 |
+#RC_NEED_6to4="net.eth0" |
6479 |
+# To ensure that eth0 is configured before 6to4. Of course, the tunnel could be |
6480 |
+# any name and this also works for any configured interface. |
6481 |
+# NOTE: If you're not using iproute2 then your 6to4 tunnel has to be called |
6482 |
+# sit0 - otherwise use a different name like 6to4 in the example above. |
6483 |
+ |
6484 |
+ |
6485 |
+#----------------------------------------------------------------------------- |
6486 |
+# System |
6487 |
+# For configuring system specifics such as domain, dns, ntp and nis servers |
6488 |
+# It's rare that you would need todo this, but you can anyway. |
6489 |
+# This is most benefit to wireless users who don't use DHCP so they can change |
6490 |
+# their configs based on ESSID. See wireless.example for more details |
6491 |
+ |
6492 |
+# To use dns settings such as these, dns_servers_eth0 must be set! |
6493 |
+# If you omit the _eth0 suffix, then it applies to all interfaces unless |
6494 |
+# overridden by the interface suffix. |
6495 |
+#dns_domain_eth0="your.domain" |
6496 |
+#dns_servers_eth0="192.168.0.2 192.168.0.3" |
6497 |
+#dns_search_eth0="this.domain that.domain" |
6498 |
+#dns_options_eth0=( "timeout 1" "rotate" ) |
6499 |
+#dns_sortlist_eth0="130.155.160.0/255.255.240.0 130.155.0.0" |
6500 |
+# See the man page for resolv.conf for details about the options and sortlist |
6501 |
+# directives |
6502 |
+ |
6503 |
+#ntp_servers_eth0="192.168.0.2 192.168.0.3" |
6504 |
+ |
6505 |
+#nis_domain_eth0="domain" |
6506 |
+#nis_servers_eth0="192.168.0.2 192.168.0.3" |
6507 |
+ |
6508 |
+#----------------------------------------------------------------------------- |
6509 |
+# Cable in/out detection |
6510 |
+# Sometimes the cable is in, others it's out. Obviously you don't want to |
6511 |
+# restart net.eth0 every time when you plug it in either. |
6512 |
+# |
6513 |
+# netplug is a package that detects this and requires no extra configuration |
6514 |
+# on your part. |
6515 |
+# emerge sys-apps/netplug |
6516 |
+# or |
6517 |
+# emerge sys-apps/ifplugd |
6518 |
+# and you're done :) |
6519 |
+ |
6520 |
+# By default we don't wait for netplug/ifplugd to configure the interface. |
6521 |
+# If you would like it to wait so that other services now that network is up |
6522 |
+# then you can specify a timeout here. |
6523 |
+#plug_timeout="10" |
6524 |
+# A value of 0 means wait forever. |
6525 |
+ |
6526 |
+# If you don't want to use netplug on a specific interface but you have it |
6527 |
+# installed, you can disable it for that interface via the modules statement |
6528 |
+#modules_eth0=( "!netplug" ) |
6529 |
+# You can do the same for ifplugd |
6530 |
+# |
6531 |
+# You can disable them both with the generic plug |
6532 |
+#modules_eth0=( "!plug" ) |
6533 |
+ |
6534 |
+# To use specific ifplugd options, fex specifying wireless mode |
6535 |
+#ifplugd_eth0="--api-mode=wlan" |
6536 |
+# man ifplugd for more options |
6537 |
+ |
6538 |
+############################################################################## |
6539 |
+# ADVANCED CONFIGURATION |
6540 |
+# |
6541 |
+# Four functions can be defined which will be called surrounding the |
6542 |
+# start/stop operations. The functions are called with the interface |
6543 |
+# name first so that one function can control multiple adapters. An extra two |
6544 |
+# functions can be defined when an interface fails to start or stop. |
6545 |
+# |
6546 |
+# The return values for the preup and predown functions should be 0 |
6547 |
+# (success) to indicate that configuration or deconfiguration of the |
6548 |
+# interface can continue. If preup returns a non-zero value, then |
6549 |
+# interface configuration will be aborted. If predown returns a |
6550 |
+# non-zero value, then the interface will not be allowed to continue |
6551 |
+# deconfiguration. |
6552 |
+# |
6553 |
+# The return values for the postup, postdown, failup and faildown functions are |
6554 |
+# ignored since there's nothing to do if they indicate failure. |
6555 |
+# |
6556 |
+# ${IFACE} is set to the interface being brought up/down |
6557 |
+# ${IFVAR} is ${IFACE} converted to variable name bash allows |
6558 |
+ |
6559 |
+#preup() { |
6560 |
+# # Test for link on the interface prior to bringing it up. This |
6561 |
+# # only works on some network adapters and requires the mii-diag |
6562 |
+# # package to be installed. |
6563 |
+# if mii-tool "${IFACE}" 2> /dev/null | grep -q 'no link'; then |
6564 |
+# ewarn "No link on ${IFACE}, aborting configuration" |
6565 |
+# return 1 |
6566 |
+# fi |
6567 |
+# |
6568 |
+# # Test for link on the interface prior to bringing it up. This |
6569 |
+# # only works on some network adapters and requires the ethtool |
6570 |
+# # package to be installed. |
6571 |
+# if ethtool "${IFACE}" | grep -q 'Link detected: no'; then |
6572 |
+# ewarn "No link on ${IFACE}, aborting configuration" |
6573 |
+# return 1 |
6574 |
+# fi |
6575 |
+# |
6576 |
+# |
6577 |
+# # Remember to return 0 on success |
6578 |
+# return 0 |
6579 |
+#} |
6580 |
+ |
6581 |
+#predown() { |
6582 |
+# # The default in the script is to test for NFS root and disallow |
6583 |
+# # downing interfaces in that case. Note that if you specify a |
6584 |
+# # predown() function you will override that logic. Here it is, in |
6585 |
+# # case you still want it... |
6586 |
+# if is_net_fs /; then |
6587 |
+# eerror "root filesystem is network mounted -- can't stop ${IFACE}" |
6588 |
+# return 1 |
6589 |
+# fi |
6590 |
+# |
6591 |
+# # Remember to return 0 on success |
6592 |
+# return 0 |
6593 |
+#} |
6594 |
+ |
6595 |
+#postup() { |
6596 |
+# # This function could be used, for example, to register with a |
6597 |
+# # dynamic DNS service. Another possibility would be to |
6598 |
+# # send/receive mail once the interface is brought up. |
6599 |
+ |
6600 |
+# # Here is an example that allows the use of iproute rules |
6601 |
+# # which have been configured using the rules_eth0 variable. |
6602 |
+# #rules_eth0=( |
6603 |
+# # "from 24.80.102.112/32 to 192.168.1.0/24 table localnet priority 100" |
6604 |
+# # "from 216.113.223.51/32 to 192.168.1.0/24 table localnet priority 100" |
6605 |
+# #) |
6606 |
+# local x="rules_${IFVAR}[@]" |
6607 |
+# local -a rules=( "${!x}" ) |
6608 |
+# if [[ -n ${rules} ]] ; then |
6609 |
+# einfo "Adding IP policy routing rules" |
6610 |
+# eindent |
6611 |
+# # Ensure that the kernel supports policy routing |
6612 |
+# if ! ip rule list | grep -q "^" ; then |
6613 |
+# eerror "You need to enable IP Policy Routing (CONFIG_IP_MULTIPLE_TABLES)" |
6614 |
+# eerror "in your kernel to use ip rules" |
6615 |
+# else |
6616 |
+# for x in "${rules[@]}" ; do |
6617 |
+# ebegin "${x}" |
6618 |
+# ip rule add ${x} dev "${IFACE}" |
6619 |
+# eend $? |
6620 |
+# done |
6621 |
+# fi |
6622 |
+# eoutdent |
6623 |
+# # Flush the cache |
6624 |
+# ip route flush cache dev "${IFACE}" |
6625 |
+# fi |
6626 |
+ |
6627 |
+#} |
6628 |
+ |
6629 |
+#postdown() { |
6630 |
+# # Enable Wake-On-LAN for every interface except for lo |
6631 |
+# # Probably a good idea to set RC_DOWN_INTERFACE="no" in /etc/conf.d/rc |
6632 |
+# # as well ;) |
6633 |
+# [[ ${IFACE} != "lo" ]] && ethtool -s "${IFACE}" wol g |
6634 |
+ |
6635 |
+# Automatically erase any ip rules created in the example postup above |
6636 |
+# if interface_exists "${IFACE}" ; then |
6637 |
+# # Remove any rules for this interface |
6638 |
+# local rule |
6639 |
+# ip rule list | grep " iif ${IFACE}[ ]*" | { |
6640 |
+# while read rule ; do |
6641 |
+# rule="${rule#*:}" |
6642 |
+# ip rule del ${rule} |
6643 |
+# done |
6644 |
+# } |
6645 |
+# # Flush the route cache |
6646 |
+# ip route flush cache dev "${IFACE}" |
6647 |
+# fi |
6648 |
+ |
6649 |
+# # Return 0 always |
6650 |
+# return 0 |
6651 |
+#} |
6652 |
+ |
6653 |
+#failup() { |
6654 |
+# # This function is mostly here for completeness... I haven't |
6655 |
+# # thought of anything nifty to do with it yet ;-) |
6656 |
+#} |
6657 |
+ |
6658 |
+#faildown() { |
6659 |
+# # This function is mostly here for completeness... I haven't |
6660 |
+# # thought of anything nifty to do with it yet ;-) |
6661 |
+#} |
6662 |
+ |
6663 |
+############################################################################## |
6664 |
+# FORCING MODULES |
6665 |
+# The Big Fat Warning :- If you use module forcing do not complain to us or |
6666 |
+# file bugs about it not working! |
6667 |
+# |
6668 |
+# Loading modules is a slow affair - we have to check each one for the following |
6669 |
+# 1) Code sanity |
6670 |
+# 2) Has the required package been emerged? |
6671 |
+# 3) Has it modified anything? |
6672 |
+# 4) Have all the dependant modules been loaded? |
6673 |
+ |
6674 |
+# Then we have to strip out the conflicting modules based on user preference |
6675 |
+# and default configuration and sort them into the correct order. |
6676 |
+# Finally we check the end result for dependencies. |
6677 |
+ |
6678 |
+# This, of course, takes valuable CPU time so we provide module forcing as a |
6679 |
+# means to speed things up. We still do *some* checking but not much. |
6680 |
+ |
6681 |
+# It is essential that you force modules in the correct order and supply all |
6682 |
+# the modules you need. You must always supply an interface module - we |
6683 |
+# supply ifconfig or iproute2. |
6684 |
+ |
6685 |
+# The Big Fat Warning :- If you use module forcing do not complain to us or |
6686 |
+# file bugs about it not working! |
6687 |
+ |
6688 |
+# Now that we've warned you twice, here's how to do it |
6689 |
+#modules_force=( "ifconfig" ) |
6690 |
+#modules_force=( "iproute2" "dhcpcd" ) |
6691 |
+ |
6692 |
+# We can also apply this to a specific interface |
6693 |
+#modules_force_eth1=( "iproute2" ) |
6694 |
+ |
6695 |
+# The below will not work |
6696 |
+#modules_force=( "dhcpcd" ) |
6697 |
+# No interface (ifconfig/iproute2) |
6698 |
+#modules_force=( "ifconfig" "essidnet" "iwconfig" ) |
6699 |
+# Although it will not crash, essidnet will not work as it has to come after |
6700 |
+# iwconfig |
6701 |
+#modules_force=( "iproute2" "ifconfig" ) |
6702 |
+# The interface will be setup twice which will cause problems |
6703 |
|
6704 |
Added: trunk/baselayout-prefix/etc/conf.d/rc |
6705 |
=================================================================== |
6706 |
--- trunk/baselayout-prefix/etc/conf.d/rc (rev 0) |
6707 |
+++ trunk/baselayout-prefix/etc/conf.d/rc 2011-03-31 14:11:17 UTC (rev 1682) |
6708 |
@@ -0,0 +1,246 @@ |
6709 |
+# /etc/conf.d/rc: Global config file for the Gentoo RC System |
6710 |
+ |
6711 |
+# This is the number of tty's used in most of the rc-scripts (like |
6712 |
+# consolefont, numlock, etc ...) |
6713 |
+ |
6714 |
+RC_TTY_NUMBER=11 |
6715 |
+ |
6716 |
+# Set to "yes" if you want the rc system to try and start services |
6717 |
+# in parallel for a slight speed improvement. NOTE: When RC_PARALLEL_STARTUP |
6718 |
+# is enabled, init script output is replaced with simple "service foo |
6719 |
+# starting/stopping" messages so that output is not mixed up. |
6720 |
+# You can stop this from happening on the command line by passing --verbose |
6721 |
+# to the init script or by setting RC_VERBOSE="yes" below. |
6722 |
+ |
6723 |
+RC_PARALLEL_STARTUP="no" |
6724 |
+ |
6725 |
+# Set RC_INTERACTIVE to "yes" and you'll be able to press the I key during |
6726 |
+# boot so you can choose to start specific services. Set to "no" to disable |
6727 |
+# this feature. |
6728 |
+ |
6729 |
+RC_INTERACTIVE="yes" |
6730 |
+ |
6731 |
+# Do we allow services to be hotplugged? If not, set to RC_HOTPLUG="no" |
6732 |
+# NOTE: This does not affect anything hotplug/udev related, just the |
6733 |
+# starting/stopping of the init.d service triggered by hotplug. |
6734 |
+ |
6735 |
+RC_HOTPLUG="yes" |
6736 |
+ |
6737 |
+# Dynamic /dev managers can trigger coldplug events which cause services to |
6738 |
+# start before we are ready for them. If this happens, we can defer these |
6739 |
+# services to start in the boot runlevel. Set RC_COLDPLUG="no" if you don't |
6740 |
+# want this. |
6741 |
+# NOTE: This also affects module coldplugging in udev-096 and higher |
6742 |
+# If you want module coldplugging but not coldplugging of services then you |
6743 |
+# can set RC_COLDPLUG="yes" and RC_PLUG_SERVICES="!*" |
6744 |
+ |
6745 |
+RC_COLDPLUG="yes" |
6746 |
+ |
6747 |
+# Some people want a finer grain over hotplug/coldplug. RC_PLUG_SERVICES is a |
6748 |
+# list of services that are matched in order, either allowing or not. By |
6749 |
+# default we allow services through as RC_COLDPLUG/RC_HOTPLUG has to be yes |
6750 |
+# anyway. |
6751 |
+# Example - RC_PLUG_SERVICES="net.wlan !net.*" |
6752 |
+# This allows net.wlan and any service not matching net.* to be plugged. |
6753 |
+ |
6754 |
+RC_PLUG_SERVICES="" |
6755 |
+ |
6756 |
+# RC_NET_STRICT_CHECKING allows some flexibility with the 'net' service. |
6757 |
+# The following values are allowed: |
6758 |
+# none - The 'net' service is always considered up. |
6759 |
+# no - This basically means that at least one net.* service besides net.lo |
6760 |
+# must be up. This can be used by notebook users that have a wifi and |
6761 |
+# a static nic, and only wants one up at any given time to have the |
6762 |
+# 'net' service seen as up. |
6763 |
+# lo - This is the same as the 'no' option, but net.lo is also counted. |
6764 |
+# This should be useful to people that do not care about any specific |
6765 |
+# interface being up at boot. |
6766 |
+# yes - For this ALL network interfaces MUST be up for the 'net' service to |
6767 |
+# be considered up. |
6768 |
+ |
6769 |
+RC_NET_STRICT_CHECKING="no" |
6770 |
+ |
6771 |
+# RC_DOWN_INTERFACE allows you to specify if RC will bring the interface |
6772 |
+# compeletly down when it stops. The default is yes, but there are some |
6773 |
+# instances where you may not want this to happen such as using Wake On LAN. |
6774 |
+ |
6775 |
+RC_DOWN_INTERFACE="yes" |
6776 |
+ |
6777 |
+# RC_VOLUME_ORDER allows you to specify, or even remove the volume setup |
6778 |
+# for various volume managers (MD, EVMS2, LVM, DM, etc). Note that they are |
6779 |
+# stopped in reverse order. |
6780 |
+ |
6781 |
+RC_VOLUME_ORDER="raid evms lvm dm" |
6782 |
+ |
6783 |
+# RC_VERBOSE will make init scripts more verbose. Only networking scripts |
6784 |
+# really use this at this time, and this is useful for trouble shooting |
6785 |
+# any issues you may have. |
6786 |
+# This is also used to re-enable init script output for init scripts |
6787 |
+# started or stopped from the command line. |
6788 |
+ |
6789 |
+RC_VERBOSE="no" |
6790 |
+ |
6791 |
+# RC_BOOTLOG will generate a log of the boot messages shown on the console. |
6792 |
+# Useful for headless machines or debugging. You need to emerge the |
6793 |
+# app-admin/showconsole package for this to work. Note that this probably |
6794 |
+# won't work correctly with boot splash. |
6795 |
+ |
6796 |
+RC_BOOTLOG="no" |
6797 |
+ |
6798 |
+# Set to "yes" if you want to benchmark system boot with bootchart. |
6799 |
+# You'll need to emerge the app-benchmark/bootchart package for this to work. |
6800 |
+ |
6801 |
+RC_BOOTCHART="no" |
6802 |
+ |
6803 |
+# RC_USE_FSTAB allows you to override the default mount options for the |
6804 |
+# standard /proc, /sys, /dev, and /dev/pts mount points. Note that this |
6805 |
+# is the new way for selecting ramfs/tmpfs/etc... for udev mounting. |
6806 |
+ |
6807 |
+RC_USE_FSTAB="no" |
6808 |
+ |
6809 |
+# RC_USE_CONFIG_PROFILE allows you to have different /etc/conf.d files |
6810 |
+# based on your runlevel - if a conf.d file for your profile does not exist |
6811 |
+# then we try and use the default one. |
6812 |
+# To enable runlevel selection at boot, append "softlevel=foobar" to your |
6813 |
+# kernel line to change to the foobar runlevel. Here we would search for |
6814 |
+# /etc/conf.d/<service>.foobar config files before trying to use the default |
6815 |
+# /etc/conf.d/<service>. |
6816 |
+# Note that it is only active if 'softlevel' was specified via the kernel line, |
6817 |
+# and it is intended to use for different grub/lilo entries to specify config |
6818 |
+# changes for say laptops between home and work, where you would have setup |
6819 |
+# 'work' and 'home' runlevels, with /etc/conf.d/*.<runlevel> as needed. |
6820 |
+ |
6821 |
+RC_USE_CONFIG_PROFILE="yes" |
6822 |
+ |
6823 |
+# RC_FORCE_AUTO tries its best to prevent user interaction during the boot and |
6824 |
+# shutdown process. For example, fsck will automatically be run or volumes |
6825 |
+# remounted to create proper directory trees. This feature can be dangerous |
6826 |
+# and is meant ONLY for headless machines where getting a physical console |
6827 |
+# hooked up is a huge pita. |
6828 |
+ |
6829 |
+RC_FORCE_AUTO="no" |
6830 |
+ |
6831 |
+# Use this variable to control the /dev management behavior. |
6832 |
+# auto - let the scripts figure out what's best at boot |
6833 |
+# devfs - use devfs (requires sys-fs/devfsd) |
6834 |
+# udev - use udev (requires sys-fs/udev) |
6835 |
+# static - let the user manage /dev |
6836 |
+ |
6837 |
+RC_DEVICES="auto" |
6838 |
+ |
6839 |
+# UDEV OPTION: |
6840 |
+# Set to "yes" if you want to save /dev to a tarball on shutdown |
6841 |
+# and restore it on startup. This is useful if you have a lot of |
6842 |
+# custom device nodes that udev does not handle/know about. |
6843 |
+ |
6844 |
+RC_DEVICE_TARBALL="no" |
6845 |
+ |
6846 |
+# RC_SWAP_ERASE controls erasing of swap partitions at shutdown. |
6847 |
+# Useful for all those paranoid peeps to nuke their memory. |
6848 |
+ |
6849 |
+RC_SWAP_ERASE="no" |
6850 |
+ |
6851 |
+# RC_DMESG_LEVEL sets the level at which logging of messages is done to the |
6852 |
+# console. See dmesg(8) for more info. |
6853 |
+ |
6854 |
+RC_DMESG_LOGLEVEL="1" |
6855 |
+ |
6856 |
+ |
6857 |
+ |
6858 |
+ |
6859 |
+ |
6860 |
+# |
6861 |
+# Controlling start-stop-daemon behavior |
6862 |
+ |
6863 |
+# Set to "yes" if start-stop-daemon should always retry killing the |
6864 |
+# service with sig KILL if it fails the first time. |
6865 |
+ |
6866 |
+RC_RETRY_KILL="yes" |
6867 |
+ |
6868 |
+ |
6869 |
+# Set the amount of seconds start-stop-daemon should wait between |
6870 |
+# retries. |
6871 |
+ |
6872 |
+RC_RETRY_TIMEOUT=1 |
6873 |
+ |
6874 |
+ |
6875 |
+# Set the amount of times start-stop-daemon should try to kill |
6876 |
+# a service before giving up. |
6877 |
+ |
6878 |
+RC_RETRY_COUNT=5 |
6879 |
+ |
6880 |
+ |
6881 |
+# Set to "yes" if start-stop-daemon should fail if the service |
6882 |
+# is marked as started, but not actually running on stop. |
6883 |
+ |
6884 |
+RC_FAIL_ON_ZOMBIE="no" |
6885 |
+ |
6886 |
+ |
6887 |
+# Set to "yes" if start-stop-daemon should attempt to kill |
6888 |
+# any children left in the system. |
6889 |
+# Be careful with this as it really does what it was on the tin. |
6890 |
+# fex, if you're in an ssh process and you restart a service on which ssh |
6891 |
+# depends then your terminal will be killed also. |
6892 |
+ |
6893 |
+RC_KILL_CHILDREN="no" |
6894 |
+ |
6895 |
+ |
6896 |
+# Set the amount of seconds start-stop-daemon waits after starting |
6897 |
+# the daemon to check it is still running. If it's not then we |
6898 |
+# try and stop any children if possible. |
6899 |
+RC_WAIT_ON_START="0.1" |
6900 |
+ |
6901 |
+ |
6902 |
+############################################################################## |
6903 |
+# SERVICE CONFIGURATION VARIABLES |
6904 |
+# These variables are documented here, but should be configured in |
6905 |
+# /etc/conf.d/foo for service foo and NOT enabled here unless you |
6906 |
+# really want them to work on a global basis. |
6907 |
+ |
6908 |
+# Some daemons are started and stopped via start-stop-daemon. |
6909 |
+# We can launch them through other daemons here, for example valgrind. |
6910 |
+# This is only useful for serious debugging of the daemon |
6911 |
+# WARNING: If the script's "stop" function does not supply a PID file then |
6912 |
+# all processes using the same daemon will be killed. |
6913 |
+#RC_DAEMON="/usr/bin/valgrind --tool=memcheck --log-file=/tmp/valgrind.syslog-ng" |
6914 |
+ |
6915 |
+# strace needs to be prefixed with --background as it does not detach when |
6916 |
+# it's following |
6917 |
+#RC_DAEMON="--background /usr/sbin/strace -f -o /tmp/strace.syslog-ng" |
6918 |
+ |
6919 |
+# Pass ulimit parameters |
6920 |
+#RC_ULIMIT="-u 30" |
6921 |
+ |
6922 |
+############################################################################## |
6923 |
+ |
6924 |
+ |
6925 |
+# |
6926 |
+# Internal configuration variables |
6927 |
+# |
6928 |
+# NB: These are for advanced users, and you should really |
6929 |
+# know what you are doing before changing them! |
6930 |
+# |
6931 |
+ |
6932 |
+# rc-scripts dep-cache directory |
6933 |
+# |
6934 |
+# NOTE: Do not remove the next line, as its needed by the baselayout ebuild! |
6935 |
+# |
6936 |
+# svcdir="/var/lib/init.d" |
6937 |
+ |
6938 |
+svcdir="/var/lib/init.d" |
6939 |
+ |
6940 |
+# Should we mount $svcdir in a ram disk for some speed increase |
6941 |
+# for slower machines, or for the more extreme setups ? |
6942 |
+ |
6943 |
+svcmount="no" |
6944 |
+ |
6945 |
+# FS type that should be used for $svcdir. Note that you need |
6946 |
+# $svcmount above set to "yes" for this to work ... Currently |
6947 |
+# tmpfs, ramfs, and ramdisk are supported (tmpfs is the default). |
6948 |
+ |
6949 |
+svcfstype="tmpfs" |
6950 |
+ |
6951 |
+# Size of $svcdir in KB. Note that ramfs doesn't support this |
6952 |
+# due to kernel limitations. |
6953 |
+ |
6954 |
+svcsize=2048 |
6955 |
|
6956 |
Added: trunk/baselayout-prefix/etc/conf.d/wireless.example |
6957 |
=================================================================== |
6958 |
--- trunk/baselayout-prefix/etc/conf.d/wireless.example (rev 0) |
6959 |
+++ trunk/baselayout-prefix/etc/conf.d/wireless.example 2011-03-31 14:11:17 UTC (rev 1682) |
6960 |
@@ -0,0 +1,292 @@ |
6961 |
+# /etc/conf.d/wireless: |
6962 |
+# Global wireless config file for net.* rc-scripts |
6963 |
+ |
6964 |
+############################################################################## |
6965 |
+# IMPORTANT |
6966 |
+# linux-wlan-ng is not supported as they have their own configuration program |
6967 |
+# ensure that /etc/conf.d/net has the entry "!iwconfig" in it's modules line |
6968 |
+# Try and use an alternative driver if you need to use this - hostap-driver |
6969 |
+# supports non-usb linux-wlan-ng driven devices |
6970 |
+############################################################################## |
6971 |
+ |
6972 |
+############################################################################## |
6973 |
+# HINTS |
6974 |
+############################################################################## |
6975 |
+# Remember to change eth0 to your wireless interface which may be |
6976 |
+# eth0, eth1, wlan0, ath0 - you get the idea. If you're not sure |
6977 |
+# you can type "iwconfig" at the command prompt and it will tell you which |
6978 |
+# interfaces are wireless. |
6979 |
+# Say that your wireless interface is ath0 - the line |
6980 |
+# #essid_eth0="any" |
6981 |
+# becomes |
6982 |
+# #essid_ath0="any" |
6983 |
+# |
6984 |
+# Remember to change ESSID to your ESSID. |
6985 |
+# Say that your ESSID is My NET - the line |
6986 |
+# #key_ESSID="s:passkey" |
6987 |
+# becomes |
6988 |
+# #key_My_NET="s:passkey" |
6989 |
+# Notice that the space has changed to an underscore - do the same with all |
6990 |
+# characters not in a-z A-Z (english alphabet) 0-9. This only applies to |
6991 |
+# variables and not values. |
6992 |
+# |
6993 |
+# Any ESSID's in values like essid_eth0="My NET" may need to be escaped |
6994 |
+# This means placing the character \ before the character |
6995 |
+# \" need to be escaped for example |
6996 |
+# So if your ESSID is |
6997 |
+# My "\ NET |
6998 |
+# it becomes |
6999 |
+# My \"\\ NET |
7000 |
+# for example |
7001 |
+# #essid_eth0="My\"\\NET" |
7002 |
+# |
7003 |
+# So using the above we can use |
7004 |
+# #dns_domain_My____NET="My\"\\NET" |
7005 |
+# which is an invalid dns domain, but shows the how to use the variable |
7006 |
+# structure |
7007 |
+# |
7008 |
+# As a final note, most users will just need to set the following options |
7009 |
+# key_ESSID1="s:yourkeyhere enc open" # s: means a text key |
7010 |
+# key_ESSID2="aaaa-bbbb-cccc-dd" # no s: means a hex key |
7011 |
+# preferred_aps=( "ESSID1" "ESSID2" ) |
7012 |
+# |
7013 |
+# Clear? Good. Now configure your wireless network below |
7014 |
+######################################################### |
7015 |
+ |
7016 |
+############################################################################## |
7017 |
+# SETTINGS |
7018 |
+############################################################################## |
7019 |
+# Hard code an ESSID to an interface - leave this unset if you wish the driver |
7020 |
+# to scan for available Access Points |
7021 |
+# Set to "any" to connect to any ESSID - the driver picks an Access Point |
7022 |
+# This needs to be done when the driver doesn't support scanning |
7023 |
+# This may work for drivers that don't support scanning but you need automatic |
7024 |
+# AP association |
7025 |
+# I would only set this as a last resort really - use the preferred_aps |
7026 |
+# setting at the bottom of this file |
7027 |
+ |
7028 |
+# However, using ad-hoc (without scanning for APs) and master mode |
7029 |
+# do require the ESSID to be set - do this here |
7030 |
+#essid_eth0="any" |
7031 |
+ |
7032 |
+# Set the mode of the interface (managed, ad-hoc, master or auto) |
7033 |
+# The default is auto |
7034 |
+# If it's ad-hoc or master you also may need to specify the channel below |
7035 |
+#mode_eth0="auto" |
7036 |
+ |
7037 |
+# If managed mode fails, drop to ad-hoc mode with the below ESSID? |
7038 |
+#adhoc_essid_eth0="WLAN" |
7039 |
+ |
7040 |
+#Channel can be set (1-14), but defaults to 3 if not set. |
7041 |
+# |
7042 |
+# The below is taken verbatim from the BSD wavelan documentation found at |
7043 |
+# http://www.netbsd.org/Documentation/network/wavelan.html |
7044 |
+# There are 14 channels possible; We are told that channels 1-11 are legal for |
7045 |
+# North America, channels 1-13 for most of Europe, channels 10-13 for France, |
7046 |
+# and only channel 14 for Japan. If in doubt, please refer to the documentation |
7047 |
+# that came with your card or access point. Make sure that the channel you |
7048 |
+# select is the same channel your access point (or the other card in an ad-hoc |
7049 |
+# network) is on. The default for cards sold in North America and most of Europe |
7050 |
+# is 3; the default for cards sold in France is 11, and the default for cards |
7051 |
+# sold in Japan is 14. |
7052 |
+#channel_eth0="3" |
7053 |
+ |
7054 |
+# Setup any other config commands. This is basically the iwconfig argument |
7055 |
+# without the iwconfig $iface. |
7056 |
+#iwconfig_eth0="" |
7057 |
+ |
7058 |
+# Set private driver ioctls. This is basically the iwpriv argument without |
7059 |
+# the iwpriv $iface. If you use the rt2500 driver (not the rt2x00 one) then |
7060 |
+# you can set WPA here, below is an example. |
7061 |
+#iwpriv_eth0="" |
7062 |
+#iwpriv_ESSID=( |
7063 |
+# "set AuthMode=WPAPSK" |
7064 |
+# "set EncrypType=TKIP" |
7065 |
+# "set WPAPSK=yourpasskey" |
7066 |
+#) |
7067 |
+#NOTE: Even though you can use WPA like so, you may have to set a WEP key |
7068 |
+#if your driver claims the AP is encrypted. The WEP key itself will not be |
7069 |
+#used though. |
7070 |
+ |
7071 |
+# Seconds to wait before scanning |
7072 |
+# Some drivers need to wait until they have finished "loading" |
7073 |
+# before they can scan - otherwise they error and claim that they cannot scan |
7074 |
+# or resource is unavailable. The default is to wait zero seconds |
7075 |
+#sleep_scan_eth0="1" |
7076 |
+ |
7077 |
+# Seconds to wait until associated. The default is to wait 10 seconds. |
7078 |
+# 0 means wait indefinitely. WARNING: this can cause an infinite delay when |
7079 |
+# booting. |
7080 |
+#associate_timeout_eth0="5" |
7081 |
+ |
7082 |
+# By default a successful association in Managed mode sets the MAC |
7083 |
+# address of the AP connected to. However, some drivers (namely |
7084 |
+# the ipw2100) don't set an invalid MAC address when association |
7085 |
+# fails - so we need to check on link quality which some drivers |
7086 |
+# don't report properly either. |
7087 |
+# So if you have connection problems try flipping this setting |
7088 |
+# Valid options are MAC, quality and all - defaults to MAC |
7089 |
+#associate_test_eth0="MAC" |
7090 |
+ |
7091 |
+# Some driver/card combinations need to scan in Ad-Hoc mode |
7092 |
+# After scanning, the mode is reset to the one defined above |
7093 |
+#scan_mode_eth0="Ad-Hoc" |
7094 |
+ |
7095 |
+# Below you can define private ioctls to run before and after scanning |
7096 |
+# Format is the same as the iwpriv_eth0 above |
7097 |
+# This is needed for the HostAP drivers |
7098 |
+#iwpriv_scan_pre_eth0="host_roaming 2" |
7099 |
+#iwpriv_scan_post_eth0="host_roaming 0" |
7100 |
+ |
7101 |
+# Define a WEP key per ESSID or MAC address (of the AP, not your card) |
7102 |
+# The encryption type (open or restricted) must match the |
7103 |
+# encryption type on the Access Point |
7104 |
+# You can't use "any" for an ESSID here |
7105 |
+#key_ESSID="1234-1234-1234-1234-1234-1234-56" |
7106 |
+# or you can use strings. Passphrase IS NOT supported |
7107 |
+# To use a string, prefix it with s: |
7108 |
+# Note - this example also sets the encryption method to open |
7109 |
+# which is regarded as more secure than restricted |
7110 |
+#key_ESSID="s:foobar enc open" |
7111 |
+#key_ESSID="s:foobar enc restricted" |
7112 |
+ |
7113 |
+# If you have whitespace in your key, here's how to set it and use other |
7114 |
+# commands like using open encryption. |
7115 |
+#key_ESSID="s:'foo bar' enc open" |
7116 |
+ |
7117 |
+# WEP key for the AP with MAC address 001122334455 |
7118 |
+#key_001122334455="s:foobar" |
7119 |
+ |
7120 |
+# Here are some more examples of keys as some users find others work |
7121 |
+# and some don't where they should all do the same thing |
7122 |
+#key_ESSID="open s:foobar" |
7123 |
+#key_ESSID="open 1234-5678-9012" |
7124 |
+#key_ESSID="s:foobar enc open" |
7125 |
+#key_ESSID="1234-5678-9012 enc open" |
7126 |
+ |
7127 |
+# You may want to set muliple keys - here's an example |
7128 |
+# It sets 4 keys on the card and instructs to use key 2 by default |
7129 |
+#key_ESSID="[1] s:passkey1 key [2] s:passkey2 key [3] s:passkey3 key [4] s:passkey4 key [2]" |
7130 |
+ |
7131 |
+# You can also override the interface settings found in /etc/conf.d/net |
7132 |
+# per ESSID - which is very handy if you use different networks a lot |
7133 |
+#config_ESSID=( "dhcp" ) |
7134 |
+#dhcpcd_ESSID="-t 5" |
7135 |
+#routes_ESSID=() |
7136 |
+#fallback_ESSID=() |
7137 |
+ |
7138 |
+# Setting name/domain server causes /etc/resolv.conf to be overwritten |
7139 |
+# Note that if DHCP is used, and you want this to take precedence then |
7140 |
+# please put -R in your dhcpcd options |
7141 |
+#dns_servers_ESSID=( "192.168.0.1" "192.168.0.2" ) |
7142 |
+#dns_domain_ESSID="some.domain" |
7143 |
+#dns_search_path_ESSID="search.this.domain search.that.domain" |
7144 |
+# Please check the man page for resolv.conf for more information |
7145 |
+# as domain and search (searchdomains) are mutually exclusive and |
7146 |
+# searchdomains takes precedence |
7147 |
+ |
7148 |
+# You can also set any of the /etc/conf.d/net variables per MAC address |
7149 |
+# incase you use Access Points with the same ESSID but need different |
7150 |
+# networking configs. Below is an example - of course you use the same |
7151 |
+# method with other variables |
7152 |
+#config_001122334455=( "dhcp" ) |
7153 |
+#dhcpcd_001122334455="-t 10" |
7154 |
+#dns_servers_001122334455=( "192.168.0.1" "192.168.0.2" ) |
7155 |
+ |
7156 |
+# Map a MAC address to an ESSID |
7157 |
+# This is used when the Access Point is not broadcasting it's ESSID |
7158 |
+# WARNING: This will override the ESSID being broadcast due to some |
7159 |
+# Access Points sending an ESSID even when they have been configured |
7160 |
+# not to! |
7161 |
+# Change 001122334455 to the MAC address and ESSID to the ESSID |
7162 |
+# it should map to |
7163 |
+#essid_001122334455="ESSID" |
7164 |
+ |
7165 |
+# This lists the preferred ESSIDs to connect to in order |
7166 |
+# ESSID's can contain any characters here as they must match the broadcast |
7167 |
+# ESSID exactly. |
7168 |
+# Surround each ESSID with the " character and seperate them with a space |
7169 |
+# If the first ESSID isn't found then it moves onto the next |
7170 |
+# If this isn't defined then it connects to the first one found |
7171 |
+#preferred_aps=( "ESSID 1" "ESSID 2" ) |
7172 |
+ |
7173 |
+# You can also define a preferred_aps list per interface |
7174 |
+#preferred_aps_eth0=( "ESSID 3" "ESSID 4" ) |
7175 |
+ |
7176 |
+# You can also say whether we only connect to preferred APs or not |
7177 |
+# Values are "any", "preferredonly", "forcepreferred", "forcepreferredonly" and "forceany" |
7178 |
+# "any" means it will connect to visible APs in the preferred list and then any |
7179 |
+# other available AP |
7180 |
+# "preferredonly" means it will only connect to visible APs in the preferred list |
7181 |
+# "forcepreferred" means it will forceably connect to APs in order if it does not find |
7182 |
+# them in a scan |
7183 |
+# "forcepreferredonly" means it forceably connects to the APs in order and does not bother |
7184 |
+# to scan |
7185 |
+# "forceany" does the same as forcepreferred + connects to any other available AP |
7186 |
+# Default is "any" |
7187 |
+#associate_order="any" |
7188 |
+#associate_order_eth0="any" |
7189 |
+ |
7190 |
+# You can define blacklisted Access Points in the same way |
7191 |
+#blacklist_aps=( "ESSID 1" "ESSID 2" ) |
7192 |
+#blacklist_aps_eth0=( "ESSID 3" ESSID 4" ) |
7193 |
+ |
7194 |
+# If you have more than one wireless card, you can say if you want |
7195 |
+# to allow each card to associate with the same Access Point or not |
7196 |
+# Values are "yes" and "no" |
7197 |
+# Default is "yes" |
7198 |
+#unique_ap="yes" |
7199 |
+#unique_ap_eth0="yes" |
7200 |
+ |
7201 |
+# IMPORTANT: preferred_only, blacklisted_aps and unique_ap only work when |
7202 |
+# essid_eth0 is not set and your card is capable of scanning |
7203 |
+ |
7204 |
+# NOTE: preferred_aps list ignores blacklisted_aps - so if you have |
7205 |
+# the same ESSID in both, well, you're a bit silly :p |
7206 |
+ |
7207 |
+ |
7208 |
+############################################################################## |
7209 |
+# ADVANCED CONFIGURATION |
7210 |
+# |
7211 |
+# Two functions can be defined which will be called surrounding the |
7212 |
+# associate function. The functions are called with the interface |
7213 |
+# name first so that one function can control multiple adapters. |
7214 |
+# |
7215 |
+# The return values for the preassociate function should be 0 |
7216 |
+# (success) to indicate that configuration or deconfiguration of the |
7217 |
+# interface can continue. If preassociate returns a non-zero value, then |
7218 |
+# interface configuration will be aborted. |
7219 |
+# |
7220 |
+# The return value for the postassociate function is ignored |
7221 |
+# since there's nothing to do if it indicates failure. |
7222 |
+ |
7223 |
+#preassociate() { |
7224 |
+# # The below adds two configuration variables leap_user_ESSID |
7225 |
+# # and leap_pass_ESSID. When they are both confiugred for the ESSID |
7226 |
+# # being connected to then we run the CISCO LEAP script |
7227 |
+# |
7228 |
+# local user pass |
7229 |
+# eval user=\"\$\{leap_user_${ESSIDVAR}\}\" |
7230 |
+# eval pass=\"\$\{leap_pass_${ESSIDVAR}\}\" |
7231 |
+# |
7232 |
+# if [[ -n ${user} && -n ${pass} ]]; then |
7233 |
+# if [[ ! -x /opt/cisco/bin/leapscript ]]; then |
7234 |
+# eend "For LEAP support, please emerge net-misc/cisco-aironet-client-utils" |
7235 |
+# return 1 |
7236 |
+# fi |
7237 |
+# einfo "Waiting for LEAP Authentication on \"${ESSID//\\\\//}\"" |
7238 |
+# if /opt/cisco/bin/leapscript ${user} ${pass} | grep -q 'Login incorrect'; then |
7239 |
+# ewarn "Login Failed for ${user}" |
7240 |
+# return 1 |
7241 |
+# fi |
7242 |
+# fi |
7243 |
+# |
7244 |
+# return 0 |
7245 |
+#} |
7246 |
+ |
7247 |
+#postassociate() { |
7248 |
+# # This function is mostly here for completeness... I haven't |
7249 |
+# # thought of anything nifty to do with it yet ;-) |
7250 |
+# # Return 0 always |
7251 |
+# return 0 |
7252 |
+#} |
7253 |
|
7254 |
Added: trunk/baselayout-prefix/etc/env.d/00basic |
7255 |
=================================================================== |
7256 |
--- trunk/baselayout-prefix/etc/env.d/00basic (rev 0) |
7257 |
+++ trunk/baselayout-prefix/etc/env.d/00basic 2011-03-31 14:11:17 UTC (rev 1682) |
7258 |
@@ -0,0 +1,10 @@ |
7259 |
+# /etc/env.d/00basic |
7260 |
+ |
7261 |
+PATH="/opt/bin" |
7262 |
+ROOTPATH="/opt/bin" |
7263 |
+LDPATH="/usr/local/lib" |
7264 |
+MANPATH="/usr/local/share/man:/usr/share/man" |
7265 |
+INFOPATH="/usr/share/info" |
7266 |
+CVS_RSH="ssh" |
7267 |
+PAGER="/usr/bin/less" |
7268 |
+LESSOPEN="|lesspipe.sh %s" |
7269 |
|
7270 |
Added: trunk/baselayout-prefix/etc/filesystems |
7271 |
=================================================================== |
7272 |
--- trunk/baselayout-prefix/etc/filesystems (rev 0) |
7273 |
+++ trunk/baselayout-prefix/etc/filesystems 2011-03-31 14:11:17 UTC (rev 1682) |
7274 |
@@ -0,0 +1,14 @@ |
7275 |
+# /etc/filesystems |
7276 |
+# |
7277 |
+# This file defines the filesystems search order used by a |
7278 |
+# 'mount -t auto' command. |
7279 |
+# |
7280 |
+ |
7281 |
+# Uncomment the following line if your modular kernel has vfat |
7282 |
+# support and you want mount to try vfat. |
7283 |
+#vfat |
7284 |
+ |
7285 |
+# Keep the last '*' intact as it directs mount to use the |
7286 |
+# filesystems list available at /proc/filesystems also. |
7287 |
+# Don't remove it unless you REALLY know what you are doing! |
7288 |
+* |
7289 |
|
7290 |
Added: trunk/baselayout-prefix/etc/fstab |
7291 |
=================================================================== |
7292 |
--- trunk/baselayout-prefix/etc/fstab (rev 0) |
7293 |
+++ trunk/baselayout-prefix/etc/fstab 2011-03-31 14:11:17 UTC (rev 1682) |
7294 |
@@ -0,0 +1,27 @@ |
7295 |
+# /etc/fstab: static file system information. |
7296 |
+# |
7297 |
+# noatime turns off atimes for increased performance (atimes normally aren't |
7298 |
+# needed; notail increases performance of ReiserFS (at the expense of storage |
7299 |
+# efficiency). It's safe to drop the noatime options if you want and to |
7300 |
+# switch between notail / tail freely. |
7301 |
+# |
7302 |
+# The root filesystem should have a pass number of either 0 or 1. |
7303 |
+# All other filesystems should have a pass number of 0 or greater than 1. |
7304 |
+# |
7305 |
+# See the manpage fstab(5) for more information. |
7306 |
+# |
7307 |
+ |
7308 |
+# <fs> <mountpoint> <type> <opts> <dump/pass> |
7309 |
+ |
7310 |
+# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts. |
7311 |
+/dev/BOOT /boot ext2 noauto,noatime 1 2 |
7312 |
+/dev/ROOT / ext3 noatime 0 1 |
7313 |
+/dev/SWAP none swap sw 0 0 |
7314 |
+/dev/cdrom /mnt/cdrom audo noauto,ro 0 0 |
7315 |
+#/dev/fd0 /mnt/floppy auto noauto 0 0 |
7316 |
+ |
7317 |
+# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for |
7318 |
+# POSIX shared memory (shm_open, shm_unlink). |
7319 |
+# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will |
7320 |
+# use almost no memory if not populated with files) |
7321 |
+shm /dev/shm tmpfs nodev,nosuid,noexec 0 0 |
7322 |
|
7323 |
Added: trunk/baselayout-prefix/etc/group |
7324 |
=================================================================== |
7325 |
--- trunk/baselayout-prefix/etc/group (rev 0) |
7326 |
+++ trunk/baselayout-prefix/etc/group 2011-03-31 14:11:17 UTC (rev 1682) |
7327 |
@@ -0,0 +1,31 @@ |
7328 |
+root::0:root |
7329 |
+bin::1:root,bin,daemon |
7330 |
+daemon::2:root,bin,daemon |
7331 |
+sys::3:root,bin,adm |
7332 |
+adm::4:root,adm,daemon |
7333 |
+tty::5: |
7334 |
+disk::6:root,adm |
7335 |
+lp::7:lp |
7336 |
+mem::8: |
7337 |
+kmem::9: |
7338 |
+wheel::10:root |
7339 |
+floppy::11:root |
7340 |
+mail::12:mail |
7341 |
+news::13:news |
7342 |
+uucp::14:uucp |
7343 |
+man::15:man |
7344 |
+console::17: |
7345 |
+audio::18: |
7346 |
+cdrom::19: |
7347 |
+dialout::20:root |
7348 |
+tape::26:root |
7349 |
+video::27:root |
7350 |
+cdrw::80: |
7351 |
+usb::85: |
7352 |
+users::100:games |
7353 |
+nofiles:x:200: |
7354 |
+smmsp:x:209:smmsp |
7355 |
+portage::250:portage |
7356 |
+utmp:x:406: |
7357 |
+nogroup::65533: |
7358 |
+nobody::65534: |
7359 |
|
7360 |
Added: trunk/baselayout-prefix/etc/hosts |
7361 |
=================================================================== |
7362 |
--- trunk/baselayout-prefix/etc/hosts (rev 0) |
7363 |
+++ trunk/baselayout-prefix/etc/hosts 2011-03-31 14:11:17 UTC (rev 1682) |
7364 |
@@ -0,0 +1,31 @@ |
7365 |
+# /etc/hosts: Local Host Database |
7366 |
+# |
7367 |
+# This file describes a number of aliases-to-address mappings for the for |
7368 |
+# local hosts that share this file. |
7369 |
+# |
7370 |
+# In the presence of the domain name service or NIS, this file may not be |
7371 |
+# consulted at all; see /etc/host.conf for the resolution order. |
7372 |
+# |
7373 |
+ |
7374 |
+# IPv4 and IPv6 localhost aliases |
7375 |
+127.0.0.1 localhost |
7376 |
+::1 localhost |
7377 |
+ |
7378 |
+# |
7379 |
+# Imaginary network. |
7380 |
+#10.0.0.2 myname |
7381 |
+#10.0.0.3 myfriend |
7382 |
+# |
7383 |
+# According to RFC 1918, you can use the following IP networks for private |
7384 |
+# nets which will never be connected to the Internet: |
7385 |
+# |
7386 |
+# 10.0.0.0 - 10.255.255.255 |
7387 |
+# 172.16.0.0 - 172.31.255.255 |
7388 |
+# 192.168.0.0 - 192.168.255.255 |
7389 |
+# |
7390 |
+# In case you want to be able to connect directly to the Internet (i.e. not |
7391 |
+# behind a NAT, ADSL router, etc...), you need real official assigned |
7392 |
+# numbers. Do not try to invent your own network numbers but instead get one |
7393 |
+# from your network provider (if any) or from your regional registry (ARIN, |
7394 |
+# APNIC, LACNIC, RIPE NCC, or AfriNIC.) |
7395 |
+# |
7396 |
|
7397 |
Added: trunk/baselayout-prefix/etc/inputrc |
7398 |
=================================================================== |
7399 |
--- trunk/baselayout-prefix/etc/inputrc (rev 0) |
7400 |
+++ trunk/baselayout-prefix/etc/inputrc 2011-03-31 14:11:17 UTC (rev 1682) |
7401 |
@@ -0,0 +1,67 @@ |
7402 |
+# /etc/inputrc: initialization file for readline |
7403 |
+# |
7404 |
+# For more information on how this file works, please see the |
7405 |
+# INITIALIZATION FILE section of the readline(3) man page |
7406 |
+# |
7407 |
+# Quick dirty little note: |
7408 |
+# To get the key sequence for binding, you can abuse bash. |
7409 |
+# While running bash, hit CTRL+V, and then type the key sequence. |
7410 |
+# So, typing 'ALT + left arrow' in Konsole gets you back: |
7411 |
+# ^[[1;3D |
7412 |
+# The readline entry to make this skip back a word will then be: |
7413 |
+# "\e[1;3D" backward-word |
7414 |
+# |
7415 |
+ |
7416 |
+# do not bell on tab-completion |
7417 |
+#set bell-style none |
7418 |
+ |
7419 |
+set meta-flag on |
7420 |
+set input-meta on |
7421 |
+set convert-meta off |
7422 |
+set output-meta on |
7423 |
+ |
7424 |
+# Completed names which are symbolic links to |
7425 |
+# directories have a slash appended. |
7426 |
+set mark-symlinked-directories on |
7427 |
+ |
7428 |
+$if mode=emacs |
7429 |
+ |
7430 |
+# for linux console and RH/Debian xterm |
7431 |
+"\e[1~": beginning-of-line |
7432 |
+"\e[4~": end-of-line |
7433 |
+#"\e[5~": beginning-of-history |
7434 |
+#"\e[6~": end-of-history |
7435 |
+"\e[5~": history-search-backward |
7436 |
+"\e[6~": history-search-forward |
7437 |
+"\e[3~": delete-char |
7438 |
+"\e[2~": quoted-insert |
7439 |
+ |
7440 |
+# gnome-terminal (escape + arrow key) |
7441 |
+"\e[5C": forward-word |
7442 |
+"\e[5D": backward-word |
7443 |
+# konsole / xterm / rxvt (escape + arrow key) |
7444 |
+"\e\e[C": forward-word |
7445 |
+"\e\e[D": backward-word |
7446 |
+# konsole (alt + arrow key) |
7447 |
+"\e[1;3C": forward-word |
7448 |
+"\e[1;3D": backward-word |
7449 |
+# aterm / eterm (control + arrow key) |
7450 |
+"\eOc": forward-word |
7451 |
+"\eOd": backward-word |
7452 |
+ |
7453 |
+$if term=rxvt |
7454 |
+"\e[8~": end-of-line |
7455 |
+$endif |
7456 |
+ |
7457 |
+# for non RH/Debian xterm, can't hurt for RH/Debian xterm |
7458 |
+"\eOH": beginning-of-line |
7459 |
+"\eOF": end-of-line |
7460 |
+ |
7461 |
+# for freebsd console |
7462 |
+"\e[H": beginning-of-line |
7463 |
+"\e[F": end-of-line |
7464 |
+$endif |
7465 |
+ |
7466 |
+# fix Home and End for German users |
7467 |
+"\e[7~": beginning-of-line |
7468 |
+"\e[8~": end-of-line |
7469 |
|
7470 |
Added: trunk/baselayout-prefix/etc/issue |
7471 |
=================================================================== |
7472 |
--- trunk/baselayout-prefix/etc/issue (rev 0) |
7473 |
+++ trunk/baselayout-prefix/etc/issue 2011-03-31 14:11:17 UTC (rev 1682) |
7474 |
@@ -0,0 +1,3 @@ |
7475 |
+ |
7476 |
+This is \n.\O (\s \m \r) \t |
7477 |
+ |
7478 |
|
7479 |
Added: trunk/baselayout-prefix/etc/issue.devfix |
7480 |
=================================================================== |
7481 |
--- trunk/baselayout-prefix/etc/issue.devfix (rev 0) |
7482 |
+++ trunk/baselayout-prefix/etc/issue.devfix 2011-03-31 14:11:17 UTC (rev 1682) |
7483 |
@@ -0,0 +1,21 @@ |
7484 |
+----------------------------------------------------- |
7485 |
+Your system seems to be missing critical device files |
7486 |
+in /dev ! Although you may be running udev or devfs, |
7487 |
+the root partition is missing these required files ! |
7488 |
+ |
7489 |
+To rectify this situation, please do the following: |
7490 |
+mkdir /mnt/fixit |
7491 |
+mount --bind / /mnt/fixit |
7492 |
+cp -a /dev/* /mnt/fixit/dev/ |
7493 |
+umount /mnt/fixit |
7494 |
+rmdir /mnt/fixit |
7495 |
+ |
7496 |
+You may refer to these instructions at /etc/issue. |
7497 |
+If you previously had an issue file, it has been |
7498 |
+backed up at /etc/issue.devfix. Once you've fixed |
7499 |
+your system, you will have to restore your old issue |
7500 |
+file in order to get rid of this warning. |
7501 |
+ |
7502 |
+Thanks for using Gentoo ! :) |
7503 |
+http://bugs.gentoo.org/show_bug.cgi?id=40987 |
7504 |
+----------------------------------------------------- |
7505 |
|
7506 |
Added: trunk/baselayout-prefix/etc/issue.logo |
7507 |
=================================================================== |
7508 |
--- trunk/baselayout-prefix/etc/issue.logo (rev 0) |
7509 |
+++ trunk/baselayout-prefix/etc/issue.logo 2011-03-31 14:11:17 UTC (rev 1682) |
7510 |
@@ -0,0 +1,13 @@ |
7511 |
+[0;35;40m . |
7512 |
+[0;35;40m .vir. d$b |
7513 |
+[0;35;40m .d$$$$$$b. .cd$$b. .d$$b. d$$$$$$$$$$$b .d$$b. .d$$b. |
7514 |
+[0;35;40m $$$$( )$$$b d$$$()$$$. d$$$$$$$b Q$$$$$$$P$$$P.$$$$$$$b. .$$$$$$$b. |
7515 |
+[0;35;40m Q$$$$$$$$$$B$$$$$$$$P" d$$$PQ$$$$b. $$$$. .$$$P' `$$$ .$$$P' `$$$ |
7516 |
+[0;35;40m "$$$$$$$P Q$$$$$$$b d$$$P Q$$$$b $$$$b $$$$b..d$$$ $$$$b..d$$$ |
7517 |
+[0;35;40m d$$$$$$P" "$$$$$$$$ Q$$$ Q$$$$ $$$$$ `Q$$$$$$$P `Q$$$$$$$P |
7518 |
+[0;35;40m $$$$$$$P `""""" "" "" Q$$$P "Q$$$P" "Q$$$P" |
7519 |
+[0;35;40m `Q$$P" """ |
7520 |
+[0;37;40m |
7521 |
+ |
7522 |
+This is \n.\O (\s \m \r) \t |
7523 |
+ |
7524 |
|
7525 |
Added: trunk/baselayout-prefix/etc/modules.autoload.d/kernel-2.4 |
7526 |
=================================================================== |
7527 |
--- trunk/baselayout-prefix/etc/modules.autoload.d/kernel-2.4 (rev 0) |
7528 |
+++ trunk/baselayout-prefix/etc/modules.autoload.d/kernel-2.4 2011-03-31 14:11:17 UTC (rev 1682) |
7529 |
@@ -0,0 +1,11 @@ |
7530 |
+# /etc/modules.autoload.d/kernel-2.4: kernel modules to load when system boots. |
7531 |
+# |
7532 |
+# Note that this file is for 2.4 kernels. If you need different modules |
7533 |
+# for a 2.6 kernel, you can create /etc/modules.autoload.d/kernel-2.6 |
7534 |
+# |
7535 |
+# Add the names of modules that you'd like to load when the system |
7536 |
+# starts into this file, one per line. Comments begin with # and |
7537 |
+# are ignored. Read man modules.autoload for additional details. |
7538 |
+ |
7539 |
+# For example: |
7540 |
+# aic7xxx |
7541 |
|
7542 |
Added: trunk/baselayout-prefix/etc/modules.autoload.d/kernel-2.6 |
7543 |
=================================================================== |
7544 |
--- trunk/baselayout-prefix/etc/modules.autoload.d/kernel-2.6 (rev 0) |
7545 |
+++ trunk/baselayout-prefix/etc/modules.autoload.d/kernel-2.6 2011-03-31 14:11:17 UTC (rev 1682) |
7546 |
@@ -0,0 +1,10 @@ |
7547 |
+# /etc/modules.autoload.d/kernel-2.6: kernel modules to load when system boots. |
7548 |
+# |
7549 |
+# Note that this file is for 2.6 kernels. |
7550 |
+# |
7551 |
+# Add the names of modules that you'd like to load when the system |
7552 |
+# starts into this file, one per line. Comments begin with # and |
7553 |
+# are ignored. Read man modules.autoload for additional details. |
7554 |
+ |
7555 |
+# For example: |
7556 |
+# aic7xxx |
7557 |
|
7558 |
Added: trunk/baselayout-prefix/etc/modules.d/aliases |
7559 |
=================================================================== |
7560 |
--- trunk/baselayout-prefix/etc/modules.d/aliases (rev 0) |
7561 |
+++ trunk/baselayout-prefix/etc/modules.d/aliases 2011-03-31 14:11:17 UTC (rev 1682) |
7562 |
@@ -0,0 +1,46 @@ |
7563 |
+# Aliases to tell insmod/modprobe which modules to use |
7564 |
+ |
7565 |
+# Uncomment the network protocols you don't want loaded: |
7566 |
+# alias net-pf-1 off # Unix |
7567 |
+# alias net-pf-2 off # IPv4 |
7568 |
+# alias net-pf-3 off # Amateur Radio AX.25 |
7569 |
+# alias net-pf-4 off # IPX |
7570 |
+# alias net-pf-5 off # DDP / appletalk |
7571 |
+# alias net-pf-6 off # Amateur Radio NET/ROM |
7572 |
+# alias net-pf-9 off # X.25 |
7573 |
+# alias net-pf-10 off # IPv6 |
7574 |
+# alias net-pf-11 off # ROSE / Amateur Radio X.25 PLP |
7575 |
+# alias net-pf-19 off # Acorn Econet |
7576 |
+ |
7577 |
+alias char-major-10-175 agpgart |
7578 |
+alias char-major-10-200 tun |
7579 |
+alias char-major-81 bttv |
7580 |
+alias char-major-108 ppp_generic |
7581 |
+alias /dev/ppp ppp_generic |
7582 |
+alias tty-ldisc-3 ppp_async |
7583 |
+alias tty-ldisc-14 ppp_synctty |
7584 |
+alias ppp-compress-21 bsd_comp |
7585 |
+alias ppp-compress-24 ppp_deflate |
7586 |
+alias ppp-compress-26 ppp_deflate |
7587 |
+ |
7588 |
+# Crypto modules (see http://www.kerneli.org/) |
7589 |
+alias loop-xfer-gen-0 loop_gen |
7590 |
+alias loop-xfer-3 loop_fish2 |
7591 |
+alias loop-xfer-gen-10 loop_gen |
7592 |
+alias cipher-2 des |
7593 |
+alias cipher-3 fish2 |
7594 |
+alias cipher-4 blowfish |
7595 |
+alias cipher-6 idea |
7596 |
+alias cipher-7 serp6f |
7597 |
+alias cipher-8 mars6 |
7598 |
+alias cipher-11 rc62 |
7599 |
+alias cipher-15 dfc2 |
7600 |
+alias cipher-16 rijndael |
7601 |
+alias cipher-17 rc5 |
7602 |
+ |
7603 |
+# Support for i2c and lm_sensors |
7604 |
+alias char-major-89 i2c-dev |
7605 |
+ |
7606 |
+# Old nvidia support ... |
7607 |
+alias char-major-195 NVdriver |
7608 |
+alias /dev/nvidiactl char-major-195 |
7609 |
|
7610 |
Added: trunk/baselayout-prefix/etc/modules.d/i386 |
7611 |
=================================================================== |
7612 |
--- trunk/baselayout-prefix/etc/modules.d/i386 (rev 0) |
7613 |
+++ trunk/baselayout-prefix/etc/modules.d/i386 2011-03-31 14:11:17 UTC (rev 1682) |
7614 |
@@ -0,0 +1,4 @@ |
7615 |
+alias parport_lowlevel parport_pc |
7616 |
+alias char-major-10-144 nvram |
7617 |
+alias binfmt-0064 binfmt_aout |
7618 |
+alias char-major-10-135 rtc |
7619 |
|
7620 |
Added: trunk/baselayout-prefix/etc/networks |
7621 |
=================================================================== |
7622 |
--- trunk/baselayout-prefix/etc/networks (rev 0) |
7623 |
+++ trunk/baselayout-prefix/etc/networks 2011-03-31 14:11:17 UTC (rev 1682) |
7624 |
@@ -0,0 +1,8 @@ |
7625 |
+# /etc/networks |
7626 |
+# |
7627 |
+# This file describes a number of netname-to-adress |
7628 |
+# mappings for the TCP/IP subsytem. It is mostly |
7629 |
+# used at boot time, when no name servers are running. |
7630 |
+# |
7631 |
+ |
7632 |
+loopback 127.0.0.0 |
7633 |
|
7634 |
Added: trunk/baselayout-prefix/etc/passwd |
7635 |
=================================================================== |
7636 |
--- trunk/baselayout-prefix/etc/passwd (rev 0) |
7637 |
+++ trunk/baselayout-prefix/etc/passwd 2011-03-31 14:11:17 UTC (rev 1682) |
7638 |
@@ -0,0 +1,17 @@ |
7639 |
+root:x:0:0:root:/root:/bin/bash |
7640 |
+bin:x:1:1:bin:/bin:/bin/false |
7641 |
+daemon:x:2:2:daemon:/sbin:/bin/false |
7642 |
+adm:x:3:4:adm:/var/adm:/bin/false |
7643 |
+lp:x:4:7:lp:/var/spool/lpd:/bin/false |
7644 |
+sync:x:5:0:sync:/sbin:/bin/sync |
7645 |
+shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown |
7646 |
+halt:x:7:0:halt:/sbin:/sbin/halt |
7647 |
+mail:x:8:12:mail:/var/spool/mail:/bin/false |
7648 |
+news:x:9:13:news:/usr/lib/news:/bin/false |
7649 |
+uucp:x:10:14:uucp:/var/spool/uucppublic:/bin/false |
7650 |
+operator:x:11:0:operator:/root:/bin/bash |
7651 |
+man:x:13:15:man:/usr/share/man:/bin/false |
7652 |
+postmaster:x:14:12:postmaster:/var/spool/mail:/bin/false |
7653 |
+smmsp:x:209:209:smmsp:/var/spool/mqueue:/bin/false |
7654 |
+portage:x:250:250:portage:/var/tmp/portage:/bin/false |
7655 |
+nobody:x:65534:65534:nobody:/:/bin/false |
7656 |
|
7657 |
Added: trunk/baselayout-prefix/etc/profile |
7658 |
=================================================================== |
7659 |
--- trunk/baselayout-prefix/etc/profile (rev 0) |
7660 |
+++ trunk/baselayout-prefix/etc/profile 2011-03-31 14:11:17 UTC (rev 1682) |
7661 |
@@ -0,0 +1,65 @@ |
7662 |
+# /etc/profile: login shell setup |
7663 |
+# |
7664 |
+# That this file is used by any Bourne-shell derivative to setup the |
7665 |
+# environment for login shells. |
7666 |
+# |
7667 |
+ |
7668 |
+# Load environment settings from profile.env, which is created by |
7669 |
+# env-update from the files in /etc/env.d |
7670 |
+if [ -e /etc/profile.env ] ; then |
7671 |
+ . /etc/profile.env |
7672 |
+fi |
7673 |
+ |
7674 |
+# 077 would be more secure, but 022 is generally quite realistic |
7675 |
+umask 022 |
7676 |
+ |
7677 |
+# Set up PATH depending on whether we're root or a normal user. |
7678 |
+# There's no real reason to exclude sbin paths from the normal user, |
7679 |
+# but it can make tab-completion easier when they aren't in the |
7680 |
+# user's PATH to pollute the executable namespace. |
7681 |
+# |
7682 |
+# It is intentional in the following line to use || instead of -o. |
7683 |
+# This way the evaluation can be short-circuited and calling whoami is |
7684 |
+# avoided. |
7685 |
+if [ "$EUID" = "0" ] || [ "$USER" = "root" ] ; then |
7686 |
+ PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:${ROOTPATH}" |
7687 |
+else |
7688 |
+ PATH="/usr/local/bin:/usr/bin:/bin:${PATH}" |
7689 |
+fi |
7690 |
+export PATH |
7691 |
+unset ROOTPATH |
7692 |
+ |
7693 |
+# Extract the value of EDITOR |
7694 |
+[ -z "$EDITOR" ] && EDITOR="`. /etc/rc.conf 2>/dev/null; echo $EDITOR`" |
7695 |
+[ -z "$EDITOR" ] && EDITOR="/bin/nano" |
7696 |
+export EDITOR |
7697 |
+ |
7698 |
+if [ -n "${BASH_VERSION}" ] ; then |
7699 |
+ # Newer bash ebuilds include /etc/bash/bashrc which will setup PS1 |
7700 |
+ # including color. We leave out color here because not all |
7701 |
+ # terminals support it. |
7702 |
+ if [ -f /etc/bash/bashrc ] ; then |
7703 |
+ # Bash login shells run only /etc/profile |
7704 |
+ # Bash non-login shells run only /etc/bash/bashrc |
7705 |
+ # Since we want to run /etc/bash/bashrc regardless, we source it |
7706 |
+ # from here. It is unfortunate that there is no way to do |
7707 |
+ # this *after* the user's .bash_profile runs (without putting |
7708 |
+ # it in the user's dot-files), but it shouldn't make any |
7709 |
+ # difference. |
7710 |
+ . /etc/bash/bashrc |
7711 |
+ else |
7712 |
+ PS1='\u@\h \w \$ ' |
7713 |
+ fi |
7714 |
+else |
7715 |
+ # Setup a bland default prompt. Since this prompt should be useable |
7716 |
+ # on color and non-color terminals, as well as shells that don't |
7717 |
+ # understand sequences such as \h, don't put anything special in it. |
7718 |
+ PS1="`whoami`@`uname -n | cut -f1 -d.` \$ " |
7719 |
+fi |
7720 |
+ |
7721 |
+for sh in /etc/profile.d/*.sh ; do |
7722 |
+ if [ -r "$sh" ] ; then |
7723 |
+ . "$sh" |
7724 |
+ fi |
7725 |
+done |
7726 |
+unset sh |
7727 |
|
7728 |
Added: trunk/baselayout-prefix/etc/protocols |
7729 |
=================================================================== |
7730 |
--- trunk/baselayout-prefix/etc/protocols (rev 0) |
7731 |
+++ trunk/baselayout-prefix/etc/protocols 2011-03-31 14:11:17 UTC (rev 1682) |
7732 |
@@ -0,0 +1,42 @@ |
7733 |
+# /etc/protocols |
7734 |
+# |
7735 |
+# Internet (IP) protocols definition file |
7736 |
+# |
7737 |
+# See protocols(5) for more info |
7738 |
+# |
7739 |
+ |
7740 |
+ip 0 IP # internet protocol, pseudo protocol number |
7741 |
+icmp 1 ICMP # internet control message protocol |
7742 |
+igmp 2 IGMP # Internet Group Management |
7743 |
+ggp 3 GGP # gateway-gateway protocol |
7744 |
+ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') |
7745 |
+st 5 ST # ST datagram mode |
7746 |
+tcp 6 TCP # transmission control protocol |
7747 |
+egp 8 EGP # exterior gateway protocol |
7748 |
+pup 12 PUP # PARC universal packet protocol |
7749 |
+udp 17 UDP # user datagram protocol |
7750 |
+hmp 20 HMP # host monitoring protocol |
7751 |
+xns-idp 22 XNS-IDP # Xerox NS IDP |
7752 |
+rdp 27 RDP # "reliable datagram" protocol |
7753 |
+iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 |
7754 |
+xtp 36 XTP # Xpress Tranfer Protocol |
7755 |
+ddp 37 DDP # Datagram Delivery Protocol |
7756 |
+idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport |
7757 |
+ipv6 41 IPv6 # IPv6 |
7758 |
+ipv6-route 43 IPv6-Route # Routing Header for IPv6 |
7759 |
+ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6 |
7760 |
+idrp 45 IDRP # Inter-Domain Routing Protocol |
7761 |
+rsvp 46 RSVP # Reservation Protocol |
7762 |
+gre 47 GRE # General Routing Encapsulation |
7763 |
+esp 50 ESP # Encap Security Payload for IPv6 |
7764 |
+ah 51 AH # Authentication Header for IPv6 |
7765 |
+skip 57 SKIP # SKIP |
7766 |
+ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 |
7767 |
+ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6 |
7768 |
+ipv6-opts 60 IPv6-Opts # Destination Options for IPv6 |
7769 |
+rspf 73 RSPF # Radio Shortest Path First. |
7770 |
+vmtp 81 VMTP # Versatile Message Transport |
7771 |
+ospf 89 OSPFIGP # Open Shortest Path First IGP |
7772 |
+ipip 94 IPIP # IP-within-IP Encapsulation Protocol |
7773 |
+encap 98 ENCAP # Yet Another IP encapsulation |
7774 |
+pim 103 PIM # Protocol Independent Multicast |
7775 |
|
7776 |
Added: trunk/baselayout-prefix/etc/rc.conf |
7777 |
=================================================================== |
7778 |
--- trunk/baselayout-prefix/etc/rc.conf (rev 0) |
7779 |
+++ trunk/baselayout-prefix/etc/rc.conf 2011-03-31 14:11:17 UTC (rev 1682) |
7780 |
@@ -0,0 +1,39 @@ |
7781 |
+# /etc/rc.conf: Global startup script configuration settings |
7782 |
+ |
7783 |
+# UNICODE specifies whether you want to have UNICODE support in the console. |
7784 |
+# If you set to yes, please make sure to set a UNICODE aware CONSOLEFONT and |
7785 |
+# KEYMAP in the /etc/conf.d/consolefont and /etc/conf.d/keymaps config files. |
7786 |
+ |
7787 |
+UNICODE="no" |
7788 |
+ |
7789 |
+# Set EDITOR to your preferred editor. |
7790 |
+# You may use something other than what is listed here. |
7791 |
+ |
7792 |
+EDITOR="/bin/nano" |
7793 |
+#EDITOR="/usr/bin/vim" |
7794 |
+#EDITOR="/usr/bin/emacs" |
7795 |
+ |
7796 |
+# What display manager do you use ? [ xdm | gdm | kdm | entrance ] |
7797 |
+#DISPLAYMANAGER="xdm" |
7798 |
+ |
7799 |
+# XSESSION is a new variable to control what window manager to start |
7800 |
+# default with X if run with xdm, startx or xinit. The default behavior |
7801 |
+# is to look in /etc/X11/Sessions/ and run the script in matching the |
7802 |
+# value that XSESSION is set to. The support scripts are smart enough to |
7803 |
+# look in all bin directories if it cant find a match in /etc/X11/Sessions/, |
7804 |
+# so setting it to "enlightenment" can also work. This is basically used |
7805 |
+# as a way for the system admin to configure a default system wide WM, |
7806 |
+# allthough it will work if the user export XSESSION in his .bash_profile, etc. |
7807 |
+# |
7808 |
+# NOTE: 1) this behaviour is overridden when a ~/.xinitrc exists, and startx |
7809 |
+# is called. |
7810 |
+# 2) even if ~/.xsession exists, if XSESSION can be resolved, it will |
7811 |
+# be executed rather than ~/.xsession, else KDM breaks ... |
7812 |
+# |
7813 |
+# Defaults depending on what you install currently include: |
7814 |
+# |
7815 |
+# Gnome - will start gnome-session |
7816 |
+# kde-<version> - will start startkde (look in /etc/X11/Sessions/) |
7817 |
+# Xsession - will start a terminal and a few other nice apps |
7818 |
+ |
7819 |
+#XSESSION="Gnome" |
7820 |
|
7821 |
Added: trunk/baselayout-prefix/etc/services |
7822 |
=================================================================== |
7823 |
--- trunk/baselayout-prefix/etc/services (rev 0) |
7824 |
+++ trunk/baselayout-prefix/etc/services 2011-03-31 14:11:17 UTC (rev 1682) |
7825 |
@@ -0,0 +1,1176 @@ |
7826 |
+# /etc/services |
7827 |
+# |
7828 |
+# Network services, Internet style |
7829 |
+# |
7830 |
+# Note that it is presently the policy of IANA to assign a single well-known |
7831 |
+# port number for both TCP and UDP; hence, most entries here have two entries |
7832 |
+# even if the protocol doesn't support UDP operations. |
7833 |
+# |
7834 |
+# Some References: |
7835 |
+# http://www.iana.org/assignments/port-numbers |
7836 |
+# http://www.freebsd.org/cgi/cvsweb.cgi/src/etc/services |
7837 |
+# |
7838 |
+# Each line describes one service, and is of the form: |
7839 |
+# service-name port/protocol [aliases ...] [# comment] |
7840 |
+# |
7841 |
+ |
7842 |
+# |
7843 |
+# IANA Assignments [Well Known Ports] |
7844 |
+# The Well Known Ports are assigned by the IANA and on most systems can |
7845 |
+# only be used by system (or root) processes or by programs executed by |
7846 |
+# privileged users. |
7847 |
+# The range for assigned ports managed by the IANA is 0-1023. |
7848 |
+# |
7849 |
+tcpmux 1/tcp # TCP port service multiplexer |
7850 |
+tcpmux 1/udp |
7851 |
+compressnet 2/tcp # Management Utility |
7852 |
+compressnet 2/udp |
7853 |
+compressnet 3/tcp # Compression Process |
7854 |
+compressnet 3/udp |
7855 |
+rje 5/tcp # Remote Job Entry |
7856 |
+rje 5/udp |
7857 |
+echo 7/tcp # Echo |
7858 |
+echo 7/udp |
7859 |
+discard 9/tcp sink null # Discard |
7860 |
+discard 9/udp sink null |
7861 |
+systat 11/tcp users # Active Users |
7862 |
+systat 11/udp users |
7863 |
+daytime 13/tcp # Daytime (RFC 867) |
7864 |
+daytime 13/udp |
7865 |
+#netstat 15/tcp # (was once asssigned, no more) |
7866 |
+qotd 17/tcp quote # Quote of the Day |
7867 |
+qotd 17/udp quote |
7868 |
+msp 18/tcp # Message Send Protocol |
7869 |
+msp 18/udp |
7870 |
+chargen 19/tcp ttytst source # Character Generator |
7871 |
+chargen 19/udp ttytst source |
7872 |
+ftp-data 20/tcp # File Transfer [Default Data] |
7873 |
+ftp-data 20/udp |
7874 |
+ftp 21/tcp # File Transfer [Control] |
7875 |
+ftp 21/udp fsp fspd |
7876 |
+ssh 22/tcp # SSH Remote Login Protocol |
7877 |
+ssh 22/udp |
7878 |
+telnet 23/tcp # Telnet |
7879 |
+telnet 23/udp |
7880 |
+# private 24/tcp # any private mail system |
7881 |
+# private 24/udp |
7882 |
+smtp 25/tcp mail # Simple Mail Transfer |
7883 |
+smtp 25/udp |
7884 |
+nsw-fe 27/tcp # NSW User System FE |
7885 |
+nsw-fe 27/udp |
7886 |
+msg-icp 29/tcp # MSG ICP |
7887 |
+msg-icp 29/udp |
7888 |
+msg-auth 31/tcp # MSG Authentication |
7889 |
+msg-auth 31/udp |
7890 |
+dsp 33/tcp # Display Support Protocol |
7891 |
+dsp 33/udp |
7892 |
+# private 35/tcp # any private printer server |
7893 |
+# private 35/udp |
7894 |
+time 37/tcp timserver |
7895 |
+time 37/udp timserver |
7896 |
+rap 38/tcp # Route Access Protocol |
7897 |
+rap 38/udp |
7898 |
+rlp 39/tcp resource # Resource Location Protocol |
7899 |
+rlp 39/udp resource |
7900 |
+graphics 41/tcp # Graphics |
7901 |
+graphics 41/udp |
7902 |
+nameserver 42/tcp name # Host Name Server |
7903 |
+nameserver 42/udp name |
7904 |
+nicname 43/tcp whois # Who Is |
7905 |
+nicname 43/udp whois |
7906 |
+mpm-flags 44/tcp # MPM FLAGS Protocol |
7907 |
+mpm-flags 44/udp |
7908 |
+mpm 45/tcp # Message Processing Module [recv] |
7909 |
+mpm 45/udp |
7910 |
+mpm-snd 46/tcp # MPM [default send] |
7911 |
+mpm-snd 46/udp |
7912 |
+ni-ftp 47/tcp # NI FTP |
7913 |
+ni-ftp 47/udp |
7914 |
+auditd 48/tcp # Digital Audit Daemon |
7915 |
+auditd 48/udp |
7916 |
+tacacs 49/tcp # Login Host Protocol (TACACS) |
7917 |
+tacacs 49/udp |
7918 |
+re-mail-ck 50/tcp # Remote Mail Checking Protocol |
7919 |
+re-mail-ck 50/udp |
7920 |
+domain 53/tcp # Domain Name Server |
7921 |
+domain 53/udp |
7922 |
+xns-ch 54/tcp # XNS Clearinghouse |
7923 |
+xns-ch 54/udp |
7924 |
+isi-gl 55/tcp # ISI Graphics Language |
7925 |
+isi-gl 55/udp |
7926 |
+xns-auth 56/tcp # XNS Authentication |
7927 |
+xns-auth 56/udp |
7928 |
+# private 57/tcp # any private terminal access |
7929 |
+# private 57/udp |
7930 |
+xns-mail 58/tcp # XNS Mail |
7931 |
+xns-mail 58/udp |
7932 |
+# private 59/tcp # any private file service |
7933 |
+# private 59/udp |
7934 |
+ni-mail 61/tcp # NI MAIL |
7935 |
+ni-mail 61/udp |
7936 |
+acas 62/tcp # ACA Services |
7937 |
+acas 62/udp |
7938 |
+whois++ 63/tcp # whois++ |
7939 |
+whois++ 63/udp |
7940 |
+covia 64/tcp # Communications Integrator (CI) |
7941 |
+covia 64/udp |
7942 |
+tacacs-ds 65/tcp # TACACS-Database Service |
7943 |
+tacacs-ds 65/udp |
7944 |
+sql*net 66/tcp # Oracle SQL*NET |
7945 |
+sql*net 66/udp |
7946 |
+bootps 67/tcp # Bootstrap Protocol Server (BOOTP) |
7947 |
+bootps 67/udp |
7948 |
+bootpc 68/tcp # Bootstrap Protocol Client (BOOTP) |
7949 |
+bootpc 68/udp |
7950 |
+tftp 69/tcp # Trivial File Transfer |
7951 |
+tftp 69/udp |
7952 |
+gopher 70/tcp # Gopher |
7953 |
+gopher 70/udp |
7954 |
+netrjs-1 71/tcp # Remote Job Service |
7955 |
+netrjs-1 71/udp |
7956 |
+netrjs-2 72/tcp |
7957 |
+netrjs-2 72/udp |
7958 |
+netrjs-3 73/tcp |
7959 |
+netrjs-3 73/udp |
7960 |
+netrjs-4 74/tcp |
7961 |
+netrjs-4 74/udp |
7962 |
+# private 75/tcp # any private dial out service |
7963 |
+# private 75/udp |
7964 |
+deos 76/tcp # Distributed External Object Store |
7965 |
+deos 76/udp |
7966 |
+# private 77/tcp # any private RJE service |
7967 |
+# private 77/udp |
7968 |
+vettcp 78/tcp # vettcp |
7969 |
+vettcp 78/udp |
7970 |
+finger 79/tcp # Finger |
7971 |
+finger 79/udp |
7972 |
+http 80/tcp www www-http # World Wide Web HTTP |
7973 |
+http 80/udp www www-http |
7974 |
+hosts2-ns 81/tcp # HOSTS2 Name Server |
7975 |
+hosts2-ns 81/udp |
7976 |
+xfer 82/tcp # XFER Utility |
7977 |
+xfer 82/udp |
7978 |
+mit-ml-dev 83/tcp # MIT ML Device |
7979 |
+mit-ml-dev 83/udp |
7980 |
+ctf 84/tcp # Common Trace Facility |
7981 |
+ctf 84/udp |
7982 |
+mit-ml-dev 85/tcp # MIT ML Device |
7983 |
+mit-ml-dev 85/udp |
7984 |
+mfcobol 86/tcp # Micro Focus Cobol |
7985 |
+mfcobol 86/udp |
7986 |
+# private 87/tcp # any private terminal link |
7987 |
+# private 87/udp |
7988 |
+kerberos 88/tcp kerberos5 krb5 # Kerberos |
7989 |
+kerberos 88/udp kerberos5 krb5 |
7990 |
+su-mit-tg 89/tcp # SU/MIT Telnet Gateway |
7991 |
+su-mit-tg 89/udp |
7992 |
+dnsix 90/tcp # DNSIX Securit Attribute Token Map |
7993 |
+dnsix 90/udp |
7994 |
+mit-dov 91/tcp # MIT Dover Spooler |
7995 |
+mit-dov 91/udp |
7996 |
+npp 92/tcp # Network Printing Protocol |
7997 |
+npp 92/udp |
7998 |
+dcp 93/tcp # Device Control Protocol |
7999 |
+dcp 93/udp |
8000 |
+objcall 94/tcp # Tivoli Object Dispatcher |
8001 |
+objcall 94/udp |
8002 |
+supdup 95/tcp # SUPDUP |
8003 |
+supdup 95/udp |
8004 |
+dixie 96/tcp # DIXIE Protocol Specification |
8005 |
+dixie 96/udp |
8006 |
+swift-rvf 97/tcp # Swift Remote Virtural File Protocol |
8007 |
+swift-rvf 97/udp |
8008 |
+tacnews 98/tcp linuxconf # TAC News |
8009 |
+tacnews 98/udp |
8010 |
+metagram 99/tcp # Metagram Relay |
8011 |
+metagram 99/udp |
8012 |
+#newacct 100/tcp # [unauthorized use] |
8013 |
+hostname 101/tcp hostnames # NIC Host Name Server |
8014 |
+hostname 101/udp hostnames |
8015 |
+iso-tsap 102/tcp tsap # ISO-TSAP Class 0 |
8016 |
+iso-tsap 102/udp tsap |
8017 |
+gppitnp 103/tcp # Genesis Point-to-Point Trans Net |
8018 |
+gppitnp 103/udp |
8019 |
+acr-nema 104/tcp # ACR-NEMA Digital Imag. & Comm. 300 |
8020 |
+acr-nema 104/udp |
8021 |
+cso 105/tcp csnet-ns cso-ns # CCSO name server protocol |
8022 |
+cso 105/udp csnet-ns cso-ns |
8023 |
+3com-tsmux 106/tcp poppassd # 3COM-TSMUX |
8024 |
+3com-tsmux 106/udp poppassd # Eudora: Unauthorized use by insecure poppassd protocol |
8025 |
+rtelnet 107/tcp # Remote Telnet Service |
8026 |
+rtelnet 107/udp |
8027 |
+snagas 108/tcp # SNA Gateway Access Server |
8028 |
+snagas 108/udp |
8029 |
+pop2 109/tcp pop-2 postoffice# Post Office Protocol - Version 2 |
8030 |
+pop2 109/udp pop-2 |
8031 |
+pop3 110/tcp pop-3 # Post Office Protocol - Version 3 |
8032 |
+pop3 110/udp pop-3 |
8033 |
+sunrpc 111/tcp portmapper # SUN Remote Procedure Call |
8034 |
+sunrpc 111/udp portmapper |
8035 |
+mcidas 112/tcp # McIDAS Data Transmission Protocol |
8036 |
+mcidas 112/udp |
8037 |
+auth 113/tcp authentication tap ident # Authentication Service |
8038 |
+auth 113/udp |
8039 |
+sftp 115/tcp # Simple File Transfer Protocol |
8040 |
+sftp 115/udp |
8041 |
+ansanotify 116/tcp # ANSA REX Notify |
8042 |
+ansanotify 116/udp |
8043 |
+uucp-path 117/tcp # UUCP Path Service |
8044 |
+uucp-path 117/udp |
8045 |
+sqlserv 118/tcp # SQL Services |
8046 |
+sqlserv 118/udp |
8047 |
+nntp 119/tcp readnews untp # Network News Transfer Protocol |
8048 |
+nntp 119/udp readnews untp |
8049 |
+cfdptkt 120/tcp # CFDPTKT |
8050 |
+cfdptkt 120/udp |
8051 |
+erpc 121/tcp # Encore Expedited Remote Pro.Call |
8052 |
+erpc 121/udp |
8053 |
+smakynet 122/tcp # SMAKYNET |
8054 |
+smakynet 122/udp |
8055 |
+ntp 123/tcp # Network Time Protocol |
8056 |
+ntp 123/udp |
8057 |
+ansatrader 124/tcp # ANSA REX Trader |
8058 |
+ansatrader 124/udp |
8059 |
+locus-map 125/tcp # Locus PC-Interface Net Map Ser |
8060 |
+locus-map 125/udp |
8061 |
+nxedit 126/tcp unitary # NXEdit |
8062 |
+nxedit 126/udp unitary # Unisys Unitary Login |
8063 |
+locus-con 127/tcp # Locus PC-Interface Conn Server |
8064 |
+locus-con 127/udp |
8065 |
+gss-xlicen 128/tcp # GSS X License Verification |
8066 |
+gss-xlicen 128/udp |
8067 |
+pwdgen 129/tcp # Password Generator Protocol |
8068 |
+pwdgen 129/udp |
8069 |
+cisco-fna 130/tcp # cisco FNATIVE |
8070 |
+cisco-fna 130/udp |
8071 |
+cisco-tna 131/tcp # cisco TNATIVE |
8072 |
+cisco-tna 131/udp |
8073 |
+cisco-sys 132/tcp # cisco SYSMAINT |
8074 |
+cisco-sys 132/udp |
8075 |
+statsrv 133/tcp # Statistics Service |
8076 |
+statsrv 133/udp |
8077 |
+ingres-net 134/tcp # INGRES-NET Service |
8078 |
+ingres-net 134/udp |
8079 |
+epmap 135/tcp loc-srv # DCE endpoint resolution |
8080 |
+epmap 135/udp loc-srv |
8081 |
+profile 136/tcp # PROFILE Naming System |
8082 |
+profile 136/udp |
8083 |
+netbios-ns 137/tcp # NETBIOS Name Service |
8084 |
+netbios-ns 137/udp |
8085 |
+netbios-dgm 138/tcp # NETBIOS Datagram Service |
8086 |
+netbios-dgm 138/udp |
8087 |
+netbios-ssn 139/tcp # NETBIOS Session Service |
8088 |
+netbios-ssn 139/udp |
8089 |
+emfis-data 140/tcp # EMFIS Data Service |
8090 |
+emfis-data 140/udp |
8091 |
+emfis-cntl 141/tcp # EMFIS Control Service |
8092 |
+emfis-cntl 141/udp |
8093 |
+imap 143/tcp imap2 # Internet Message Access Protocol |
8094 |
+imap 143/udp imap2 |
8095 |
+uma 144/tcp # Universal Management Architecture |
8096 |
+uma 144/udp |
8097 |
+uaac 145/tcp # UAAC Protocol |
8098 |
+uaac 145/udp |
8099 |
+iso-tp0 146/tcp # ISO-TP0 |
8100 |
+iso-tp0 146/udp |
8101 |
+iso-ip 147/tcp # ISO-IP |
8102 |
+iso-ip 147/udp |
8103 |
+jargon 148/tcp # Jargon |
8104 |
+jargon 148/udp |
8105 |
+aed-512 149/tcp # AED 512 Emulation Service |
8106 |
+aed-512 149/udp |
8107 |
+sql-net 150/tcp # SQL-NET |
8108 |
+sql-net 150/udp |
8109 |
+hems 151/tcp # HEMS |
8110 |
+hems 151/udp |
8111 |
+bftp 152/tcp # Background File Transfer Program |
8112 |
+bftp 152/udp |
8113 |
+sgmp 153/tcp # SGMP |
8114 |
+sgmp 153/udp |
8115 |
+netsc-prod 154/tcp # NETSC |
8116 |
+netsc-prod 154/udp |
8117 |
+netsc-dev 155/tcp |
8118 |
+netsc-dev 155/udp |
8119 |
+sqlsrv 156/tcp # SQL Service |
8120 |
+sqlsrv 156/udp |
8121 |
+knet-cmp 157/tcp # KNET/VM Command/Message Protocol |
8122 |
+knet-cmp 157/udp |
8123 |
+pcmail-srv 158/tcp # PCMail Server |
8124 |
+pcmail-srv 158/udp |
8125 |
+nss-routing 159/tcp # NSS-Routing |
8126 |
+nss-routing 159/udp |
8127 |
+sgmp-traps 160/tcp # SGMP-TRAPS |
8128 |
+sgmp-traps 160/udp |
8129 |
+snmp 161/tcp # Simple Net Mgmt Proto |
8130 |
+snmp 161/udp |
8131 |
+snmptrap 162/tcp snmp-trap # Traps for SNMP |
8132 |
+snmptrap 162/udp snmp-trap |
8133 |
+cmip-man 163/tcp # CMIP/TCP Manager |
8134 |
+cmip-man 163/udp |
8135 |
+cmip-agent 164/tcp # CMIP/TCP Agent |
8136 |
+cmip-agent 164/udp |
8137 |
+xns-courier 165/tcp # Xerox |
8138 |
+xns-courier 165/udp |
8139 |
+s-net 166/tcp # Sirius Systems |
8140 |
+s-net 166/udp |
8141 |
+namp 167/tcp # NAMP |
8142 |
+namp 167/udp |
8143 |
+rsvd 168/tcp # RSVD |
8144 |
+rsvd 168/udp |
8145 |
+send 169/tcp # SEND |
8146 |
+send 169/udp |
8147 |
+print-srv 170/tcp # Network PostScript |
8148 |
+print-srv 170/udp |
8149 |
+multiplex 171/tcp # Network Innovations Multiplex |
8150 |
+multiplex 171/udp |
8151 |
+cl/1 172/tcp # Network Innovations CL/1 |
8152 |
+cl/1 172/udp |
8153 |
+xyplex-mux 173/tcp # Xyplex |
8154 |
+xyplex-mux 173/udp |
8155 |
+mailq 174/tcp # Mailer transport queue for Zmailer |
8156 |
+mailq 174/udp |
8157 |
+vmnet 175/tcp # VMNET |
8158 |
+vmnet 175/udp |
8159 |
+genrad-mux 176/tcp # GENRAD-MUX |
8160 |
+genrad-mux 176/udp |
8161 |
+xdmcp 177/tcp # X Display Manager Control Protocol |
8162 |
+xdmcp 177/udp |
8163 |
+nextstep 178/tcp NeXTStep NextStep# NextStep Window Server |
8164 |
+nextstep 178/udp NeXTStep NextStep |
8165 |
+bgp 179/tcp # Border Gateway Protocol |
8166 |
+bgp 179/udp |
8167 |
+ris 180/tcp # Intergraph |
8168 |
+ris 180/udp |
8169 |
+unify 181/tcp # Unify |
8170 |
+unify 181/udp |
8171 |
+audit 182/tcp # Unisys Audit SITP |
8172 |
+audit 182/udp |
8173 |
+ocbinder 183/tcp # OCBinder |
8174 |
+ocbinder 183/udp |
8175 |
+ocserver 184/tcp # OCServer |
8176 |
+ocserver 184/udp |
8177 |
+remote-kis 185/tcp # Remote-KIS |
8178 |
+remote-kis 185/udp |
8179 |
+kis 186/tcp # KIS Protocol |
8180 |
+kis 186/udp |
8181 |
+aci 187/tcp # Application Communication Interface |
8182 |
+aci 187/udp |
8183 |
+mumps 188/tcp # Plus Five's MUMPS |
8184 |
+mumps 188/udp |
8185 |
+qft 189/tcp # Queued File Transport |
8186 |
+qft 189/udp |
8187 |
+gacp 190/tcp # Gateway Access Control Protocol |
8188 |
+gacp 190/udp |
8189 |
+prospero 191/tcp # Prospero Directory Service |
8190 |
+prospero 191/udp |
8191 |
+osu-nms 192/tcp # OSU Network Monitoring System |
8192 |
+osu-nms 192/udp |
8193 |
+srmp 193/tcp # Spider Remote Monitoring Protocol |
8194 |
+srmp 193/udp |
8195 |
+irc 194/tcp # Internet Relay Chat Protocol |
8196 |
+irc 194/udp |
8197 |
+dn6-nlm-aud 195/tcp # DNSIX Network Level Module Audit |
8198 |
+dn6-nlm-aud 195/udp |
8199 |
+dn6-smm-red 196/tcp # DNSIX Session Mgt Module Audit Redir |
8200 |
+dn6-smm-red 196/udp |
8201 |
+dls 197/tcp # Directory Location Service |
8202 |
+dls 197/udp |
8203 |
+dls-mon 198/tcp # Directory Location Service Monitor |
8204 |
+dls-mon 198/udp |
8205 |
+smux 199/tcp # SNMP Unix Multiplexer |
8206 |
+smux 199/udp |
8207 |
+src 200/tcp # IBM System Resource Controller |
8208 |
+src 200/udp |
8209 |
+at-rtmp 201/tcp # AppleTalk Routing Maintenance |
8210 |
+at-rtmp 201/udp |
8211 |
+at-nbp 202/tcp # AppleTalk Name Binding |
8212 |
+at-nbp 202/udp |
8213 |
+at-echo 204/tcp # AppleTalk Echo |
8214 |
+at-echo 204/udp |
8215 |
+at-zis 206/tcp # AppleTalk Zone Information |
8216 |
+at-zis 206/udp |
8217 |
+qmtp 209/tcp # The Quick Mail Transfer Protocol |
8218 |
+qmtp 209/udp |
8219 |
+z39.50 210/tcp wais z3950 # ANSI Z39.50 |
8220 |
+z39.50 210/udp wais z3950 |
8221 |
+914c/g 211/tcp # Texas Instruments 914C/G Terminal |
8222 |
+914c/g 211/udp |
8223 |
+anet 212/tcp # ATEXSSTR |
8224 |
+anet 212/udp |
8225 |
+ipx 213/tcp # IPX |
8226 |
+ipx 213/udp |
8227 |
+imap3 220/tcp # Interactive Mail Access |
8228 |
+imap3 220/udp |
8229 |
+link 245/tcp # ttylink |
8230 |
+link 245/udp |
8231 |
+pawserv 345/tcp # Perf Analysis Workbench |
8232 |
+pawserv 345/udp |
8233 |
+zserv 346/tcp # Zebra server |
8234 |
+zserv 346/udp |
8235 |
+fatserv 347/tcp # Fatmen Server |
8236 |
+fatserv 347/udp |
8237 |
+scoi2odialog 360/tcp # scoi2odialog |
8238 |
+scoi2odialog 360/udp |
8239 |
+semantix 361/tcp # Semantix |
8240 |
+semantix 361/udp |
8241 |
+srssend 362/tcp # SRS Send |
8242 |
+srssend 362/udp |
8243 |
+rsvp_tunnel 363/tcp # RSVP Tunnel |
8244 |
+rsvp_tunnel 363/udp |
8245 |
+aurora-cmgr 364/tcp # Aurora CMGR |
8246 |
+aurora-cmgr 364/udp |
8247 |
+dtk 365/tcp # Deception Tool Kit |
8248 |
+dtk 365/udp |
8249 |
+odmr 366/tcp # ODMR |
8250 |
+odmr 366/udp |
8251 |
+rpc2portmap 369/tcp # Coda portmapper |
8252 |
+rpc2portmap 369/udp |
8253 |
+codaauth2 370/tcp # Coda authentication server |
8254 |
+codaauth2 370/udp |
8255 |
+clearcase 371/tcp # Clearcase |
8256 |
+clearcase 371/udp |
8257 |
+ulistproc 372/tcp ulistserv # UNIX Listserv |
8258 |
+ulistproc 372/udp ulistserv |
8259 |
+ldap 389/tcp # Lightweight Directory Access Protocol |
8260 |
+ldap 389/udp |
8261 |
+imsp 406/tcp # Interactive Mail Support Protocol |
8262 |
+imsp 406/udp |
8263 |
+svrloc 427/tcp # Server Location |
8264 |
+svrloc 427/udp |
8265 |
+mobileip-agent 434/tcp # MobileIP-Agent |
8266 |
+mobileip-agent 434/udp |
8267 |
+mobilip-mn 435/tcp # MobilIP-MN |
8268 |
+mobilip-mn 435/udp |
8269 |
+https 443/tcp # MCom |
8270 |
+https 443/udp |
8271 |
+snpp 444/tcp # Simple Network Paging Protocol |
8272 |
+snpp 444/udp |
8273 |
+microsoft-ds 445/tcp Microsoft-DS |
8274 |
+microsoft-ds 445/udp Microsoft-DS |
8275 |
+kpasswd 464/tcp kpwd # Kerberos "passwd" |
8276 |
+kpasswd 464/udp kpwd |
8277 |
+urd 465/tcp smtps ssmtp # URL Rendesvous Directory for SSM / smtp protocol over TLS/SSL |
8278 |
+igmpv3lite 465/udp smtps ssmtp # IGMP over UDP for SSM |
8279 |
+photuris 468/tcp |
8280 |
+photuris 468/udp |
8281 |
+rcp 469/tcp # Radio Control Protocol |
8282 |
+rcp 469/udp |
8283 |
+saft 487/tcp # Simple Asynchronous File Transfer |
8284 |
+saft 487/udp |
8285 |
+gss-http 488/tcp |
8286 |
+gss-http 488/udp |
8287 |
+pim-rp-disc 496/tcp |
8288 |
+pim-rp-disc 496/udp |
8289 |
+isakmp 500/tcp # IPsec - Internet Security Association and Key Management Protocol |
8290 |
+isakmp 500/udp |
8291 |
+exec 512/tcp # remote process execution |
8292 |
+comsat 512/udp biff # notify users of new mail received |
8293 |
+login 513/tcp # remote login a la telnet |
8294 |
+who 513/udp whod # who's logged in to machines |
8295 |
+shell 514/tcp cmd # no passwords used |
8296 |
+syslog 514/udp |
8297 |
+printer 515/tcp spooler # line printer spooler |
8298 |
+printer 515/udp spooler |
8299 |
+videotex 516/tcp |
8300 |
+videotex 516/udp |
8301 |
+talk 517/tcp # like tenex link |
8302 |
+talk 517/udp |
8303 |
+ntalk 518/tcp |
8304 |
+ntalk 518/udp |
8305 |
+utime 519/tcp unixtime |
8306 |
+utime 519/udp unixtime |
8307 |
+efs 520/tcp # extended file name server |
8308 |
+router 520/udp route routed # local routing process |
8309 |
+ripng 521/tcp |
8310 |
+ripng 521/udp |
8311 |
+ulp 522/tcp |
8312 |
+ulp 522/udp |
8313 |
+ibm-db2 523/tcp |
8314 |
+ibm-db2 523/udp |
8315 |
+ncp 524/tcp |
8316 |
+ncp 524/udp |
8317 |
+timed 525/tcp timeserver |
8318 |
+timed 525/udp timeserver |
8319 |
+tempo 526/tcp newdate |
8320 |
+tempo 526/udp newdate |
8321 |
+courier 530/tcp rpc |
8322 |
+courier 530/udp rpc |
8323 |
+conference 531/tcp chat |
8324 |
+conference 531/udp chat |
8325 |
+netnews 532/tcp readnews |
8326 |
+netnews 532/udp readnews |
8327 |
+netwall 533/tcp # -for emergency broadcasts |
8328 |
+netwall 533/udp |
8329 |
+mm-admin 534/tcp # MegaMedia Admin |
8330 |
+mm-admin 534/udp |
8331 |
+iiop 535/tcp |
8332 |
+iiop 535/udp |
8333 |
+opalis-rdv 536/tcp |
8334 |
+opalis-rdv 536/udp |
8335 |
+nmsp 537/tcp # Networked Media Streaming Protocol |
8336 |
+nmsp 537/udp |
8337 |
+gdomap 538/tcp # GNUstep distributed objects |
8338 |
+gdomap 538/udp |
8339 |
+uucp 540/tcp uucpd # uucp daemon |
8340 |
+uucp 540/udp uucpd |
8341 |
+klogin 543/tcp # Kerberized `rlogin' (v5) |
8342 |
+klogin 543/udp |
8343 |
+kshell 544/tcp krcmd # Kerberized `rsh' (v5) |
8344 |
+kshell 544/udp krcmd |
8345 |
+appleqtcsrvr 545/tcp |
8346 |
+appleqtcsrvr 545/udp |
8347 |
+dhcpv6-client 546/tcp # DHCPv6 Client |
8348 |
+dhcpv6-client 546/udp |
8349 |
+dhcpv6-server 547/tcp # DHCPv6 Server |
8350 |
+dhcpv6-server 547/udp |
8351 |
+afpovertcp 548/tcp # AFP over TCP |
8352 |
+afpovertcp 548/udp |
8353 |
+rtsp 554/tcp # Real Time Stream Control Protocol |
8354 |
+rtsp 554/udp |
8355 |
+dsf 555/tcp |
8356 |
+dsf 555/udp |
8357 |
+remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem |
8358 |
+remotefs 556/udp rfs_server rfs |
8359 |
+nntps 563/tcp snntp # NNTP over SSL |
8360 |
+nntps 563/udp snntp |
8361 |
+9pfs 564/tcp # plan 9 file service |
8362 |
+9pfs 564/udp |
8363 |
+whoami 565/tcp |
8364 |
+whoami 565/udp |
8365 |
+submission 587/tcp # mail message submission |
8366 |
+submission 587/udp |
8367 |
+http-alt 591/tcp # FileMaker, Inc. - HTTP Alternate |
8368 |
+http-alt 591/udp |
8369 |
+nqs 607/tcp # Network Queuing system |
8370 |
+nqs 607/udp |
8371 |
+npmp-local 610/tcp dqs313_qmaster # npmp-local / DQS |
8372 |
+npmp-local 610/udp dqs313_qmaster |
8373 |
+npmp-gui 611/tcp dqs313_execd # npmp-gui / DQS |
8374 |
+npmp-gui 611/udp dqs313_execd |
8375 |
+hmmp-ind 612/tcp dqs313_intercell# HMMP Indication / DQS |
8376 |
+hmmp-ind 612/udp dqs313_intercell |
8377 |
+cryptoadmin 624/tcp # Crypto Admin |
8378 |
+cryptoadmin 624/udp |
8379 |
+dec_dlm 625/tcp # DEC DLM |
8380 |
+dec_dlm 625/udp |
8381 |
+asia 626/tcp |
8382 |
+asia 626/udp |
8383 |
+passgo-tivoli 627/tcp # PassGo Tivoli |
8384 |
+passgo-tivoli 627/udp |
8385 |
+qmqp 628/tcp # Qmail QMQP |
8386 |
+qmqp 628/udp |
8387 |
+3com-amp3 629/tcp |
8388 |
+3com-amp3 629/udp |
8389 |
+rda 630/tcp |
8390 |
+rda 630/udp |
8391 |
+ipp 631/tcp # Internet Printing Protocol |
8392 |
+ipp 631/udp |
8393 |
+ldaps 636/tcp # LDAP over SSL |
8394 |
+ldaps 636/udp |
8395 |
+tinc 655/tcp # TINC control port |
8396 |
+tinc 655/udp |
8397 |
+acap 674/tcp # Application Configuration Access Protocol |
8398 |
+acap 674/udp |
8399 |
+asipregistry 687/tcp |
8400 |
+asipregistry 687/udp |
8401 |
+realm-rusd 688/tcp # ApplianceWare managment protocol |
8402 |
+realm-rusd 688/udp |
8403 |
+nmap 689/tcp # Opensource Network Mapper |
8404 |
+nmap 689/udp |
8405 |
+ha-cluster 694/tcp # Heartbeat HA-cluster |
8406 |
+ha-cluster 694/udp |
8407 |
+epp 700/tcp # Extensible Provisioning Protocol |
8408 |
+epp 700/udp |
8409 |
+iris-beep 702/tcp # IRIS over BEEP |
8410 |
+iris-beep 702/udp |
8411 |
+silc 706/tcp # SILC |
8412 |
+silc 706/udp |
8413 |
+kerberos-adm 749/tcp # Kerberos `kadmin' (v5) |
8414 |
+kerberos-adm 749/udp |
8415 |
+kerberos-iv 750/tcp kerberos4 kdc # Kerberos (server) |
8416 |
+kerberos-iv 750/udp kerberos4 kdc |
8417 |
+pump 751/tcp kerberos_master |
8418 |
+pump 751/udp kerberos_master # Kerberos authentication |
8419 |
+qrh 752/tcp passwd_server |
8420 |
+qrh 752/udp passwd_server # Kerberos passwd server |
8421 |
+rrh 753/tcp |
8422 |
+rrh 753/udp |
8423 |
+tell 754/tcp send krb_prop krb5_prop # Kerberos slave propagation |
8424 |
+tell 754/udp send |
8425 |
+nlogin 758/tcp |
8426 |
+nlogin 758/udp |
8427 |
+con 759/tcp |
8428 |
+con 759/udp |
8429 |
+ns 760/tcp krbupdate kreg # Kerberos registration |
8430 |
+ns 760/udp |
8431 |
+webster 765/tcp # Network dictionary |
8432 |
+webster 765/udp |
8433 |
+phonebook 767/tcp # Network phonebook |
8434 |
+phonebook 767/udp |
8435 |
+rsync 873/tcp # rsync |
8436 |
+rsync 873/udp |
8437 |
+ftps-data 989/tcp # ftp protocol, data, over TLS/SSL |
8438 |
+ftps-data 989/udp |
8439 |
+ftps 990/tcp # ftp protocol, control, over TLS/SSL |
8440 |
+ftps 990/udp |
8441 |
+nas 991/tcp # Netnews Administration System |
8442 |
+nas 991/udp |
8443 |
+telnets 992/tcp # telnet protocol over TLS/SSL |
8444 |
+telnets 992/udp |
8445 |
+imaps 993/tcp # imap4 protocol over TLS/SSL |
8446 |
+imaps 993/udp |
8447 |
+ircs 994/tcp # irc protocol over TLS/SSL |
8448 |
+ircs 994/udp |
8449 |
+pop3s 995/tcp # pop3 protocol over TLS/SSL |
8450 |
+pop3s 995/udp |
8451 |
+ |
8452 |
+# |
8453 |
+# IANA Assignments [Registered Ports] |
8454 |
+# |
8455 |
+# The Registered Ports are listed by the IANA and on most systems can be |
8456 |
+# used by ordinary user processes or programs executed by ordinary |
8457 |
+# users. |
8458 |
+# Ports are used in the TCP [RFC793] to name the ends of logical |
8459 |
+# connections which carry long term conversations. For the purpose of |
8460 |
+# providing services to unknown callers, a service contact port is |
8461 |
+# defined. This list specifies the port used by the server process as |
8462 |
+# its contact port. |
8463 |
+# The IANA registers uses of these ports as a convenience to the |
8464 |
+# community. |
8465 |
+# To the extent possible, these same port assignments are used with the |
8466 |
+# UDP [RFC768]. |
8467 |
+# The Registered Ports are in the range 1024-49151. |
8468 |
+# |
8469 |
+imgames 1077/tcp |
8470 |
+imgames 1077/udp |
8471 |
+socks 1080/tcp # socks proxy server |
8472 |
+socks 1080/udp |
8473 |
+rmiregistry 1099/tcp # Java RMI Registry |
8474 |
+rmiregistry 1099/udp |
8475 |
+bnetgame 1119/tcp # Battle.net Chat/Game Protocol |
8476 |
+bnetgame 1119/udp |
8477 |
+bnetfile 1120/tcp # Battle.net File Transfer Protocol |
8478 |
+bnetfile 1120/udp |
8479 |
+hpvmmcontrol 1124/tcp # HP VMM Control |
8480 |
+hpvmmcontrol 1124/udp |
8481 |
+hpvmmagent 1125/tcp # HP VMM Agent |
8482 |
+hpvmmagent 1125/udp |
8483 |
+hpvmmdata 1126/tcp # HP VMM Agent |
8484 |
+hpvmmdata 1126/udp |
8485 |
+resacommunity 1154/tcp # Community Service |
8486 |
+resacommunity 1154/udp |
8487 |
+3comnetman 1181/tcp # 3Com Net Management |
8488 |
+3comnetman 1181/udp |
8489 |
+mysql-cluster 1186/tcp # MySQL Cluster Manager |
8490 |
+mysql-cluster 1186/udp |
8491 |
+alias 1187/tcp # Alias Service |
8492 |
+alias 1187/udp |
8493 |
+openvpn 1194/tcp # OpenVPN |
8494 |
+openvpn 1194/udp |
8495 |
+kazaa 1214/tcp # KAZAA |
8496 |
+kazaa 1214/udp |
8497 |
+bvcontrol 1236/tcp rmtcfg # Gracilis Packeten remote config server |
8498 |
+bvcontrol 1236/udp rmtcfg |
8499 |
+nessus 1241/tcp # Nessus vulnerability assessment scanner |
8500 |
+nessus 1241/udp |
8501 |
+h323hostcallsc 1300/tcp # H323 Host Call Secure |
8502 |
+h323hostcallsc 1300/udp |
8503 |
+lotusnote 1352/tcp # Lotus Note |
8504 |
+lotusnote 1352/udp |
8505 |
+ms-sql-s 1433/tcp # Microsoft-SQL-Server |
8506 |
+ms-sql-s 1433/udp |
8507 |
+ms-sql-m 1434/tcp # Microsoft-SQL-Monitor |
8508 |
+ms-sql-m 1434/udp |
8509 |
+ica 1494/tcp # Citrix ICA Client |
8510 |
+ica 1494/udp |
8511 |
+wins 1512/tcp # Microsoft's Windows Internet Name Service |
8512 |
+wins 1512/udp |
8513 |
+ingreslock 1524/tcp |
8514 |
+ingreslock 1524/udp |
8515 |
+prospero-np 1525/tcp # Prospero non-privileged |
8516 |
+prospero-np 1525/udp |
8517 |
+datametrics 1645/tcp old-radius # datametrics / old radius entry |
8518 |
+datametrics 1645/udp old-radius |
8519 |
+sa-msg-port 1646/tcp old-radacct # sa-msg-port / old radacct entry |
8520 |
+sa-msg-port 1646/udp old-radacct |
8521 |
+rsap 1647/tcp |
8522 |
+rsap 1647/udp |
8523 |
+concurrent-lm 1648/tcp |
8524 |
+concurrent-lm 1648/udp |
8525 |
+kermit 1649/tcp |
8526 |
+kermit 1649/udp |
8527 |
+l2tp 1701/tcp |
8528 |
+l2tp 1701/udp |
8529 |
+h323gatedisc 1718/tcp |
8530 |
+h323gatedisc 1718/udp |
8531 |
+h323gatestat 1719/tcp |
8532 |
+h323gatestat 1719/udp |
8533 |
+h323hostcall 1720/tcp |
8534 |
+h323hostcall 1720/udp |
8535 |
+iberiagames 1726/tcp |
8536 |
+iberiagames 1726/udp |
8537 |
+gamegen1 1738/tcp |
8538 |
+gamegen1 1738/udp |
8539 |
+tftp-mcast 1758/tcp |
8540 |
+tftp-mcast 1758/udp |
8541 |
+hello 1789/tcp |
8542 |
+hello 1789/udp |
8543 |
+radius 1812/tcp # Radius |
8544 |
+radius 1812/udp |
8545 |
+radius-acct 1813/tcp radacct # Radius Accounting |
8546 |
+radius-acct 1813/udp radacct |
8547 |
+mtp 1911/tcp # Starlight Networks Multimedia Transport Protocol |
8548 |
+mtp 1911/udp |
8549 |
+egs 1926/tcp # Evolution Game Server |
8550 |
+egs 1926/udp |
8551 |
+unix-status 1957/tcp # remstats unix-status server |
8552 |
+unix-status 1957/udp |
8553 |
+hsrp 1985/tcp # Hot Standby Router Protocol |
8554 |
+hsrp 1985/udp |
8555 |
+licensedaemon 1986/tcp # cisco license management |
8556 |
+licensedaemon 1986/udp |
8557 |
+tr-rsrb-p1 1987/tcp # cisco RSRB Priority 1 port |
8558 |
+tr-rsrb-p1 1987/udp |
8559 |
+tr-rsrb-p2 1988/tcp # cisco RSRB Priority 2 port |
8560 |
+tr-rsrb-p2 1988/udp |
8561 |
+tr-rsrb-p3 1989/tcp # cisco RSRB Priority 3 port |
8562 |
+tr-rsrb-p3 1989/udp |
8563 |
+stun-p1 1990/tcp # cisco STUN Priority 1 port |
8564 |
+stun-p1 1990/udp |
8565 |
+stun-p2 1991/tcp # cisco STUN Priority 2 port |
8566 |
+stun-p2 1991/udp |
8567 |
+stun-p3 1992/tcp # cisco STUN Priority 3 port |
8568 |
+stun-p3 1992/udp |
8569 |
+snmp-tcp-port 1994/tcp # cisco SNMP TCP port |
8570 |
+snmp-tcp-port 1994/udp |
8571 |
+stun-port 1995/tcp # cisco serial tunnel port |
8572 |
+stun-port 1995/udp |
8573 |
+perf-port 1996/tcp # cisco Remote SRB port |
8574 |
+perf-port 1996/udp |
8575 |
+gdp-port 1997/tcp # cisco Gateway Discovery Protocol |
8576 |
+gdp-port 1997/udp |
8577 |
+x25-svc-port 1998/tcp # cisco X.25 service (XOT) |
8578 |
+x25-svc-port 1998/udp |
8579 |
+tcp-id-port 1999/tcp # cisco identification port |
8580 |
+tcp-id-port 1999/udp |
8581 |
+cisco-sccp 2000/tcp sieve # Cisco SCCP |
8582 |
+cisco-sccp 2000/udp sieve |
8583 |
+nfs 2049/tcp # Network File System |
8584 |
+nfs 2049/udp |
8585 |
+radsec 2083/tcp # Secure Radius Service |
8586 |
+radsec 2083/udp |
8587 |
+gnunet 2086/tcp # GNUnet |
8588 |
+gnunet 2086/udp |
8589 |
+rtcm-sc104 2101/tcp # RTCM SC-104 |
8590 |
+rtcm-sc104 2101/udp |
8591 |
+zephyr-srv 2102/tcp # Zephyr server |
8592 |
+zephyr-srv 2102/udp |
8593 |
+zephyr-clt 2103/tcp # Zephyr serv-hm connection |
8594 |
+zephyr-clt 2103/udp |
8595 |
+zephyr-hm 2104/tcp # Zephyr hostmanager |
8596 |
+zephyr-hm 2104/udp |
8597 |
+eyetv 2170/tcp # EyeTV Server Port |
8598 |
+eyetv 2170/udp |
8599 |
+msfw-storage 2171/tcp # MS Firewall Storage |
8600 |
+msfw-storage 2171/udp |
8601 |
+msfw-s-storage 2172/tcp # MS Firewall SecureStorage |
8602 |
+msfw-s-storage 2172/udp |
8603 |
+msfw-replica 2173/tcp # MS Firewall Replication |
8604 |
+msfw-replica 2173/udp |
8605 |
+msfw-array 2174/tcp # MS Firewall Intra Array |
8606 |
+msfw-array 2174/udp |
8607 |
+airsync 2175/tcp # Microsoft Desktop AirSync Protocol |
8608 |
+airsync 2175/udp |
8609 |
+rapi 2176/tcp # Microsoft ActiveSync Remote API |
8610 |
+rapi 2176/udp |
8611 |
+qwave 2177/tcp # qWAVE Bandwidth Estimate |
8612 |
+qwave 2177/udp |
8613 |
+tivoconnect 2190/tcp # TiVoConnect Beacon |
8614 |
+tivoconnect 2190/udp |
8615 |
+tvbus 2191/tcp # TvBus Messaging |
8616 |
+tvbus 2191/udp |
8617 |
+mysql-im 2273/tcp # MySQL Instance Manager |
8618 |
+mysql-im 2273/udp |
8619 |
+dict-lookup 2289/tcp # Lookup dict server |
8620 |
+dict-lookup 2289/udp |
8621 |
+redstorm_join 2346/tcp # Game Connection Port |
8622 |
+redstorm_join 2346/udp |
8623 |
+redstorm_find 2347/tcp # Game Announcement and Location |
8624 |
+redstorm_find 2347/udp |
8625 |
+redstorm_info 2348/tcp # Information to query for game status |
8626 |
+redstorm_info 2348/udp |
8627 |
+cvspserver 2401/tcp # CVS client/server operations |
8628 |
+cvspserver 2401/udp |
8629 |
+venus 2430/tcp # codacon port |
8630 |
+venus 2430/udp |
8631 |
+venus-se 2431/tcp # tcp side effects |
8632 |
+venus-se 2431/udp |
8633 |
+codasrv 2432/tcp # not used |
8634 |
+codasrv 2432/udp |
8635 |
+codasrv-se 2433/tcp # tcp side effects |
8636 |
+codasrv-se 2433/udp |
8637 |
+netadmin 2450/tcp |
8638 |
+netadmin 2450/udp |
8639 |
+netchat 2451/tcp |
8640 |
+netchat 2451/udp |
8641 |
+snifferclient 2452/tcp |
8642 |
+snifferclient 2452/udp |
8643 |
+ppcontrol 2505/tcp # PowerPlay Control |
8644 |
+ppcontrol 2505/udp |
8645 |
+lstp 2559/tcp # |
8646 |
+lstp 2559/udp |
8647 |
+mon 2583/tcp |
8648 |
+mon 2583/udp |
8649 |
+hpstgmgr 2600/tcp zebrasrv |
8650 |
+hpstgmgr 2600/udp zebrasrv |
8651 |
+discp-client 2601/tcp zebra # discp client |
8652 |
+discp-client 2601/udp zebra |
8653 |
+discp-server 2602/tcp ripd # discp server |
8654 |
+discp-server 2602/udp ripd |
8655 |
+servicemeter 2603/tcp ripngd # Service Meter |
8656 |
+servicemeter 2603/udp ripngd |
8657 |
+nsc-ccs 2604/tcp ospfd # NSC CCS |
8658 |
+nsc-ccs 2604/udp ospfd |
8659 |
+nsc-posa 2605/tcp bgpd # NSC POSA |
8660 |
+nsc-posa 2605/udp bgpd |
8661 |
+netmon 2606/tcp ospf6d # Dell Netmon |
8662 |
+netmon 2606/udp ospf6d |
8663 |
+connection 2607/tcp # Dell Connection |
8664 |
+connection 2607/udp |
8665 |
+wag-service 2608/tcp # Wag Service |
8666 |
+wag-service 2608/udp |
8667 |
+dict 2628/tcp # Dictionary server |
8668 |
+dict 2628/udp |
8669 |
+exce 2769/tcp # eXcE |
8670 |
+exce 2769/udp |
8671 |
+dvr-esm 2804/tcp # March Networks Digital Video Recorders and Enterprise Service Manager products |
8672 |
+dvr-esm 2804/udp |
8673 |
+corbaloc 2809/tcp # CORBA LOC |
8674 |
+corbaloc 2809/udp |
8675 |
+ndtp 2882/tcp # Network Dictionary Transfer Protocol |
8676 |
+ndtp 2882/udp |
8677 |
+gamelobby 2914/tcp # Game Lobby |
8678 |
+gamelobby 2914/udp |
8679 |
+gds_db 3050/tcp # InterBase server |
8680 |
+gds_db 3050/udp |
8681 |
+xbox 3074/tcp # Xbox game port |
8682 |
+xbox 3074/udp |
8683 |
+icpv2 3130/tcp icp # Internet Cache Protocol (Squid) |
8684 |
+icpv2 3130/udp icp |
8685 |
+nm-game-admin 3148/tcp # NetMike Game Administrator |
8686 |
+nm-game-admin 3148/udp |
8687 |
+nm-game-server 3149/tcp # NetMike Game Server |
8688 |
+nm-game-server 3149/udp |
8689 |
+mysql 3306/tcp # MySQL |
8690 |
+mysql 3306/udp |
8691 |
+sftu 3326/tcp |
8692 |
+sftu 3326/udp |
8693 |
+trnsprntproxy 3346/tcp # Transparent Proxy |
8694 |
+trnsprntproxy 3346/udp |
8695 |
+ms-wbt-server 3389/tcp rdp # MS WBT Server |
8696 |
+ms-wbt-server 3389/udp rdp # Microsoft Remote Desktop Protocol |
8697 |
+prsvp 3455/tcp # RSVP Port |
8698 |
+prsvp 3455/udp |
8699 |
+nut 3493/tcp # Network UPS Tools |
8700 |
+nut 3493/udp |
8701 |
+ironstorm 3504/tcp # IronStorm game server |
8702 |
+ironstorm 3504/udp |
8703 |
+cctv-port 3559/tcp # CCTV control port |
8704 |
+cctv-port 3559/udp |
8705 |
+iw-mmogame 3596/tcp # Illusion Wireless MMOG |
8706 |
+iw-mmogame 3596/udp |
8707 |
+distcc 3632/tcp # Distributed Compiler |
8708 |
+distcc 3632/udp |
8709 |
+daap 3689/tcp # Digital Audio Access Protocol |
8710 |
+daap 3689/udp |
8711 |
+svn 3690/tcp # Subversion |
8712 |
+svn 3690/udp |
8713 |
+blizwow 3724/tcp # World of Warcraft |
8714 |
+blizwow 3724/udp |
8715 |
+netboot-pxe 3928/tcp pxe # PXE NetBoot Manager |
8716 |
+netboot-pxe 3928/udp pxe |
8717 |
+smauth-port 3929/tcp # AMS Port |
8718 |
+smauth-port 3929/udp |
8719 |
+treehopper 3959/tcp # Tree Hopper Networking |
8720 |
+treehopper 3959/udp |
8721 |
+cobraclient 3970/tcp # Cobra Client |
8722 |
+cobraclient 3970/udp |
8723 |
+cobraserver 3971/tcp # Cobra Server |
8724 |
+cobraserver 3971/udp |
8725 |
+pxc-spvr-ft 4002/tcp pxc-spvr-ft |
8726 |
+pxc-spvr-ft 4002/udp pxc-spvr-ft |
8727 |
+pxc-splr-ft 4003/tcp pxc-splr-ft rquotad |
8728 |
+pxc-splr-ft 4003/udp pxc-splr-ft rquotad |
8729 |
+pxc-roid 4004/tcp pxc-roid |
8730 |
+pxc-roid 4004/udp pxc-roid |
8731 |
+pxc-pin 4005/tcp pxc-pin |
8732 |
+pxc-pin 4005/udp pxc-pin |
8733 |
+pxc-spvr 4006/tcp pxc-spvr |
8734 |
+pxc-spvr 4006/udp pxc-spvr |
8735 |
+pxc-splr 4007/tcp pxc-splr |
8736 |
+pxc-splr 4007/udp pxc-splr |
8737 |
+xgrid 4111/tcp # Mac OS X Server Xgrid |
8738 |
+xgrid 4111/udp |
8739 |
+rwhois 4321/tcp # Remote Who Is |
8740 |
+rwhois 4321/udp |
8741 |
+epmd 4369/tcp # Erlang Port Mapper Daemon |
8742 |
+epmd 4369/udp |
8743 |
+krb524 4444/tcp |
8744 |
+krb524 4444/udp |
8745 |
+ipsec-nat-t 4500/tcp # IPsec NAT-Traversal |
8746 |
+ipsec-nat-t 4500/udp |
8747 |
+hylafax 4559/tcp # HylaFAX client-server protocol (new) |
8748 |
+hylafax 4559/udp |
8749 |
+piranha1 4600/tcp |
8750 |
+piranha1 4600/udp |
8751 |
+playsta2-app 4658/tcp # PlayStation2 App Port |
8752 |
+playsta2-app 4658/udp |
8753 |
+playsta2-lob 4659/tcp # PlayStation2 Lobby Port |
8754 |
+playsta2-lob 4659/udp |
8755 |
+snap 4752/tcp # Simple Network Audio Protocol |
8756 |
+snap 4752/udp |
8757 |
+radmin-port 4899/tcp # RAdmin Port |
8758 |
+radmin-port 4899/udp |
8759 |
+rfe 5002/tcp # Radio Free Ethernet |
8760 |
+rfe 5002/udp |
8761 |
+ita-agent 5051/tcp # ITA Agent |
8762 |
+ita-agent 5051/udp |
8763 |
+sdl-ets 5081/tcp # SDL - Ent Trans Server |
8764 |
+sdl-ets 5081/udp |
8765 |
+bzflag 5154/tcp # BZFlag game server |
8766 |
+bzflag 5154/udp |
8767 |
+aol 5190/tcp # America-Online |
8768 |
+aol 5190/udp |
8769 |
+xmpp-client 5222/tcp # XMPP Client Connection |
8770 |
+xmpp-client 5222/udp |
8771 |
+caevms 5251/tcp # CA eTrust VM Service |
8772 |
+caevms 5251/udp |
8773 |
+xmpp-server 5269/tcp # XMPP Server Connection |
8774 |
+xmpp-server 5269/udp |
8775 |
+cfengine 5308/tcp # CFengine |
8776 |
+cfengine 5308/udp |
8777 |
+nat-pmp 5351/tcp # NAT Port Mapping Protocol |
8778 |
+nat-pmp 5351/udp |
8779 |
+dns-llq 5352/tcp # DNS Long-Lived Queries |
8780 |
+dns-llq 5352/udp |
8781 |
+mdns 5353/tcp # Multicast DNS |
8782 |
+mdns 5353/udp |
8783 |
+mdnsresponder 5354/tcp noclog # Multicast DNS Responder IPC |
8784 |
+mdnsresponder 5354/udp noclog # noclogd with TCP (nocol) |
8785 |
+llmnr 5355/tcp hostmon # Link-Local Multicast Name Resolution |
8786 |
+llmnr 5355/udp hostmon # hostmon uses TCP (nocol) |
8787 |
+dj-ice 5419/tcp |
8788 |
+dj-ice 5419/udp |
8789 |
+beyond-remote 5424/tcp # Beyond Remote |
8790 |
+beyond-remote 5424/udp |
8791 |
+br-channel 5425/tcp # Beyond Remote Command Channel |
8792 |
+br-channel 5425/udp |
8793 |
+postgresql 5432/tcp # POSTGRES |
8794 |
+postgresql 5432/udp |
8795 |
+sgi-eventmond 5553/tcp # SGI Eventmond Port |
8796 |
+sgi-eventmond 5553/udp |
8797 |
+sgi-esphttp 5554/tcp # SGI ESP HTTP |
8798 |
+sgi-esphttp 5554/udp |
8799 |
+cvsup 5999/tcp # CVSup |
8800 |
+cvsup 5999/udp |
8801 |
+x11 6000/tcp # X Window System |
8802 |
+x11 6000/udp |
8803 |
+kftp-data 6620/tcp # Kerberos V5 FTP Data |
8804 |
+kftp-data 6620/udp |
8805 |
+kftp 6621/tcp # Kerberos V5 FTP Control |
8806 |
+kftp 6621/udp |
8807 |
+ktelnet 6623/tcp # Kerberos V5 Telnet |
8808 |
+ktelnet 6623/udp |
8809 |
+gnutella-svc 6346/tcp |
8810 |
+gnutella-svc 6346/udp |
8811 |
+gnutella-rtr 6347/tcp |
8812 |
+gnutella-rtr 6347/udp |
8813 |
+sane-port 6566/tcp # SANE Network Scanner Control Port |
8814 |
+sane-port 6566/udp |
8815 |
+parsec-game 6582/tcp # Parsec Gameserver |
8816 |
+parsec-game 6582/udp |
8817 |
+afs3-fileserver 7000/tcp bbs # file server itself |
8818 |
+afs3-fileserver 7000/udp bbs |
8819 |
+afs3-callback 7001/tcp # callbacks to cache managers |
8820 |
+afs3-callback 7001/udp |
8821 |
+afs3-prserver 7002/tcp # users & groups database |
8822 |
+afs3-prserver 7002/udp |
8823 |
+afs3-vlserver 7003/tcp # volume location database |
8824 |
+afs3-vlserver 7003/udp |
8825 |
+afs3-kaserver 7004/tcp # AFS/Kerberos authentication |
8826 |
+afs3-kaserver 7004/udp |
8827 |
+afs3-volser 7005/tcp # volume managment server |
8828 |
+afs3-volser 7005/udp |
8829 |
+afs3-errors 7006/tcp # error interpretation service |
8830 |
+afs3-errors 7006/udp |
8831 |
+afs3-bos 7007/tcp # basic overseer process |
8832 |
+afs3-bos 7007/udp |
8833 |
+afs3-update 7008/tcp # server-to-server updater |
8834 |
+afs3-update 7008/udp |
8835 |
+afs3-rmtsys 7009/tcp # remote cache manager service |
8836 |
+afs3-rmtsys 7009/udp |
8837 |
+font-service 7100/tcp xfs # X Font Service |
8838 |
+font-service 7100/udp xfs |
8839 |
+sncp 7560/tcp # Sniffer Command Protocol |
8840 |
+sncp 7560/udp |
8841 |
+soap-http 7627/tcp # SOAP Service Port |
8842 |
+soap-http 7627/udp |
8843 |
+http-alt 8008/tcp # HTTP Alternate |
8844 |
+http-alt 8008/udp |
8845 |
+http-alt 8080/tcp webcache # HTTP Alternate |
8846 |
+http-alt 8080/udp webcache # WWW caching service |
8847 |
+sunproxyadmin 8081/tcp tproxy # Sun Proxy Admin Service |
8848 |
+sunproxyadmin 8081/udp tproxy # Transparent Proxy |
8849 |
+pichat 9009/tcp # Pichat Server |
8850 |
+pichat 9009/udp |
8851 |
+bacula-dir 9101/tcp # Bacula Director |
8852 |
+bacula-dir 9101/udp |
8853 |
+bacula-fd 9102/tcp # Bacula File Daemon |
8854 |
+bacula-fd 9102/udp |
8855 |
+bacula-sd 9103/tcp # Bacula Storage Daemon |
8856 |
+bacula-sd 9103/udp |
8857 |
+dddp 9131/tcp # Dynamic Device Discovery |
8858 |
+dddp 9131/udp |
8859 |
+wap-wsp 9200/tcp # WAP connectionless session service |
8860 |
+wap-wsp 9200/udp |
8861 |
+wap-wsp-wtp 9201/tcp # WAP session service |
8862 |
+wap-wsp-wtp 9201/udp |
8863 |
+wap-wsp-s 9202/tcp # WAP secure connectionless session service |
8864 |
+wap-wsp-s 9202/udp |
8865 |
+wap-wsp-wtp-s 9203/tcp # WAP secure session service |
8866 |
+wap-wsp-wtp-s 9203/udp |
8867 |
+wap-vcard 9204/tcp # WAP vCard |
8868 |
+wap-vcard 9204/udp |
8869 |
+wap-vcal 9205/tcp # WAP vCal |
8870 |
+wap-vcal 9205/udp |
8871 |
+wap-vcard-s 9206/tcp # WAP vCard Secure |
8872 |
+wap-vcard-s 9206/udp |
8873 |
+wap-vcal-s 9207/tcp # WAP vCal Secure |
8874 |
+wap-vcal-s 9207/udp |
8875 |
+git 9418/tcp # git pack transfer service |
8876 |
+git 9418/udp |
8877 |
+cba8 9593/tcp # LANDesk Management Agent |
8878 |
+cba8 9593/udp |
8879 |
+davsrc 9800/tcp # WebDav Source Port |
8880 |
+davsrc 9800/udp |
8881 |
+sd 9876/tcp # Session Director |
8882 |
+sd 9876/udp |
8883 |
+cyborg-systems 9888/tcp # CYBORG Systems |
8884 |
+cyborg-systems 9888/udp |
8885 |
+monkeycom 9898/tcp # MonkeyCom |
8886 |
+monkeycom 9898/udp |
8887 |
+sctp-tunneling 9899/tcp # SCTP TUNNELING |
8888 |
+sctp-tunneling 9899/udp |
8889 |
+domaintime 9909/tcp # domaintime |
8890 |
+domaintime 9909/udp |
8891 |
+amanda 10080/tcp # amanda backup services |
8892 |
+amanda 10080/udp |
8893 |
+vce 11111/tcp # Viral Computing Environment (VCE) |
8894 |
+vce 11111/udp |
8895 |
+smsqp 11201/tcp # Alamin SMS gateway |
8896 |
+smsqp 11201/udp |
8897 |
+hkp 11371/tcp # OpenPGP HTTP Keyserver |
8898 |
+hkp 11371/udp |
8899 |
+h323callsigalt 11720/tcp # h323 Call Signal Alternate |
8900 |
+h323callsigalt 11720/udp |
8901 |
+rets-ssl 12109/tcp # RETS over SSL |
8902 |
+rets-ssl 12109/udp |
8903 |
+cawas 12168/tcp # CA Web Access Service |
8904 |
+cawas 12168/udp |
8905 |
+bprd 13720/tcp # BPRD Protocol (VERITAS NetBackup) |
8906 |
+bprd 13720/udp |
8907 |
+bpdbm 13721/tcp # BPDBM Protocol (VERITAS NetBackup) |
8908 |
+bpdbm 13721/udp |
8909 |
+bpjava-msvc 13722/tcp # BP Java MSVC Protocol |
8910 |
+bpjava-msvc 13722/udp |
8911 |
+vnetd 13724/tcp # Veritas Network Utility |
8912 |
+vnetd 13724/udp |
8913 |
+bpcd 13782/tcp # VERITAS NetBackup |
8914 |
+bpcd 13782/udp |
8915 |
+vopied 13783/tcp # VOPIED Protocol |
8916 |
+vopied 13783/udp |
8917 |
+xpilot 15345/tcp # XPilot Contact Port |
8918 |
+xpilot 15345/udp |
8919 |
+wnn6 22273/tcp # wnn6 |
8920 |
+wnn6 22273/udp |
8921 |
+binkp 24554/tcp # Bink fidonet protocol |
8922 |
+binkp 24554/udp |
8923 |
+quake 26000/tcp # Quake @!# |
8924 |
+quake 26000/udp |
8925 |
+wnn6-ds 26208/tcp |
8926 |
+wnn6-ds 26208/udp |
8927 |
+tetrinet 31457/tcp # TetriNET Protocol |
8928 |
+tetrinet 31457/udp |
8929 |
+gamesmith-port 31765/tcp # GameSmith Port |
8930 |
+gamesmith-port 31765/udp |
8931 |
+traceroute 33434/tcp # traceroute use |
8932 |
+traceroute 33434/udp |
8933 |
+candp 42508/tcp # Computer Associates network discovery protocol |
8934 |
+candp 42508/udp |
8935 |
+candrp 42509/tcp # CA discovery response |
8936 |
+candrp 42509/udp |
8937 |
+caerpc 42510/tcp # CA eTrust RPC |
8938 |
+caerpc 42510/udp |
8939 |
+ |
8940 |
+#========================================================================= |
8941 |
+# The remaining port numbers are not as allocated by IANA. |
8942 |
+ |
8943 |
+# Kerberos (Project Athena/MIT) services |
8944 |
+# Note that these are for Kerberos v4, and are unofficial |
8945 |
+kpop 1109/tcp # Pop with Kerberos |
8946 |
+knetd 2053/tcp # Kerberos de-multiplexor |
8947 |
+eklogin 2105/tcp # Kerberos encrypted rlogin |
8948 |
+ |
8949 |
+# CVSup support http://www.cvsup.org/ |
8950 |
+supfilesrv 871/tcp # SUP server |
8951 |
+supfiledbg 1127/tcp # SUP debugging |
8952 |
+ |
8953 |
+# Datagram Delivery Protocol services |
8954 |
+rtmp 1/ddp # Routing Table Maintenance Protocol |
8955 |
+nbp 2/ddp # Name Binding Protocol |
8956 |
+echo 4/ddp # AppleTalk Echo Protocol |
8957 |
+zip 6/ddp # Zone Information Protocol |
8958 |
+ |
8959 |
+# Many services now accepted as 'standard' |
8960 |
+swat 901/tcp # Samba configuration tool |
8961 |
+rndc 953/tcp # rndc control sockets (BIND 9) |
8962 |
+rndc 953/udp |
8963 |
+skkserv 1178/tcp # SKK Japanese input method |
8964 |
+xtel 1313/tcp # french minitel |
8965 |
+support 1529/tcp # GNATS |
8966 |
+cfinger 2003/tcp lmtp # GNU Finger |
8967 |
+ninstall 2150/tcp # ninstall service |
8968 |
+ninstall 2150/udp |
8969 |
+afbackup 2988/tcp # Afbackup system |
8970 |
+afbackup 2988/udp |
8971 |
+fax 4557/tcp # FAX transmission service (old) |
8972 |
+rplay 5555/tcp # RPlay audio service |
8973 |
+rplay 5555/udp |
8974 |
+canna 5680/tcp # Canna (Japanese Input) |
8975 |
+x11-ssh 6010/tcp x11-ssh-offset |
8976 |
+x11-ssh 6010/udp x11-ssh-offset |
8977 |
+ircd 6667/tcp # Internet Relay Chat |
8978 |
+ircd 6667/udp |
8979 |
+jetdirect 9100/tcp # HP JetDirect card |
8980 |
+jetdirect 9100/udp |
8981 |
+mandelspawn 9359/udp mandelbrot # network mandelbrot |
8982 |
+kamanda 10081/tcp # amanda backup services (Kerberos) |
8983 |
+kamanda 10081/udp |
8984 |
+amandaidx 10082/tcp # amanda backup services |
8985 |
+amidxtape 10083/tcp # amanda backup services |
8986 |
+isdnlog 20011/tcp # isdn logging system |
8987 |
+isdnlog 20011/udp |
8988 |
+vboxd 20012/tcp # voice box system |
8989 |
+vboxd 20012/udp |
8990 |
+wnn4_Cn 22289/tcp wnn6_Cn # Wnn (Chinese input) |
8991 |
+wnn4_Kr 22305/tcp wnn6_Kr # Wnn (Korean input) |
8992 |
+wnn4_Tw 22321/tcp wnn6_Tw # Wnn (Taiwanse input) |
8993 |
+asp 27374/tcp # Address Search Protocol |
8994 |
+asp 27374/udp |
8995 |
+tfido 60177/tcp # Ifmail |
8996 |
+tfido 60177/udp |
8997 |
+fido 60179/tcp # Ifmail |
8998 |
+fido 60179/udp |
8999 |
+ |
9000 |
+# Local services |
9001 |
+ |
9002 |
|
9003 |
Added: trunk/baselayout-prefix/etc/shadow |
9004 |
=================================================================== |
9005 |
--- trunk/baselayout-prefix/etc/shadow (rev 0) |
9006 |
+++ trunk/baselayout-prefix/etc/shadow 2011-03-31 14:11:17 UTC (rev 1682) |
9007 |
@@ -0,0 +1,16 @@ |
9008 |
+root:*:10770:0::::: |
9009 |
+halt:*:9797:0::::: |
9010 |
+operator:*:9797:0::::: |
9011 |
+shutdown:*:9797:0::::: |
9012 |
+sync:*:9797:0::::: |
9013 |
+bin:*:9797:0::::: |
9014 |
+daemon:*:9797:0::::: |
9015 |
+adm:*:9797:0::::: |
9016 |
+lp:*:9797:0::::: |
9017 |
+mail:*:9797:0::::: |
9018 |
+postmaster:*:9797:0::::: |
9019 |
+news:*:9797:0::::: |
9020 |
+uucp:*:9797:0::::: |
9021 |
+games:*:9797:0::::: |
9022 |
+guest:*:9797:0::::: |
9023 |
+nobody:*:9797:0::::: |
9024 |
|
9025 |
Added: trunk/baselayout-prefix/etc/shells |
9026 |
=================================================================== |
9027 |
--- trunk/baselayout-prefix/etc/shells (rev 0) |
9028 |
+++ trunk/baselayout-prefix/etc/shells 2011-03-31 14:11:17 UTC (rev 1682) |
9029 |
@@ -0,0 +1,9 @@ |
9030 |
+# /etc/shells: valid login shells |
9031 |
+/bin/sh |
9032 |
+/bin/bash |
9033 |
+/bin/tcsh |
9034 |
+/bin/csh |
9035 |
+/bin/esh |
9036 |
+/bin/ksh |
9037 |
+/bin/zsh |
9038 |
+/bin/sash |
9039 |
|
9040 |
Added: trunk/baselayout-prefix/etc/sysctl.conf |
9041 |
=================================================================== |
9042 |
--- trunk/baselayout-prefix/etc/sysctl.conf (rev 0) |
9043 |
+++ trunk/baselayout-prefix/etc/sysctl.conf 2011-03-31 14:11:17 UTC (rev 1682) |
9044 |
@@ -0,0 +1,54 @@ |
9045 |
+# /etc/sysctl.conf |
9046 |
+# |
9047 |
+# For more information on how this file works, please see |
9048 |
+# the manpages sysctl(8) and sysctl.conf(5). |
9049 |
+# |
9050 |
+# In order for this file to work properly, you must first |
9051 |
+# enable 'Sysctl support' in the kernel. |
9052 |
+# |
9053 |
+# Look in /proc/sys/ for all the things you can setup. |
9054 |
+# |
9055 |
+ |
9056 |
+# Disables packet forwarding |
9057 |
+#net.ipv4.ip_forward = 0 |
9058 |
+# Disables IP dynaddr |
9059 |
+#net.ipv4.ip_dynaddr = 0 |
9060 |
+# Disable ECN |
9061 |
+#net.ipv4.tcp_ecn = 0 |
9062 |
+# Enables source route verification |
9063 |
+net.ipv4.conf.default.rp_filter = 1 |
9064 |
+# Enable reverse path |
9065 |
+net.ipv4.conf.all.rp_filter = 1 |
9066 |
+ |
9067 |
+# Enable SYN cookies (yum!) |
9068 |
+# http://cr.yp.to/syncookies.html |
9069 |
+#net.ipv4.tcp_syncookies = 1 |
9070 |
+ |
9071 |
+# Disable source route |
9072 |
+#net.ipv4.conf.all.accept_source_route = 0 |
9073 |
+#net.ipv4.conf.default.accept_source_route = 0 |
9074 |
+ |
9075 |
+# Disable redirects |
9076 |
+#net.ipv4.conf.all.accept_redirects = 0 |
9077 |
+#net.ipv4.conf.default.accept_redirects = 0 |
9078 |
+ |
9079 |
+# Disable secure redirects |
9080 |
+#net.ipv4.conf.all.secure_redirects = 0 |
9081 |
+#net.ipv4.conf.default.secure_redirects = 0 |
9082 |
+ |
9083 |
+# Ignore ICMP broadcasts |
9084 |
+#net.ipv4.icmp_echo_ignore_broadcasts = 1 |
9085 |
+ |
9086 |
+# Disables the magic-sysrq key |
9087 |
+#kernel.sysrq = 0 |
9088 |
+# When the kernel panics, automatically reboot in 3 seconds |
9089 |
+#kernel.panic = 3 |
9090 |
+# Allow for more PIDs (cool factor!); may break some programs |
9091 |
+#kernel.pid_max = 999999 |
9092 |
+ |
9093 |
+# You should compile nfsd into the kernel or add it |
9094 |
+# to modules.autoload for this to work properly |
9095 |
+# TCP Port for lock manager |
9096 |
+#fs.nfs.nlm_tcpport = 0 |
9097 |
+# UDP Port for lock manager |
9098 |
+#fs.nfs.nlm_udpport = 0 |
9099 |
|
9100 |
Added: trunk/baselayout-prefix/init.d/bootmisc |
9101 |
=================================================================== |
9102 |
--- trunk/baselayout-prefix/init.d/bootmisc (rev 0) |
9103 |
+++ trunk/baselayout-prefix/init.d/bootmisc 2011-03-31 14:11:17 UTC (rev 1682) |
9104 |
@@ -0,0 +1,137 @@ |
9105 |
+#!/sbin/runscript |
9106 |
+# Copyright 1999-2006 Gentoo Foundation |
9107 |
+# Distributed under the terms of the GNU General Public License v2 |
9108 |
+ |
9109 |
+depend() { |
9110 |
+ use clock hostname |
9111 |
+ need localmount |
9112 |
+ before logger |
9113 |
+} |
9114 |
+ |
9115 |
+start() { |
9116 |
+ [[ ${BOOT} != "yes" ]] && return 0 |
9117 |
+ |
9118 |
+ # |
9119 |
+ # Put a nologin file in /etc to prevent people from logging in before |
9120 |
+ # system startup is complete. |
9121 |
+ # |
9122 |
+ if [[ ${DELAYLOGIN} == "yes" ]] ; then |
9123 |
+ echo "System bootup in progress - please wait" > /etc/nologin |
9124 |
+ cp /etc/nologin /etc/nologin.boot &> /dev/null |
9125 |
+ fi |
9126 |
+ |
9127 |
+ if [[ -e /etc/sysctl.conf ]] ; then |
9128 |
+ ebegin "Configuring kernel parameters" |
9129 |
+ /sbin/sysctl -q -p /etc/sysctl.conf |
9130 |
+ eend 0 |
9131 |
+ fi |
9132 |
+ |
9133 |
+ if [[ -z ${CDBOOT} ]] && ! touch /var/run/.keep 2> /dev/null ; then |
9134 |
+ ewarn "Skipping /var and /tmp initialization (ro root?)" |
9135 |
+ return 0 |
9136 |
+ fi |
9137 |
+ |
9138 |
+ if [[ -x /sbin/env-update.sh ]] ; then |
9139 |
+ ebegin "Updating environment" |
9140 |
+ /sbin/env-update.sh -u > /dev/null |
9141 |
+ eend 0 |
9142 |
+ fi |
9143 |
+ |
9144 |
+ # |
9145 |
+ # Take care of random stuff [ /var/lock | /var/run | pam ] |
9146 |
+ # |
9147 |
+ |
9148 |
+ ebegin "Cleaning /var/lock, /var/run" |
9149 |
+ rm -rf /var/run/console.lock /var/run/console/* |
9150 |
+ |
9151 |
+ if [[ -z ${CDBOOT} ]] ; then |
9152 |
+ # |
9153 |
+ # Clean up any stale locks. |
9154 |
+ # |
9155 |
+ find /var/lock -type f -print0 | xargs -0 rm -f -- |
9156 |
+ # |
9157 |
+ # Clean up /var/run and create /var/run/utmp so that we can login. |
9158 |
+ # |
9159 |
+ for x in $(find /var/run/ ! -type d ! -name utmp ! -name innd.pid ! -name random-seed) ; do |
9160 |
+ local daemon=${x##*/} |
9161 |
+ daemon=${daemon%*.pid} |
9162 |
+ # Do not remove pidfiles of already running daemons |
9163 |
+ if [[ -z $(ps --no-heading -C "${daemon}") ]] ; then |
9164 |
+ if [[ -f ${x} || -L ${x} ]] ; then |
9165 |
+ rm -f "${x}" |
9166 |
+ fi |
9167 |
+ fi |
9168 |
+ done |
9169 |
+ fi |
9170 |
+ |
9171 |
+ # Reset pam_console permissions if we are actually using it |
9172 |
+ if [[ -x /sbin/pam_console_apply && ! -c /dev/.devfsd && \ |
9173 |
+ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ]] ; then |
9174 |
+ /sbin/pam_console_apply -r |
9175 |
+ fi |
9176 |
+ |
9177 |
+ # Create the .keep to stop portage from removing /var/lock |
9178 |
+ > /var/lock/.keep |
9179 |
+ eend 0 |
9180 |
+ |
9181 |
+ # |
9182 |
+ # Clean up /tmp directory |
9183 |
+ # |
9184 |
+ if [[ -z ${CDBOOT} ]] && [[ -d /tmp ]] ; then |
9185 |
+ cd /tmp |
9186 |
+ if [[ ${WIPE_TMP} == "yes" ]] ; then |
9187 |
+ ebegin "Wiping /tmp directory" |
9188 |
+ # This eval stuff sucks, so if someone has a better *working* |
9189 |
+ # solution, please file a bug at http://bugs.gentoo.org/ |
9190 |
+ # Originally ripped from Debian init scripts |
9191 |
+ local exceptions=" |
9192 |
+ '!' -name . -a |
9193 |
+ '!' '(' -uid 0 -a |
9194 |
+ '(' |
9195 |
+ -path './lost+found/*' -o |
9196 |
+ -path './quota.user/*' -o |
9197 |
+ -path './aquota.user/*' -o |
9198 |
+ -path './quota.group/*' -o |
9199 |
+ -path './aquota.group/*' -o |
9200 |
+ -path './.journal/*' |
9201 |
+ ')' |
9202 |
+ ')'" |
9203 |
+ # First kill most files, then kill empty dirs |
9204 |
+ eval find . -xdev -depth ${exceptions} ! -type d -print0 | xargs -0 rm -f -- |
9205 |
+ eval find . -xdev -depth ${exceptions} -type d -empty -exec rmdir '{}' \\';' |
9206 |
+ eend 0 |
9207 |
+ else |
9208 |
+ ebegin "Cleaning /tmp directory" |
9209 |
+ ( |
9210 |
+ rm -f /tmp/.X*-lock /tmp/esrv* /tmp/kio* /tmp/jpsock.* /tmp/.fam* |
9211 |
+ rm -rf /tmp/.esd* /tmp/orbit-* /tmp/ssh-* /tmp/ksocket-* /tmp/.*-unix |
9212 |
+ ) &> /dev/null |
9213 |
+ eend 0 |
9214 |
+ fi |
9215 |
+ |
9216 |
+ ( |
9217 |
+ # Make sure our X11 stuff have the correct permissions |
9218 |
+ # Omit the chown as bootmisc is run before network is up |
9219 |
+ # and users may be using lame LDAP auth #139411 |
9220 |
+ rm -rf /tmp/.{ICE,X11}-unix |
9221 |
+ mkdir -p /tmp/.{ICE,X11}-unix |
9222 |
+ #chown 0:0 /tmp/.{ICE,X11}-unix |
9223 |
+ chmod 1777 /tmp/.{ICE,X11}-unix |
9224 |
+ [[ -x /sbin/restorecon ]] && restorecon /tmp/.{ICE,X11}-unix |
9225 |
+ ) &> /dev/null |
9226 |
+ fi |
9227 |
+ |
9228 |
+ # |
9229 |
+ # Create an 'after-boot' dmesg log |
9230 |
+ # |
9231 |
+ touch /var/log/dmesg |
9232 |
+ chmod 640 /var/log/dmesg |
9233 |
+ dmesg > /var/log/dmesg |
9234 |
+ |
9235 |
+ # |
9236 |
+ # Check for /etc/resolv.conf, and create if missing |
9237 |
+ # |
9238 |
+ [[ -f /etc/resolv.conf ]] || touch /etc/resolv.conf &> /dev/null |
9239 |
+} |
9240 |
+ |
9241 |
+# vim:ts=4 |
9242 |
|
9243 |
|
9244 |
Property changes on: trunk/baselayout-prefix/init.d/bootmisc |
9245 |
___________________________________________________________________ |
9246 |
Added: svn:executable |
9247 |
+ * |
9248 |
|
9249 |
Added: trunk/baselayout-prefix/init.d/checkfs |
9250 |
=================================================================== |
9251 |
--- trunk/baselayout-prefix/init.d/checkfs (rev 0) |
9252 |
+++ trunk/baselayout-prefix/init.d/checkfs 2011-03-31 14:11:17 UTC (rev 1682) |
9253 |
@@ -0,0 +1,50 @@ |
9254 |
+#!/sbin/runscript |
9255 |
+# Copyright 1999-2006 Gentoo Foundation |
9256 |
+# Distributed under the terms of the GNU General Public License v2 |
9257 |
+ |
9258 |
+depend() { |
9259 |
+ need checkroot modules |
9260 |
+} |
9261 |
+ |
9262 |
+start() { |
9263 |
+ local retval=0 |
9264 |
+ |
9265 |
+ # Setup dm-crypt mappings if any |
9266 |
+ start_addon dm-crypt |
9267 |
+ |
9268 |
+ if [[ -f /fastboot ]] || [[ -n ${CDBOOT} ]] ; then |
9269 |
+ rm -f /fastboot |
9270 |
+ else |
9271 |
+ ebegin "Checking all filesystems" |
9272 |
+ if [[ -f /forcefsck ]] ; then |
9273 |
+ ewarn "A full fsck has been forced" |
9274 |
+ fsck -C -T -R -A -a -f |
9275 |
+ retval=$? |
9276 |
+ rm -f /forcefsck |
9277 |
+ else |
9278 |
+ fsck -C -T -R -A -a |
9279 |
+ retval=$? |
9280 |
+ fi |
9281 |
+ if [[ ${retval} -eq 0 ]] ; then |
9282 |
+ eend 0 |
9283 |
+ elif [[ ${retval} -ge 1 && ${retval} -le 3 ]] ; then |
9284 |
+ ewend 1 "Filesystem errors corrected." |
9285 |
+ # Everything should be ok, so return a pass |
9286 |
+ return 0 |
9287 |
+ else |
9288 |
+ if [[ ${RC_FORCE_AUTO} == "yes" ]] ; then |
9289 |
+ eend 2 "Fsck could not correct all errors, rerunning" |
9290 |
+ fsck -C -T -R -A -y |
9291 |
+ retval=$? |
9292 |
+ fi |
9293 |
+ |
9294 |
+ if [[ ${retval} -gt 3 ]] ; then |
9295 |
+ eend 2 "Fsck could not correct all errors, manual repair needed" |
9296 |
+ /sbin/sulogin ${CONSOLE} |
9297 |
+ fi |
9298 |
+ fi |
9299 |
+ fi |
9300 |
+} |
9301 |
+ |
9302 |
+ |
9303 |
+# vim:ts=4 |
9304 |
|
9305 |
|
9306 |
Property changes on: trunk/baselayout-prefix/init.d/checkfs |
9307 |
___________________________________________________________________ |
9308 |
Added: svn:executable |
9309 |
+ * |
9310 |
|
9311 |
Added: trunk/baselayout-prefix/init.d/checkroot |
9312 |
=================================================================== |
9313 |
--- trunk/baselayout-prefix/init.d/checkroot (rev 0) |
9314 |
+++ trunk/baselayout-prefix/init.d/checkroot 2011-03-31 14:11:17 UTC (rev 1682) |
9315 |
@@ -0,0 +1,127 @@ |
9316 |
+#!/sbin/runscript |
9317 |
+# Copyright 1999-2006 Gentoo Foundation |
9318 |
+# Distributed under the terms of the GNU General Public License v2 |
9319 |
+ |
9320 |
+depend() { |
9321 |
+ before * |
9322 |
+} |
9323 |
+ |
9324 |
+start() { |
9325 |
+ local retval=0 |
9326 |
+ |
9327 |
+ if [[ ! -f /fastboot && -z ${CDBOOT} ]] \ |
9328 |
+ && ! is_net_fs / && ! is_union_fs / ; then |
9329 |
+ if touch -c / >& /dev/null ; then |
9330 |
+ ebegin "Remounting root filesystem read-only" |
9331 |
+ mount -n -o remount,ro / |
9332 |
+ eend $? |
9333 |
+ fi |
9334 |
+ |
9335 |
+ if [[ -f /forcefsck ]] || get_bootparam "forcefsck" ; then |
9336 |
+ ebegin "Checking root filesystem (full fsck forced)" |
9337 |
+ fsck -C -a -f / |
9338 |
+ # /forcefsck isn't deleted because checkfs needs it. |
9339 |
+ # it'll be deleted in that script. |
9340 |
+ retval=$? |
9341 |
+ else |
9342 |
+ # Obey the fs_passno setting for / (see fstab(5)) |
9343 |
+ # - find the / entry |
9344 |
+ # - make sure we have 6 fields |
9345 |
+ # - see if fs_passno is something other than 0 |
9346 |
+ if [[ -n $(awk '($1 ~ /^(\/|UUID|LABEL)/ && $2 == "/" \ |
9347 |
+ && NF == 6 && $6 != 0) { print }' /etc/fstab) ]] |
9348 |
+ then |
9349 |
+ ebegin "Checking root filesystem" |
9350 |
+ fsck -C -T -a / |
9351 |
+ retval=$? |
9352 |
+ else |
9353 |
+ ebegin "Skipping root filesystem check (fstab's passno == 0)" |
9354 |
+ retval=0 |
9355 |
+ fi |
9356 |
+ fi |
9357 |
+ |
9358 |
+ if [[ ${retval} -eq 0 ]] ; then |
9359 |
+ eend 0 |
9360 |
+ elif [[ ${retval} -eq 1 ]] ; then |
9361 |
+ ewend 1 "Filesystem repaired" |
9362 |
+ elif [[ ${retval} -eq 2 || ${retval} -eq 3 ]] ; then |
9363 |
+ ewend 1 "Filesystem repaired, but reboot needed!" |
9364 |
+ echo -ne "\a"; sleep 1; echo -ne "\a"; sleep 1 |
9365 |
+ echo -ne "\a"; sleep 1; echo -ne "\a"; sleep 1 |
9366 |
+ ewarn "Rebooting in 10 seconds ..." |
9367 |
+ sleep 10 |
9368 |
+ einfo "Rebooting" |
9369 |
+ /sbin/reboot -f |
9370 |
+ else |
9371 |
+ if [[ ${RC_FORCE_AUTO} == "yes" ]] ; then |
9372 |
+ eend 2 "Rerunning fsck in force mode" |
9373 |
+ fsck -y -C -T / |
9374 |
+ else |
9375 |
+ eend 2 "Filesystem couldn't be fixed :(" |
9376 |
+ /sbin/sulogin ${CONSOLE} |
9377 |
+ fi |
9378 |
+ einfo "Unmounting filesystems" |
9379 |
+ /bin/mount -a -o remount,ro &> /dev/null |
9380 |
+ einfo "Rebooting" |
9381 |
+ /sbin/reboot -f |
9382 |
+ fi |
9383 |
+ fi |
9384 |
+ |
9385 |
+ # Should we mount root rw ? the touch check is to see if the / is |
9386 |
+ # already mounted rw in which case there's nothing for us to do |
9387 |
+ if mount -vf -o remount / 2> /dev/null | \ |
9388 |
+ awk '{ if ($6 ~ /rw/) exit 0; else exit 1; }' && \ |
9389 |
+ ! touch -c / >& /dev/null |
9390 |
+ then |
9391 |
+ ebegin "Remounting root filesystem read/write" |
9392 |
+ mount -n -o remount,rw / &> /dev/null |
9393 |
+ if [[ $? -ne 0 ]] ; then |
9394 |
+ eend 2 "Root filesystem could not be mounted read/write :(" |
9395 |
+ if [[ ${RC_FORCE_AUTO} != "yes" ]] ; then |
9396 |
+ /sbin/sulogin ${CONSOLE} |
9397 |
+ fi |
9398 |
+ else |
9399 |
+ eend 0 |
9400 |
+ fi |
9401 |
+ fi |
9402 |
+ |
9403 |
+ if [[ ${BOOT} == "yes" ]] ; then |
9404 |
+ local x= |
9405 |
+ local y= |
9406 |
+ |
9407 |
+ # |
9408 |
+ # Create /etc/mtab |
9409 |
+ # |
9410 |
+ |
9411 |
+ # Don't create mtab if /etc is readonly |
9412 |
+ if ! touch /etc/mtab 2> /dev/null ; then |
9413 |
+ ewarn "Skipping /etc/mtab initialization (ro root?)" |
9414 |
+ return 0 |
9415 |
+ fi |
9416 |
+ |
9417 |
+ # Clear the existing mtab |
9418 |
+ > /etc/mtab |
9419 |
+ |
9420 |
+ # Add the entry for / to mtab |
9421 |
+ mount -f / |
9422 |
+ |
9423 |
+ # Don't list root more than once |
9424 |
+ awk '$2 != "/" {print}' /proc/mounts >> /etc/mtab |
9425 |
+ |
9426 |
+ # Now make sure /etc/mtab have additional info (gid, etc) in there |
9427 |
+ for x in $(awk '{ print $2 }' /proc/mounts | sort -u) ; do |
9428 |
+ for y in $(awk '{ print $2 }' /etc/fstab) ; do |
9429 |
+ if [[ ${x} == ${y} ]] ; then |
9430 |
+ mount -f -o remount $x |
9431 |
+ continue |
9432 |
+ fi |
9433 |
+ done |
9434 |
+ done |
9435 |
+ |
9436 |
+ # Remove stale backups |
9437 |
+ rm -f /etc/mtab~ /etc/mtab~~ |
9438 |
+ fi |
9439 |
+} |
9440 |
+ |
9441 |
+ |
9442 |
+# vim:ts=4 |
9443 |
|
9444 |
|
9445 |
Property changes on: trunk/baselayout-prefix/init.d/checkroot |
9446 |
___________________________________________________________________ |
9447 |
Added: svn:executable |
9448 |
+ * |
9449 |
|
9450 |
Added: trunk/baselayout-prefix/init.d/clock |
9451 |
=================================================================== |
9452 |
--- trunk/baselayout-prefix/init.d/clock (rev 0) |
9453 |
+++ trunk/baselayout-prefix/init.d/clock 2011-03-31 14:11:17 UTC (rev 1682) |
9454 |
@@ -0,0 +1,143 @@ |
9455 |
+#!/sbin/runscript |
9456 |
+# Copyright 1999-2006 Gentoo Foundation |
9457 |
+# Distributed under the terms of the GNU General Public License v2 |
9458 |
+ |
9459 |
+opts="save" |
9460 |
+ |
9461 |
+depend() { |
9462 |
+ need localmount |
9463 |
+} |
9464 |
+ |
9465 |
+setupopts() { |
9466 |
+ if is_uml_sys ; then |
9467 |
+ TBLURB="UML" |
9468 |
+ fakeit=1 |
9469 |
+ elif is_vserver_sys ; then |
9470 |
+ TBLURB="VServer" |
9471 |
+ fakeit=1 |
9472 |
+ elif is_xenU_sys ; then |
9473 |
+ TBLURB="xen" |
9474 |
+ fakeit=1 |
9475 |
+ elif [[ -d /proc/vz ]] ; then |
9476 |
+ TBLURB="VZ" |
9477 |
+ fakeit=1 |
9478 |
+ elif grep -q ' cobd$' /proc/devices ; then |
9479 |
+ TBLURB="coLinux" |
9480 |
+ fakeit=1 |
9481 |
+ elif [[ $(uname -m) == s390* ]] ; then |
9482 |
+ TBLURB="s390" |
9483 |
+ fakeit=1 |
9484 |
+ elif [[ ${CLOCK} == "UTC" ]] ; then |
9485 |
+ myopts="--utc" |
9486 |
+ TBLURB="UTC" |
9487 |
+ else |
9488 |
+ myopts="--localtime" |
9489 |
+ TBLURB="Local Time" |
9490 |
+ fi |
9491 |
+ [[ ${fakeit} -eq 1 ]] && return 0 |
9492 |
+ |
9493 |
+ if [[ ${readonly} == "yes" ]] ; then |
9494 |
+ myadj="--noadjfile" |
9495 |
+ else |
9496 |
+ myadj="--adjust" |
9497 |
+ fi |
9498 |
+ |
9499 |
+ if [[ ${SRM} == "yes" ]] ; then |
9500 |
+ myopts="${myopts} --srm" |
9501 |
+ fi |
9502 |
+ if [[ ${ARC} == "arc" ]] ; then |
9503 |
+ myopts="${myopts} --arc" |
9504 |
+ fi |
9505 |
+ myopts="${myopts} ${CLOCK_OPTS}" |
9506 |
+ |
9507 |
+ # Make sure user isn't using rc.conf anymore. |
9508 |
+ if grep -qs ^CLOCK= /etc/rc.conf ; then |
9509 |
+ ewarn "CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock" |
9510 |
+ fi |
9511 |
+} |
9512 |
+ |
9513 |
+start() { |
9514 |
+ local myopts="" |
9515 |
+ local myadj="" |
9516 |
+ local TBLURB="" fakeit=0 |
9517 |
+ local errstr="" |
9518 |
+ local readonly="no" |
9519 |
+ local ret=0 |
9520 |
+ |
9521 |
+ if ! touch /etc/adjtime 2>/dev/null ; then |
9522 |
+ readonly="yes" |
9523 |
+ elif [[ ! -s /etc/adjtime ]] ; then |
9524 |
+ echo "0.0 0 0.0" > /etc/adjtime |
9525 |
+ fi |
9526 |
+ |
9527 |
+ setupopts |
9528 |
+ |
9529 |
+ if [[ ${fakeit} -ne 1 && -e /proc/modules && ! -e /dev/rtc ]] ; then |
9530 |
+ modprobe rtc &> /dev/null || modprobe genrtc &> /dev/null |
9531 |
+ fi |
9532 |
+ |
9533 |
+ ebegin "Setting system clock using the hardware clock [${TBLURB}]" |
9534 |
+ if [[ ${fakeit} -eq 1 ]] ; then |
9535 |
+ ret=0 |
9536 |
+ |
9537 |
+ elif [[ -x /sbin/hwclock ]] ; then |
9538 |
+ # Since hwclock always exit's with a 0, need to check its output. |
9539 |
+ errstr=$(/sbin/hwclock ${myadj} ${myopts} 2>&1 >/dev/null) |
9540 |
+ errstr="${errstr}$(/sbin/hwclock --hctosys ${myopts} 2>&1 >/dev/null)" |
9541 |
+ |
9542 |
+ if [[ -n ${errstr} ]] ; then |
9543 |
+ ewarn "${errstr}" |
9544 |
+ ret=1 |
9545 |
+ else |
9546 |
+ ret=0 |
9547 |
+ fi |
9548 |
+ errstr="Failed to set clock" |
9549 |
+ else |
9550 |
+ ret=1 |
9551 |
+ errstr="/sbin/hwclock not found" |
9552 |
+ fi |
9553 |
+ eend ${ret} "${errstr}" "You will need to set the clock yourself" |
9554 |
+ |
9555 |
+ return 0 |
9556 |
+} |
9557 |
+ |
9558 |
+stop() { |
9559 |
+ # Don't tweak the hardware clock on LiveCD halt. |
9560 |
+ [[ -n ${CDBOOT} ]] && return 0 |
9561 |
+ |
9562 |
+ [[ ${CLOCK_SYSTOHC} != "yes" ]] && return 0 |
9563 |
+ |
9564 |
+ local myopts="" |
9565 |
+ local TBLURB="" |
9566 |
+ local errstr="" |
9567 |
+ local ret=0 |
9568 |
+ |
9569 |
+ setupopts |
9570 |
+ |
9571 |
+ ebegin "Setting hardware clock using the system clock [${TBLURB}]" |
9572 |
+ if [[ ${fakeit} -eq 1 ]] ; then |
9573 |
+ ret=0 |
9574 |
+ |
9575 |
+ elif [[ -x /sbin/hwclock ]] ; then |
9576 |
+ errstr=$(/sbin/hwclock --systohc ${myopts} 2>&1 >/dev/null) |
9577 |
+ |
9578 |
+ if [[ -n ${errstr} ]] ; then |
9579 |
+ ret=1 |
9580 |
+ else |
9581 |
+ ret=0 |
9582 |
+ fi |
9583 |
+ errstr="Failed to sync clocks" |
9584 |
+ else |
9585 |
+ ret=1 |
9586 |
+ errstr="/sbin/hwclock not found" |
9587 |
+ fi |
9588 |
+ eend ${ret} "${errstr}" |
9589 |
+} |
9590 |
+ |
9591 |
+save() { |
9592 |
+ CLOCK_SYSTOHC="yes" |
9593 |
+ stop |
9594 |
+} |
9595 |
+ |
9596 |
+ |
9597 |
+# vim:ts=4 |
9598 |
|
9599 |
|
9600 |
Property changes on: trunk/baselayout-prefix/init.d/clock |
9601 |
___________________________________________________________________ |
9602 |
Added: svn:executable |
9603 |
+ * |
9604 |
|
9605 |
Added: trunk/baselayout-prefix/init.d/consolefont |
9606 |
=================================================================== |
9607 |
--- trunk/baselayout-prefix/init.d/consolefont (rev 0) |
9608 |
+++ trunk/baselayout-prefix/init.d/consolefont 2011-03-31 14:11:17 UTC (rev 1682) |
9609 |
@@ -0,0 +1,68 @@ |
9610 |
+#!/sbin/runscript |
9611 |
+# Copyright 1999-2006 Gentoo Foundation |
9612 |
+# Distributed under the terms of the GNU General Public License v2 |
9613 |
+ |
9614 |
+depend() { |
9615 |
+ need localmount |
9616 |
+ need keymaps # sets up terminal encoding scheme |
9617 |
+ after hotplug |
9618 |
+} |
9619 |
+ |
9620 |
+start() { |
9621 |
+ if is_uml_sys || is_xenU_sys ; then |
9622 |
+ ebegin "Setting user font" |
9623 |
+ eend 0 |
9624 |
+ return 0 |
9625 |
+ elif [[ -z ${CONSOLEFONT} ]] ; then |
9626 |
+ ebegin "Using the default console font" |
9627 |
+ eend 0 |
9628 |
+ return 0 |
9629 |
+ fi |
9630 |
+ |
9631 |
+ local x= |
9632 |
+ local param= |
9633 |
+ local sf_param= |
9634 |
+ local retval=1 |
9635 |
+ |
9636 |
+ # Get additional parameters |
9637 |
+ if [[ -n ${CONSOLETRANSLATION} ]] ; then |
9638 |
+ param="-m ${CONSOLETRANSLATION}" |
9639 |
+ fi |
9640 |
+ |
9641 |
+ # Set the console font |
9642 |
+ local errmsg="" |
9643 |
+ ebegin "Setting user font" |
9644 |
+ if [[ -x /bin/setfont ]] ; then |
9645 |
+ # We patched setfont to have --tty support ... |
9646 |
+ if [[ -n $(setfont --help 2>&1 | grep -e '--tty') || \ |
9647 |
+ -n $(setfont --help 2>&1 | grep -e '-C') ]] |
9648 |
+ then |
9649 |
+ if [[ -n $(setfont --help 2>&1 | grep -e '--tty') ]] ; then |
9650 |
+ sf_param="--tty=" |
9651 |
+ else |
9652 |
+ sf_param="-C " |
9653 |
+ fi |
9654 |
+ local ttydev= |
9655 |
+ [[ -d /dev/vc ]] \ |
9656 |
+ && ttydev=/dev/vc/ \ |
9657 |
+ || ttydev=/dev/tty |
9658 |
+ |
9659 |
+ for x in $(seq 1 "${RC_TTY_NUMBER}") ; do |
9660 |
+ /bin/setfont ${CONSOLEFONT} ${param} \ |
9661 |
+ ${sf_param}/${ttydev}${x} > /dev/null |
9662 |
+ retval=$? |
9663 |
+ done |
9664 |
+ else |
9665 |
+ /bin/setfont ${CONSOLEFONT} ${param} > /dev/null |
9666 |
+ retval=$? |
9667 |
+ fi |
9668 |
+ errmsg="Failed to set user font" |
9669 |
+ else |
9670 |
+ retval=1 |
9671 |
+ errmsg="/bin/setfont not found" |
9672 |
+ fi |
9673 |
+ eend ${retval} "${errmsg}" |
9674 |
+} |
9675 |
+ |
9676 |
+ |
9677 |
+# vim:ts=4 |
9678 |
|
9679 |
|
9680 |
Property changes on: trunk/baselayout-prefix/init.d/consolefont |
9681 |
___________________________________________________________________ |
9682 |
Added: svn:executable |
9683 |
+ * |
9684 |
|
9685 |
Added: trunk/baselayout-prefix/init.d/halt.sh |
9686 |
=================================================================== |
9687 |
--- trunk/baselayout-prefix/init.d/halt.sh (rev 0) |
9688 |
+++ trunk/baselayout-prefix/init.d/halt.sh 2011-03-31 14:11:17 UTC (rev 1682) |
9689 |
@@ -0,0 +1,221 @@ |
9690 |
+#!/bin/bash |
9691 |
+# Copyright 1999-2006 Gentoo Foundation |
9692 |
+# Distributed under the terms of the GNU General Public License v2 |
9693 |
+ |
9694 |
+[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh |
9695 |
+ |
9696 |
+# Check to see if this is a livecd, if it is read the commandline |
9697 |
+# this mainly makes sure $CDBOOT is defined if it's a livecd |
9698 |
+[[ -f /sbin/livecd-functions.sh ]] && \ |
9699 |
+ source /sbin/livecd-functions.sh && \ |
9700 |
+ livecd_read_commandline |
9701 |
+ |
9702 |
+# livecd-functions.sh should _ONLY_ set this differently if CDBOOT is |
9703 |
+# set, else the default one should be used for normal boots. |
9704 |
+# say: RC_NO_UMOUNTS="/mnt/livecd|/newroot" |
9705 |
+RC_NO_UMOUNTS=${RC_NO_UMOUNTS:-/mnt/livecd|/newroot} |
9706 |
+RC_NO_UMOUNT_FS="^(proc|devpts|sysfs|devfs|tmpfs|usb(dev)?fs|unionfs|rootfs)$" |
9707 |
+ |
9708 |
+# Reset pam_console permissions if we are actually using it |
9709 |
+if [[ -x /sbin/pam_console_apply && ! -c /dev/.devfsd && \ |
9710 |
+ -n $(grep -v -e '^[[:space:]]*#' /etc/pam.d/* | grep 'pam_console') ]]; then |
9711 |
+ /sbin/pam_console_apply -r |
9712 |
+fi |
9713 |
+ |
9714 |
+stop_addon devfs |
9715 |
+stop_addon udev |
9716 |
+ |
9717 |
+# Try to unmount all tmpfs filesystems not in use, else a deadlock may |
9718 |
+# occure, bug #13599. |
9719 |
+umount -at tmpfs &>/dev/null |
9720 |
+ |
9721 |
+# Turn off swap and perhaps zero it out for fun |
9722 |
+swap_list=$(swapon -s 2>/dev/null) |
9723 |
+ |
9724 |
+if [[ -n ${swap_list} ]] ; then |
9725 |
+ ebegin $"Deactivating swap" |
9726 |
+ swapoff -a |
9727 |
+ eend $? |
9728 |
+ |
9729 |
+ if [[ ${RC_SWAP_ERASE} == "yes" ]] ; then |
9730 |
+ for s in $(echo "${swap_list}" | awk '$2 == "partition" {print $1}') ; do |
9731 |
+ ebegin $"Erasing swap space" ${s} |
9732 |
+ ssize=$(awk '$4 == "'${s##*/}'" {print $3}' /proc/partitions 2> /dev/null) |
9733 |
+ dd if=/dev/zero of=${s} bs=1024 count=${ssize} 2> /dev/null |
9734 |
+ eend $? |
9735 |
+ ebegin $"Creating swap space" ${s} |
9736 |
+ mkswap ${s} > /dev/null |
9737 |
+ eend $? |
9738 |
+ done |
9739 |
+ fi |
9740 |
+fi |
9741 |
+ |
9742 |
+# Write a reboot record to /var/log/wtmp before unmounting |
9743 |
+ |
9744 |
+halt -w &>/dev/null |
9745 |
+ |
9746 |
+# Unmounting should use /proc/mounts and work with/without devfsd running |
9747 |
+ |
9748 |
+# Credits for next function to unmount loop devices, goes to: |
9749 |
+# |
9750 |
+# Miquel van Smoorenburg, <miquels@×××××××××××××××××.org> |
9751 |
+# Modified for RHS Linux by Damien Neil |
9752 |
+# |
9753 |
+# |
9754 |
+# Unmount file systems, killing processes if we have to. |
9755 |
+# Unmount loopback stuff first |
9756 |
+# Use `umount -d` to detach the loopback device |
9757 |
+ |
9758 |
+# Remove loopback devices started by dm-crypt |
9759 |
+ |
9760 |
+remaining=$(awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts | \ |
9761 |
+ sort -r | egrep -v "^(${RC_NO_UMOUNTS})$") |
9762 |
+[[ -n ${remaining} ]] && { |
9763 |
+ sig= |
9764 |
+ retry=3 |
9765 |
+ |
9766 |
+ while [[ -n ${remaining} && ${retry} -gt 0 ]]; do |
9767 |
+ if [[ ${retry} -lt 3 ]]; then |
9768 |
+ ebegin "Unmounting loopback filesystems (retry)" |
9769 |
+ umount -d ${remaining} &>/dev/null |
9770 |
+ eend $? "Failed to unmount filesystems this retry" |
9771 |
+ else |
9772 |
+ ebegin "Unmounting loopback filesystems" |
9773 |
+ umount -d ${remaining} &>/dev/null |
9774 |
+ eend $? "Failed to unmount filesystems" |
9775 |
+ fi |
9776 |
+ |
9777 |
+ remaining=$(awk '!/^#/ && $1 ~ /^\/dev\/loop/ && $2 != "/" {print $2}' /proc/mounts | \ |
9778 |
+ sort -r | egrep -v "^(${RC_NO_UMOUNTS})$") |
9779 |
+ [[ -z ${remaining} ]] && break |
9780 |
+ |
9781 |
+ /bin/fuser -s -k ${sig} -m ${remaining} |
9782 |
+ sleep 5 |
9783 |
+ retry=$((${retry} - 1)) |
9784 |
+ sig=-9 |
9785 |
+ done |
9786 |
+} |
9787 |
+ |
9788 |
+# Try to unmount all filesystems (no /proc,tmpfs,devfs,etc). |
9789 |
+# This is needed to make sure we dont have a mounted filesystem |
9790 |
+# on a LVM volume when shutting LVM down ... |
9791 |
+ebegin "Unmounting filesystems" |
9792 |
+unmounts=$(awk -v NO_UMOUNT_FS="${RC_NO_UMOUNT_FS}" \ |
9793 |
+ '{ \ |
9794 |
+ if (($3 !~ NO_UMOUNT_FS) && \ |
9795 |
+ ($1 != "none") && \ |
9796 |
+ ($1 !~ /^(rootfs|\/dev\/root)$/) && \ |
9797 |
+ ($2 != "/")) \ |
9798 |
+ print $2 \ |
9799 |
+ }' /proc/mounts | sort -ur) |
9800 |
+for x in ${unmounts}; do |
9801 |
+ # Do not umount these ... will be different depending on value of CDBOOT |
9802 |
+ if [[ -n $(echo "${x}" | egrep "^(${RC_NO_UMOUNTS})$") ]] ; then |
9803 |
+ continue |
9804 |
+ fi |
9805 |
+ |
9806 |
+ x=${x//\\040/ } |
9807 |
+ if ! umount "${x}" &>/dev/null; then |
9808 |
+ # Kill processes still using this mount |
9809 |
+ /bin/fuser -s -k -9 -m "${x}" |
9810 |
+ sleep 2 |
9811 |
+ # Now try to unmount it again ... |
9812 |
+ umount -f -r "${x}" &>/dev/null |
9813 |
+ fi |
9814 |
+done |
9815 |
+eend 0 |
9816 |
+ |
9817 |
+# Try to remove any dm-crypt mappings |
9818 |
+stop_addon dm-crypt |
9819 |
+ |
9820 |
+# Stop LVM, etc |
9821 |
+for x in $(reverse_list ${RC_VOLUME_ORDER}) ; do |
9822 |
+ stop_addon "${x}" |
9823 |
+done |
9824 |
+ |
9825 |
+# This is a function because its used twice below |
9826 |
+ups_kill_power() { |
9827 |
+ local UPS_CTL UPS_POWERDOWN |
9828 |
+ if [[ -f /etc/killpower ]] ; then |
9829 |
+ UPS_CTL=/sbin/upsdrvctl |
9830 |
+ UPS_POWERDOWN="${UPS_CTL} shutdown" |
9831 |
+ elif [[ -f /etc/apcupsd/powerfail ]] ; then |
9832 |
+ UPS_CTL=/etc/apcupsd/apccontrol |
9833 |
+ UPS_POWERDOWN="${UPS_CTL} killpower" |
9834 |
+ else |
9835 |
+ return 0 |
9836 |
+ fi |
9837 |
+ if [[ -x ${UPS_CTL} ]] ; then |
9838 |
+ ewarn "Signalling ups driver(s) to kill the load!" |
9839 |
+ ${UPS_POWERDOWN} |
9840 |
+ ewarn "Halt system and wait for the UPS to kill our power" |
9841 |
+ /sbin/halt -id |
9842 |
+ while [ 1 ]; do sleep 60; done |
9843 |
+ fi |
9844 |
+} |
9845 |
+ |
9846 |
+mount_readonly() { |
9847 |
+ local x= |
9848 |
+ local retval=0 |
9849 |
+ local cmd=$1 |
9850 |
+ |
9851 |
+ # Get better results with a sync and sleep |
9852 |
+ sync; sync |
9853 |
+ sleep 1 |
9854 |
+ |
9855 |
+ for x in $(awk -v NO_UMOUNT_FS="${RC_NO_UMOUNT_FS}" \ |
9856 |
+ '{ \ |
9857 |
+ if (($1 != "none") && ($3 !~ NO_UMOUNT_FS)) \ |
9858 |
+ print $2 \ |
9859 |
+ }' /proc/mounts | sort -ur) ; do |
9860 |
+ x=${x//\\040/ } |
9861 |
+ if [[ -n $(echo "${x}" | egrep "^(${RC_NO_UMOUNTS})$") ]] ; then |
9862 |
+ continue |
9863 |
+ fi |
9864 |
+ if [[ ${cmd} == "u" ]]; then |
9865 |
+ umount -n -r "${x}" |
9866 |
+ else |
9867 |
+ mount -n -o remount,ro "${x}" &>/dev/null |
9868 |
+ fi |
9869 |
+ retval=$((${retval} + $?)) |
9870 |
+ done |
9871 |
+ [[ ${retval} -ne 0 ]] && killall5 -9 &>/dev/null |
9872 |
+ |
9873 |
+ return ${retval} |
9874 |
+} |
9875 |
+ |
9876 |
+# Since we use `mount` in mount_readonly(), but we parse /proc/mounts, we |
9877 |
+# have to make sure our /etc/mtab and /proc/mounts agree |
9878 |
+cp /proc/mounts /etc/mtab &>/dev/null |
9879 |
+ebegin "Remounting remaining filesystems readonly" |
9880 |
+mount_worked=0 |
9881 |
+if ! mount_readonly ; then |
9882 |
+ if ! mount_readonly ; then |
9883 |
+ # If these things really don't want to remount ro, then |
9884 |
+ # let's try to force them to unmount |
9885 |
+ if ! mount_readonly u ; then |
9886 |
+ mount_worked=1 |
9887 |
+ fi |
9888 |
+ fi |
9889 |
+fi |
9890 |
+eend ${mount_worked} |
9891 |
+if [[ ${mount_worked} -eq 1 ]]; then |
9892 |
+ ups_kill_power |
9893 |
+ /sbin/sulogin -t 10 /dev/console |
9894 |
+fi |
9895 |
+ |
9896 |
+# Inform if there is a forced or skipped fsck |
9897 |
+if [[ -f /fastboot ]]; then |
9898 |
+ echo |
9899 |
+ ewarn "Fsck will be skipped on next startup" |
9900 |
+elif [[ -f /forcefsck ]]; then |
9901 |
+ echo |
9902 |
+ ewarn "A full fsck will be forced on next startup" |
9903 |
+fi |
9904 |
+ |
9905 |
+ups_kill_power |
9906 |
+ |
9907 |
+# Load the final script depending on how we are called |
9908 |
+[[ -e /etc/init.d/"$1".sh ]] && source /etc/init.d/"$1".sh |
9909 |
+ |
9910 |
+# vim:ts=4 |
9911 |
|
9912 |
|
9913 |
Property changes on: trunk/baselayout-prefix/init.d/halt.sh |
9914 |
___________________________________________________________________ |
9915 |
Added: svn:executable |
9916 |
+ * |
9917 |
|
9918 |
Added: trunk/baselayout-prefix/init.d/hostname |
9919 |
=================================================================== |
9920 |
--- trunk/baselayout-prefix/init.d/hostname (rev 0) |
9921 |
+++ trunk/baselayout-prefix/init.d/hostname 2011-03-31 14:11:17 UTC (rev 1682) |
9922 |
@@ -0,0 +1,20 @@ |
9923 |
+#!/sbin/runscript |
9924 |
+# Copyright 1999-2006 Gentoo Foundation |
9925 |
+# Distributed under the terms of the GNU General Public License v2 |
9926 |
+ |
9927 |
+depend() { |
9928 |
+ need checkroot |
9929 |
+} |
9930 |
+ |
9931 |
+start() { |
9932 |
+ if [[ -f /etc/hostname ]] ; then |
9933 |
+ ewarn "You should stop using /etc/hostname and use /etc/conf.d/hostname" |
9934 |
+ HOSTNAME="$(< /etc/hostname)" |
9935 |
+ fi |
9936 |
+ |
9937 |
+ ebegin "Setting hostname to ${HOSTNAME}" |
9938 |
+ hostname "${HOSTNAME}" |
9939 |
+ eend $? "Failed to set the hostname" |
9940 |
+} |
9941 |
+ |
9942 |
+# vim: ts=4 : |
9943 |
|
9944 |
|
9945 |
Property changes on: trunk/baselayout-prefix/init.d/hostname |
9946 |
___________________________________________________________________ |
9947 |
Added: svn:executable |
9948 |
+ * |
9949 |
|
9950 |
Added: trunk/baselayout-prefix/init.d/keymaps |
9951 |
=================================================================== |
9952 |
--- trunk/baselayout-prefix/init.d/keymaps (rev 0) |
9953 |
+++ trunk/baselayout-prefix/init.d/keymaps 2011-03-31 14:11:17 UTC (rev 1682) |
9954 |
@@ -0,0 +1,79 @@ |
9955 |
+#!/sbin/runscript |
9956 |
+# Copyright 1999-2006 Gentoo Foundation |
9957 |
+# Distributed under the terms of the GNU General Public License v2 |
9958 |
+ |
9959 |
+depend() { |
9960 |
+ need localmount |
9961 |
+} |
9962 |
+ |
9963 |
+checkconfig() { |
9964 |
+ if [[ -z ${KEYMAP} ]] ; then |
9965 |
+ eerror "You need to setup KEYMAP in /etc/conf.d/keymaps first" |
9966 |
+ return 1 |
9967 |
+ fi |
9968 |
+ |
9969 |
+ # Make sure user isn't using rc.conf anymore |
9970 |
+ if grep -qs ^KEYMAP= /etc/rc.conf ; then |
9971 |
+ ewarn "KEYMAP should not be set in /etc/rc.conf but in /etc/conf.d/keymaps" |
9972 |
+ fi |
9973 |
+} |
9974 |
+ |
9975 |
+start() { |
9976 |
+ if is_uml_sys || is_xenU_sys ; then |
9977 |
+ ebegin "Loading key mappings" |
9978 |
+ eend 0 |
9979 |
+ return 0 |
9980 |
+ fi |
9981 |
+ |
9982 |
+ local WINDOWKEYS_KEYMAP= |
9983 |
+ |
9984 |
+ checkconfig || return 1 |
9985 |
+ |
9986 |
+ # Force linux keycodes for PPC. |
9987 |
+ if [[ -f /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes ]] ; then |
9988 |
+ echo 1 > /proc/sys/dev/mac_hid/keyboard_sends_linux_keycodes |
9989 |
+ fi |
9990 |
+ |
9991 |
+ # Turn on unicode if user wants it |
9992 |
+ if [[ ${UNICODE} == "yes" ]] ; then |
9993 |
+ /usr/bin/kbd_mode -u |
9994 |
+ fi |
9995 |
+ |
9996 |
+ ebegin "Loading key mappings" |
9997 |
+ if [[ -x /bin/loadkeys ]] ; then |
9998 |
+ [[ ${SET_WINDOWKEYS} == "yes" ]] && WINDOWKEYS_KEYMAP="windowkeys" |
9999 |
+ /bin/loadkeys -q ${WINDOWKEYS_KEYMAP} ${KEYMAP} \ |
10000 |
+ ${EXTENDED_KEYMAPS} > /dev/null |
10001 |
+ eend $? "Error loading key mappings" |
10002 |
+ else |
10003 |
+ eend 1 "/bin/loadkeys not found" |
10004 |
+ return 1 |
10005 |
+ fi |
10006 |
+ |
10007 |
+ # Set terminal encoding to either ASCII or UNICODE. |
10008 |
+ # See utf-8(7) for more information. |
10009 |
+ local termencoding="" termmsg="" |
10010 |
+ if [[ ${UNICODE} == "yes" ]] ; then |
10011 |
+ local dumpkey_opts="" |
10012 |
+ [[ -n ${DUMPKEYS_CHARSET} ]] && dumpkey_opts="-c ${DUMPKEYS_CHARSET}" |
10013 |
+ |
10014 |
+ dumpkeys ${dumpkey_opts} | loadkeys --unicode |
10015 |
+ termencoding=$'\033%G' |
10016 |
+ termmsg="UTF-8" |
10017 |
+ else |
10018 |
+ termencoding=$'\033(K' |
10019 |
+ termmsg="ASCII" |
10020 |
+ fi |
10021 |
+ local n ttydev="" |
10022 |
+ [[ -d /dev/vc ]] \ |
10023 |
+ && ttydev=/dev/vc/ \ |
10024 |
+ || ttydev=/dev/tty |
10025 |
+ ebegin "Setting terminal encoding to ${termmsg}" |
10026 |
+ for n in $(seq 1 "${RC_TTY_NUMBER}") ; do |
10027 |
+ echo -n -e ${termencoding} > ${ttydev}${n} |
10028 |
+ done |
10029 |
+ eend 0 |
10030 |
+} |
10031 |
+ |
10032 |
+ |
10033 |
+# vim:ts=4 |
10034 |
|
10035 |
|
10036 |
Property changes on: trunk/baselayout-prefix/init.d/keymaps |
10037 |
___________________________________________________________________ |
10038 |
Added: svn:executable |
10039 |
+ * |
10040 |
|
10041 |
Added: trunk/baselayout-prefix/init.d/local |
10042 |
=================================================================== |
10043 |
--- trunk/baselayout-prefix/init.d/local (rev 0) |
10044 |
+++ trunk/baselayout-prefix/init.d/local 2011-03-31 14:11:17 UTC (rev 1682) |
10045 |
@@ -0,0 +1,34 @@ |
10046 |
+#!/sbin/runscript |
10047 |
+# Copyright 1999-2006 Gentoo Foundation |
10048 |
+# Distributed under the terms of the GNU General Public License v2 |
10049 |
+ |
10050 |
+depend() { |
10051 |
+ after * |
10052 |
+} |
10053 |
+ |
10054 |
+start() { |
10055 |
+ ebegin "Starting local" |
10056 |
+ |
10057 |
+ # Add any misc programs that should be started |
10058 |
+ # to /etc/conf.d/local.start |
10059 |
+ if [[ -e /etc/conf.d/local.start ]] ; then |
10060 |
+ source /etc/conf.d/local.start |
10061 |
+ fi |
10062 |
+ |
10063 |
+ eend $? "Failed to start local" |
10064 |
+} |
10065 |
+ |
10066 |
+stop() { |
10067 |
+ ebegin "Stopping local" |
10068 |
+ |
10069 |
+ # Add any misc programs that should be stopped |
10070 |
+ # to /etc/conf.d/local.stop |
10071 |
+ if [[ -e /etc/conf.d/local.stop ]] ; then |
10072 |
+ source /etc/conf.d/local.stop |
10073 |
+ fi |
10074 |
+ |
10075 |
+ eend $? "Failed to stop local" |
10076 |
+} |
10077 |
+ |
10078 |
+ |
10079 |
+# vim:ts=4 |
10080 |
|
10081 |
|
10082 |
Property changes on: trunk/baselayout-prefix/init.d/local |
10083 |
___________________________________________________________________ |
10084 |
Added: svn:executable |
10085 |
+ * |
10086 |
|
10087 |
Added: trunk/baselayout-prefix/init.d/localmount |
10088 |
=================================================================== |
10089 |
--- trunk/baselayout-prefix/init.d/localmount (rev 0) |
10090 |
+++ trunk/baselayout-prefix/init.d/localmount 2011-03-31 14:11:17 UTC (rev 1682) |
10091 |
@@ -0,0 +1,57 @@ |
10092 |
+#!/sbin/runscript |
10093 |
+# Copyright 1999-2006 Gentoo Foundation |
10094 |
+# Distributed under the terms of the GNU General Public License v2 |
10095 |
+ |
10096 |
+depend() { |
10097 |
+ need checkfs |
10098 |
+} |
10099 |
+ |
10100 |
+start() { |
10101 |
+ # Mount local filesystems in /etc/fstab. |
10102 |
+ ebegin "Mounting local filesystems" |
10103 |
+ mount -at noproc,noshm${NET_FS_LIST:+,no}${NET_FS_LIST// /,no} \ |
10104 |
+ -O no_netdev >/dev/null |
10105 |
+ eend $? "Some local filesystem failed to mount" |
10106 |
+ |
10107 |
+ # Make sure we insert usbcore if its a module |
10108 |
+ if [[ -f /proc/modules && ! -d /proc/bus/usb ]] ; then |
10109 |
+ # >/dev/null to hide errors from non-USB users |
10110 |
+ modprobe usbcore &> /dev/null |
10111 |
+ fi |
10112 |
+ |
10113 |
+ # Check what USB fs the kernel support. Currently |
10114 |
+ # 2.5+ kernels, and later 2.4 kernels have 'usbfs', |
10115 |
+ # while older kernels have 'usbdevfs'. |
10116 |
+ local usbfs=$(grep -Fow usbfs /proc/filesystems || |
10117 |
+ grep -Fow usbdevfs /proc/filesystems) |
10118 |
+ |
10119 |
+ if [[ -n ${usbfs} ]] && \ |
10120 |
+ [[ -e /proc/bus/usb && ! -e /proc/bus/usb/devices ]] |
10121 |
+ then |
10122 |
+ ebegin "Mounting USB device filesystem (${usbfs})" |
10123 |
+ usbgid=$(echo $(getent group usb) | awk -F: '{print $3}') |
10124 |
+ mount -t ${usbfs} usbfs /proc/bus/usb \ |
10125 |
+ -o ${usbgid:+devmode=0664,devgid=${usbgid},}noexec,nosuid |
10126 |
+ eend $? "Failed to mount USB device filesystem" |
10127 |
+ fi |
10128 |
+ |
10129 |
+ # Setup Kernel Support for miscellaneous Binary Formats |
10130 |
+ local binfmt=$(grep -Fow binfmt_misc /proc/filesystems) |
10131 |
+ if [[ -n ${binfmt} ]] && [[ -e /proc/sys/fs/binfmt_misc ]] ; then |
10132 |
+ ebegin $"Mounting misc binary format filesystem" |
10133 |
+ mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc \ |
10134 |
+ -o nodev,noexec,nosuid |
10135 |
+ eend $? |
10136 |
+ fi |
10137 |
+ |
10138 |
+ # We do our swapping here instead of rc so we can get urandom started |
10139 |
+ # before us for people that like an encrypted swap. |
10140 |
+ ebegin "Activating (possible) swap" |
10141 |
+ /sbin/swapon -a |
10142 |
+ eend $? |
10143 |
+ |
10144 |
+ # Start dm-crypt mappings, if any |
10145 |
+ start_addon dm-crypt |
10146 |
+} |
10147 |
+ |
10148 |
+# vim:ts=4 |
10149 |
|
10150 |
|
10151 |
Property changes on: trunk/baselayout-prefix/init.d/localmount |
10152 |
___________________________________________________________________ |
10153 |
Added: svn:executable |
10154 |
+ * |
10155 |
|
10156 |
Added: trunk/baselayout-prefix/init.d/modules |
10157 |
=================================================================== |
10158 |
--- trunk/baselayout-prefix/init.d/modules (rev 0) |
10159 |
+++ trunk/baselayout-prefix/init.d/modules 2011-03-31 14:11:17 UTC (rev 1682) |
10160 |
@@ -0,0 +1,122 @@ |
10161 |
+#!/sbin/runscript |
10162 |
+# Copyright 1999-2006 Gentoo Foundation |
10163 |
+# Distributed under the terms of the GNU General Public License v2 |
10164 |
+ |
10165 |
+depend() { |
10166 |
+ need checkroot |
10167 |
+ use isapnp |
10168 |
+} |
10169 |
+ |
10170 |
+load_modules() { |
10171 |
+ local x= |
10172 |
+ local i=0 |
10173 |
+ local retval=0 |
10174 |
+ local modules= |
10175 |
+ local modargs= |
10176 |
+ local modcount=0 |
10177 |
+ local config="$1" |
10178 |
+ |
10179 |
+ [[ -z ${config} || ! -r ${config} ]] && return 0 |
10180 |
+ |
10181 |
+ # Loop over every line in $config |
10182 |
+ eval $(awk ' |
10183 |
+ BEGIN { |
10184 |
+ COUNT = 0 # Make sure COUNT is set |
10185 |
+ } |
10186 |
+ |
10187 |
+ $0 !~ /(^[[:space:]]*(#|$))/ { |
10188 |
+ if (MODULES == "") |
10189 |
+ MODULES = $1 |
10190 |
+ else |
10191 |
+ MODULES = MODULES " " $1 |
10192 |
+ |
10193 |
+ # Not the greatest method to remove $1 from $0, but it works |
10194 |
+ sub(/^[[:space:]]*[^[:space:]]*[[:space:]]*/, "") |
10195 |
+ # Trim trailing comments on the line |
10196 |
+ sub(/#.*$/, "") |
10197 |
+ ARGS[COUNT] = $0 |
10198 |
+ COUNT++ |
10199 |
+ } |
10200 |
+ |
10201 |
+ END { |
10202 |
+ # 'eval' will make sure these are set to proper bash variables |
10203 |
+ print "modcount=" COUNT |
10204 |
+ print "modules=\"" MODULES "\"" |
10205 |
+ for (x = 0;x < COUNT;x++) |
10206 |
+ print "modargs[" x "]=\"" ARGS[x] "\"" |
10207 |
+ } |
10208 |
+ ' "${config}") |
10209 |
+ |
10210 |
+ if [[ ${modcount} -gt 0 ]]; then |
10211 |
+ einfo "Using ${config} as config:" |
10212 |
+ |
10213 |
+ for x in ${modules}; do |
10214 |
+ ebegin " Loading module ${x}" |
10215 |
+ modprobe -q ${x} ${modargs[${i}]} &>/dev/null |
10216 |
+ retval=$? |
10217 |
+ eend ${retval} " Failed to load ${x}" |
10218 |
+ |
10219 |
+ i=$((i+1)) |
10220 |
+ [[ ${retval} -eq 0 ]] || modcount=$((modcount-1)) |
10221 |
+ done |
10222 |
+ |
10223 |
+ einfo "Autoloaded ${modcount} module(s)" |
10224 |
+ fi |
10225 |
+ |
10226 |
+ return 0 |
10227 |
+} |
10228 |
+ |
10229 |
+start() { |
10230 |
+ local KV=$(uname -r) |
10231 |
+ local KV_MAJOR=$(KV_major "${KV}") |
10232 |
+ local KV_MINOR=$(KV_minor "${KV}") |
10233 |
+ local KV_MICRO=$(KV_micro "${KV}") |
10234 |
+ |
10235 |
+ # Should not fail if kernel do not have module |
10236 |
+ # support compiled in ... |
10237 |
+ [[ -f /proc/modules ]] || return 0 |
10238 |
+ |
10239 |
+ # Make sure depmod from modutils do not whine, but do not bother if |
10240 |
+ # we are on a 2.6 kernel without modprobe.old |
10241 |
+ if [[ -z "${CDBOOT}" ]] && [[ ! -e /etc/modules.conf ]] && \ |
10242 |
+ [[ $(get_KV) -lt $(KV_to_int '2.5.48') || -x /sbin/modprobe.old ]] |
10243 |
+ then |
10244 |
+ echo '### This file is automatically generated by modules-update' \ |
10245 |
+ > /etc/modules.conf 2>/dev/null |
10246 |
+ [[ ! -f /etc/modules.conf ]] && \ |
10247 |
+ ewarn "Cannot update /etc/modules.conf!" |
10248 |
+ fi |
10249 |
+ |
10250 |
+ # Only do this if we have modules.conf or a 2.6 kernel |
10251 |
+ if [[ -z "${CDBOOT}" ]] && \ |
10252 |
+ [[ -f /etc/modules.conf || $(get_KV) -ge $(KV_to_int '2.5.48') ]] |
10253 |
+ then |
10254 |
+ /sbin/modules-update |
10255 |
+ fi |
10256 |
+ |
10257 |
+ local autoload="" |
10258 |
+ if [[ -f /etc/modules.autoload && ! -L /etc/modules.autoload ]]; then |
10259 |
+ autoload=/etc/modules.autoload |
10260 |
+ else |
10261 |
+ local x |
10262 |
+ for x in "${KV}" ${KV_MAJOR}.${KV_MINOR}.${KV_MICRO} ${KV_MAJOR}.${KV_MINOR} ; do |
10263 |
+ if [[ -f /etc/modules.autoload.d/kernel-"${x}" ]] ; then |
10264 |
+ autoload="/etc/modules.autoload.d/kernel-${x}" |
10265 |
+ break |
10266 |
+ fi |
10267 |
+ done |
10268 |
+ fi |
10269 |
+ [[ -n ${autoload} ]] && load_modules "${autoload}" |
10270 |
+ |
10271 |
+ # |
10272 |
+ # Just in case a sysadmin prefers generic symbolic links in |
10273 |
+ # /lib/modules/boot for boot time modules we will load these modules |
10274 |
+ # |
10275 |
+ [[ -n $(modprobe -l -t boot) ]] && modprobe -a -t boot \* &>/dev/null |
10276 |
+ |
10277 |
+ # Above test clobbers the return |
10278 |
+ return 0 |
10279 |
+} |
10280 |
+ |
10281 |
+ |
10282 |
+# vim:ts=4 |
10283 |
|
10284 |
|
10285 |
Property changes on: trunk/baselayout-prefix/init.d/modules |
10286 |
___________________________________________________________________ |
10287 |
Added: svn:executable |
10288 |
+ * |
10289 |
|
10290 |
Added: trunk/baselayout-prefix/init.d/net.eth0 |
10291 |
=================================================================== |
10292 |
--- trunk/baselayout-prefix/init.d/net.eth0 (rev 0) |
10293 |
+++ trunk/baselayout-prefix/init.d/net.eth0 2011-03-31 14:11:17 UTC (rev 1682) |
10294 |
@@ -0,0 +1 @@ |
10295 |
+link net.lo |
10296 |
\ No newline at end of file |
10297 |
|
10298 |
|
10299 |
Property changes on: trunk/baselayout-prefix/init.d/net.eth0 |
10300 |
___________________________________________________________________ |
10301 |
Added: svn:special |
10302 |
+ * |
10303 |
|
10304 |
Added: trunk/baselayout-prefix/init.d/net.lo |
10305 |
=================================================================== |
10306 |
--- trunk/baselayout-prefix/init.d/net.lo (rev 0) |
10307 |
+++ trunk/baselayout-prefix/init.d/net.lo 2011-03-31 14:11:17 UTC (rev 1682) |
10308 |
@@ -0,0 +1,1124 @@ |
10309 |
+#!/sbin/runscript |
10310 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
10311 |
+# Distributed under the terms of the GNU General Public License v2 |
10312 |
+ |
10313 |
+# Contributed by Roy Marples (uberlord@g.o) |
10314 |
+# Many thanks to Aron Griffis (agriffis@g.o) |
10315 |
+# for help, ideas and patches |
10316 |
+ |
10317 |
+#NB: Config is in /etc/conf.d/net |
10318 |
+ |
10319 |
+# For pcmcia users. note that pcmcia must be added to the same |
10320 |
+# runlevel as the net.* script that needs it. |
10321 |
+depend() { |
10322 |
+ need localmount |
10323 |
+ after bootmisc hostname |
10324 |
+ use isapnp isdn pcmcia usb wlan |
10325 |
+ |
10326 |
+ # Load any custom depend functions for the given interface |
10327 |
+ # For example, br0 may need eth0 and eth1 |
10328 |
+ local iface="${SVCNAME#*.}" |
10329 |
+ [[ $(type -t "depend_${iface}") == "function" ]] && depend_${iface} |
10330 |
+ |
10331 |
+ if [[ ${iface} != "lo" && ${iface} != "lo0" ]] ; then |
10332 |
+ after net.lo net.lo0 |
10333 |
+ |
10334 |
+ # Support new style RC_NEED and RC_USE in one net file |
10335 |
+ local x="RC_NEED_${iface}" |
10336 |
+ [[ -n ${!x} ]] && need ${!x} |
10337 |
+ x="RC_USE_${iface}" |
10338 |
+ [[ -n ${!x} ]] && use ${!x} |
10339 |
+ fi |
10340 |
+ |
10341 |
+ return 0 |
10342 |
+} |
10343 |
+ |
10344 |
+# Define where our modules are |
10345 |
+MODULES_DIR="${svclib}/net" |
10346 |
+ |
10347 |
+# Make some wrappers to fudge after/before/need/use depend flags. |
10348 |
+# These are callbacks so MODULE will be set. |
10349 |
+after() { |
10350 |
+ eval "${MODULE}_after() { echo \"$*\"; }" |
10351 |
+} |
10352 |
+before() { |
10353 |
+ eval "${MODULE}_before() { echo \"$*\"; }" |
10354 |
+} |
10355 |
+need() { |
10356 |
+ eval "${MODULE}_need() { echo \"$*\"; }" |
10357 |
+} |
10358 |
+installed() { |
10359 |
+ # We deliberately misspell this as _installed will probably be used |
10360 |
+ # at some point |
10361 |
+ eval "${MODULE}_instlled() { echo \"$*\"; }" |
10362 |
+} |
10363 |
+provide() { |
10364 |
+ eval "${MODULE}_provide() { echo \"$*\"; }" |
10365 |
+} |
10366 |
+functions() { |
10367 |
+ eval "${MODULE}_functions() { echo \"$*\"; }" |
10368 |
+} |
10369 |
+variables() { |
10370 |
+ eval "${MODULE}_variables() { echo \"$*\"; }" |
10371 |
+} |
10372 |
+ |
10373 |
+is_loopback() { |
10374 |
+ [[ $1 == "lo" || $1 == "lo0" ]] |
10375 |
+} |
10376 |
+ |
10377 |
+# char* interface_device(char *iface) |
10378 |
+# |
10379 |
+# Gets the base device of the interface |
10380 |
+# Can handle eth0:1 and eth0.1 |
10381 |
+# Which returns eth0 in this case |
10382 |
+interface_device() { |
10383 |
+ local dev="${1%%.*}" |
10384 |
+ [[ ${dev} == "$1" ]] && dev="${1%%:*}" |
10385 |
+ echo "${dev}" |
10386 |
+} |
10387 |
+ |
10388 |
+# char* interface_type(char* iface) |
10389 |
+# |
10390 |
+# Returns the base type of the interface |
10391 |
+# eth, ippp, etc |
10392 |
+interface_type() { |
10393 |
+ echo "${1%%[0-9]*}" |
10394 |
+} |
10395 |
+ |
10396 |
+# int calculate_metric(char *interface, int base) |
10397 |
+# |
10398 |
+# Calculates the best metric for the interface |
10399 |
+# We use this when we add routes so we can prefer interfaces over each other |
10400 |
+calculate_metric() { |
10401 |
+ local iface="$1" metric="$2" |
10402 |
+ |
10403 |
+ # Have we already got a metric? |
10404 |
+ local m=$(awk '$1=="'${iface}'" && $2=="00000000" { print $7 }' \ |
10405 |
+ /proc/net/route) |
10406 |
+ if [[ -n ${m} ]] ; then |
10407 |
+ echo "${m}" |
10408 |
+ return 0 |
10409 |
+ fi |
10410 |
+ |
10411 |
+ local i= dest= gw= flags= ref= u= m= mtu= metrics= |
10412 |
+ while read i dest gw flags ref u m mtu ; do |
10413 |
+ # Ignore lo |
10414 |
+ is_loopback "${i}" && continue |
10415 |
+ # We work out metrics from default routes only |
10416 |
+ [[ ${dest} != "00000000" || ${gw} == "00000000" ]] && continue |
10417 |
+ metrics="${metrics}\n${m}" |
10418 |
+ done < /proc/net/route |
10419 |
+ |
10420 |
+ # Now, sort our metrics |
10421 |
+ metrics=$(echo -e "${metrics}" | sort -n) |
10422 |
+ |
10423 |
+ # Now, find the lowest we can use |
10424 |
+ local gotbase=false |
10425 |
+ for m in ${metrics} ; do |
10426 |
+ [[ ${m} -lt ${metric} ]] && continue |
10427 |
+ [[ ${m} == ${metric} ]] && ((metric++)) |
10428 |
+ [[ ${m} -gt ${metric} ]] && break |
10429 |
+ done |
10430 |
+ |
10431 |
+ echo "${metric}" |
10432 |
+} |
10433 |
+ |
10434 |
+# int netmask2cidr(char *netmask) |
10435 |
+# |
10436 |
+# Returns the CIDR of a given netmask |
10437 |
+netmask2cidr() { |
10438 |
+ local binary= i= bin= |
10439 |
+ |
10440 |
+ for i in ${1//./ }; do |
10441 |
+ bin="" |
10442 |
+ while [[ ${i} != "0" ]] ; do |
10443 |
+ bin=$[${i}%2]${bin} |
10444 |
+ (( i=i>>1 )) |
10445 |
+ done |
10446 |
+ binary="${binary}${bin}" |
10447 |
+ done |
10448 |
+ binary="${binary%%0*}" |
10449 |
+ echo "${#binary}" |
10450 |
+} |
10451 |
+ |
10452 |
+ |
10453 |
+# bool is_function(char* name) |
10454 |
+# |
10455 |
+# Returns 0 if the given name is a shell function, otherwise 1 |
10456 |
+is_function() { |
10457 |
+ [[ -z $1 ]] && return 1 |
10458 |
+ [[ $(type -t "$1") == "function" ]] |
10459 |
+} |
10460 |
+ |
10461 |
+# void function_wrap(char* source, char* target) |
10462 |
+# |
10463 |
+# wraps function calls - for example function_wrap(this, that) |
10464 |
+# maps function names this_* to that_* |
10465 |
+function_wrap() { |
10466 |
+ local i= |
10467 |
+ |
10468 |
+ is_function "${2}_depend" && return |
10469 |
+ |
10470 |
+ for i in $(typeset -f | grep -o '^'"${1}"'_[^ ]*'); do |
10471 |
+ eval "${2}${i#${1}}() { ${i} \"\$@\"; }" |
10472 |
+ done |
10473 |
+} |
10474 |
+ |
10475 |
+# char[] * expand_parameters(char *cmd) |
10476 |
+# |
10477 |
+# Returns an array after expanding parameters. For example |
10478 |
+# "192.168.{1..3}.{1..3}/24 brd +" |
10479 |
+# will return |
10480 |
+# "192.168.1.1/24 brd +" |
10481 |
+# "192.168.1.2/24 brd +" |
10482 |
+# "192.168.1.3/24 brd +" |
10483 |
+# "192.168.2.1/24 brd +" |
10484 |
+# "192.168.2.2/24 brd +" |
10485 |
+# "192.168.2.3/24 brd +" |
10486 |
+# "192.168.3.1/24 brd +" |
10487 |
+# "192.168.3.2/24 brd +" |
10488 |
+# "192.168.3.3/24 brd +" |
10489 |
+expand_parameters() { |
10490 |
+ local x=$(eval echo ${@// /_}) |
10491 |
+ local -a a=( ${x} ) |
10492 |
+ |
10493 |
+ a=( "${a[@]/#/\"}" ) |
10494 |
+ a=( "${a[@]/%/\"}" ) |
10495 |
+ echo "${a[*]//_/ }" |
10496 |
+} |
10497 |
+ |
10498 |
+# void configure_variables(char *interface, char *option1, [char *option2]) |
10499 |
+# |
10500 |
+# Maps configuration options from <variable>_<option> to <variable>_<iface> |
10501 |
+# option2 takes precedence over option1 |
10502 |
+configure_variables() { |
10503 |
+ local iface="$1" option1="$2" option2="$3" |
10504 |
+ |
10505 |
+ local mod= func= x= i= |
10506 |
+ local -a ivars=() ovars1=() ovars2=() |
10507 |
+ local ifvar=$(bash_variable "${iface}") |
10508 |
+ |
10509 |
+ for mod in ${MODULES[@]}; do |
10510 |
+ is_function ${mod}_variables || continue |
10511 |
+ for v in $(${mod}_variables) ; do |
10512 |
+ x= |
10513 |
+ [[ -n ${option2} ]] && x="${v}_${option2}[@]" |
10514 |
+ [[ -z ${!x} ]] && x="${v}_${option1}[@]" |
10515 |
+ [[ -n ${!x} ]] && eval "${v}_${ifvar}=( \"\${!x}\" )" |
10516 |
+ done |
10517 |
+ done |
10518 |
+ |
10519 |
+ return 0 |
10520 |
+} |
10521 |
+# bool module_load_minimum(char *module) |
10522 |
+# |
10523 |
+# Does the minimum checking on a module - even when forcing |
10524 |
+module_load_minimum() { |
10525 |
+ local f="$1.sh" MODULE="${1##*/}" |
10526 |
+ |
10527 |
+ if [[ ! -f ${f} ]] ; then |
10528 |
+ eerror "${f} does not exist" |
10529 |
+ return 1 |
10530 |
+ fi |
10531 |
+ |
10532 |
+ if ! source "${f}" ; then |
10533 |
+ eerror "${MODULE} failed a sanity check" |
10534 |
+ return 1 |
10535 |
+ fi |
10536 |
+ |
10537 |
+ for f in depend; do |
10538 |
+ is_function "${MODULE}_${f}" && continue |
10539 |
+ eerror "${MODULE}.sh does not support the required function ${f}" |
10540 |
+ return 1 |
10541 |
+ done |
10542 |
+ |
10543 |
+ return 0 |
10544 |
+} |
10545 |
+ |
10546 |
+# bool modules_load_auto() |
10547 |
+# |
10548 |
+# Load and check each module for sanity |
10549 |
+# If the module is not installed, the functions are to be removed |
10550 |
+modules_load_auto() { |
10551 |
+ local i j inst |
10552 |
+ |
10553 |
+ # Populate the MODULES array |
10554 |
+ # Basically we treat evey file in ${MODULES_DIR} as a module |
10555 |
+ MODULES=( $( cd "${MODULES_DIR}" ; ls *.sh ) ) |
10556 |
+ j="${#MODULES[@]}" |
10557 |
+ for (( i=0; i<j; i++ )); do |
10558 |
+ MODULES[i]="${MODULES_DIR}/${MODULES[i]}" |
10559 |
+ [[ ! -f ${MODULES[i]} ]] && unset MODULES[i] |
10560 |
+ done |
10561 |
+ MODULES=( "${MODULES[@]}" ) |
10562 |
+ |
10563 |
+ # Each of these sources into the global namespace, so it's |
10564 |
+ # important that module functions and variables are prefixed with |
10565 |
+ # the module name, for example iproute2_ |
10566 |
+ |
10567 |
+ j="${#MODULES[@]}" |
10568 |
+ loaded_interface=false |
10569 |
+ for (( i=0; i<j; i++ )); do |
10570 |
+ MODULES[i]="${MODULES[i]%.sh*}" |
10571 |
+ if [[ ${MODULES[i]##*/} == "interface" ]] ; then |
10572 |
+ eerror "interface is a reserved name - cannot load a module called interface" |
10573 |
+ return 1 |
10574 |
+ fi |
10575 |
+ |
10576 |
+ ( |
10577 |
+ u=0; |
10578 |
+ module_load_minimum "${MODULES[i]}" || u=1; |
10579 |
+ if [[ ${u} == 0 ]] ; then |
10580 |
+ inst="${MODULES[i]##*/}_check_installed"; |
10581 |
+ if is_function "${inst}" ; then |
10582 |
+ ${inst} false || u=1; |
10583 |
+ fi |
10584 |
+ fi |
10585 |
+ exit "${u}"; |
10586 |
+ ) |
10587 |
+ |
10588 |
+ if [[ $? == 0 ]] ; then |
10589 |
+ source "${MODULES[i]}.sh" |
10590 |
+ MODULES[i]="${MODULES[i]##*/}" |
10591 |
+ else |
10592 |
+ unset MODULES[i] |
10593 |
+ fi |
10594 |
+ done |
10595 |
+ |
10596 |
+ MODULES=( "${MODULES[@]}" ) |
10597 |
+ return 0 |
10598 |
+} |
10599 |
+ |
10600 |
+# bool modules_check_installed(void) |
10601 |
+# |
10602 |
+# Ensure that all modules have the required modules loaded |
10603 |
+# This enables us to remove modules from the MODULES array |
10604 |
+# Whilst other modules can still explicitly call them |
10605 |
+# One example of this is essidnet which configures network |
10606 |
+# settings for the specific ESSID connected to as the user |
10607 |
+# may be using a daemon to configure wireless instead of our |
10608 |
+# iwconfig module |
10609 |
+modules_check_installed() { |
10610 |
+ local i j missingdeps nmods="${#MODULES[@]}" |
10611 |
+ |
10612 |
+ for (( i=0; i<nmods; i++ )); do |
10613 |
+ is_function "${MODULES[i]}_instlled" || continue |
10614 |
+ for j in $( ${MODULES[i]}_instlled ); do |
10615 |
+ missingdeps=true |
10616 |
+ if is_function "${j}_check_installed" ; then |
10617 |
+ ${j}_check_installed && missingdeps=false |
10618 |
+ elif is_function "${j}_depend" ; then |
10619 |
+ missingdeps=false |
10620 |
+ fi |
10621 |
+ ${missingdeps} && unset MODULES[i] && unset PROVIDES[i] && break |
10622 |
+ done |
10623 |
+ done |
10624 |
+ |
10625 |
+ MODULES=( "${MODULES[@]}" ) |
10626 |
+ PROVIDES=( "${PROVIDES[@]}" ) |
10627 |
+} |
10628 |
+ |
10629 |
+# bool modules_check_user(void) |
10630 |
+modules_check_user() { |
10631 |
+ local iface="$1" ifvar=$(bash_variable "${IFACE}") |
10632 |
+ local i= j= k= l= nmods="${#MODULES[@]}" |
10633 |
+ local -a umods=() |
10634 |
+ |
10635 |
+ # Has the interface got any specific modules? |
10636 |
+ umods="modules_${ifvar}[@]" |
10637 |
+ umods=( "${!umods}" ) |
10638 |
+ |
10639 |
+ # Global setting follows interface-specific setting |
10640 |
+ umods=( "${umods[@]}" "${modules[@]}" ) |
10641 |
+ |
10642 |
+ # Add our preferred modules |
10643 |
+ local -a pmods=( "iproute2" "dhcpcd" "iwconfig" "netplugd" ) |
10644 |
+ umods=( "${umods[@]}" "${pmods[@]}" ) |
10645 |
+ |
10646 |
+ # First we strip any modules that conflict from user settings |
10647 |
+ # So if the user specifies pump then we don't use dhcpcd |
10648 |
+ for (( i=0; i<${#umods[@]}; i++ )); do |
10649 |
+ # Some users will inevitably put "dhcp" in their modules |
10650 |
+ # list. To keep users from screwing up their system this |
10651 |
+ # way, ignore this setting so that the default dhcp |
10652 |
+ # module will be used. |
10653 |
+ [[ ${umods[i]} == "dhcp" ]] && continue |
10654 |
+ |
10655 |
+ # We remove any modules we explicitly don't want |
10656 |
+ if [[ ${umods[i]} == "!"* ]] ; then |
10657 |
+ for (( j=0; j<nmods; j++ )); do |
10658 |
+ [[ -z ${MODULES[j]} ]] && continue |
10659 |
+ if [[ ${umods[i]:1} == "${MODULES[j]}" \ |
10660 |
+ || ${umods[i]:1} == "${PROVIDES[j]}" ]] ; then |
10661 |
+ # We may need to setup a class wrapper for it even though |
10662 |
+ # we don't use it directly |
10663 |
+ # However, we put it into an array and wrap later as |
10664 |
+ # another module may provide the same thing |
10665 |
+ ${MODULES[j]}_check_installed \ |
10666 |
+ && WRAP_MODULES=( |
10667 |
+ "${WRAP_MODULES[@]}" |
10668 |
+ "${MODULES[j]} ${PROVIDES[j]}" |
10669 |
+ ) |
10670 |
+ unset MODULES[j] |
10671 |
+ unset PROVIDES[j] |
10672 |
+ fi |
10673 |
+ done |
10674 |
+ continue |
10675 |
+ fi |
10676 |
+ |
10677 |
+ if ! is_function "${umods[i]}_depend" ; then |
10678 |
+ # If the module is one of our preferred modules, then |
10679 |
+ # ignore this error; whatever is available will be |
10680 |
+ # used instead. |
10681 |
+ (( i < ${#umods[@]} - ${#pmods[@]} )) || continue |
10682 |
+ |
10683 |
+ # The function may not exist because the modules software is |
10684 |
+ # not installed. Load the module and report its error |
10685 |
+ if [[ -e "${MODULES_DIR}/${umods[i]}.sh" ]] ; then |
10686 |
+ source "${MODULES_DIR}/${umods[i]}.sh" |
10687 |
+ is_function "${umods[i]}_check_installed" \ |
10688 |
+ && ${umods[i]}_check_installed true |
10689 |
+ else |
10690 |
+ eerror "The module \"${umods[i]}\" does not exist" |
10691 |
+ fi |
10692 |
+ return 1 |
10693 |
+ fi |
10694 |
+ |
10695 |
+ if is_function "${umods[i]}_provide" ; then |
10696 |
+ mod=$(${umods[i]}_provide) |
10697 |
+ else |
10698 |
+ mod="${umods[i]}" |
10699 |
+ fi |
10700 |
+ for (( j=0; j<nmods; j++ )); do |
10701 |
+ [[ -z ${MODULES[j]} ]] && continue |
10702 |
+ if [[ ${PROVIDES[j]} == "${mod}" && ${umods[i]} != "${MODULES[j]}" ]] ; then |
10703 |
+ # We don't have a match - now ensure that we still provide an |
10704 |
+ # alternative. This is to handle our preferred modules. |
10705 |
+ for (( l=0; l<nmods; l++ )); do |
10706 |
+ [[ ${l} == "${j}" || -z ${MODULES[l]} ]] && continue |
10707 |
+ if [[ ${PROVIDES[l]} == "${mod}" ]] ; then |
10708 |
+ unset MODULES[j] |
10709 |
+ unset PROVIDES[j] |
10710 |
+ break |
10711 |
+ fi |
10712 |
+ done |
10713 |
+ fi |
10714 |
+ done |
10715 |
+ done |
10716 |
+ |
10717 |
+ # Then we strip conflicting modules. |
10718 |
+ # We only need to do this for 3rd party modules that conflict with |
10719 |
+ # our own modules and the preferred list AND the user modules |
10720 |
+ # list doesn't specify a preference. |
10721 |
+ for (( i=0; i<nmods-1; i++ )); do |
10722 |
+ [[ -z ${MODULES[i]} ]] && continue |
10723 |
+ for (( j=i+1; j<nmods; j++)); do |
10724 |
+ [[ -z ${MODULES[j]} ]] && continue |
10725 |
+ [[ ${PROVIDES[i]} == "${PROVIDES[j]}" ]] \ |
10726 |
+ && unset MODULES[j] && unset PROVIDES[j] |
10727 |
+ done |
10728 |
+ done |
10729 |
+ |
10730 |
+ MODULES=( "${MODULES[@]}" ) |
10731 |
+ PROVIDES=( "${PROVIDES[@]}" ) |
10732 |
+ return 0 |
10733 |
+} |
10734 |
+ |
10735 |
+# void modules_sort(void) |
10736 |
+# |
10737 |
+# Sort our modules |
10738 |
+modules_sort() { |
10739 |
+ local i= j= nmods=${#MODULES[@]} m= |
10740 |
+ local -a provide=() provide_list=() after=() dead=() sorted=() sortedp=() |
10741 |
+ |
10742 |
+ # Make our provide list |
10743 |
+ for ((i=0; i<nmods; i++)); do |
10744 |
+ dead[i]="false" |
10745 |
+ if [[ ${MODULES[i]} != "${PROVIDES[i]}" ]] ; then |
10746 |
+ local provided=false |
10747 |
+ for ((j=0; j<${#provide[@]}; j++)); do |
10748 |
+ if [[ ${provide[j]} == "${PROVIDES[i]}" ]] ; then |
10749 |
+ provide_list[j]="${provide_list[j]} ${MODULES[i]}" |
10750 |
+ provided=true |
10751 |
+ fi |
10752 |
+ done |
10753 |
+ if ! ${provided}; then |
10754 |
+ provide[j]="${PROVIDES[i]}" |
10755 |
+ provide_list[j]="${MODULES[i]}" |
10756 |
+ fi |
10757 |
+ fi |
10758 |
+ done |
10759 |
+ |
10760 |
+ # Create an after array, which holds which modules the module at |
10761 |
+ # index i must be after |
10762 |
+ for ((i=0; i<nmods; i++)); do |
10763 |
+ if is_function "${MODULES[i]}_after" ; then |
10764 |
+ after[i]=" ${after[i]} $(${MODULES[i]}_after) " |
10765 |
+ fi |
10766 |
+ if is_function "${MODULES[i]}_before" ; then |
10767 |
+ for m in $(${MODULES[i]}_before); do |
10768 |
+ for ((j=0; j<nmods; j++)) ; do |
10769 |
+ if [[ ${PROVIDES[j]} == "${m}" ]] ; then |
10770 |
+ after[j]=" ${after[j]} ${MODULES[i]} " |
10771 |
+ break |
10772 |
+ fi |
10773 |
+ done |
10774 |
+ done |
10775 |
+ fi |
10776 |
+ done |
10777 |
+ |
10778 |
+ # Replace the after list modules with real modules |
10779 |
+ for ((i=0; i<nmods; i++)); do |
10780 |
+ if [[ -n ${after[i]} ]] ; then |
10781 |
+ for ((j=0; j<${#provide[@]}; j++)); do |
10782 |
+ after[i]="${after[i]// ${provide[j]} / ${provide_list[j]} }" |
10783 |
+ done |
10784 |
+ fi |
10785 |
+ done |
10786 |
+ |
10787 |
+ # We then use the below code to provide a topologial sort |
10788 |
+ module_after_visit() { |
10789 |
+ local name="$1" i= x= |
10790 |
+ |
10791 |
+ for ((i=0; i<nmods; i++)); do |
10792 |
+ [[ ${MODULES[i]} == "$1" ]] && break |
10793 |
+ done |
10794 |
+ |
10795 |
+ ${dead[i]} && return |
10796 |
+ dead[i]="true" |
10797 |
+ |
10798 |
+ for x in ${after[i]} ; do |
10799 |
+ module_after_visit "${x}" |
10800 |
+ done |
10801 |
+ |
10802 |
+ sorted=( "${sorted[@]}" "${MODULES[i]}" ) |
10803 |
+ sortedp=( "${sortedp[@]}" "${PROVIDES[i]}" ) |
10804 |
+ } |
10805 |
+ |
10806 |
+ for x in ${MODULES[@]}; do |
10807 |
+ module_after_visit "${x}" |
10808 |
+ done |
10809 |
+ |
10810 |
+ MODULES=( "${sorted[@]}" ) |
10811 |
+ PROVIDES=( "${sortedp[@]}" ) |
10812 |
+} |
10813 |
+ |
10814 |
+# bool modules_check_depends(bool showprovides) |
10815 |
+modules_check_depends() { |
10816 |
+ local showprovides="${1:-false}" nmods="${#MODULES[@]}" i= j= needmod= |
10817 |
+ local missingdeps= p= interface=false |
10818 |
+ |
10819 |
+ for (( i=0; i<nmods; i++ )); do |
10820 |
+ if is_function "${MODULES[i]}_need" ; then |
10821 |
+ for needmod in $(${MODULES[i]}_need); do |
10822 |
+ missingdeps=true |
10823 |
+ for (( j=0; j<nmods; j++ )); do |
10824 |
+ if [[ ${needmod} == "${MODULES[j]}" \ |
10825 |
+ || ${needmod} == "${PROVIDES[j]}" ]] ; then |
10826 |
+ missingdeps=false |
10827 |
+ break |
10828 |
+ fi |
10829 |
+ done |
10830 |
+ if ${missingdeps} ; then |
10831 |
+ eerror "${MODULES[i]} needs ${needmod} (dependency failure)" |
10832 |
+ return 1 |
10833 |
+ fi |
10834 |
+ done |
10835 |
+ fi |
10836 |
+ |
10837 |
+ if is_function "${MODULES[i]}_functions" ; then |
10838 |
+ for f in $(${MODULES[i]}_functions); do |
10839 |
+ if ! is_function "${f}" ; then |
10840 |
+ eerror "${MODULES[i]}: missing required function \"${f}\"" |
10841 |
+ return 1 |
10842 |
+ fi |
10843 |
+ done |
10844 |
+ fi |
10845 |
+ |
10846 |
+ [[ ${PROVIDES[i]} == "interface" ]] && interface=true |
10847 |
+ |
10848 |
+ if ${showprovides} ; then |
10849 |
+ [[ ${PROVIDES[i]} != "${MODULES[i]}" ]] \ |
10850 |
+ && veinfo "${MODULES[i]} provides ${PROVIDES[i]}" |
10851 |
+ fi |
10852 |
+ done |
10853 |
+ |
10854 |
+ if ! ${interface} ; then |
10855 |
+ eerror "no interface module has been loaded" |
10856 |
+ return 1 |
10857 |
+ fi |
10858 |
+ |
10859 |
+ return 0 |
10860 |
+} |
10861 |
+ |
10862 |
+# bool modules_load(char *iface, bool starting) |
10863 |
+# |
10864 |
+# Loads the defined handler and modules for the interface |
10865 |
+# Returns 0 on success, otherwise 1 |
10866 |
+modules_load() { |
10867 |
+ local iface="$1" starting="${2:-true}" MODULE= p=false i= j= k= |
10868 |
+ local -a x=() |
10869 |
+ local RC_INDENTATION="${RC_INDENTATION}" |
10870 |
+ local -a PROVIDES=() WRAP_MODULES=() |
10871 |
+ |
10872 |
+ if ! is_loopback "${iface}" ; then |
10873 |
+ x="modules_force_${iface}[@]" |
10874 |
+ [[ -n ${!x} ]] && modules_force=( "${!x}" ) |
10875 |
+ if [[ -n ${modules_force} ]] ; then |
10876 |
+ ewarn "WARNING: You are forcing modules!" |
10877 |
+ ewarn "Do not complain or file bugs if things start breaking" |
10878 |
+ report=true |
10879 |
+ fi |
10880 |
+ fi |
10881 |
+ |
10882 |
+ veinfo "Loading networking modules for ${iface}" |
10883 |
+ eindent |
10884 |
+ |
10885 |
+ if [[ -z ${modules_force} ]] ; then |
10886 |
+ modules_load_auto || return 1 |
10887 |
+ else |
10888 |
+ j="${#modules_force[@]}" |
10889 |
+ for (( i=0; i<j; i++ )); do |
10890 |
+ module_load_minimum "${MODULES_DIR}/${modules_force[i]}" || return 1 |
10891 |
+ if is_function "${modules_force[i]}_check_installed" ; then |
10892 |
+ ${modules_force[i]}_check_installed || unset modules_force[i] |
10893 |
+ fi |
10894 |
+ done |
10895 |
+ MODULES=( "${modules_force[@]}" ) |
10896 |
+ fi |
10897 |
+ |
10898 |
+ j="${#MODULES[@]}" |
10899 |
+ for (( i=0; i<j; i++ )); do |
10900 |
+ # Now load our dependencies - we need to use the MODULE variable |
10901 |
+ # here as the after/before/need functions use it |
10902 |
+ MODULE="${MODULES[i]}" |
10903 |
+ ${MODULE}_depend |
10904 |
+ |
10905 |
+ # expose does exactly the same thing as depend |
10906 |
+ # However it is more "correct" as it exposes things to other modules |
10907 |
+ # instead of depending on them ;) |
10908 |
+ is_function "${MODULES[i]}_expose" && ${MODULES[i]}_expose |
10909 |
+ |
10910 |
+ # If no provide is given, assume module name |
10911 |
+ if is_function "${MODULES[i]}_provide" ; then |
10912 |
+ PROVIDES[i]=$(${MODULES[i]}_provide) |
10913 |
+ else |
10914 |
+ PROVIDES[i]="${MODULES[i]}" |
10915 |
+ fi |
10916 |
+ done |
10917 |
+ |
10918 |
+ if [[ -n ${modules_force[@]} ]] ; then |
10919 |
+ # Strip any duplicate modules providing the same thing |
10920 |
+ j="${#MODULES[@]}" |
10921 |
+ for (( i=0; i<j-1; i++ )); do |
10922 |
+ [[ -z ${MODULES[i]} ]] && continue |
10923 |
+ for (( k=i+1; k<j; k++ )); do |
10924 |
+ if [[ ${PROVIDES[i]} == ${PROVIDES[k]} ]] ; then |
10925 |
+ unset MODULES[k] |
10926 |
+ unset PROVIDES[k] |
10927 |
+ fi |
10928 |
+ done |
10929 |
+ done |
10930 |
+ MODULES=( "${MODULES[@]}" ) |
10931 |
+ PROVIDES=( "${PROVIDES[@]}" ) |
10932 |
+ else |
10933 |
+ if ${starting}; then |
10934 |
+ modules_check_user "${iface}" || return 1 |
10935 |
+ else |
10936 |
+ # Always prefer iproute2 for taking down interfaces |
10937 |
+ if is_function iproute2_provide ; then |
10938 |
+ function_wrap iproute2 "$(iproute2_provide)" |
10939 |
+ fi |
10940 |
+ fi |
10941 |
+ fi |
10942 |
+ |
10943 |
+ # Wrap our modules |
10944 |
+ j="${#MODULES[@]}" |
10945 |
+ for (( i=0; i<j; i++ )); do |
10946 |
+ function_wrap "${MODULES[i]}" "${PROVIDES[i]}" |
10947 |
+ done |
10948 |
+ j="${#WRAP_MODULES[@]}" |
10949 |
+ for (( i=0; i<j; i++ )); do |
10950 |
+ function_wrap ${WRAP_MODULES[i]} |
10951 |
+ done |
10952 |
+ |
10953 |
+ if [[ -z ${modules_force[@]} ]] ; then |
10954 |
+ modules_check_installed || return 1 |
10955 |
+ modules_sort || return 1 |
10956 |
+ fi |
10957 |
+ |
10958 |
+ veinfo "modules: ${MODULES[@]}" |
10959 |
+ eindent |
10960 |
+ |
10961 |
+ ${starting} && p=true |
10962 |
+ modules_check_depends "${p}" || return 1 |
10963 |
+ return 0 |
10964 |
+} |
10965 |
+ |
10966 |
+# bool iface_start(char *interface) |
10967 |
+# |
10968 |
+# iface_start is called from start. It's expected to start the base |
10969 |
+# interface (for example "eth0"), aliases (for example "eth0:1") and to start |
10970 |
+# VLAN interfaces (for example eth0.0, eth0.1). VLAN setup is accomplished by |
10971 |
+# calling itself recursively. |
10972 |
+iface_start() { |
10973 |
+ local iface="$1" mod config_counter="-1" x config_worked=false |
10974 |
+ local RC_INDENTATION="${RC_INDENTATION}" |
10975 |
+ local -a config=() fallback=() fallback_route=() conf=() a=() b=() |
10976 |
+ local ifvar=$(bash_variable "$1") i= j= metric=0 |
10977 |
+ |
10978 |
+ # pre Start any modules with |
10979 |
+ for mod in ${MODULES[@]}; do |
10980 |
+ if is_function "${mod}_pre_start" ; then |
10981 |
+ ${mod}_pre_start "${iface}" || { eend 1; return 1; } |
10982 |
+ fi |
10983 |
+ done |
10984 |
+ |
10985 |
+ x="metric_${ifvar}" |
10986 |
+ # If we don't have a metric then calculate one |
10987 |
+ # Our modules will set the metric variable to a suitable base |
10988 |
+ # in their pre starts. |
10989 |
+ if [[ -z ${!x} ]] ; then |
10990 |
+ eval "metric_${ifvar}=\"$(calculate_metric "${iface}" "${metric}")\"" |
10991 |
+ fi |
10992 |
+ |
10993 |
+ # We now expand the configuration parameters and pray that the |
10994 |
+ # fallbacks expand to the same number as config or there will be |
10995 |
+ # trouble! |
10996 |
+ a="config_${ifvar}[@]" |
10997 |
+ a=( "${!a}" ) |
10998 |
+ for (( i=0; i<${#a[@]}; i++ )); do |
10999 |
+ eval b=( $(expand_parameters "${a[i]}") ) |
11000 |
+ config=( "${config[@]}" "${b[@]}" ) |
11001 |
+ done |
11002 |
+ |
11003 |
+ a="fallback_${ifvar}[@]" |
11004 |
+ a=( "${!a}" ) |
11005 |
+ for (( i=0; i<${#a[@]}; i++ )); do |
11006 |
+ eval b=( $(expand_parameters "${a[i]}") ) |
11007 |
+ fallback=( "${fallback[@]}" "${b[@]}" ) |
11008 |
+ done |
11009 |
+ |
11010 |
+ # We don't expand routes |
11011 |
+ fallback_route="fallback_route_${ifvar}[@]" |
11012 |
+ fallback_route=( "${!fallback_route}" ) |
11013 |
+ |
11014 |
+ # We must support old configs |
11015 |
+ if [[ -z ${config} ]] ; then |
11016 |
+ interface_get_old_config "${iface}" || return 1 |
11017 |
+ if [[ -n ${config} ]] ; then |
11018 |
+ ewarn "You are using a deprecated configuration syntax for ${iface}" |
11019 |
+ ewarn "You are advised to read /etc/conf.d/net.example and upgrade it accordingly" |
11020 |
+ fi |
11021 |
+ fi |
11022 |
+ |
11023 |
+ # Handle "noop" correctly |
11024 |
+ if [[ ${config[0]} == "noop" ]] ; then |
11025 |
+ if interface_is_up "${iface}" true ; then |
11026 |
+ einfo "Keeping current configuration for ${iface}" |
11027 |
+ eend 0 |
11028 |
+ return 0 |
11029 |
+ fi |
11030 |
+ |
11031 |
+ # Remove noop from the config var |
11032 |
+ config=( "${config[@]:1}" ) |
11033 |
+ fi |
11034 |
+ |
11035 |
+ # Provide a default of DHCP if no configuration is set and we're auto |
11036 |
+ # Otherwise a default of NULL |
11037 |
+ if [[ -z ${config} ]] ; then |
11038 |
+ ewarn "Configuration not set for ${iface} - assuming DHCP" |
11039 |
+ if is_function "dhcp_start" ; then |
11040 |
+ config=( "dhcp" ) |
11041 |
+ else |
11042 |
+ eerror "No DHCP client installed" |
11043 |
+ return 1 |
11044 |
+ fi |
11045 |
+ fi |
11046 |
+ |
11047 |
+ einfo "Bringing up ${iface}" |
11048 |
+ eindent |
11049 |
+ for (( config_counter=0; config_counter<${#config[@]}; config_counter++ )); do |
11050 |
+ # Handle null and noop correctly |
11051 |
+ if [[ ${config[config_counter]} == "null" \ |
11052 |
+ || ${config[config_counter]} == "noop" ]] ; then |
11053 |
+ eend 0 |
11054 |
+ config_worked=true |
11055 |
+ continue |
11056 |
+ fi |
11057 |
+ |
11058 |
+ # We convert it to an array - this has the added |
11059 |
+ # bonus of trimming spaces! |
11060 |
+ conf=( ${config[config_counter]} ) |
11061 |
+ einfo "${conf[0]}" |
11062 |
+ |
11063 |
+ # Do we have a function for our config? |
11064 |
+ if is_function "${conf[0]}_start" ; then |
11065 |
+ eindent |
11066 |
+ ${conf[0]}_start "${iface}" ; x=$? |
11067 |
+ eoutdent |
11068 |
+ [[ ${x} == 0 ]] && config_worked=true && continue |
11069 |
+ # We need to test to see if it's an IP address or a function |
11070 |
+ # We do this by testing if the 1st character is a digit |
11071 |
+ elif [[ ${conf[0]:0:1} == [[:digit:]] || ${conf[0]} == *:* ]] ; then |
11072 |
+ x="0" |
11073 |
+ if ! is_loopback "${iface}" ; then |
11074 |
+ if [[ " ${MODULES[@]} " == *" arping "* ]] ; then |
11075 |
+ if arping_address_exists "${iface}" "${conf[0]}" ; then |
11076 |
+ eerror "${conf[0]%%/*} already taken on ${iface}" |
11077 |
+ x="1" |
11078 |
+ fi |
11079 |
+ fi |
11080 |
+ fi |
11081 |
+ [[ ${x} == "0" ]] && interface_add_address "${iface}" ${conf[@]}; x="$?" |
11082 |
+ eend "${x}" && config_worked=true && continue |
11083 |
+ else |
11084 |
+ if [[ ${conf[0]} == "dhcp" ]] ; then |
11085 |
+ eerror "No DHCP client installed" |
11086 |
+ else |
11087 |
+ eerror "No loaded modules provide \"${conf[0]}\" (${conf[0]}_start)" |
11088 |
+ fi |
11089 |
+ fi |
11090 |
+ |
11091 |
+ if [[ -n ${fallback[config_counter]} ]] ; then |
11092 |
+ einfo "Trying fallback configuration" |
11093 |
+ config[config_counter]="${fallback[config_counter]}" |
11094 |
+ fallback[config_counter]="" |
11095 |
+ |
11096 |
+ # Do we have a fallback route? |
11097 |
+ if [[ -n ${fallback_route[config_counter]} ]] ; then |
11098 |
+ x="fallback_route[config_counter]" |
11099 |
+ eval "routes_${ifvar}=( \"\${!x}\" )" |
11100 |
+ fallback_route[config_counter]="" |
11101 |
+ fi |
11102 |
+ |
11103 |
+ (( config_counter-- )) # since the loop will increment it |
11104 |
+ continue |
11105 |
+ fi |
11106 |
+ done |
11107 |
+ eoutdent |
11108 |
+ |
11109 |
+ # We return failure if no configuration parameters worked |
11110 |
+ ${config_worked} || return 1 |
11111 |
+ |
11112 |
+ # Start any modules with _post_start |
11113 |
+ for mod in ${MODULES[@]}; do |
11114 |
+ if is_function "${mod}_post_start" ; then |
11115 |
+ ${mod}_post_start "${iface}" || return 1 |
11116 |
+ fi |
11117 |
+ done |
11118 |
+ |
11119 |
+ return 0 |
11120 |
+} |
11121 |
+ |
11122 |
+# bool iface_stop(char *interface) |
11123 |
+# |
11124 |
+# iface_stop: bring down an interface. Don't trust information in |
11125 |
+# /etc/conf.d/net since the configuration might have changed since |
11126 |
+# iface_start ran. Instead query for current configuration and bring |
11127 |
+# down the interface. |
11128 |
+iface_stop() { |
11129 |
+ local iface="$1" i= aliases= need_begin=false mod= |
11130 |
+ local RC_INDENTATION="${RC_INDENTATION}" |
11131 |
+ |
11132 |
+ # pre Stop any modules |
11133 |
+ for mod in ${MODULES[@]}; do |
11134 |
+ if is_function "${mod}_pre_stop" ; then |
11135 |
+ ${mod}_pre_stop "${iface}" || return 1 |
11136 |
+ fi |
11137 |
+ done |
11138 |
+ |
11139 |
+ einfo "Bringing down ${iface}" |
11140 |
+ eindent |
11141 |
+ |
11142 |
+ # Collect list of aliases for this interface. |
11143 |
+ # List will be in reverse order. |
11144 |
+ if interface_exists "${iface}" ; then |
11145 |
+ aliases=$(interface_get_aliases_rev "${iface}") |
11146 |
+ fi |
11147 |
+ |
11148 |
+ # Stop aliases before primary interface. |
11149 |
+ # Note this must be done in reverse order, since ifconfig eth0:1 |
11150 |
+ # will remove eth0:2, etc. It might be sufficient to simply remove |
11151 |
+ # the base interface but we're being safe here. |
11152 |
+ for i in ${aliases} ${iface}; do |
11153 |
+ # Stop all our modules |
11154 |
+ for mod in ${MODULES[@]}; do |
11155 |
+ if is_function "${mod}_stop" ; then |
11156 |
+ ${mod}_stop "${i}" || return 1 |
11157 |
+ fi |
11158 |
+ done |
11159 |
+ |
11160 |
+ # A module may have removed the interface |
11161 |
+ if ! interface_exists "${iface}" ; then |
11162 |
+ eend 0 |
11163 |
+ continue |
11164 |
+ fi |
11165 |
+ |
11166 |
+ # We don't delete ppp assigned addresses |
11167 |
+ if ! is_function pppd_exists || ! pppd_exists "${i}" ; then |
11168 |
+ # Delete all the addresses for this alias |
11169 |
+ interface_del_addresses "${i}" |
11170 |
+ fi |
11171 |
+ |
11172 |
+ # Do final shut down of this alias |
11173 |
+ if [[ ${IN_BACKGROUND} != "true" \ |
11174 |
+ && ${RC_DOWN_INTERFACE} == "yes" ]] ; then |
11175 |
+ ebegin "Shutting down ${i}" |
11176 |
+ interface_iface_stop "${i}" |
11177 |
+ eend "$?" |
11178 |
+ fi |
11179 |
+ done |
11180 |
+ |
11181 |
+ # post Stop any modules |
11182 |
+ for mod in ${MODULES[@]}; do |
11183 |
+ # We have already taken down the interface, so no need to error |
11184 |
+ is_function "${mod}_post_stop" && ${mod}_post_stop "${iface}" |
11185 |
+ done |
11186 |
+ |
11187 |
+ return 0 |
11188 |
+} |
11189 |
+ |
11190 |
+# bool run_start(char *iface) |
11191 |
+# |
11192 |
+# Brings up ${IFACE}. Calls preup, iface_start, then postup. |
11193 |
+# Returns 0 (success) unless preup or iface_start returns 1 (failure). |
11194 |
+# Ignores the return value from postup. |
11195 |
+# We cannot check that the device exists ourselves as modules like |
11196 |
+# tuntap make create it. |
11197 |
+run_start() { |
11198 |
+ local iface="$1" IFVAR=$(bash_variable "$1") |
11199 |
+ |
11200 |
+ # We do this so users can specify additional addresses for lo if they |
11201 |
+ # need too - additional routes too |
11202 |
+ # However, no extra modules are loaded as they are just not needed |
11203 |
+ if [[ ${iface} == "lo" ]] ; then |
11204 |
+ metric_lo="0" |
11205 |
+ config_lo=( "127.0.0.1/8 brd 127.255.255.255" "${config_lo[@]}" ) |
11206 |
+ routes_lo=( "127.0.0.0/8" "${routes_lo[@]}" ) |
11207 |
+ elif [[ ${iface} == "lo0" ]] ; then |
11208 |
+ metric_lo0="0" |
11209 |
+ config_lo0=( "127.0.0.1/8 brd 127.255.255.255" "${config_lo[@]}" ) |
11210 |
+ routes_lo0=( "127.0.0.0/8" "${routes_lo[@]}" ) |
11211 |
+ fi |
11212 |
+ |
11213 |
+ # We may not have a loaded module for ${iface} |
11214 |
+ # Some users may have "alias natsemi eth0" in /etc/modules.d/foo |
11215 |
+ # so we can work with this |
11216 |
+ # However, if they do the same with eth1 and try to start it |
11217 |
+ # but eth0 has not been loaded then the module gets loaded as |
11218 |
+ # eth0. |
11219 |
+ # Not much we can do about this :( |
11220 |
+ # Also, we cannot error here as some modules - such as bridge |
11221 |
+ # create interfaces |
11222 |
+ if ! interface_exists "${iface}" ; then |
11223 |
+ /sbin/modprobe "${iface}" &>/dev/null |
11224 |
+ fi |
11225 |
+ |
11226 |
+ # Call user-defined preup function if it exists |
11227 |
+ if is_function preup ; then |
11228 |
+ einfo "Running preup function" |
11229 |
+ eindent |
11230 |
+ ( preup "${iface}" ) |
11231 |
+ eend "$?" "preup ${iface} failed" || return 1 |
11232 |
+ eoutdent |
11233 |
+ fi |
11234 |
+ |
11235 |
+ # If config is set to noop and the interface is up with an address |
11236 |
+ # then we don't start it |
11237 |
+ local config= |
11238 |
+ config="config_${IFVAR}[@]" |
11239 |
+ config=( "${!config}" ) |
11240 |
+ if [[ ${config[0]} == "noop" ]] && interface_is_up "${iface}" true ; then |
11241 |
+ einfo "Keeping current configuration for ${iface}" |
11242 |
+ eend 0 |
11243 |
+ else |
11244 |
+ # Remove noop from the config var |
11245 |
+ [[ ${config[0]} == "noop" ]] \ |
11246 |
+ && eval "config_${IFVAR}=( "\"\$\{config\[@\]:1\}\"" )" |
11247 |
+ |
11248 |
+ # There may be existing ip address info - so we strip it |
11249 |
+ if [[ ${RC_INTERFACE_KEEP_CONFIG} != "yes" \ |
11250 |
+ && ${IN_BACKGROUND} != "true" ]] ; then |
11251 |
+ interface_del_addresses "${iface}" |
11252 |
+ fi |
11253 |
+ |
11254 |
+ # Start the interface |
11255 |
+ if ! iface_start "${iface}" ; then |
11256 |
+ if [[ ${IN_BACKGROUND} != "true" ]] ; then |
11257 |
+ interface_exists "${iface}" && interface_down "${iface}" |
11258 |
+ fi |
11259 |
+ eend 1 |
11260 |
+ return 1 |
11261 |
+ fi |
11262 |
+ fi |
11263 |
+ |
11264 |
+ # Call user-defined postup function if it exists |
11265 |
+ if is_function postup ; then |
11266 |
+ # We need to mark the service as started incase a |
11267 |
+ # postdown function wants to restart services that depend on us |
11268 |
+ mark_service_started "net.${iface}" |
11269 |
+ end_service "net.${iface}" 0 |
11270 |
+ einfo "Running postup function" |
11271 |
+ eindent |
11272 |
+ ( postup "${iface}" ) |
11273 |
+ eoutdent |
11274 |
+ fi |
11275 |
+ |
11276 |
+ return 0 |
11277 |
+} |
11278 |
+ |
11279 |
+# bool run_stop(char *iface) { |
11280 |
+# |
11281 |
+# Brings down ${iface}. If predown call returns non-zero, then |
11282 |
+# stop returns non-zero to indicate failure bringing down device. |
11283 |
+# In all other cases stop returns 0 to indicate success. |
11284 |
+run_stop() { |
11285 |
+ local iface="$1" IFVAR=$(bash_variable "$1") x |
11286 |
+ |
11287 |
+ # Load our ESSID variable so users can use it in predown() instead |
11288 |
+ # of having to write code. |
11289 |
+ local ESSID=$(get_options ESSID) ESSIDVAR= |
11290 |
+ [[ -n ${ESSID} ]] && ESSIDVAR=$(bash_variable "${ESSID}") |
11291 |
+ |
11292 |
+ # Call user-defined predown function if it exists |
11293 |
+ if is_function predown ; then |
11294 |
+ einfo "Running predown function" |
11295 |
+ eindent |
11296 |
+ ( predown "${iface}" ) |
11297 |
+ eend $? "predown ${iface} failed" || return 1 |
11298 |
+ eoutdent |
11299 |
+ elif is_net_fs / ; then |
11300 |
+ eerror "root filesystem is network mounted -- can't stop ${iface}" |
11301 |
+ return 1 |
11302 |
+ elif is_union_fs / ; then |
11303 |
+ for x in $(unionctl "${dir}" --list \ |
11304 |
+ | sed -e 's/^\(.*\) .*/\1/') ; do |
11305 |
+ if is_net_fs "${x}" ; then |
11306 |
+ eerror "Part of the root filesystem is network mounted - cannot stop ${iface}" |
11307 |
+ return 1 |
11308 |
+ fi |
11309 |
+ done |
11310 |
+ fi |
11311 |
+ |
11312 |
+ iface_stop "${iface}" || return 1 # always succeeds, btw |
11313 |
+ |
11314 |
+ # Release resolv.conf information. |
11315 |
+ [[ -x /sbin/resolvconf ]] && resolvconf -d "${iface}" |
11316 |
+ |
11317 |
+ # Mark us as inactive if called from the background |
11318 |
+ [[ ${IN_BACKGROUND} == "true" ]] && mark_service_inactive "net.${iface}" |
11319 |
+ |
11320 |
+ # Call user-defined postdown function if it exists |
11321 |
+ if is_function postdown ; then |
11322 |
+ # We need to mark the service as stopped incase a |
11323 |
+ # postdown function wants to restart services that depend on us |
11324 |
+ [[ ${IN_BACKGROUND} != "true" ]] && mark_service_stopped "net.${iface}" |
11325 |
+ end_service "net.${iface}" 0 |
11326 |
+ einfo "Running postdown function" |
11327 |
+ eindent |
11328 |
+ ( postdown "${iface}" ) |
11329 |
+ eoutdent |
11330 |
+ fi |
11331 |
+ |
11332 |
+ |
11333 |
+ return 0 |
11334 |
+} |
11335 |
+ |
11336 |
+# bool run(char *iface, char *cmd) |
11337 |
+# |
11338 |
+# Main start/stop entry point |
11339 |
+# We load modules here and remove any functions that they |
11340 |
+# added as we may be called inside the same shell scope for another interface |
11341 |
+run() { |
11342 |
+ local iface="$1" cmd="$2" r=1 RC_INDENTATION="${RC_INDENTATION}" |
11343 |
+ local starting=true |
11344 |
+ local -a MODULES=() mods=() |
11345 |
+ local IN_BACKGROUND="${IN_BACKGROUND}" |
11346 |
+ |
11347 |
+ if [[ ${IN_BACKGROUND} == "true" || ${IN_BACKGROUND} == "1" ]] ; then |
11348 |
+ IN_BACKGROUND=true |
11349 |
+ else |
11350 |
+ IN_BACKGROUND=false |
11351 |
+ fi |
11352 |
+ |
11353 |
+ # We need to override the exit function as runscript.sh now checks |
11354 |
+ # for it. We need it so we can mark the service as inactive ourselves. |
11355 |
+ unset -f exit |
11356 |
+ |
11357 |
+ eindent |
11358 |
+ [[ ${cmd} == "stop" ]] && starting=false |
11359 |
+ |
11360 |
+ # We force lo to only use these modules for a major speed boost |
11361 |
+ if is_loopback "${iface}" ; then |
11362 |
+ modules_force=( "iproute2" "ifconfig" "system" ) |
11363 |
+ fi |
11364 |
+ |
11365 |
+ if modules_load "${iface}" "${starting}" ; then |
11366 |
+ if [[ ${cmd} == "stop" ]] ; then |
11367 |
+ # Reverse the module list for stopping |
11368 |
+ mods=( "${MODULES[@]}" ) |
11369 |
+ for ((i = 0; i < ${#mods[@]}; i++)); do |
11370 |
+ MODULES[i]=${mods[((${#mods[@]} - i - 1))]} |
11371 |
+ done |
11372 |
+ |
11373 |
+ run_stop "${iface}" && r=0 |
11374 |
+ else |
11375 |
+ # Only hotplug on ethernet interfaces |
11376 |
+ if [[ ${IN_HOTPLUG} == 1 ]] ; then |
11377 |
+ if ! interface_is_ethernet "${iface}" ; then |
11378 |
+ eerror "We only hotplug for ethernet interfaces" |
11379 |
+ return 1 |
11380 |
+ fi |
11381 |
+ fi |
11382 |
+ |
11383 |
+ run_start "${iface}" && r=0 |
11384 |
+ fi |
11385 |
+ fi |
11386 |
+ |
11387 |
+ if [[ ${r} != "0" ]] ; then |
11388 |
+ if [[ ${cmd} == "start" ]] ; then |
11389 |
+ # Call user-defined failup if it exists |
11390 |
+ if is_function failup ; then |
11391 |
+ einfo "Running failup function" |
11392 |
+ eindent |
11393 |
+ ( failup "${iface}" ) |
11394 |
+ eoutdent |
11395 |
+ fi |
11396 |
+ else |
11397 |
+ # Call user-defined faildown if it exists |
11398 |
+ if is_function faildown ; then |
11399 |
+ einfo "Running faildown function" |
11400 |
+ eindent |
11401 |
+ ( faildown "${iface}" ) |
11402 |
+ eoutdent |
11403 |
+ fi |
11404 |
+ fi |
11405 |
+ [[ ${IN_BACKGROUND} == "true" ]] \ |
11406 |
+ && mark_service_inactive "net.${iface}" |
11407 |
+ fi |
11408 |
+ |
11409 |
+ return "${r}" |
11410 |
+} |
11411 |
+ |
11412 |
+# bool start(void) |
11413 |
+# |
11414 |
+# Start entry point so that we only have one function |
11415 |
+# which localises variables and unsets functions |
11416 |
+start() { |
11417 |
+ declare -r IFACE="${SVCNAME#*.}" |
11418 |
+ einfo "Starting ${IFACE}" |
11419 |
+ run "${IFACE}" start |
11420 |
+} |
11421 |
+ |
11422 |
+# bool stop(void) |
11423 |
+# |
11424 |
+# Stop entry point so that we only have one function |
11425 |
+# which localises variables and unsets functions |
11426 |
+stop() { |
11427 |
+ declare -r IFACE="${SVCNAME#*.}" |
11428 |
+ einfo "Stopping ${IFACE}" |
11429 |
+ run "${IFACE}" stop |
11430 |
+} |
11431 |
+ |
11432 |
+# vim:ts=4 |
11433 |
|
11434 |
|
11435 |
Property changes on: trunk/baselayout-prefix/init.d/net.lo |
11436 |
___________________________________________________________________ |
11437 |
Added: svn:executable |
11438 |
+ * |
11439 |
|
11440 |
Added: trunk/baselayout-prefix/init.d/netmount |
11441 |
=================================================================== |
11442 |
--- trunk/baselayout-prefix/init.d/netmount (rev 0) |
11443 |
+++ trunk/baselayout-prefix/init.d/netmount 2011-03-31 14:11:17 UTC (rev 1682) |
11444 |
@@ -0,0 +1,106 @@ |
11445 |
+#!/sbin/runscript |
11446 |
+# Copyright 1999-2006 Gentoo Foundation |
11447 |
+# Distributed under the terms of the GNU General Public License v2 |
11448 |
+ |
11449 |
+depend() { |
11450 |
+ local myneed="net" |
11451 |
+ local myuse="" |
11452 |
+ |
11453 |
+ # Only have Portmap as a dependency if there is a nfs mount in fstab |
11454 |
+ # that should be mounted at boot time. Also filter out comments. |
11455 |
+ local nfsmounts=$(awk '!/^#/ && ($3=="nfs" || $3=="nfs4") && $4 !~ /noauto/ { print $0 }' /etc/fstab) |
11456 |
+ |
11457 |
+ if [[ -n ${nfsmounts} ]] ; then |
11458 |
+ myneed="${myneed} portmap" |
11459 |
+ myuse="${myuse} nfs nfsmount" |
11460 |
+ else |
11461 |
+ myuse="${myuse} portmap" |
11462 |
+ fi |
11463 |
+ |
11464 |
+ need ${myneed} |
11465 |
+ use ${myuse} |
11466 |
+} |
11467 |
+ |
11468 |
+remove_net_fs() { |
11469 |
+ local fs |
11470 |
+ rcfilesystems=" ${rcfilesystems} " |
11471 |
+ for fs in "$@" ; do |
11472 |
+ rcfilesystems=${rcfilesystems// ${fs} / } |
11473 |
+ done |
11474 |
+ rcfilesystems=${rcfilesystems# } # remove front and |
11475 |
+ rcfilesystems=${rcfilesystems% } # back spaces |
11476 |
+} |
11477 |
+ |
11478 |
+start() { |
11479 |
+ local rcfilesystems=${NET_FS_LIST} |
11480 |
+ |
11481 |
+ # Only try to mount NFS filesystems if portmap was started. |
11482 |
+ # This is to fix "hang" problems for new users who do not |
11483 |
+ # add portmap to the default runlevel. |
11484 |
+ if ! service_started portmap ; then |
11485 |
+ remove_net_fs nfs nfs4 |
11486 |
+ fi |
11487 |
+ rcfilesystems=${rcfilesystems// /,} # convert to comma-separated |
11488 |
+ |
11489 |
+ ebegin "Mounting network filesystems" |
11490 |
+ mount -at ${rcfilesystems} >/dev/null |
11491 |
+ |
11492 |
+ if [[ $? != 0 ]] ; then |
11493 |
+ ewend 1 "Could not mount all network filesystems!" |
11494 |
+ else |
11495 |
+ eend 0 |
11496 |
+ fi |
11497 |
+ |
11498 |
+ return 0 |
11499 |
+} |
11500 |
+ |
11501 |
+stop() { |
11502 |
+ local rcfilesystems=${NET_FS_LIST} |
11503 |
+ |
11504 |
+ # We let the afs init script handle unmounting afs stuff |
11505 |
+ # because it requires special handling of the afs daemon |
11506 |
+ # and similar ugly cruft |
11507 |
+ if service_started afs-client ; then |
11508 |
+ remove_net_fs afs |
11509 |
+ fi |
11510 |
+ |
11511 |
+ rcfilesystems=${rcfilesystems// /,} # convert to comma-separated |
11512 |
+ |
11513 |
+ local ret |
11514 |
+ ebegin "Unmounting network filesystems" |
11515 |
+ [[ -z $(umount -art ${rcfilesystems} 2>&1) ]] |
11516 |
+ ret=$? |
11517 |
+ eend ${ret} "Failed to simply unmount filesystems" |
11518 |
+ [[ ${ret} == 0 ]] && return 0 |
11519 |
+ |
11520 |
+ # `umount -a` will fail if the filesystems are in use. |
11521 |
+ # Here we use fuser to kill off processes that are using |
11522 |
+ # the filesystems so that we can unmount properly. |
11523 |
+ # We will gradually use harsher kill signals so that the |
11524 |
+ # processes know we aren't screwing around here ;). |
11525 |
+ declare -a siglist=( "TERM" "KILL" "KILL" ) |
11526 |
+ local retry=0 |
11527 |
+ local remaining="go" |
11528 |
+ |
11529 |
+ while [[ -n ${remaining} && ${retry} -lt 3 ]] ; do |
11530 |
+ # Populate $remaining with a newline-delimited list of network |
11531 |
+ # filesystems. Mount points have spaces swapped for '\040' (see |
11532 |
+ # fstab(5)) so we have to translate them back to spaces. |
11533 |
+ remaining="$(awk '$3 ~ /'${NET_FS_LIST// /|}'/ { if ($2 != "/") print $2 }' /proc/mounts | sort -r)" |
11534 |
+ # Since we have to worry about the spaces being quoted properly, |
11535 |
+ # we'll use `set --` and then "$@" to get the correct result. |
11536 |
+ IFS=$'\n' |
11537 |
+ set -- ${remaining//\\040/ } |
11538 |
+ unset IFS |
11539 |
+ [[ -z ${remaining} ]] && break |
11540 |
+ |
11541 |
+ # try to unmount again |
11542 |
+ ebegin $'\t'"Unmounting network filesystems (retry #$((retry+1)))" |
11543 |
+ /bin/fuser -s -k -${siglist[$((retry++))]} -m "$@" |
11544 |
+ sleep 5 |
11545 |
+ umount "$@" &>/dev/null |
11546 |
+ eend $? $'\t'"Failed to unmount filesystems" |
11547 |
+ done |
11548 |
+} |
11549 |
+ |
11550 |
+# vim:ts=4 |
11551 |
|
11552 |
|
11553 |
Property changes on: trunk/baselayout-prefix/init.d/netmount |
11554 |
___________________________________________________________________ |
11555 |
Added: svn:executable |
11556 |
+ * |
11557 |
|
11558 |
Added: trunk/baselayout-prefix/init.d/numlock |
11559 |
=================================================================== |
11560 |
--- trunk/baselayout-prefix/init.d/numlock (rev 0) |
11561 |
+++ trunk/baselayout-prefix/init.d/numlock 2011-03-31 14:11:17 UTC (rev 1682) |
11562 |
@@ -0,0 +1,34 @@ |
11563 |
+#!/sbin/runscript |
11564 |
+# Copyright 1999-2006 Gentoo Foundation |
11565 |
+# Distributed under the terms of the GNU General Public License v2 |
11566 |
+ |
11567 |
+depend() { |
11568 |
+ need localmount |
11569 |
+} |
11570 |
+ |
11571 |
+start() { |
11572 |
+ ebegin "Enabling numlock on ttys" |
11573 |
+ local dev |
11574 |
+ [[ -d /dev/vc ]] \ |
11575 |
+ && dev=/dev/vc/ \ |
11576 |
+ || dev=/dev/tty |
11577 |
+ for tty in $(seq 1 "${RC_TTY_NUMBER}") ; do |
11578 |
+ setleds -D +num < ${dev}${tty} &> /dev/null |
11579 |
+ done |
11580 |
+ eend $? "Failed to enable numlock" |
11581 |
+} |
11582 |
+ |
11583 |
+stop() { |
11584 |
+ ebegin "Disabling numlock on ttys" |
11585 |
+ local dev |
11586 |
+ [[ -d /dev/vc ]] \ |
11587 |
+ && dev=/dev/vc/ \ |
11588 |
+ || dev=/dev/tty |
11589 |
+ for tty in $(seq 1 "${RC_TTY_NUMBER}") ; do |
11590 |
+ setleds -D -num < ${dev}${tty} &> /dev/null |
11591 |
+ done |
11592 |
+ eend $? "Failed to disable numlock" |
11593 |
+} |
11594 |
+ |
11595 |
+ |
11596 |
+# vim:ts=4 |
11597 |
|
11598 |
|
11599 |
Property changes on: trunk/baselayout-prefix/init.d/numlock |
11600 |
___________________________________________________________________ |
11601 |
Added: svn:executable |
11602 |
+ * |
11603 |
|
11604 |
Added: trunk/baselayout-prefix/init.d/reboot.sh |
11605 |
=================================================================== |
11606 |
--- trunk/baselayout-prefix/init.d/reboot.sh (rev 0) |
11607 |
+++ trunk/baselayout-prefix/init.d/reboot.sh 2011-03-31 14:11:17 UTC (rev 1682) |
11608 |
@@ -0,0 +1,8 @@ |
11609 |
+# Copyright 1999-2006 Gentoo Foundation |
11610 |
+# Distributed under the terms of the GNU General Public License v2 |
11611 |
+ |
11612 |
+/sbin/reboot -idpk |
11613 |
+ |
11614 |
+# hmm, if the above failed, that's kind of odd ... |
11615 |
+# so let's force a reboot |
11616 |
+/sbin/reboot -f |
11617 |
|
11618 |
|
11619 |
Property changes on: trunk/baselayout-prefix/init.d/reboot.sh |
11620 |
___________________________________________________________________ |
11621 |
Added: svn:executable |
11622 |
+ * |
11623 |
|
11624 |
Added: trunk/baselayout-prefix/init.d/rmnologin |
11625 |
=================================================================== |
11626 |
--- trunk/baselayout-prefix/init.d/rmnologin (rev 0) |
11627 |
+++ trunk/baselayout-prefix/init.d/rmnologin 2011-03-31 14:11:17 UTC (rev 1682) |
11628 |
@@ -0,0 +1,16 @@ |
11629 |
+#!/sbin/runscript |
11630 |
+# Copyright 1999-2006 Gentoo Foundation |
11631 |
+# Distributed under the terms of the GNU General Public License v2 |
11632 |
+ |
11633 |
+depend() { |
11634 |
+ need localmount |
11635 |
+} |
11636 |
+ |
11637 |
+start() { |
11638 |
+ if [[ -f /etc/nologin.boot ]] ; then |
11639 |
+ rm -f /etc/nologin /etc/nologin.boot &> /dev/null |
11640 |
+ fi |
11641 |
+} |
11642 |
+ |
11643 |
+ |
11644 |
+# vim:ts=4 |
11645 |
|
11646 |
|
11647 |
Property changes on: trunk/baselayout-prefix/init.d/rmnologin |
11648 |
___________________________________________________________________ |
11649 |
Added: svn:executable |
11650 |
+ * |
11651 |
|
11652 |
Added: trunk/baselayout-prefix/init.d/shutdown.sh |
11653 |
=================================================================== |
11654 |
--- trunk/baselayout-prefix/init.d/shutdown.sh (rev 0) |
11655 |
+++ trunk/baselayout-prefix/init.d/shutdown.sh 2011-03-31 14:11:17 UTC (rev 1682) |
11656 |
@@ -0,0 +1,12 @@ |
11657 |
+# Copyright 1999-2006 Gentoo Foundation |
11658 |
+# Distributed under the terms of the GNU General Public License v2 |
11659 |
+ |
11660 |
+opts="-hd" |
11661 |
+[[ ${INIT_HALT} != "HALT" ]] && opts="${opts}p" |
11662 |
+[[ ${RC_DOWN_INTERFACE} == "yes" ]] && opts="${opts}i" |
11663 |
+ |
11664 |
+/sbin/halt "${opts}" |
11665 |
+ |
11666 |
+# hmm, if the above failed, that's kind of odd ... |
11667 |
+# so let's force a halt |
11668 |
+/sbin/halt -f |
11669 |
|
11670 |
|
11671 |
Property changes on: trunk/baselayout-prefix/init.d/shutdown.sh |
11672 |
___________________________________________________________________ |
11673 |
Added: svn:executable |
11674 |
+ * |
11675 |
|
11676 |
Added: trunk/baselayout-prefix/init.d/urandom |
11677 |
=================================================================== |
11678 |
--- trunk/baselayout-prefix/init.d/urandom (rev 0) |
11679 |
+++ trunk/baselayout-prefix/init.d/urandom 2011-03-31 14:11:17 UTC (rev 1682) |
11680 |
@@ -0,0 +1,37 @@ |
11681 |
+#!/sbin/runscript |
11682 |
+# Copyright 1999-2006 Gentoo Foundation |
11683 |
+# Distributed under the terms of the GNU General Public License v2 |
11684 |
+ |
11685 |
+depend() { |
11686 |
+ need localmount |
11687 |
+} |
11688 |
+ |
11689 |
+start() { |
11690 |
+ [[ -c /dev/urandom ]] || return |
11691 |
+ if [[ -f /var/run/random-seed ]] ; then |
11692 |
+ cat /var/run/random-seed > /dev/urandom |
11693 |
+ fi |
11694 |
+ if ! rm -f /var/run/random-seed &> /dev/null ; then |
11695 |
+ ewarn "Skipping /var/run/random-seed initialization (ro root?)" |
11696 |
+ return 0 |
11697 |
+ fi |
11698 |
+ ebegin "Initializing random number generator" |
11699 |
+ umask 077 |
11700 |
+ dd if=/dev/urandom of=/var/run/random-seed count=1 &> /dev/null |
11701 |
+ eend $? "Error initializing random number generator" |
11702 |
+ umask 022 |
11703 |
+} |
11704 |
+ |
11705 |
+stop() { |
11706 |
+ [[ -n ${CDBOOT} ]] && return 0 |
11707 |
+ |
11708 |
+ ebegin "Saving random seed" |
11709 |
+ # Carry a random seed from shut-down to start-up; |
11710 |
+ # see documentation in linux/drivers/char/random.c |
11711 |
+ umask 077 |
11712 |
+ dd if=/dev/urandom of=/var/run/random-seed count=1 &> /dev/null |
11713 |
+ eend $? "Failed to save random seed" |
11714 |
+} |
11715 |
+ |
11716 |
+ |
11717 |
+# vim:ts=4 |
11718 |
|
11719 |
|
11720 |
Property changes on: trunk/baselayout-prefix/init.d/urandom |
11721 |
___________________________________________________________________ |
11722 |
Added: svn:executable |
11723 |
+ * |
11724 |
|
11725 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/adsl.sh |
11726 |
=================================================================== |
11727 |
--- trunk/baselayout-prefix/lib/rcscripts/net/adsl.sh (rev 0) |
11728 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/adsl.sh 2011-03-31 14:11:17 UTC (rev 1682) |
11729 |
@@ -0,0 +1,93 @@ |
11730 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
11731 |
+# Distributed under the terms of the GNU General Public License v2 |
11732 |
+# Contributed by Roy Marples (uberlord@g.o) |
11733 |
+ |
11734 |
+# void adsl_depend(void) |
11735 |
+# |
11736 |
+# Sets up the dependancies for the module |
11737 |
+adsl_depend() { |
11738 |
+ before dhcp |
11739 |
+} |
11740 |
+ |
11741 |
+# bool adsl_check_installed(void) |
11742 |
+# |
11743 |
+# Returns 1 if rp-pppoe is installed, otherwise 0 |
11744 |
+adsl_check_installed() { |
11745 |
+ [[ -x /usr/sbin/adsl-start || -x /usr/sbin/pppoe-start ]] && return 0 |
11746 |
+ ${1:-false} && eerror "For ADSL support, emerge net-dialup/rp-pppoe" |
11747 |
+ return 1 |
11748 |
+} |
11749 |
+ |
11750 |
+# bool adsl_setup_vars(char *iface) |
11751 |
+# |
11752 |
+# Checks to see if the ADSL script has been created or not |
11753 |
+adsl_setup_vars() { |
11754 |
+ local iface="$1" startstop="$2" cfgexe= |
11755 |
+ |
11756 |
+ if [[ -x /usr/sbin/pppoe-start ]]; then |
11757 |
+ exe="/usr/sbin/pppoe-${startstop}" |
11758 |
+ cfgexe=pppoe-setup |
11759 |
+ else |
11760 |
+ exe="/usr/sbin/adsl-${startstop}" |
11761 |
+ cfgexe=adsl-setup |
11762 |
+ fi |
11763 |
+ |
11764 |
+ # Decide which configuration to use. Hopefully there is an |
11765 |
+ # interface-specific one |
11766 |
+ cfgfile="/etc/ppp/pppoe-${iface}.conf" |
11767 |
+ [[ -f ${cfgfile} ]] || cfgfile="/etc/ppp/pppoe.conf" |
11768 |
+ |
11769 |
+ if [[ ! -f ${cfgfile} ]]; then |
11770 |
+ eerror "no pppoe.conf file found!" |
11771 |
+ eerror "Please run ${cfgexe} to create one" |
11772 |
+ return 1 |
11773 |
+ fi |
11774 |
+ |
11775 |
+ return 0 |
11776 |
+} |
11777 |
+ |
11778 |
+# bool adsl_start(char *iface) |
11779 |
+# |
11780 |
+# Start ADSL on an interface by calling adsl-start |
11781 |
+# |
11782 |
+# Returns 0 (true) when successful, non-zero otherwise |
11783 |
+adsl_start() { |
11784 |
+ local iface="$1" exe= cfgfile= user= ifvar=$(bash_variable "$1") |
11785 |
+ |
11786 |
+ adsl_setup_vars "${iface}" start || return 1 |
11787 |
+ |
11788 |
+ # Might or might not be set in conf.d/net |
11789 |
+ user="adsl_user_${ifvar}" |
11790 |
+ |
11791 |
+ # Start ADSL with the cfgfile, but override ETH and PIDFILE |
11792 |
+ einfo "Starting ADSL for ${iface}" |
11793 |
+ ${exe} <(cat "${cfgfile}"; \ |
11794 |
+ echo "ETH=${iface}"; \ |
11795 |
+ echo "PIDFILE=/var/run/rp-pppoe-${iface}.pid"; \ |
11796 |
+ [[ -n ${!user} ]] && echo "USER=${!user}") \ |
11797 |
+ >/dev/null |
11798 |
+ eend $? |
11799 |
+} |
11800 |
+ |
11801 |
+# bool adsl_stop(char *iface) |
11802 |
+# |
11803 |
+# Returns 0 when there is no ADSL to stop or we stop ADSL successfully |
11804 |
+# Otherwise 1 |
11805 |
+adsl_stop() { |
11806 |
+ local iface="$1" exe= cfgfile= |
11807 |
+ |
11808 |
+ adsl_check_installed || return 1 |
11809 |
+ [[ ! -f "/var/run/rp-pppoe-${iface}.pid" ]] && return 0 |
11810 |
+ |
11811 |
+ adsl_setup_vars "${iface}" stop || return 1 |
11812 |
+ |
11813 |
+ einfo "Stopping ADSL for ${iface}" |
11814 |
+ ${exe} <(cat "${cfgfile}"; \ |
11815 |
+ echo "ETH=${iface}"; echo "PIDFILE=/var/run/rp-pppoe-${iface}.pid") \ |
11816 |
+ >/dev/null |
11817 |
+ eend $? |
11818 |
+ |
11819 |
+ return 0 |
11820 |
+} |
11821 |
+ |
11822 |
+# vim: set ts=4 : |
11823 |
|
11824 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/apipa.sh |
11825 |
=================================================================== |
11826 |
--- trunk/baselayout-prefix/lib/rcscripts/net/apipa.sh (rev 0) |
11827 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/apipa.sh 2011-03-31 14:11:17 UTC (rev 1682) |
11828 |
@@ -0,0 +1,46 @@ |
11829 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
11830 |
+# Distributed under the terms of the GNU General Public License v2 |
11831 |
+# Contributed by Roy Marples (uberlord@g.o) |
11832 |
+ |
11833 |
+# void apipa_depend(void) |
11834 |
+# |
11835 |
+# Sets up the dependancies for the module |
11836 |
+apipa_depend() { |
11837 |
+ installed arping |
11838 |
+ functions interface_exists |
11839 |
+} |
11840 |
+ |
11841 |
+# bool apipa_start(char *iface) |
11842 |
+# |
11843 |
+# Tries to detect a config based on arpinging things |
11844 |
+apipa_start() { |
11845 |
+ local iface="$1" i1= i2= addr= i=0 |
11846 |
+ |
11847 |
+ interface_exists "$1" true || return 1 |
11848 |
+ |
11849 |
+ einfo "Searching for free addresses in 169.254.0.0/16" |
11850 |
+ eindent |
11851 |
+ |
11852 |
+ while [[ ${i} -lt 64516 ]]; do |
11853 |
+ (( i1=${RANDOM}%255 )) |
11854 |
+ (( i2=${RANDOM}%255 )) |
11855 |
+ |
11856 |
+ addr="169.254.${i1}.${i2}" |
11857 |
+ vebegin "${addr}/16" |
11858 |
+ if ! arping_address_exists "${iface}" "${addr}" ; then |
11859 |
+ config[config_counter]="${addr}/16 broadcast 169.254.255.255" |
11860 |
+ (( config_counter-- )) |
11861 |
+ veend 0 |
11862 |
+ eoutdent |
11863 |
+ return 0 |
11864 |
+ fi |
11865 |
+ |
11866 |
+ (( i++ )) |
11867 |
+ done |
11868 |
+ |
11869 |
+ eerror "No free address found!" |
11870 |
+ eoutdent |
11871 |
+ return 1 |
11872 |
+} |
11873 |
+ |
11874 |
+# vim: set ts=4 : |
11875 |
|
11876 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/arping.sh |
11877 |
=================================================================== |
11878 |
--- trunk/baselayout-prefix/lib/rcscripts/net/arping.sh (rev 0) |
11879 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/arping.sh 2011-03-31 14:11:17 UTC (rev 1682) |
11880 |
@@ -0,0 +1,166 @@ |
11881 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
11882 |
+# Distributed under the terms of the GNU General Public License v2 |
11883 |
+# Contributed by Roy Marples (uberlord@g.o) |
11884 |
+ |
11885 |
+# void arping_depend(void) |
11886 |
+# |
11887 |
+# Sets up the dependancies for the module |
11888 |
+arping_depend() { |
11889 |
+ functions interface_exists interface_up |
11890 |
+} |
11891 |
+ |
11892 |
+# bool arping_check_installed(void) |
11893 |
+# |
11894 |
+# Returns 0 if arping or arping2 is installed, otherwise 1 |
11895 |
+arping_check_installed() { |
11896 |
+ [[ -x /sbin/arping || -x /usr/sbin/arping2 ]] && return 0 |
11897 |
+ if ${1:-false}; then |
11898 |
+ eerror "For arping support emerge net-misc/iputils or net-analyzer/arping" |
11899 |
+ fi |
11900 |
+ return 1 |
11901 |
+} |
11902 |
+ |
11903 |
+# void arping_sleep(char *interface) |
11904 |
+# |
11905 |
+# Allows the interface to settle on the LAN - normally takes around 3 seconds |
11906 |
+# This requires the use of a global variable, ARPING_SLEPT |
11907 |
+arping_sleep() { |
11908 |
+ local iface="$1" |
11909 |
+ [[ ${ARPING_SLEPT} == "1" ]] && return |
11910 |
+ |
11911 |
+ local ifvar=$(bash_variable "${iface}") |
11912 |
+ local s="arping_sleep_${ifvar}" |
11913 |
+ s="${!s}" |
11914 |
+ if [[ -z ${s} ]] ; then |
11915 |
+ s="${arping_sleep}" |
11916 |
+ s="${s:-1}" |
11917 |
+ fi |
11918 |
+ sleep "${s}" |
11919 |
+ ARPING_SLEPT="1" |
11920 |
+} |
11921 |
+ |
11922 |
+# bool arping_address_exists(char *interface, char *address) |
11923 |
+# |
11924 |
+# Returns 0 if the address on the interface responds to an arping |
11925 |
+# 1 if not - packets defaults to 1 |
11926 |
+# If neither arping (net-misc/iputils) or arping2 (net-analyzer/arping) |
11927 |
+# is installed then we return 1 |
11928 |
+arping_address_exists() { |
11929 |
+ local iface="$1" ip="${2%%/*}" mac="$3" foundmac= i= w= |
11930 |
+ |
11931 |
+ # We only handle IPv4 addresses |
11932 |
+ [[ ${ip} != *.*.*.* ]] && return 1 |
11933 |
+ |
11934 |
+ # 0.0.0.0 isn't a valid address - and some lusers have configured this |
11935 |
+ [[ ${ip} == "0.0.0.0" || ${ip} == "0" ]] && return 1 |
11936 |
+ |
11937 |
+ # We need to bring the interface up to test |
11938 |
+ interface_exists "${iface}" || return 1 |
11939 |
+ interface_up "${iface}" |
11940 |
+ |
11941 |
+ arping_sleep |
11942 |
+ |
11943 |
+ local ifvar=$(bash_variable "${iface}") |
11944 |
+ w="arping_wait_${ifvar}" |
11945 |
+ w="${!w}" |
11946 |
+ [[ -z ${w} ]] && w="${arping_wait:-3}" |
11947 |
+ |
11948 |
+ if [[ -x /sbin/arping ]] ; then |
11949 |
+ foundmac=$(arping -c 2 -w "${w}" -D -f -I "${iface}" \ |
11950 |
+ "${ip}" 2>/dev/null \ |
11951 |
+ | sed -n 's/.*\[\([^]]*\)\].*/\U\1/p') |
11952 |
+ elif [[ -x /usr/sbin/arping2 ]] ; then |
11953 |
+ for (( i=0; i<w; i++ )) ; do |
11954 |
+ foundmac=$(arping2 -r -0 -c 1 -i "${iface}" \ |
11955 |
+ "${ip}" 2>/dev/null) |
11956 |
+ if [[ $? == "0" ]] ; then |
11957 |
+ foundmac=$(echo "${foundmac}" \ |
11958 |
+ | tr '[:lower:]' '[:upper:]') |
11959 |
+ break |
11960 |
+ fi |
11961 |
+ foundmac= |
11962 |
+ done |
11963 |
+ fi |
11964 |
+ |
11965 |
+ [[ -z ${foundmac} ]] && return 1 |
11966 |
+ |
11967 |
+ if [[ -n ${mac} ]] ; then |
11968 |
+ if [[ ${mac} != "${foundmac}" ]] ; then |
11969 |
+ vewarn "Found ${ip} but MAC ${foundmac} does not match" |
11970 |
+ return 1 |
11971 |
+ fi |
11972 |
+ fi |
11973 |
+ |
11974 |
+ return 0 |
11975 |
+} |
11976 |
+ |
11977 |
+# bool arping_start(char *iface) |
11978 |
+# |
11979 |
+# arpings a list of gateways |
11980 |
+# If one is foung then apply it's configuration |
11981 |
+arping_start() { |
11982 |
+ local iface="$1" gateways= x= conf= i= |
11983 |
+ local ifvar=$(bash_variable "${iface}") |
11984 |
+ |
11985 |
+ einfo "Pinging gateways on ${iface} for configuration" |
11986 |
+ |
11987 |
+ gateways="gateways_${ifvar}[@]" |
11988 |
+ if [[ -z "${!gateways}" ]] ; then |
11989 |
+ eerror "No gateways have been defined (gateways_${ifvar}=( \"...\"))" |
11990 |
+ return 1 |
11991 |
+ fi |
11992 |
+ |
11993 |
+ eindent |
11994 |
+ |
11995 |
+ for x in ${!gateways}; do |
11996 |
+ local -a a=( ${x//,/ } ) |
11997 |
+ local ip="${a[0]}" mac="${a[1]}" extra= |
11998 |
+ if [[ -n ${mac} ]] ; then |
11999 |
+ mac=$(echo "${mac}" | tr '[:lower:]' '[:upper:]') |
12000 |
+ extra=(MAC ${mac}) |
12001 |
+ fi |
12002 |
+ |
12003 |
+ vebegin "${ip} ${extra}" |
12004 |
+ if arping_address_exists "${iface}" "${ip}" "${mac}" ; then |
12005 |
+ for i in ${ip//./ } ; do |
12006 |
+ if [[ ${#i} == "2" ]] ; then |
12007 |
+ conf="${conf}0${i}" |
12008 |
+ elif [[ ${#i} == "1" ]] ; then |
12009 |
+ conf="${conf}00${i}" |
12010 |
+ else |
12011 |
+ conf="${conf}${i}" |
12012 |
+ fi |
12013 |
+ done |
12014 |
+ [[ -n ${mac} ]] && conf="${conf}_${mac//:/}" |
12015 |
+ |
12016 |
+ veend 0 |
12017 |
+ eoutdent |
12018 |
+ veinfo "Configuring ${iface} for ${ip} ${extra}" |
12019 |
+ configure_variables "${iface}" "${conf}" |
12020 |
+ |
12021 |
+ # Call the system module as we've aleady passed it by .... |
12022 |
+ # And it *has* to be pre_start for other things to work correctly |
12023 |
+ system_pre_start "${iface}" |
12024 |
+ |
12025 |
+ t="config_${ifvar}[@]" |
12026 |
+ |
12027 |
+ # Only return if we HAVE a config that doesn't include |
12028 |
+ # arping to avoid infinite recursion. |
12029 |
+ if [[ " ${!t} " != *" arping "* ]] ; then |
12030 |
+ config=( "${!t}" ) |
12031 |
+ t="fallback_config_${ifvar}[@]" |
12032 |
+ fallback_config=( "${!t}" ) |
12033 |
+ t="fallback_route_${ifvar}[@]" |
12034 |
+ fallback_route=( "${!t}" ) |
12035 |
+ config_counter=-1 |
12036 |
+ return 0 |
12037 |
+ fi |
12038 |
+ fi |
12039 |
+ veend 1 |
12040 |
+ done |
12041 |
+ |
12042 |
+ eoutdent |
12043 |
+ return 1 |
12044 |
+} |
12045 |
+ |
12046 |
+# vim: set ts=4 : |
12047 |
|
12048 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/bonding.sh |
12049 |
=================================================================== |
12050 |
--- trunk/baselayout-prefix/lib/rcscripts/net/bonding.sh (rev 0) |
12051 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/bonding.sh 2011-03-31 14:11:17 UTC (rev 1682) |
12052 |
@@ -0,0 +1,120 @@ |
12053 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
12054 |
+# Distributed under the terms of the GNU General Public License v2 |
12055 |
+# Contributed by Roy Marples (uberlord@g.o) |
12056 |
+ |
12057 |
+# void bonding_depend(void) |
12058 |
+# |
12059 |
+# Sets up the dependancies for the module |
12060 |
+bonding_depend() { |
12061 |
+ before interface macchanger |
12062 |
+ functions interface_exists interface_up interface_down \ |
12063 |
+ interface_del_addresses |
12064 |
+} |
12065 |
+ |
12066 |
+# void bonding_expose(void) |
12067 |
+# |
12068 |
+# Expose variables that can be configured |
12069 |
+bonding_expose() { |
12070 |
+ variables slaves |
12071 |
+} |
12072 |
+ |
12073 |
+# bool bonding_check_installed(void) |
12074 |
+# |
12075 |
+# Returns 0 if ifenslave is installed, otherwise 1 |
12076 |
+bonding_check_installed() { |
12077 |
+ [[ -x /sbin/ifenslave ]] && return 0 |
12078 |
+ ${1:-false} && eerror "For link aggregation (bonding) support, emerge net-misc/ifenslave" |
12079 |
+ return 1 |
12080 |
+} |
12081 |
+ |
12082 |
+# bonding_exists(char *interface) |
12083 |
+# |
12084 |
+# Returns 0 if we are a bonded interface, otherwise 1 |
12085 |
+bonding_exists() { |
12086 |
+ [[ -f "/proc/net/bonding/$1" ]] |
12087 |
+} |
12088 |
+ |
12089 |
+# bool bonding_post_start(char *iface) |
12090 |
+# |
12091 |
+# Bonds the interface |
12092 |
+bonding_pre_start() { |
12093 |
+ local iface="$1" s= ifvar=$(bash_variable "$1") |
12094 |
+ local -a slaves=() |
12095 |
+ |
12096 |
+ slaves="slaves_${ifvar}[@]" |
12097 |
+ [[ -z ${!slaves} ]] && return 0 |
12098 |
+ slaves=( "${!slaves}" ) |
12099 |
+ |
12100 |
+ # Support space seperated slaves |
12101 |
+ [[ ${#slaves[@]} == 1 ]] && slaves=( ${slaves} ) |
12102 |
+ |
12103 |
+ interface_exists "${iface}" true || return 1 |
12104 |
+ |
12105 |
+ if ! bonding_exists "${iface}" ; then |
12106 |
+ eerror "${iface} is not capable of bonding" |
12107 |
+ return 1 |
12108 |
+ fi |
12109 |
+ |
12110 |
+ ebegin "Adding slaves to ${iface}" |
12111 |
+ eindent |
12112 |
+ einfo "${slaves[@]}" |
12113 |
+ |
12114 |
+ # Check that our slaves exist |
12115 |
+ for s in "${slaves[@]}" ; do |
12116 |
+ interface_exists "${s}" true || return 1 |
12117 |
+ done |
12118 |
+ |
12119 |
+ # Must force the slaves to a particular state before adding them |
12120 |
+ for s in "${slaves[@]}" ; do |
12121 |
+ interface_del_addresses "${s}" |
12122 |
+ interface_up "${s}" |
12123 |
+ done |
12124 |
+ |
12125 |
+ # now force the master to up |
12126 |
+ interface_up "${iface}" |
12127 |
+ |
12128 |
+ # finally add in slaves |
12129 |
+ eoutdent |
12130 |
+ /sbin/ifenslave "${iface}" ${slaves[@]} >/dev/null |
12131 |
+ eend $? |
12132 |
+ |
12133 |
+ return 0 #important |
12134 |
+} |
12135 |
+ |
12136 |
+# bool bonding_stop(void) |
12137 |
+# Unbonds bonded interfaces |
12138 |
+# |
12139 |
+# Always returns 0 (true) |
12140 |
+bonding_stop() { |
12141 |
+ local iface="$1" slaves= s= |
12142 |
+ |
12143 |
+ # return silently if this is not a bonding interface |
12144 |
+ ! bonding_exists "${iface}" && return 0 |
12145 |
+ |
12146 |
+ # don't trust the config, get the active list instead |
12147 |
+ slaves=$( \ |
12148 |
+ sed -n -e 's/^Slave Interface: //p' "/proc/net/bonding/${iface}" \ |
12149 |
+ | tr '\n' ' ' \ |
12150 |
+ ) |
12151 |
+ [[ -z ${slaves} ]] && return 0 |
12152 |
+ |
12153 |
+ # remove all slaves |
12154 |
+ ebegin "Removing slaves from ${iface}" |
12155 |
+ eindent |
12156 |
+ einfo "${slaves}" |
12157 |
+ eoutdent |
12158 |
+ /sbin/ifenslave -d "${iface}" ${slaves} |
12159 |
+ |
12160 |
+ # reset all slaves |
12161 |
+ for s in ${slaves}; do |
12162 |
+ if interface_exists "${s}" ; then |
12163 |
+ interface_del_addresses "${s}" |
12164 |
+ interface_down "${s}" |
12165 |
+ fi |
12166 |
+ done |
12167 |
+ |
12168 |
+ eend 0 |
12169 |
+ return 0 |
12170 |
+} |
12171 |
+ |
12172 |
+# vim: set ts=4 : |
12173 |
|
12174 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/br2684ctl.sh |
12175 |
=================================================================== |
12176 |
--- trunk/baselayout-prefix/lib/rcscripts/net/br2684ctl.sh (rev 0) |
12177 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/br2684ctl.sh 2011-03-31 14:11:17 UTC (rev 1682) |
12178 |
@@ -0,0 +1,65 @@ |
12179 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
12180 |
+# Distributed under the terms of the GNU General Public License v2 |
12181 |
+# Contributed by Roy Marples (uberlord@g.o) |
12182 |
+ |
12183 |
+# void br2684ctl_depend(void) |
12184 |
+br2684ctl_depend() { |
12185 |
+ before ppp |
12186 |
+} |
12187 |
+br2684ctl_expose() { |
12188 |
+ variables br2684ctl |
12189 |
+} |
12190 |
+ |
12191 |
+# bool br2684ctl_check_installed(void) |
12192 |
+br2684ctl_check_installed() { |
12193 |
+ [[ -x /sbin/br2684ctl ]] && return 0 |
12194 |
+ ${1:-false} && eerror "For RFC 2684 Bridge control support, emerge net-misc/br2684ctl" |
12195 |
+ return 1 |
12196 |
+} |
12197 |
+ |
12198 |
+# bool br2684ctl_start(char *iface) |
12199 |
+br2684ctl_pre_start() { |
12200 |
+ local iface="$1" ifvar=$(bash_variable "$1") opts= |
12201 |
+ local number="${iface#${iface%%[0-9]}}" |
12202 |
+ |
12203 |
+ opts="br2684ctl_${ifvar}" |
12204 |
+ [[ -z ${!opts} ]] && return 0 |
12205 |
+ |
12206 |
+ if [[ $(interface_type "${iface}") != "nas" || -z ${number} ]] ; then |
12207 |
+ eerror "interface must be called nas[0-9] for RFC 2684 Bridging" |
12208 |
+ return 1 |
12209 |
+ fi |
12210 |
+ |
12211 |
+ if [[ " ${!opts} " != *" -a "* ]] ; then |
12212 |
+ eerror "-a option (VPI and VCI) is required in br2684_ctl" |
12213 |
+ return 1 |
12214 |
+ fi |
12215 |
+ |
12216 |
+ if [[ " ${!opts} " == *" -b "* || " {!opts} " == *" -c "* ]] ; then |
12217 |
+ eerror "The -b and -c options are not allowed for br2684ctl_${ifvar}" |
12218 |
+ return 1 |
12219 |
+ fi |
12220 |
+ |
12221 |
+ einfo "Starting RFC 2684 Bridge control on ${iface}" |
12222 |
+ start-stop-daemon --start --exec /sbin/br2684ctl --background \ |
12223 |
+ --make-pidfile --pidfile "/var/run/br2684ctl-${iface}.pid" \ |
12224 |
+ -- -c "${number}" ${!opts} |
12225 |
+ eend $? |
12226 |
+} |
12227 |
+ |
12228 |
+# bool br2684ctl_post_stop(char *iface) |
12229 |
+br2684ctl_post_stop() { |
12230 |
+ local iface="$1" |
12231 |
+ local number="${iface#${iface%%[0-9]}}" |
12232 |
+ local pidfile="/var/run/br2684ctl-${iface}.pid" |
12233 |
+ |
12234 |
+ [[ $(interface_type "${iface}") != "nas" ]] && return 0 |
12235 |
+ |
12236 |
+ [[ -e ${pidfile} ]] || return 0 |
12237 |
+ |
12238 |
+ einfo "Stopping RFC 2684 Bridge control on ${iface}" |
12239 |
+ start-stop-daemon --stop --exec /sbin/br2684ctl --pidfile "${pidfile}" |
12240 |
+ eend $? |
12241 |
+} |
12242 |
+ |
12243 |
+# vim: set ts=4 : |
12244 |
|
12245 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/bridge.sh |
12246 |
=================================================================== |
12247 |
--- trunk/baselayout-prefix/lib/rcscripts/net/bridge.sh (rev 0) |
12248 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/bridge.sh 2011-03-31 14:11:17 UTC (rev 1682) |
12249 |
@@ -0,0 +1,204 @@ |
12250 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
12251 |
+# Distributed under the terms of the GNU General Public License v2 |
12252 |
+# Contributed by Roy Marples (uberlord@g.o) |
12253 |
+ |
12254 |
+# Fix any potential localisation problems |
12255 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
12256 |
+brctl() { |
12257 |
+ LC_ALL=C /sbin/brctl "$@" |
12258 |
+} |
12259 |
+# void bridge_depend(void) |
12260 |
+# |
12261 |
+# Sets up the dependancies for the module |
12262 |
+bridge_depend() { |
12263 |
+ before interface macnet |
12264 |
+ functions interface_down interface_del_addresses interface_set_flag |
12265 |
+} |
12266 |
+ |
12267 |
+# void bridge_expose(void) |
12268 |
+# |
12269 |
+# Expose variables that can be configured |
12270 |
+bridge_expose() { |
12271 |
+ variables bridge bridge_add brctl |
12272 |
+} |
12273 |
+ |
12274 |
+# bool bridge_check_installed(void) |
12275 |
+# |
12276 |
+# Returns 1 if bridge is installed, otherwise 0 |
12277 |
+bridge_check_installed() { |
12278 |
+ [[ -x /sbin/brctl ]] && return 0 |
12279 |
+ ${1:-false} && eerror "For bridge support, emerge net-misc/bridge-utils" |
12280 |
+ return 1 |
12281 |
+} |
12282 |
+ |
12283 |
+# char* bridge_get_ports(char *interface) |
12284 |
+# |
12285 |
+# Returns the interfaces added to the given bridge |
12286 |
+bridge_get_ports() { |
12287 |
+ brctl show 2>/dev/null \ |
12288 |
+ | sed -n -e '/^'"$1"'[[:space:]]/,/^\S/ { /^\('"$1"'[[:space:]]\|\t\)/s/^.*\t//p }' |
12289 |
+} |
12290 |
+ |
12291 |
+# char* bridge_get_bridge(char *interface) |
12292 |
+# |
12293 |
+# Returns the bridge interface of the given interface |
12294 |
+bridge_get_bridge() { |
12295 |
+ local myiface="$1" |
12296 |
+ local bridge= idx= stp= iface= x= |
12297 |
+ while read bridge idx stp iface x ; do |
12298 |
+ if [[ -z ${iface} ]] ; then |
12299 |
+ iface="${stp}" |
12300 |
+ stp="${idx}" |
12301 |
+ idx="${bridge}" |
12302 |
+ fi |
12303 |
+ if [[ ${iface} == "${myiface}" ]] ; then |
12304 |
+ echo "${bridge}" |
12305 |
+ return 0 |
12306 |
+ fi |
12307 |
+ done < <(brctl show 2>/dev/null) |
12308 |
+} |
12309 |
+ |
12310 |
+# bool bridge_exists(char *interface) |
12311 |
+# |
12312 |
+# Returns 0 if the bridge exists, otherwise 1 |
12313 |
+bridge_exists() { |
12314 |
+ brctl show 2>/dev/null | grep -q "^$1[[:space:]]" |
12315 |
+} |
12316 |
+ |
12317 |
+# bool bridge_create(char *interface) |
12318 |
+# |
12319 |
+# Creates the bridge - no ports are added here though |
12320 |
+# Returns 0 on success otherwise 1 |
12321 |
+bridge_create() { |
12322 |
+ local iface="$1" ifvar=$(bash_variable "$1") x= i= opts= |
12323 |
+ |
12324 |
+ ebegin "Creating bridge ${iface}" |
12325 |
+ x=$(brctl addbr "${iface}" 2>&1) |
12326 |
+ if [[ -n ${x} ]] ; then |
12327 |
+ if [[ ${x//Package not installed/} != "${x}" ]] ; then |
12328 |
+ eend 1 "Bridging (802.1d) support is not present in this kernel" |
12329 |
+ else |
12330 |
+ eend 1 "${x}" |
12331 |
+ fi |
12332 |
+ return 1 |
12333 |
+ fi |
12334 |
+ |
12335 |
+ opts="brctl_${ifvar}[@]" |
12336 |
+ for i in "${!opts}" ; do |
12337 |
+ x="${i/ / ${iface} }" |
12338 |
+ [[ ${x} == "${i}" ]] && x="${x} ${iface}" |
12339 |
+ x=$(brctl ${x} 2>&1 1>/dev/null) |
12340 |
+ [[ -n ${x} ]] && ewarn "${x}" |
12341 |
+ done |
12342 |
+ eend 0 |
12343 |
+} |
12344 |
+ |
12345 |
+# bool bridge_add_port(char *interface, char *port) |
12346 |
+# |
12347 |
+# Adds the port to the bridge |
12348 |
+bridge_add_port() { |
12349 |
+ local iface="$1" port="$2" e= |
12350 |
+ |
12351 |
+ interface_set_flag "${port}" promisc true |
12352 |
+ interface_up "${port}" |
12353 |
+ e=$(brctl addif "${iface}" "${port}" 2>&1) |
12354 |
+ if [[ -n ${e} ]] ; then |
12355 |
+ interface_set_flag "${port}" promisc false |
12356 |
+ echo "${e}" >&2 |
12357 |
+ return 1 |
12358 |
+ fi |
12359 |
+ return 0 |
12360 |
+} |
12361 |
+ |
12362 |
+# bool bridge_delete_port(char *interface, char *port) |
12363 |
+# |
12364 |
+# Deletes a port from a bridge |
12365 |
+bridge_delete_port() { |
12366 |
+ interface_set_flag "$2" promisc false |
12367 |
+ brctl delif "$1" "$2" |
12368 |
+} |
12369 |
+ |
12370 |
+# bool bridge_start(char *iface) |
12371 |
+# |
12372 |
+# set up bridge |
12373 |
+# This can also be called by non-bridges so that the bridge can be created |
12374 |
+# dynamically |
12375 |
+bridge_pre_start() { |
12376 |
+ local iface="$1" ports= briface= i= ifvar=$(bash_variable "$1") opts= |
12377 |
+ ports="bridge_${ifvar}[@]" |
12378 |
+ briface="bridge_add_${ifvar}" |
12379 |
+ opts="brctl_${ifvar}[@]" |
12380 |
+ |
12381 |
+ [[ -z ${!ports} && -z ${!briface} && -z ${!opts} ]] && return 0 |
12382 |
+ |
12383 |
+ # Destroy the bridge if it exists |
12384 |
+ [[ -n ${!ports} ]] && bridge_stop "${iface}" |
12385 |
+ |
12386 |
+ # Allow ourselves to add to the bridge |
12387 |
+ if [[ -z ${!ports} && -n ${!briface} ]] ; then |
12388 |
+ ports="${iface}" |
12389 |
+ iface="${!briface}" |
12390 |
+ else |
12391 |
+ ports="${!ports}" |
12392 |
+ # We are the bridge, so set our base metric to 1000. |
12393 |
+ metric=1000 |
12394 |
+ fi |
12395 |
+ |
12396 |
+ # Create the bridge if needed |
12397 |
+ bridge_exists "${iface}" || bridge_create "${iface}" |
12398 |
+ |
12399 |
+ if [[ -n ${ports} ]] ; then |
12400 |
+ einfo "Adding ports to ${iface}" |
12401 |
+ eindent |
12402 |
+ |
12403 |
+ for i in ${ports} ; do |
12404 |
+ interface_exists "${i}" true || return 1 |
12405 |
+ done |
12406 |
+ |
12407 |
+ for i in ${ports} ; do |
12408 |
+ ebegin "${i}" |
12409 |
+ bridge_add_port "${iface}" "${i}" |
12410 |
+ eend $? || return 1 |
12411 |
+ done |
12412 |
+ eoutdent |
12413 |
+ fi |
12414 |
+ |
12415 |
+ return 0 |
12416 |
+} |
12417 |
+ |
12418 |
+# bool bridge_stop(char *iface) |
12419 |
+# |
12420 |
+# Removes the device |
12421 |
+# returns 0 |
12422 |
+bridge_stop() { |
12423 |
+ local iface="$1" ports= i= deletebridge=false extra="" |
12424 |
+ |
12425 |
+ if bridge_exists "${iface}" ; then |
12426 |
+ ebegin "Destroying bridge ${iface}" |
12427 |
+ interface_down "${iface}" |
12428 |
+ ports=$(bridge_get_ports "${iface}") |
12429 |
+ deletebridge=true |
12430 |
+ eindent |
12431 |
+ else |
12432 |
+ # Work out if we're added to a bridge for removal or not |
12433 |
+ ports="${iface}" |
12434 |
+ iface=$(bridge_get_bridge "${iface}") |
12435 |
+ [[ -z ${iface} ]] && return 0 |
12436 |
+ extra=" from ${iface}" |
12437 |
+ fi |
12438 |
+ |
12439 |
+ for i in ${ports} ; do |
12440 |
+ ebegin "Removing port ${i}${extra}" |
12441 |
+ bridge_delete_port "${iface}" "${i}" |
12442 |
+ eend $? |
12443 |
+ done |
12444 |
+ |
12445 |
+ if ${deletebridge} ; then |
12446 |
+ eoutdent |
12447 |
+ brctl delbr "${iface}" &>/dev/null |
12448 |
+ eend 0 |
12449 |
+ fi |
12450 |
+ return 0 |
12451 |
+} |
12452 |
+ |
12453 |
+# vim: set ts=4 : |
12454 |
|
12455 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/ccwgroup.sh |
12456 |
=================================================================== |
12457 |
--- trunk/baselayout-prefix/lib/rcscripts/net/ccwgroup.sh (rev 0) |
12458 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/ccwgroup.sh 2011-03-31 14:11:17 UTC (rev 1682) |
12459 |
@@ -0,0 +1,55 @@ |
12460 |
+# Copyright (c) 2006 Gentoo Foundation |
12461 |
+# Distributed under the terms of the GNU General Public License v2 |
12462 |
+# Contributed by Roy Marples (uberlord@g.o) |
12463 |
+ |
12464 |
+ccwgroup_depend() { |
12465 |
+ before interface |
12466 |
+} |
12467 |
+ccwgroup_expose() { |
12468 |
+ variables ccwgroup |
12469 |
+} |
12470 |
+ |
12471 |
+ccwgroup_pre_start() { |
12472 |
+ local iface="$1" ifvar=$(bash_variable "$1") |
12473 |
+ local ccw="ccwgroup_${ifvar}[@]" |
12474 |
+ local -a ccwgroup=( "${!ccw}" ) |
12475 |
+ |
12476 |
+ [[ -z ${!ccw} ]] && return 0 |
12477 |
+ if [[ ! -d /sys/bus/ccwgroup ]] ; then |
12478 |
+ eerror "ccwgroup support missing in kernel" |
12479 |
+ return 1 |
12480 |
+ fi |
12481 |
+ |
12482 |
+ einfo "Enabling ccwgroup on ${iface}" |
12483 |
+ echo "${!ccw// /,}" > /sys/bus/ccwgroup/drivers/qeth/group |
12484 |
+ echo "1" > /sys/devices/qeth/"${ccwgroup[0]}"/online |
12485 |
+ eend $? |
12486 |
+} |
12487 |
+ |
12488 |
+ccwgroup_pre_stop() { |
12489 |
+ local iface="$1" |
12490 |
+ |
12491 |
+ # Erase any existing ccwgroup to be safe |
12492 |
+ save_options ccwgroup_device "" |
12493 |
+ |
12494 |
+ [[ ! -L /sys/class/net/"${iface}"/driver ]] && return 0 |
12495 |
+ local driver=$(readlink /sys/class/net/"${iface}"/driver) |
12496 |
+ [[ ${driver} != *"/bus/ccwgroup/"* ]] && return 0 |
12497 |
+ |
12498 |
+ local device=$(readlink /sys/class/net/"${iface}"/device) |
12499 |
+ device="${device##*/}" |
12500 |
+ save_options ccwgroup_device "${device}" |
12501 |
+} |
12502 |
+ |
12503 |
+ccwgroup_post_stop() { |
12504 |
+ local iface="$1" device=$(get_options ccwgroup_device) |
12505 |
+ |
12506 |
+ [[ -z ${device} ]] && return 0 |
12507 |
+ |
12508 |
+ einfo "Disabling ccwgroup on ${iface}" |
12509 |
+ echo "0" > /sys/devices/qeth/"${device}"/online |
12510 |
+ echo "1" > /sys/devices/qeth/"${device}"/ungroup |
12511 |
+ eend $? |
12512 |
+} |
12513 |
+ |
12514 |
+# vim: set ts=4 : |
12515 |
|
12516 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/clip.sh |
12517 |
=================================================================== |
12518 |
--- trunk/baselayout-prefix/lib/rcscripts/net/clip.sh (rev 0) |
12519 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/clip.sh 2011-03-31 14:11:17 UTC (rev 1682) |
12520 |
@@ -0,0 +1,290 @@ |
12521 |
+# Copyright (c) 2005-2006 Gentoo Foundation |
12522 |
+# Distributed under the terms of the GNU General Public License v2 |
12523 |
+# Contributed by Giampaolo Tomassoni <g.tomassoni@××××××.it> |
12524 |
+ |
12525 |
+# int atmclip_svc_start(char *name, char *desc) |
12526 |
+# |
12527 |
+# This starts a service. Albeit atmsigd, ilmid and atmarpd do allow for back- |
12528 |
+# grounding through the -b option, its usage causes them to be sensible to |
12529 |
+# SIGHUP, which is sent to all daemons when console detaches right after |
12530 |
+# startup. This is probably due to the fact that these programs don't detach |
12531 |
+# themself from the controlling terminal when backgrounding... The only way I |
12532 |
+# see to overcame this is to use the --background option in start-stop-daemon, |
12533 |
+# which is reported as a "last resort" method, but it acts correctly about this. |
12534 |
+atmclip_svc_start() { |
12535 |
+ ebegin "Starting $2 Daemon ($1)" |
12536 |
+ start-stop-daemon --start \ |
12537 |
+ --background \ |
12538 |
+ --make-pidfile --pidfile "/var/run/$1.pid" \ |
12539 |
+ --exec "/usr/sbin/$1" -- -l syslog |
12540 |
+ eend $? |
12541 |
+} |
12542 |
+ |
12543 |
+# int atmclip_svcs_start() |
12544 |
+# |
12545 |
+# This starts the whole set of atm services needed by clip |
12546 |
+atmclip_svcs_start() { |
12547 |
+ einfo "First CLIP instance: starting ATM CLIP daemons" |
12548 |
+ eindent |
12549 |
+ |
12550 |
+ if [[ ${clip_full:-yes} == "yes" ]]; then |
12551 |
+ atmclip_svc_start atmsigd "Signaling" && \ |
12552 |
+ atmclip_svc_start ilmid "Integrated Local Management Interface" && \ |
12553 |
+ atmclip_svc_start atmarpd "Address Resolution Protocol" |
12554 |
+ else |
12555 |
+ atmclip_svc_start atmarpd "Address Resolution Protocol" |
12556 |
+ fi |
12557 |
+ |
12558 |
+ local r=$? |
12559 |
+ |
12560 |
+ eoutdent |
12561 |
+ return ${r} |
12562 |
+} |
12563 |
+ |
12564 |
+# void atmclip_svc_stop(char *name, char* desc) |
12565 |
+# |
12566 |
+atmclip_svc_stop() { |
12567 |
+ ebegin "Stopping $2 Daemon ($1)" |
12568 |
+ start-stop-daemon --stop \ |
12569 |
+ --retry \ |
12570 |
+ --pidfile "/var/run/$1.pid" \ |
12571 |
+ --exec "/usr/sbin/$1" |
12572 |
+ eend $? |
12573 |
+} |
12574 |
+ |
12575 |
+# void atmclip_svcs_stop() |
12576 |
+# |
12577 |
+atmclip_svcs_stop() { |
12578 |
+ einfo "Last CLIP instance: stopping ATM CLIP daemons" |
12579 |
+ eindent |
12580 |
+ |
12581 |
+ # Heartake operation! |
12582 |
+ sync |
12583 |
+ |
12584 |
+ atmclip_svc_stop atmarpd "Address Resolution Protocol" |
12585 |
+ if [[ ${clip_full:-yes} == "yes" ]]; then |
12586 |
+ atmclip_svc_stop ilmid "Integrated Local Management Interface" |
12587 |
+ atmclip_svc_stop atmsigd "Signaling" |
12588 |
+ fi |
12589 |
+ |
12590 |
+ eoutdent |
12591 |
+} |
12592 |
+ |
12593 |
+ |
12594 |
+# bool are_atmclip_svcs_running() |
12595 |
+# |
12596 |
+are_atmclip_svcs_running() { |
12597 |
+ is_daemon_running atmarpd || return 1 |
12598 |
+ if [[ ${clip_full:-yes} == "yes" ]]; then |
12599 |
+ is_daemon_running ilmid || return 1 |
12600 |
+ is_daemon_running atmsigd || return 1 |
12601 |
+ fi |
12602 |
+ |
12603 |
+ return 0 |
12604 |
+} |
12605 |
+ |
12606 |
+atmarp() { |
12607 |
+ /usr/sbin/atmarp "$@" |
12608 |
+} |
12609 |
+ |
12610 |
+ |
12611 |
+# void clip_depend(void) |
12612 |
+# |
12613 |
+# Sets up the dependancies for this module |
12614 |
+clip_depend() { |
12615 |
+ before interface |
12616 |
+ provide clip |
12617 |
+ functions interface_down interface_up interface_exists is_daemon_running |
12618 |
+ variables clip |
12619 |
+} |
12620 |
+ |
12621 |
+ |
12622 |
+# bool clip_check_installed(void) |
12623 |
+# |
12624 |
+# Returns true if the kernel clip module and linux-atm tools are installed, |
12625 |
+# otherwise false. Please note that I'm checking for the presence of some |
12626 |
+# daemons which are not needed in case you set "clip_full=no". They are part of |
12627 |
+# the linux-atm package anyway, so it shouldn't hurt to check them too out. |
12628 |
+clip_check_installed() { |
12629 |
+ local x |
12630 |
+ for x in atmsigd ilmid atmarpd atmarp ; do |
12631 |
+ if [[ ! -x "/usr/sbin/${x}" ]] ; then |
12632 |
+ ${1:-false} && eerror "You need first to emerge net-dialup/linux-atm" |
12633 |
+ return 1 |
12634 |
+ fi |
12635 |
+ done |
12636 |
+ |
12637 |
+ return 0 |
12638 |
+} |
12639 |
+ |
12640 |
+# bool clip_pre_start(char *iface) |
12641 |
+# |
12642 |
+# Start the CLIP daemons |
12643 |
+# Create the interface by calling atmarp -c |
12644 |
+# |
12645 |
+# Returns 0 (true) when successful, non-zero otherwise |
12646 |
+clip_pre_start() { |
12647 |
+ local iface="$1" ifvar=$(bash_variable "$1") |
12648 |
+ local x="clip_$ifvar[@]" |
12649 |
+ local -a opts=( "${!x}" ) |
12650 |
+ |
12651 |
+ [[ -z ${opts} ]] && return 0 |
12652 |
+ clip_check_installed || return 1 |
12653 |
+ |
12654 |
+ if [[ ! -r /proc/net/atm/arp ]] ; then |
12655 |
+ modprobe clip && sleep 2 |
12656 |
+ if [[ ! -r /proc/net/atm/arp ]] ; then |
12657 |
+ eerror "You need first to enable kernel support for ATM CLIP" |
12658 |
+ return 1 |
12659 |
+ fi |
12660 |
+ fi |
12661 |
+ |
12662 |
+ local started_here |
12663 |
+ if ! are_atmclip_svcs_running ; then |
12664 |
+ atmclip_svcs_start || return 1 |
12665 |
+ started_here=1 |
12666 |
+ fi |
12667 |
+ |
12668 |
+ if ! interface_exists "${iface}" ; then |
12669 |
+ ebegin "Creating CLIP interface ${iface}" |
12670 |
+ atmarp -c "${iface}" |
12671 |
+ eend $? |
12672 |
+ |
12673 |
+ if [[ $? != "0" && ! -z ${started_here} ]]; then |
12674 |
+ atmclip_svcs_stop |
12675 |
+ return 1 |
12676 |
+ fi |
12677 |
+ fi |
12678 |
+ |
12679 |
+ return 0 |
12680 |
+} |
12681 |
+ |
12682 |
+# bool clip_post_start(char *iface) |
12683 |
+# |
12684 |
+# Basically we create PVCs here. |
12685 |
+clip_post_start() { |
12686 |
+ local iface="$1" ifvar=$(bash_variable "$1") i |
12687 |
+ local x="clip_$ifvar[@]" |
12688 |
+ local -a opts=( "${!x}" ) |
12689 |
+ |
12690 |
+ [[ -z ${opts} ]] && return 0 |
12691 |
+ clip_check_installed || return 1 |
12692 |
+ are_atmclip_svcs_running || return 1 |
12693 |
+ |
12694 |
+ # The atm tools (atmarpd?) are silly enough that they would not work with |
12695 |
+ # iproute2 interface setup as opposed to the ifconfig one. |
12696 |
+ # The workaround is to temporarily toggle the interface state from up |
12697 |
+ # to down and then up again, without touching its address. This (should) |
12698 |
+ # work with both iproute2 and ifconfig. |
12699 |
+ interface_down "${iface}" |
12700 |
+ interface_up "${iface}" |
12701 |
+ |
12702 |
+ # Now the real thing: create a PVC with our peer(s). |
12703 |
+ # There are cases in which the ATM interface is not yet |
12704 |
+ # ready to establish new VCCs. In that cases, atmarp would |
12705 |
+ # fail. Here we allow 10 retries to happen every 2 seconds before |
12706 |
+ # reporting problems. Also, when no defined VC can be established, |
12707 |
+ # we stop the ATM daemons. |
12708 |
+ local has_failures i |
12709 |
+ for (( i=0; i<${#opts[@]}; i++ )); do |
12710 |
+ set -- ${opts[${i}]} |
12711 |
+ local peerip="$1"; shift |
12712 |
+ local ifvpivci="$1"; shift |
12713 |
+ |
12714 |
+ ebegin "Creating PVC ${ifvpivci} for peer ${peerip}" |
12715 |
+ |
12716 |
+ local nleftretries emsg ecode |
12717 |
+ for ((nleftretries=10; nleftretries > 0; nleftretries--)); do |
12718 |
+ emsg=$(atmarp -s "${peerip}" "${ifvpivci}" "$@" 2>&1) |
12719 |
+ ecode=$? |
12720 |
+ [[ ${ecode} == "0" ]] && break |
12721 |
+ sleep 2 |
12722 |
+ done |
12723 |
+ |
12724 |
+ eend ${ecode} |
12725 |
+ |
12726 |
+ if [[ ${ecode} != "0" ]]; then |
12727 |
+ eerror "Creation failed for PVC ${ifvpivci}: ${emsg}" |
12728 |
+ has_failures=1 |
12729 |
+ fi |
12730 |
+ done |
12731 |
+ |
12732 |
+ if [[ -n ${has_failures} ]]; then |
12733 |
+ clip_pre_stop "${iface}" |
12734 |
+ clip_post_stop "${iface}" |
12735 |
+ return 1 |
12736 |
+ else |
12737 |
+ return 0 |
12738 |
+ fi |
12739 |
+} |
12740 |
+ |
12741 |
+# bool clip_pre_stop(char *iface) |
12742 |
+# |
12743 |
+# Here we basicly undo the PVC creation previously created through the |
12744 |
+# clip_post_start function. When we establish a new PVC, a corresponding line |
12745 |
+# is added to the /proc/net/atm/arp file, so we inspect it to extract all the |
12746 |
+# outstanding PVCs of this interface. |
12747 |
+clip_pre_stop() { |
12748 |
+ local iface="$1" ifvar=$(bash_variable "$1") i |
12749 |
+ local x="clip_$ifvar[@]" |
12750 |
+ local -a opts=( "${!x}" ) |
12751 |
+ |
12752 |
+ [[ -z ${opts} ]] && return 0 |
12753 |
+ |
12754 |
+ are_atmclip_svcs_running || return 0 |
12755 |
+ |
12756 |
+ # We remove all the PVCs which may have been created by |
12757 |
+ # clip_post_start for this interface. This shouldn't be |
12758 |
+ # needed by the ATM stack, but sometimes I got a panic |
12759 |
+ # killing CLIP daemons without previously vacuuming |
12760 |
+ # every active CLIP PVCs. |
12761 |
+ # The linux 2.6's ATM stack is really a mess... |
12762 |
+ local itf t encp idle ipaddr left |
12763 |
+ einfo "Removing PVCs on this interface" |
12764 |
+ eindent |
12765 |
+ { |
12766 |
+ read left && \ |
12767 |
+ while read itf t encp idle ipaddr left ; do |
12768 |
+ if [[ ${itf} == "${iface}" ]]; then |
12769 |
+ ebegin "Removing PVC to ${ipaddr}" |
12770 |
+ atmarp -d "${ipaddr}" |
12771 |
+ eend $? |
12772 |
+ fi |
12773 |
+ done |
12774 |
+ } < /proc/net/atm/arp |
12775 |
+ eoutdent |
12776 |
+} |
12777 |
+ |
12778 |
+# bool clip_post_stop(char *iface) |
12779 |
+# |
12780 |
+# Here we should teorically delete the interface previously created in the |
12781 |
+# clip_pre_start function, but there is no way to "undo" an interface creation. |
12782 |
+# We can just leave the interface down. "ifconfig -a" will still list it... |
12783 |
+# Also, here we can stop the ATM CLIP daemons if there is no other CLIP PVC |
12784 |
+# outstanding. We check this condition by inspecting the /proc/net/atm/arp file. |
12785 |
+clip_post_stop() { |
12786 |
+ local iface="$1" ifvar=$( bash_variable "$1" ) i |
12787 |
+ local x="clip_$ifvar[@]" |
12788 |
+ local -a opts=( "${!x}" ) |
12789 |
+ |
12790 |
+ [[ -z ${opts} ]] && return 0 |
12791 |
+ |
12792 |
+ are_atmclip_svcs_running || return 0 |
12793 |
+ |
12794 |
+ local itf left hasothers |
12795 |
+ { |
12796 |
+ read left && \ |
12797 |
+ while read itf left ; do |
12798 |
+ if [[ ${itf} != "${iface}" ]] ; then |
12799 |
+ hasothers=1 |
12800 |
+ break |
12801 |
+ fi |
12802 |
+ done |
12803 |
+ } < /proc/net/atm/arp |
12804 |
+ |
12805 |
+ if [[ -z ${hasothers} ]] ; then |
12806 |
+ atmclip_svcs_stop || return 1 |
12807 |
+ fi |
12808 |
+} |
12809 |
+ |
12810 |
+# vim: set ts=4 : |
12811 |
|
12812 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/dhclient.sh |
12813 |
=================================================================== |
12814 |
--- trunk/baselayout-prefix/lib/rcscripts/net/dhclient.sh (rev 0) |
12815 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/dhclient.sh 2011-03-31 14:11:17 UTC (rev 1682) |
12816 |
@@ -0,0 +1,119 @@ |
12817 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
12818 |
+# Distributed under the terms of the GNU General Public License v2 |
12819 |
+# Contributed by Roy Marples (uberlord@g.o) |
12820 |
+ |
12821 |
+# Fix any potential localisation problems |
12822 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
12823 |
+dhclient() { |
12824 |
+ LC_ALL=C /sbin/dhclient "$@" |
12825 |
+} |
12826 |
+ |
12827 |
+# void dhclient_depend(void) |
12828 |
+# |
12829 |
+# Sets up the dependancies for the module |
12830 |
+dhclient_depend() { |
12831 |
+ after interface |
12832 |
+ provide dhcp |
12833 |
+ functions interface_exists interface_get_address |
12834 |
+} |
12835 |
+ |
12836 |
+# void dhclient_expose(void) |
12837 |
+# |
12838 |
+# Expose variables that can be configured |
12839 |
+dhclient_expose() { |
12840 |
+ variables dhclient dhcp |
12841 |
+} |
12842 |
+ |
12843 |
+# bool dhclient_check_installed(void) |
12844 |
+# |
12845 |
+# Returns 1 if dhclient is installed, otherwise 0 |
12846 |
+dhclient_check_installed() { |
12847 |
+ [[ -x /sbin/dhclient ]] && return 0 |
12848 |
+ ${1:-false} && eerror "For DHCP (dhclient) support, emerge net-misc/dhcp" |
12849 |
+ return 1 |
12850 |
+} |
12851 |
+ |
12852 |
+# bool dhclient_stop(char *iface) |
12853 |
+# |
12854 |
+# Stop dhclient on an interface |
12855 |
+# Always returns 0 |
12856 |
+dhclient_stop() { |
12857 |
+ local iface="$1" pidfile="/var/run/dhclient-$1.pid" |
12858 |
+ |
12859 |
+ [[ ! -f ${pidfile} ]] && return 0 |
12860 |
+ |
12861 |
+ ebegin "Stopping dhclient on ${iface}" |
12862 |
+ local ifvar=$(bash_variable "${iface}") |
12863 |
+ local d="dhcp_${ifvar}" |
12864 |
+ [[ -z ${!d} ]] && d="dhcp" |
12865 |
+ if [[ " ${!d} " == *" release "* ]] ; then |
12866 |
+ dhclient -q -r -pf "${pidfile}" "${iface}" |
12867 |
+ else |
12868 |
+ start-stop-daemon --stop --exec /sbin/dhclient --pidfile "${pidfile}" |
12869 |
+ fi |
12870 |
+ eend $? |
12871 |
+} |
12872 |
+ |
12873 |
+# bool dhclient_start(char *iface) |
12874 |
+# |
12875 |
+# Start DHCP on an interface by calling dhclient $iface $options |
12876 |
+# |
12877 |
+# Returns 0 (true) when a DHCP address is obtained, otherwise 1 |
12878 |
+dhclient_start() { |
12879 |
+ local iface="$1" ifvar=$(bash_variable "$1") dhconf= |
12880 |
+ local pidfile="/var/run/dhclient-${iface}.pid" |
12881 |
+ |
12882 |
+ interface_exists "${iface}" true || return 1 |
12883 |
+ |
12884 |
+ # Load our default options |
12885 |
+ opts="dhclient_${ifvar}" |
12886 |
+ opts="${!opts} ${dhclient}" |
12887 |
+ |
12888 |
+ local d="dhcp_${ifvar}" |
12889 |
+ [[ -z ${!d} ]] && d="dhcp" |
12890 |
+ |
12891 |
+ # Add our peer and metric options |
12892 |
+ if [[ " ${!d} " == *" nogateway "* ]] ; then |
12893 |
+ opts="${opts} -e PEER_ROUTERS=no" |
12894 |
+ elif [[ " ${opts} " != *" -e PEER_ROUTERS="* ]] ; then |
12895 |
+ opts="${opts} -e PEER_ROUTERS=yes" |
12896 |
+ fi |
12897 |
+ if [[ " ${!d} " == *" nodns "* ]] ; then |
12898 |
+ opts="${opts} -e PEER_DNS=no" |
12899 |
+ elif [[ " ${opts} " != *" -e PEER_DNS="* ]] ; then |
12900 |
+ opts="${opts} -e PEER_DNS=yes" |
12901 |
+ fi |
12902 |
+ if [[ " ${!d} " == *" nontp "* ]] ; then |
12903 |
+ opts="${opts} -e PEER_NTP=no" |
12904 |
+ elif [[ " ${opts} " != *" -e PEER_NTP="* ]] ; then |
12905 |
+ opts="${opts} -e PEER_NTP=yes" |
12906 |
+ fi |
12907 |
+ local metric="metric_${ifvar}" |
12908 |
+ if [[ -n ${!metric} && ${!metric} != "0" ]] ; then |
12909 |
+ opts="${opts} -e IF_METRIC=${!metric}" |
12910 |
+ fi |
12911 |
+ |
12912 |
+ # Send our hostname by editing cffile |
12913 |
+ if [[ " ${!d} " != *" nosendhost "* ]] ; then |
12914 |
+ local hname=$(hostname) |
12915 |
+ if [[ ${hname} != "(none)" && ${hname} != "localhost" ]]; then |
12916 |
+ dhconf="${dhconf} interface \"${iface}\" {\n" |
12917 |
+ dhconf="${dhconf} send host-name \"${hname}\"\n;" |
12918 |
+ dhconf="${dhconf}}" |
12919 |
+ fi |
12920 |
+ fi |
12921 |
+ |
12922 |
+ # Bring up DHCP for this interface (or alias) |
12923 |
+ ebegin "Running dhclient" |
12924 |
+ echo -e "${dhconf}" | start-stop-daemon --start --exec /sbin/dhclient \ |
12925 |
+ --pidfile "${pidfile}" -- ${opts} -q -1 -pf "${pidfile}" "${iface}" |
12926 |
+ eend $? || return 1 |
12927 |
+ |
12928 |
+ # DHCP succeeded, show address retrieved |
12929 |
+ local addr=$(interface_get_address "${iface}") |
12930 |
+ einfo "${iface} received address ${addr}" |
12931 |
+ |
12932 |
+ return 0 |
12933 |
+} |
12934 |
+ |
12935 |
+# vim: set ts=4 : |
12936 |
|
12937 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/dhcpcd.sh |
12938 |
=================================================================== |
12939 |
--- trunk/baselayout-prefix/lib/rcscripts/net/dhcpcd.sh (rev 0) |
12940 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/dhcpcd.sh 2011-03-31 14:11:17 UTC (rev 1682) |
12941 |
@@ -0,0 +1,105 @@ |
12942 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
12943 |
+# Distributed under the terms of the GNU General Public License v2 |
12944 |
+ |
12945 |
+# Contributed by Roy Marples (uberlord@g.o) |
12946 |
+ |
12947 |
+# void dhcpcd_depend(void) |
12948 |
+# |
12949 |
+# Sets up the dependancies for the module |
12950 |
+dhcpcd_depend() { |
12951 |
+ after interface |
12952 |
+ provide dhcp |
12953 |
+ functions interface_exists interface_get_address |
12954 |
+} |
12955 |
+ |
12956 |
+# void dhcpcd_expose(void) |
12957 |
+# |
12958 |
+# Expose variables that can be configured |
12959 |
+dhcpcd_expose() { |
12960 |
+ variables dhcpcd dhcp |
12961 |
+} |
12962 |
+ |
12963 |
+# bool dhcpcd_check_installed(void) |
12964 |
+# |
12965 |
+# Returns 1 if dhcpcd is installed, otherwise 0 |
12966 |
+dhcpcd_check_installed() { |
12967 |
+ [[ -x /sbin/dhcpcd ]] && return 0 |
12968 |
+ ${1:-false} && eerror "For DHCP (dhcpcd) support, emerge net-misc/dhcpcd" |
12969 |
+ return 1 |
12970 |
+} |
12971 |
+ |
12972 |
+# bool dhcpcd_stop(char *iface) |
12973 |
+# |
12974 |
+# Stop DHCP on an interface by calling dhcpcd -z $iface |
12975 |
+# |
12976 |
+# Returns 0 (true) when a DHCP address dropped |
12977 |
+# otherwise return 1 |
12978 |
+dhcpcd_stop() { |
12979 |
+ local iface=$1 signal= pidfile="/var/run/dhcpcd-$1.pid" d= |
12980 |
+ |
12981 |
+ [[ ! -f ${pidfile} ]] && return 0 |
12982 |
+ |
12983 |
+ ebegin "Stopping dhcpcd on ${iface}" |
12984 |
+ |
12985 |
+ local ifvar=$(bash_variable "${iface}") |
12986 |
+ d="dhcp_${ifvar}" |
12987 |
+ d=" ${!d} " |
12988 |
+ [[ ${d} == " " ]] && d=" ${dhcp} " |
12989 |
+ |
12990 |
+ if [[ ${d} == *" release "* ]] ; then |
12991 |
+ /sbin/dhcpcd -k "${iface}" |
12992 |
+ else |
12993 |
+ start-stop-daemon --stop --exec /sbin/dhcpcd --pidfile "${pidfile}" |
12994 |
+ fi |
12995 |
+ eend $? |
12996 |
+} |
12997 |
+ |
12998 |
+# bool dhcpcd_start(char *iface) |
12999 |
+# |
13000 |
+# Start DHCP on an interface by calling dhcpcd $iface $options |
13001 |
+# |
13002 |
+# Returns 0 (true) when a DHCP address is obtained, otherwise 1 |
13003 |
+dhcpcd_start() { |
13004 |
+ local iface="$1" opts= pidfile="/var/run/dhcpcd-$1.pid" |
13005 |
+ local ifvar=$(bash_variable "${iface}") metric= d= |
13006 |
+ |
13007 |
+ interface_exists "${iface}" true || return 1 |
13008 |
+ |
13009 |
+ # Get our options |
13010 |
+ opts="dhcpcd_${ifvar}" |
13011 |
+ opts="${!opts} ${dhcpcd}" |
13012 |
+ |
13013 |
+ # Map some generic options to dhcpcd |
13014 |
+ d="dhcp_${ifvar}" |
13015 |
+ d=" ${!d} " |
13016 |
+ [[ ${d} == " " ]] && d=" ${dhcp} " |
13017 |
+ [[ ${d} == *" nodns "* ]] && opts="${opts} -R" |
13018 |
+ [[ ${d} == *" nontp "* ]] && opts="${opts} -N" |
13019 |
+ [[ ${d} == *" nonis "* ]] && opts="${opts} -Y" |
13020 |
+ [[ ${d} == *" nogateway "* ]] && opts="${opts} -G" |
13021 |
+ |
13022 |
+ # We transmit the hostname by default |
13023 |
+ if [[ " ${d} " != *" nosendhost "* && " ${opts} " != *" -h "* ]]; then |
13024 |
+ local hname=$(hostname) |
13025 |
+ [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ |
13026 |
+ && opts="-h \"${hname}\" ${opts}" |
13027 |
+ fi |
13028 |
+ |
13029 |
+ # Add our route metric |
13030 |
+ metric="metric_${ifvar}" |
13031 |
+ [[ -n ${!metric} && ${!metric} != "0" ]] && opts="${opts} -m ${!metric}" |
13032 |
+ |
13033 |
+ # Bring up DHCP for this interface (or alias) |
13034 |
+ ebegin "Running dhcpcd" |
13035 |
+ |
13036 |
+ eval /sbin/dhcpcd "${opts}" "${iface}" |
13037 |
+ eend $? || return 1 |
13038 |
+ |
13039 |
+ # DHCP succeeded, show address retrieved |
13040 |
+ local addr=$(interface_get_address "${iface}") |
13041 |
+ einfo "${iface} received address ${addr}" |
13042 |
+ |
13043 |
+ return 0 |
13044 |
+} |
13045 |
+ |
13046 |
+# vim: set ts=4 : |
13047 |
|
13048 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/essidnet.sh |
13049 |
=================================================================== |
13050 |
--- trunk/baselayout-prefix/lib/rcscripts/net/essidnet.sh (rev 0) |
13051 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/essidnet.sh 2011-03-31 14:11:17 UTC (rev 1682) |
13052 |
@@ -0,0 +1,49 @@ |
13053 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
13054 |
+# Distributed under the terms of the GNU General Public License v2 |
13055 |
+# Contributed by Roy Marples (uberlord@g.o) |
13056 |
+# Many thanks to all the people in the Gentoo forums for their ideas and |
13057 |
+# motivation for me to make this and keep on improving it |
13058 |
+ |
13059 |
+# Load our config if it exists |
13060 |
+[[ -f "$(add_suffix "/etc/conf.d/wireless" )" ]] \ |
13061 |
+ && source "$(add_suffix "/etc/conf.d/wireless" )" |
13062 |
+ |
13063 |
+# void essidnet_depend(void) |
13064 |
+# |
13065 |
+# Sets up the dependancies for the module |
13066 |
+essidnet_depend() { |
13067 |
+ before interface system |
13068 |
+ after wireless |
13069 |
+ installed wireless |
13070 |
+ functions wireless_exists wireless_get_essid wireless_get_ap_mac_address |
13071 |
+} |
13072 |
+ |
13073 |
+# bool essidnet_start(char *iface) |
13074 |
+# |
13075 |
+# All interfaces and module scripts can depend on the variables function |
13076 |
+# which returns a space seperated list of user configuration variables |
13077 |
+# We can override each variable here from a given ESSID or the MAC |
13078 |
+# of the AP connected to. MAC configuration takes precedence |
13079 |
+# Always returns 0 |
13080 |
+essidnet_pre_start() { |
13081 |
+ local iface="$1" |
13082 |
+ |
13083 |
+ wireless_exists "${iface}" || return 0 |
13084 |
+ |
13085 |
+ local mac=$(wireless_get_ap_mac_address "${iface}") |
13086 |
+ local ESSID=$(wireless_get_essid "${iface}") |
13087 |
+ local essid=$(bash_variable "${ESSID}") |
13088 |
+ mac="${mac//:/}" |
13089 |
+ |
13090 |
+ vebegin "Configuring ${iface} for ESSID \"${ESSID//\\\\/\\\\}\"" 2>/dev/null |
13091 |
+ configure_variables "${iface}" "${essid}" "${mac}" |
13092 |
+ |
13093 |
+ # Backwards compat for old gateway var |
13094 |
+ x="gateway_${essid}" |
13095 |
+ [[ -n ${!x} ]] && gateway="${iface}/${!x}" |
13096 |
+ |
13097 |
+ veend 0 2>/dev/null |
13098 |
+ return 0 |
13099 |
+} |
13100 |
+ |
13101 |
+# vim: set ts=4 : |
13102 |
|
13103 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/ifconfig.sh |
13104 |
=================================================================== |
13105 |
--- trunk/baselayout-prefix/lib/rcscripts/net/ifconfig.sh (rev 0) |
13106 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/ifconfig.sh 2011-03-31 14:11:17 UTC (rev 1682) |
13107 |
@@ -0,0 +1,439 @@ |
13108 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
13109 |
+# Distributed under the terms of the GNU General Public License v2 |
13110 |
+# Contributed by Roy Marples (uberlord@g.o) |
13111 |
+ |
13112 |
+# Fix any potential localisation problems |
13113 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
13114 |
+ifconfig() { |
13115 |
+ LC_ALL=C /sbin/ifconfig "$@" |
13116 |
+} |
13117 |
+ |
13118 |
+ifconfig_tunnel() { |
13119 |
+ LC_ALL=C /sbin/iptunnel "$@" |
13120 |
+} |
13121 |
+ |
13122 |
+route() { |
13123 |
+ LC_ALL=C /sbin/route "$@" |
13124 |
+} |
13125 |
+ |
13126 |
+# void ifconfig_depend(void) |
13127 |
+# |
13128 |
+# Sets up the dependancies for the module |
13129 |
+ifconfig_depend() { |
13130 |
+ provide interface |
13131 |
+} |
13132 |
+ |
13133 |
+# void ifconfig_expose(void) |
13134 |
+# |
13135 |
+# Expose variables that can be configured |
13136 |
+ifconfig_expose() { |
13137 |
+ variables config routes fallback metric ifconfig \ |
13138 |
+ ifconfig_fallback routes inet6 iface alias broadcast netmask |
13139 |
+} |
13140 |
+ |
13141 |
+# bool ifconfig_check_installed(void) |
13142 |
+# |
13143 |
+# Returns 1 if ifconfig is installed, otherwise 0 |
13144 |
+ifconfig_check_installed() { |
13145 |
+ [[ -x /sbin/ifconfig ]] && return 0 |
13146 |
+ ${1:-false} && eerror "For ifconfig support, emerge sys-apps/net-tools" |
13147 |
+ return 1 |
13148 |
+} |
13149 |
+ |
13150 |
+# bool ifconfig_exists(char *interface, bool report) |
13151 |
+# |
13152 |
+# Returns 1 if the interface exists, otherwise 0 |
13153 |
+ifconfig_exists() { |
13154 |
+ local e=$(ifconfig -a | grep -o "^$1") report="${2:-false}" |
13155 |
+ [[ -n ${e} ]] && return 0 |
13156 |
+ |
13157 |
+ if ${report} ; then |
13158 |
+ eerror "network interface $1 does not exist" |
13159 |
+ eerror "Please verify hardware or kernel module (driver)" |
13160 |
+ fi |
13161 |
+ |
13162 |
+ return 1 |
13163 |
+} |
13164 |
+ |
13165 |
+# char* cidr2netmask(int cidr) |
13166 |
+# |
13167 |
+# Returns the netmask of a given CIDR |
13168 |
+cidr2netmask() { |
13169 |
+ local cidr="$1" netmask="" done=0 i sum=0 cur=128 |
13170 |
+ local octets= frac= |
13171 |
+ |
13172 |
+ (( octets=cidr/8 )) |
13173 |
+ (( frac=cidr%8 )) |
13174 |
+ while [[ octets -gt 0 ]] ; do |
13175 |
+ netmask="${netmask}.255" |
13176 |
+ (( octets-- )) |
13177 |
+ (( done++ )) |
13178 |
+ done |
13179 |
+ |
13180 |
+ if [[ ${done} -lt 4 ]] ; then |
13181 |
+ for (( i=0; i<${frac}; i++ )); do |
13182 |
+ (( sum+=cur )) |
13183 |
+ (( cur/=2 )) |
13184 |
+ done |
13185 |
+ netmask="${netmask}.${sum}" |
13186 |
+ (( done++ )) |
13187 |
+ |
13188 |
+ while [[ ${done} -lt 4 ]] ; do |
13189 |
+ netmask="${netmask}.0" |
13190 |
+ (( done++ )) |
13191 |
+ done |
13192 |
+ fi |
13193 |
+ |
13194 |
+ echo "${netmask:1}" |
13195 |
+} |
13196 |
+ |
13197 |
+# void ifconfig_up(char *iface) |
13198 |
+# |
13199 |
+# provides a generic interface for bringing interfaces up |
13200 |
+ifconfig_up() { |
13201 |
+ ifconfig "$1" up |
13202 |
+} |
13203 |
+ |
13204 |
+# void ifconfig_down(char *iface) |
13205 |
+# |
13206 |
+# provides a generic interface for bringing interfaces down |
13207 |
+ifconfig_down() { |
13208 |
+ ifconfig "$1" down |
13209 |
+} |
13210 |
+ |
13211 |
+# bool ifconfig_is_up(char *iface, bool withaddress) |
13212 |
+# |
13213 |
+# Returns 0 if the interface is up, otherwise 1 |
13214 |
+# If withaddress is true then the interface has to have an IPv4 address |
13215 |
+# assigned as well |
13216 |
+ifconfig_is_up() { |
13217 |
+ local check="\<UP\>" addr="${2:-false}" |
13218 |
+ ${addr} && check="\<inet addr:.*${check}" |
13219 |
+ ifconfig "$1" | tr '\n' ' ' | grep -Eq "${check}" && return 0 |
13220 |
+ return 1 |
13221 |
+} |
13222 |
+ |
13223 |
+# void ifconfig_set_flag(char *iface, char *flag, bool enabled) |
13224 |
+# |
13225 |
+# Sets or disables the interface flag |
13226 |
+ifconfig_set_flag() { |
13227 |
+ local iface="$1" flag="$2" enable="$3" |
13228 |
+ ${enable} || flag="-${flag}" |
13229 |
+ ifconfig "${iface}" "${flag}" |
13230 |
+} |
13231 |
+ |
13232 |
+# void ifconfig_get_address(char *interface) |
13233 |
+# |
13234 |
+# Fetch the address retrieved by DHCP. If successful, echoes the |
13235 |
+# address on stdout, otherwise echoes nothing. |
13236 |
+ifconfig_get_address() { |
13237 |
+ local -a x=( $( ifconfig "$1" \ |
13238 |
+ | sed -n -e 's/.*inet addr:\([^ ]*\).*Mask:\([^ ]*\).*/\1 \2/p' ) ) |
13239 |
+ x[1]=$(netmask2cidr "${x[1]}") |
13240 |
+ [[ -n ${x[0]} ]] && echo "${x[0]}/${x[1]}" |
13241 |
+} |
13242 |
+ |
13243 |
+# bool ifconfig_is_ethernet(char *interface) |
13244 |
+# |
13245 |
+# Return 0 if the link is ethernet, otherwise 1. |
13246 |
+ifconfig_is_ethernet() { |
13247 |
+ ifconfig "$1" | grep -q "^$1[[:space:]]*Link encap:Ethernet[[:space:]]" |
13248 |
+} |
13249 |
+ |
13250 |
+# void ifconfig_get_mac_address(char *interface) |
13251 |
+# |
13252 |
+# Fetch the mac address assingned to the network card |
13253 |
+ifconfig_get_mac_address() { |
13254 |
+ local mac=$(ifconfig "$1" | sed -n -e \ |
13255 |
+ 's/.*HWaddr[ \t]*\<\(..:..:..:..:..:..\)\>.*/\U\1/p') |
13256 |
+ [[ ${mac} != '00:00:00:00:00:00' \ |
13257 |
+ && ${mac} != '44:44:44:44:44:44' \ |
13258 |
+ && ${mac} != 'FF:FF:FF:FF:FF:FF' ]] \ |
13259 |
+ && echo "${mac}" |
13260 |
+} |
13261 |
+ |
13262 |
+# void ifconfig_set_mac_address(char *interface, char *mac) |
13263 |
+# |
13264 |
+# Assigned the mac address to the network card |
13265 |
+ifconfig_set_mac_address() { |
13266 |
+ ifconfig "$1" hw ether "$2" |
13267 |
+} |
13268 |
+ |
13269 |
+# int ifconfig_set_name(char *interface, char *new_name) |
13270 |
+# |
13271 |
+# Renames the interface |
13272 |
+# This will not work if the interface is setup! |
13273 |
+ifconfig_set_name() { |
13274 |
+ [[ -z $2 ]] && return 1 |
13275 |
+ local current="$1" new="$2" |
13276 |
+ |
13277 |
+ local mac=$(ifconfig_get_mac_address "${current}") |
13278 |
+ if [[ -z ${mac} ]]; then |
13279 |
+ eerror "${iface} does not have a MAC address" |
13280 |
+ return 1 |
13281 |
+ fi |
13282 |
+ |
13283 |
+ /sbin/nameif "${new}" "${mac}" |
13284 |
+} |
13285 |
+ |
13286 |
+# void ifconfig_get_aliases_rev(char *interface) |
13287 |
+# |
13288 |
+# Fetch the list of aliases for an interface. |
13289 |
+# Outputs a space-separated list on stdout, in reverse order, for |
13290 |
+# example "eth0:2 eth0:1" |
13291 |
+ifconfig_get_aliases_rev() { |
13292 |
+ ifconfig | grep -o "^$1:[0-9]* " | tac |
13293 |
+} |
13294 |
+ |
13295 |
+# bool ifconfig_del_addresses(char *interface, bool onlyinet) |
13296 |
+# |
13297 |
+# Remove addresses from interface. Returns 0 (true) if there |
13298 |
+# were addresses to remove (whether successful or not). Returns 1 |
13299 |
+# (false) if there were no addresses to remove. |
13300 |
+# If onlyinet is true then we only delete IPv4 / inet addresses |
13301 |
+ifconfig_del_addresses() { |
13302 |
+ local iface="$1" i= onlyinet="${2:-false}" |
13303 |
+ # We don't remove addresses from aliases |
13304 |
+ [[ ${iface} == *:* ]] && return 0 |
13305 |
+ |
13306 |
+ # If the interface doesn't exist, don't try and delete |
13307 |
+ ifconfig_exists "${iface}" || return 0 |
13308 |
+ |
13309 |
+ # iproute2 can add many addresses to an iface unlike ifconfig ... |
13310 |
+ # iproute2 added addresses cause problems for ifconfig |
13311 |
+ # as we delete an address, a new one appears, so we have to |
13312 |
+ # keep polling |
13313 |
+ while ifconfig "${iface}" | grep -q -m1 -o 'inet addr:[^ ]*' ; do |
13314 |
+ ifconfig "${iface}" 0.0.0.0 || break |
13315 |
+ done |
13316 |
+ |
13317 |
+ # Remove IPv6 addresses |
13318 |
+ if ! ${onlyinet} ; then |
13319 |
+ for i in $( ifconfig "${iface}" \ |
13320 |
+ | sed -n -e 's/^.*inet6 addr: \([^ ]*\) Scope:[^L].*/\1/p' ) ; do |
13321 |
+ /sbin/ifconfig "${iface}" inet6 del "${i}" |
13322 |
+ done |
13323 |
+ fi |
13324 |
+ return 0 |
13325 |
+} |
13326 |
+ |
13327 |
+# bool ifconfig_get_old_config(char *iface) |
13328 |
+# |
13329 |
+# Returns config and config_fallback for the given interface |
13330 |
+ifconfig_get_old_config() { |
13331 |
+ local iface="$1" ifvar=$(bash_variable "$1") i= inet6= |
13332 |
+ |
13333 |
+ config="ifconfig_${ifvar}[@]" |
13334 |
+ config=( "${!config}" ) |
13335 |
+ config_fallback="ifconfig_fallback_${ifvar}[@]" |
13336 |
+ config_fallback=( "${!config_fallback}" ) |
13337 |
+ inet6="inet6_${ifvar}[@]" |
13338 |
+ inet6=( "${!inet6}" ) |
13339 |
+ |
13340 |
+ # BACKWARD COMPATIBILITY: populate the config_IFACE array |
13341 |
+ # if iface_IFACE is set (fex. iface_eth0 instead of ifconfig_eth0) |
13342 |
+ i="iface_${ifvar}" |
13343 |
+ if [[ -n ${!i} && -z ${config} ]]; then |
13344 |
+ # Make sure these get evaluated as arrays |
13345 |
+ local -a aliases=() broadcasts=() netmasks=() |
13346 |
+ |
13347 |
+ # Start with the primary interface |
13348 |
+ config=( "${!i}" ) |
13349 |
+ |
13350 |
+ # ..then add aliases |
13351 |
+ aliases="alias_${ifvars}" |
13352 |
+ aliases=( ${!aliases} ) |
13353 |
+ broadcasts="broadcast_${ifvar}" |
13354 |
+ broadcasts=( ${!broadcasts} ) |
13355 |
+ netmasks="netmask_${ifvar}" |
13356 |
+ netmasks=( ${!netmasks} ) |
13357 |
+ for (( i=0; i<${#aliases[@]}; i++ )); do |
13358 |
+ config[i+1]="${aliases[i]} ${broadcasts[i]:+broadcast ${broadcasts[i]}} ${netmasks[i]:+netmask ${netmasks[i]}}" |
13359 |
+ done |
13360 |
+ fi |
13361 |
+ |
13362 |
+ # BACKWARD COMPATIBILITY: check for space-separated inet6 addresses |
13363 |
+ [[ ${#inet6[@]} == 1 && ${inet6} == *' '* ]] && inet6=( ${inet6} ) |
13364 |
+ |
13365 |
+ # Add inet6 addresses to our config if required |
13366 |
+ [[ -n ${inet6} ]] && config=( "${config[@]}" "${inet6[@]}" ) |
13367 |
+ |
13368 |
+ # BACKWARD COMPATIBILITY: set the default gateway |
13369 |
+ if [[ ${gateway} == "${iface}/"* ]]; then |
13370 |
+ i="routes_${ifvar}[@]" |
13371 |
+ local -a routes=( "${!i}" ) |
13372 |
+ |
13373 |
+ # We don't add the old gateway if one has been set in routes_IFACE |
13374 |
+ local gw=true |
13375 |
+ for i in "${routes[@]}"; do |
13376 |
+ [[ ${i} != *"default gw"* ]] && continue |
13377 |
+ gw=false |
13378 |
+ break |
13379 |
+ done |
13380 |
+ |
13381 |
+ if ${gw} ; then |
13382 |
+ eval "routes_${ifvar}=( \"default gw \${gateway#*/}\" \"\${routes[@]}\" )" |
13383 |
+ fi |
13384 |
+ fi |
13385 |
+ |
13386 |
+ return 0 |
13387 |
+} |
13388 |
+ |
13389 |
+# bool ifconfig_iface_stop(char *interface) |
13390 |
+# |
13391 |
+# Do final shutdown for an interface or alias. |
13392 |
+# |
13393 |
+# Returns 0 (true) when successful, non-zero (false) on failure |
13394 |
+ifconfig_iface_stop() { |
13395 |
+ # If an alias is already down, then "ifconfig eth0:1 down" |
13396 |
+ # will try to bring it up with an address of "down" which |
13397 |
+ # fails. Do some double-checking before returning error |
13398 |
+ # status |
13399 |
+ ifconfig_is_up "$1" || return 0 |
13400 |
+ ifconfig_down "$1" && return 0 |
13401 |
+ |
13402 |
+ # It is sometimes impossible to transition an alias from the |
13403 |
+ # UP state... particularly if the alias has no address. So |
13404 |
+ # ignore the failure, which should be okay since the entire |
13405 |
+ # interface will be shut down eventually. |
13406 |
+ [[ $1 == *:* ]] && return 0 |
13407 |
+ return 1 |
13408 |
+} |
13409 |
+ |
13410 |
+# bool ifconfig_pre_start(char *interface) |
13411 |
+# |
13412 |
+# Runs any pre_start stuff on our interface - just the MTU atm |
13413 |
+# We set MTU twice as it may be needed for DHCP - a dhcp client could |
13414 |
+# change it in error, so we set MTU in post start too |
13415 |
+ifconfig_pre_start() { |
13416 |
+ local iface="$1" |
13417 |
+ |
13418 |
+ interface_exists "${iface}" || return 0 |
13419 |
+ |
13420 |
+ local ifvar=$(bash_variable "$1") mtu= |
13421 |
+ |
13422 |
+ # MTU support |
13423 |
+ mtu="mtu_${ifvar}" |
13424 |
+ [[ -n ${!mtu} ]] && ifconfig "${iface}" mtu "${!mtu}" |
13425 |
+ |
13426 |
+ return 0 |
13427 |
+} |
13428 |
+ |
13429 |
+ |
13430 |
+# bool ifconfig_post_start(char *iface) |
13431 |
+# |
13432 |
+# Bring up iface using ifconfig utilities, called from iface_start |
13433 |
+# |
13434 |
+# Returns 0 (true) when successful on the primary interface, non-zero |
13435 |
+# (false) when the primary interface fails. Aliases are allowed to |
13436 |
+# fail, the routine should still return success to indicate that |
13437 |
+# net.eth0 was successful |
13438 |
+ifconfig_post_start() { |
13439 |
+ local iface="$1" ifvar=$(bash_variable "$1") x= y= metric= mtu= |
13440 |
+ local -a routes=() |
13441 |
+ metric="metric_${ifvar}" |
13442 |
+ |
13443 |
+ ifconfig_exists "${iface}" || return 0 |
13444 |
+ |
13445 |
+ # Make sure interface is marked UP |
13446 |
+ ifconfig_up "${iface}" |
13447 |
+ |
13448 |
+ # MTU support |
13449 |
+ mtu="mtu_${ifvar}" |
13450 |
+ [[ -n ${!mtu} ]] && ifconfig "${iface}" mtu "${!mtu}" |
13451 |
+ |
13452 |
+ x="routes_${ifvar}[@]" |
13453 |
+ routes=( "${!x}" ) |
13454 |
+ |
13455 |
+ [[ -z ${routes} ]] && return 0 |
13456 |
+ |
13457 |
+ # Add routes for this interface, might even include default gw |
13458 |
+ einfo "Adding routes" |
13459 |
+ eindent |
13460 |
+ for x in "${routes[@]}"; do |
13461 |
+ ebegin "${x}" |
13462 |
+ |
13463 |
+ # Support iproute2 style routes |
13464 |
+ x="${x//via/gw} " |
13465 |
+ x="${x//scope * / }" |
13466 |
+ |
13467 |
+ # Work out if we're a host or a net if not told |
13468 |
+ if [[ " ${x} " != *" -net "* && " ${x} " != *" -host "* ]] ; then |
13469 |
+ y="${x%% *}" |
13470 |
+ if [[ ${y} == *.*.*.* && ${y} != *.*.*.0 && ${y} != *.*.*.0/* ]] ; then |
13471 |
+ x="-host ${x}" |
13472 |
+ else |
13473 |
+ x="-net ${x}" |
13474 |
+ fi |
13475 |
+ fi |
13476 |
+ |
13477 |
+ # Support adding IPv6 addresses easily |
13478 |
+ if [[ ${x} == *:* ]]; then |
13479 |
+ [[ ${x} != *"-A inet6"* ]] && x="-A inet6 ${x}" |
13480 |
+ x="${x// -net / }" |
13481 |
+ fi |
13482 |
+ |
13483 |
+ # Add a metric if we don't have one |
13484 |
+ [[ ${x} != *" metric "* ]] && x="${x} metric ${!metric}" |
13485 |
+ |
13486 |
+ route add ${x} dev "${iface}" |
13487 |
+ eend $? |
13488 |
+ done |
13489 |
+ eoutdent |
13490 |
+ |
13491 |
+ return 0 |
13492 |
+} |
13493 |
+ |
13494 |
+# bool ifconfig_add_address(char *iface, char *options ...) |
13495 |
+# |
13496 |
+# Adds the given address to the interface |
13497 |
+ifconfig_add_address() { |
13498 |
+ local iface="$1" i=0 r= e= real_iface=$(interface_device "$1") |
13499 |
+ |
13500 |
+ ifconfig_exists "${real_iface}" true || return 1 |
13501 |
+ |
13502 |
+ # Extract the config |
13503 |
+ local -a config=( "$@" ) |
13504 |
+ config=( ${config[@]:1} ) |
13505 |
+ |
13506 |
+ if [[ ${config[0]} == *:* ]]; then |
13507 |
+ # Support IPv6 - nice and simple |
13508 |
+ config[0]="inet6 add ${config[0]}" |
13509 |
+ else |
13510 |
+ # IPv4 is tricky - ifconfig requires an aliased device |
13511 |
+ # for multiple addresses |
13512 |
+ if ifconfig "${iface}" | grep -Eq "\<inet addr:.*" ; then |
13513 |
+ # Get the last alias made for the interface and add 1 to it |
13514 |
+ i=$(ifconfig | tac | grep -m 1 -o "^${iface}:[0-9]*" \ |
13515 |
+ | sed -n -e 's/'"${iface}"'://p') |
13516 |
+ i="${i:-0}" |
13517 |
+ (( i++ )) |
13518 |
+ iface="${iface}:${i}" |
13519 |
+ fi |
13520 |
+ |
13521 |
+ # ifconfig doesn't like CIDR addresses |
13522 |
+ local ip="${config[0]%%/*}" cidr="${config[0]##*/}" netmask= |
13523 |
+ if [[ -n ${cidr} && ${cidr} != "${ip}" ]]; then |
13524 |
+ netmask=$(cidr2netmask "${cidr}") |
13525 |
+ config[0]="${ip} netmask ${netmask}" |
13526 |
+ fi |
13527 |
+ |
13528 |
+ # Support iproute2 style config where possible |
13529 |
+ r="${config[@]}" |
13530 |
+ config=( ${r//brd +/} ) |
13531 |
+ config=( "${config[@]//brd/broadcast}" ) |
13532 |
+ config=( "${config[@]//peer/pointopoint}" ) |
13533 |
+ fi |
13534 |
+ |
13535 |
+ # Ensure that the interface is up so we can add IPv6 addresses |
13536 |
+ interface_up "${real_iface}" |
13537 |
+ |
13538 |
+ # Some kernels like to apply lo with an address when they are brought up |
13539 |
+ if [[ ${config[@]} == "127.0.0.1 netmask 255.0.0.0 broadcast 127.255.255.255" ]]; then |
13540 |
+ is_loopback "${iface}" && ifconfig "${iface}" 0.0.0.0 |
13541 |
+ fi |
13542 |
+ |
13543 |
+ ifconfig "${iface}" ${config[@]} |
13544 |
+} |
13545 |
+ |
13546 |
+# vim: set ts=4 : |
13547 |
|
13548 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/ifplugd.sh |
13549 |
=================================================================== |
13550 |
--- trunk/baselayout-prefix/lib/rcscripts/net/ifplugd.sh (rev 0) |
13551 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/ifplugd.sh 2011-03-31 14:11:17 UTC (rev 1682) |
13552 |
@@ -0,0 +1,146 @@ |
13553 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
13554 |
+# Distributed under the terms of the GNU General Public License v2 |
13555 |
+# Contributed by Roy Marples (uberlord@g.o) |
13556 |
+ |
13557 |
+# void ifplugd_depend(void) |
13558 |
+# |
13559 |
+# Sets up the dependancies for the module |
13560 |
+ifplugd_depend() { |
13561 |
+ after macnet rename |
13562 |
+ before interface |
13563 |
+ functions interface_exists interface_get_mac_address |
13564 |
+ provide plug |
13565 |
+} |
13566 |
+ |
13567 |
+# void ifplugd_expose(void) |
13568 |
+# |
13569 |
+# Expose variables that can be configured |
13570 |
+ifplugd_expose() { |
13571 |
+ variables plug_timeout |
13572 |
+} |
13573 |
+ |
13574 |
+# bool ifplugd_check_installed(void) |
13575 |
+# |
13576 |
+# Returns 0 if ifplugd is installed, otherwise 1 |
13577 |
+ifplugd_check_installed() { |
13578 |
+ if [[ ! -x /usr/sbin/ifplugd ]]; then |
13579 |
+ ${1:-false} && eerror "For ifplugd support, emerge sys-apps/ifplugd" |
13580 |
+ return 1 |
13581 |
+ fi |
13582 |
+ return 0 |
13583 |
+} |
13584 |
+ |
13585 |
+# bool ifplugd_pre_start(char *interface) |
13586 |
+# |
13587 |
+# Start ifplugd on an interface |
13588 |
+ifplugd_pre_start() { |
13589 |
+ local iface="$1" ifvar=$(bash_variable "$1") timeout= opts= |
13590 |
+ local pidfile="/var/run/ifplugd.${iface}.pid" |
13591 |
+ |
13592 |
+ # We don't start ifplugd if we're being called from the background |
13593 |
+ ${IN_BACKGROUND} && return 0 |
13594 |
+ |
13595 |
+ interface_exists "${iface}" || return 0 |
13596 |
+ |
13597 |
+ # ifplugd could have been started by the old init script |
13598 |
+ if [[ -e ${pidfile} ]] ; then |
13599 |
+ vewarn "ifplugd is already running on ${iface}" |
13600 |
+ return 0 |
13601 |
+ fi |
13602 |
+ |
13603 |
+ # We need a valid MAC address |
13604 |
+ # It's a basic test to ensure it's not a virtual interface |
13605 |
+ local mac=$(interface_get_mac_address "${iface}") |
13606 |
+ if [[ -z ${mac} ]] ; then |
13607 |
+ vewarn "ifplugd only works on interfaces with a valid MAC address" |
13608 |
+ return 0 |
13609 |
+ fi |
13610 |
+ |
13611 |
+ # We don't work on bonded, bridges, tun/tap, vlan or wireless |
13612 |
+ for f in bonding bridge tuntap vlan ; do |
13613 |
+ if is_function "${f}_exists" ; then |
13614 |
+ if ${f}_exists "${iface}" ; then |
13615 |
+ veinfo "ifplugd does not work with ${f}" |
13616 |
+ return 0 |
13617 |
+ fi |
13618 |
+ fi |
13619 |
+ done |
13620 |
+ |
13621 |
+ # Do some options |
13622 |
+ opts="ifplugd_${ifvar}" |
13623 |
+ |
13624 |
+ # We don't work on wirelesss interfaces |
13625 |
+ # Although ifplugd can, we prefer wpa_supplicant, unless explicitly told |
13626 |
+ # so via our options |
13627 |
+ if [[ " ${!opts} " != *" -m wlan "* \ |
13628 |
+ && " ${!opts} " != *" --api-mode=wlan "* ]] ; then |
13629 |
+ if is_function wireless_exists ; then |
13630 |
+ if wireless_exists "${iface}" ; then |
13631 |
+ veinfo "ifplugd does not work on wireless interfaces" |
13632 |
+ return 0 |
13633 |
+ fi |
13634 |
+ fi |
13635 |
+ fi |
13636 |
+ |
13637 |
+ ebegin "Starting ifplugd on ${iface}" |
13638 |
+ |
13639 |
+ # We need the interface up for ifplugd to listen to netlink events |
13640 |
+ interface_up "${iface}" |
13641 |
+ |
13642 |
+ # Mark the us as inactive so ifplugd can restart us |
13643 |
+ mark_service_inactive "net.${iface}" |
13644 |
+ |
13645 |
+ # Start ifplugd |
13646 |
+ eval start-stop-daemon --start --exec /usr/sbin/ifplugd \ |
13647 |
+ --pidfile "${pidfile}" \ |
13648 |
+ -- "${!opts}" --iface="${iface}" |
13649 |
+ eend "$?" || return 1 |
13650 |
+ |
13651 |
+ eindent |
13652 |
+ |
13653 |
+ timeout="timeout_${ifvar}" |
13654 |
+ timeout="${!timeout:--1}" |
13655 |
+ if [[ ${timeout} == "0" ]] ; then |
13656 |
+ ewarn "WARNING: infinite timeout set for ${iface} to come up" |
13657 |
+ elif [[ ${timeout} -lt 0 ]] ; then |
13658 |
+ einfo "Backgrounding ..." |
13659 |
+ exit 0 |
13660 |
+ fi |
13661 |
+ |
13662 |
+ veinfo "Waiting for ${iface} to be marked as started" |
13663 |
+ |
13664 |
+ local i=0 |
13665 |
+ while true ; do |
13666 |
+ if service_started "net.${iface}" ; then |
13667 |
+ local addr=$(interface_get_address "${iface}") |
13668 |
+ einfo "${iface} configured with address ${addr}" |
13669 |
+ exit 0 |
13670 |
+ fi |
13671 |
+ sleep 1 |
13672 |
+ [[ ${timeout} == "0" ]] && continue |
13673 |
+ (( i++ )) |
13674 |
+ [[ ${i} == "${timeout}" || ${i} -gt "${timeout}" ]] && break |
13675 |
+ done |
13676 |
+ |
13677 |
+ eend 1 "Failed to configure ${iface} in the background" |
13678 |
+ exit 0 |
13679 |
+} |
13680 |
+ |
13681 |
+# bool ifplugd_stop(char *iface) |
13682 |
+# |
13683 |
+# Stops ifplugd on an interface |
13684 |
+# Returns 0 (true) when successful, non-zero otherwise |
13685 |
+ifplugd_stop() { |
13686 |
+ ${IN_BACKGROUND} && return 0 |
13687 |
+ local iface="$1" |
13688 |
+ local pidfile="/var/run/ifplugd.${iface}.pid" |
13689 |
+ |
13690 |
+ [[ ! -e ${pidfile} ]] && return 0 |
13691 |
+ |
13692 |
+ ebegin "Stopping ifplugd on ${iface}" |
13693 |
+ start-stop-daemon --stop --exec /usr/sbin/ifplugd \ |
13694 |
+ --pidfile "${pidfile}" --signal 3 |
13695 |
+ eend $? |
13696 |
+} |
13697 |
+ |
13698 |
+# vim: set ts=4 : |
13699 |
|
13700 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/ip6to4.sh |
13701 |
=================================================================== |
13702 |
--- trunk/baselayout-prefix/lib/rcscripts/net/ip6to4.sh (rev 0) |
13703 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/ip6to4.sh 2011-03-31 14:11:17 UTC (rev 1682) |
13704 |
@@ -0,0 +1,97 @@ |
13705 |
+#!/bin/bash |
13706 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
13707 |
+# Distributed under the terms of the GNU General Public License v2 |
13708 |
+ |
13709 |
+# Contributed by Roy Marples (uberlord@g.o) |
13710 |
+ |
13711 |
+# void ip6to4_depend(void) |
13712 |
+# |
13713 |
+# Sets up the dependancies for the module |
13714 |
+ip6to4_depend() { |
13715 |
+ after interface |
13716 |
+ functions interface_exists interface_get_address interface_tunnel |
13717 |
+} |
13718 |
+ |
13719 |
+# void ip6to4_expose(void) |
13720 |
+# |
13721 |
+# Expose variables that can be configured |
13722 |
+ip6to4_expose() { |
13723 |
+ variables link |
13724 |
+} |
13725 |
+ |
13726 |
+# bool ip6to4_start(char *interface) |
13727 |
+# |
13728 |
+# Configures IPv6 addresses to be added to the tunnel based on a IPv4 |
13729 |
+# addresses on a pre-configured interface. |
13730 |
+# Returns 0 on success, otherwise 1. |
13731 |
+ip6to4_start() { |
13732 |
+ local iface="$1" addr="" |
13733 |
+ local ifvar=$(bash_variable "${iface}") |
13734 |
+ |
13735 |
+ # Ensure the interface is sit0 if we're using ifconfig |
13736 |
+ if [[ " ${MODULES[@]} " == *" ifconfig "* && ${iface} != "sit0" ]] ; then |
13737 |
+ eerror "ip6to4 can only on interface sit0 using ifconfig" |
13738 |
+ eerror "emerge sys-apps/iproute2 to use other interfaces" |
13739 |
+ return 1 |
13740 |
+ fi |
13741 |
+ |
13742 |
+ local host="link_${ifvar}" |
13743 |
+ if [[ -z ${!host} ]] ; then |
13744 |
+ eerror "link_${ifvar} is not set" |
13745 |
+ return 1 |
13746 |
+ fi |
13747 |
+ |
13748 |
+ interface_exists "${!host}" true || return 1 |
13749 |
+ |
13750 |
+ # An interface can have more than 1 ip address |
13751 |
+ local -a addrs=( $(interface_get_address "${!host}") ) |
13752 |
+ if [[ -z ${addrs} ]] ; then |
13753 |
+ eerror "${!host} is not configured with an IPv4 address" |
13754 |
+ return 1 |
13755 |
+ fi |
13756 |
+ |
13757 |
+ local -a new=() |
13758 |
+ local addr="" |
13759 |
+ for addr in "${addrs[@]}" ; do |
13760 |
+ # Strip the subnet |
13761 |
+ local ip="${addr%/*}" subnet="${addr#*/}" |
13762 |
+ # We don't work on private IPv4 addresses |
13763 |
+ [[ ${ip} == "127."* ]] && continue |
13764 |
+ [[ ${ip} == "10."* ]] && continue |
13765 |
+ [[ ${ip} == "192.168."* ]] && continue |
13766 |
+ local i= |
13767 |
+ for ((i=16; i<32; i++)); do |
13768 |
+ [[ ${ip} == "172.${i}."* ]] && break |
13769 |
+ done |
13770 |
+ [[ ${i} -lt 32 ]] && continue |
13771 |
+ |
13772 |
+ veinfo "IPv4 address on ${!host}: ${ip}" |
13773 |
+ local ip6=$(printf "2002:%02x%02x:%02x%02x::1" ${ip//./ }) |
13774 |
+ veinfo "Derived IPv6 address: ${ip6}" |
13775 |
+ |
13776 |
+ # Now apply our IPv6 address to our config |
13777 |
+ new=( "${new[@]}" "${ip6}/16" ) |
13778 |
+ done |
13779 |
+ |
13780 |
+ if [[ -z ${new} ]] ; then |
13781 |
+ eerror "No global IPv4 addresses found on interface ${!host}" |
13782 |
+ return 1 |
13783 |
+ fi |
13784 |
+ |
13785 |
+ if [[ ${iface} != "sit0" ]] ; then |
13786 |
+ ebegin "Creating 6to4 tunnel on ${iface}" |
13787 |
+ interface_tunnel add "${iface}" mode sit ttl 255 remote any local "${ip}" |
13788 |
+ eend $? || return 1 |
13789 |
+ fi |
13790 |
+ |
13791 |
+ # Now apply our config |
13792 |
+ config=( "${config[@]}" "${new[@]}" ) |
13793 |
+ |
13794 |
+ # Add a route for us, ensuring we don't delete anything else |
13795 |
+ local routes="routes_${ifvar}[@]" |
13796 |
+ eval "routes_${ifvar}=( \"\${!routes}\" \ |
13797 |
+ \"2003::/3 via ::192.88.99.1 metric 2147483647\" )" |
13798 |
+} |
13799 |
+ |
13800 |
+# vim:ts=4 |
13801 |
+# vim: set ts=4 : |
13802 |
|
13803 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/ipppd.sh |
13804 |
=================================================================== |
13805 |
--- trunk/baselayout-prefix/lib/rcscripts/net/ipppd.sh (rev 0) |
13806 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/ipppd.sh 2011-03-31 14:11:17 UTC (rev 1682) |
13807 |
@@ -0,0 +1,71 @@ |
13808 |
+#!/bin/bash |
13809 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
13810 |
+# Distributed under the terms of the GNU General Public License v2 |
13811 |
+ |
13812 |
+# Contributed by Roy Marples (uberlord@g.o) |
13813 |
+ |
13814 |
+# void ipppd_depend(void) |
13815 |
+# |
13816 |
+# Sets up the dependancies for the module |
13817 |
+ipppd_depend() { |
13818 |
+ after macnet |
13819 |
+ before interface |
13820 |
+ provide isdn |
13821 |
+ functions interface_exists interface_type |
13822 |
+ variables ipppd |
13823 |
+} |
13824 |
+ |
13825 |
+# bool ipppd_check_installed(void) |
13826 |
+# |
13827 |
+# Returns 1 if isnd4k-utils is installed, otherwise 0 |
13828 |
+ipppd_check_installed() { |
13829 |
+ [[ -x /usr/sbin/ipppd ]] && return 0 |
13830 |
+ ${1:-false} && eerror "For ISDN (ipppd) support, emerge net-dialup/isdn4k-utils" |
13831 |
+ return 1 |
13832 |
+} |
13833 |
+ |
13834 |
+# bool ipppd_start(char *iface) |
13835 |
+# |
13836 |
+# Start isdn on an interface |
13837 |
+# |
13838 |
+# Returns 0 (true) when successful, non-zero otherwise |
13839 |
+ipppd_pre_start() { |
13840 |
+ local iface="$1" opts= itype=$(interface_type "$1") |
13841 |
+ local pidfile="/var/run/ipppd-${iface}.pid" |
13842 |
+ |
13843 |
+ # Check that we are a valid isdn interface |
13844 |
+ [[ ${itype} != "ippp" && ${itype} != "isdn" ]] && return 0 |
13845 |
+ |
13846 |
+ # Check that the interface exists |
13847 |
+ interface_exists "${iface}" true || return 1 |
13848 |
+ |
13849 |
+ local ifvar=$(bash_variable "${iface}") |
13850 |
+ # Might or might not be set in conf.d/net |
13851 |
+ opts="ipppd_${ifvar}" |
13852 |
+ |
13853 |
+ einfo "Starting ipppd for ${iface}" |
13854 |
+ start-stop-daemon --start --exec /usr/sbin/ipppd \ |
13855 |
+ --pidfile "${pidfile}" \ |
13856 |
+ -- ${!opts} pidfile "${pidfile}" \ |
13857 |
+ file "/etc/ppp/options.${iface}" >/dev/null |
13858 |
+ eend $? || return $? |
13859 |
+ |
13860 |
+ return 0 |
13861 |
+} |
13862 |
+ |
13863 |
+# bool ipppd_stop(char *iface) |
13864 |
+# |
13865 |
+# Stop isdn on an interface |
13866 |
+# Returns 0 (true) when successful, non-zero otherwise |
13867 |
+ipppd_stop() { |
13868 |
+ local iface="$1" pidfile="/var/run/ipppd-$1.pid" |
13869 |
+ |
13870 |
+ [[ ! -f ${pidfile} ]] && return 0 |
13871 |
+ |
13872 |
+ einfo "Stopping ipppd for ${iface}" |
13873 |
+ start-stop-daemon --stop --exec /usr/sbin/ippd \ |
13874 |
+ --pidfile "${pidfile}" |
13875 |
+ eend $? |
13876 |
+} |
13877 |
+ |
13878 |
+# vim: set ts=4 : |
13879 |
|
13880 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/iproute2.sh |
13881 |
=================================================================== |
13882 |
--- trunk/baselayout-prefix/lib/rcscripts/net/iproute2.sh (rev 0) |
13883 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/iproute2.sh 2011-03-31 14:11:17 UTC (rev 1682) |
13884 |
@@ -0,0 +1,342 @@ |
13885 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
13886 |
+# Distributed under the terms of the GNU General Public License v2 |
13887 |
+# Contributed by Roy Marples (uberlord@g.o) |
13888 |
+ |
13889 |
+# Fix any potential localisation problems |
13890 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
13891 |
+ip() { |
13892 |
+ LC_ALL=C /sbin/ip "$@" |
13893 |
+} |
13894 |
+iproute2_tunnel() { |
13895 |
+ LC_ALL=C /sbin/ip tunnel "$@" |
13896 |
+} |
13897 |
+ |
13898 |
+# void iproute2_depend(void) |
13899 |
+# |
13900 |
+# Sets up the dependancies for the module |
13901 |
+iproute2_depend() { |
13902 |
+ provide interface |
13903 |
+ functions interface_device |
13904 |
+} |
13905 |
+ |
13906 |
+# void iproute2_expose(void) |
13907 |
+# |
13908 |
+# Expose variables that can be configured |
13909 |
+iproute2_expose() { |
13910 |
+ variables config routes fallback metric ipaddr ipaddr_fallback iproute inet6 |
13911 |
+} |
13912 |
+ |
13913 |
+# bool iproute2_check_installed(void) |
13914 |
+# |
13915 |
+# Returns 1 if iproute2 is installed, otherwise 0 |
13916 |
+iproute2_check_installed() { |
13917 |
+ [[ -x /sbin/ip ]] && return 0 |
13918 |
+ ${1:-false} && eerror "For iproute2 support, emerge sys-apps/iproute2" |
13919 |
+ return 1 |
13920 |
+} |
13921 |
+ |
13922 |
+# bool iproute2_exists(char *interface, bool report) |
13923 |
+# |
13924 |
+# Returns 1 if the interface exists, otherwise 0 |
13925 |
+iproute2_exists() { |
13926 |
+ local e=$(ip addr show label "$1") report="${2:-false}" |
13927 |
+ [[ -n ${e} ]] && return 0 |
13928 |
+ |
13929 |
+ if ${report} ; then |
13930 |
+ eerror "network interface $1 does not exist" |
13931 |
+ eerror "Please verify hardware or kernel module (driver)" |
13932 |
+ fi |
13933 |
+ return 1 |
13934 |
+} |
13935 |
+ |
13936 |
+# void iproute2_up(char *interface) |
13937 |
+# |
13938 |
+# provides a generic interface for bringing interfaces up |
13939 |
+iproute2_up() { |
13940 |
+ ip link set up dev "$1" |
13941 |
+} |
13942 |
+ |
13943 |
+# void iproute2_down(char *interface) |
13944 |
+# |
13945 |
+# provides a generic interface for bringing interfaces up |
13946 |
+iproute2_down() { |
13947 |
+ ip link set down dev "$1" |
13948 |
+} |
13949 |
+ |
13950 |
+# bool ifproute2_is_up(char *iface, bool withaddress) |
13951 |
+# |
13952 |
+# Returns 0 if the interface is up, otherwise 1 |
13953 |
+# If withaddress is true then the interface has to have an IPv4 address |
13954 |
+# assigned as well |
13955 |
+iproute2_is_up() { |
13956 |
+ local check="\<UP\>" addr="${2:-false}" |
13957 |
+ ${addr} && check="${check}.*inet " |
13958 |
+ ip addr show "$1" | tr '\n' ' ' | grep -Eq "${check}" |
13959 |
+} |
13960 |
+ |
13961 |
+# void iproute2_set_flag(char *iface, char *flag, bool enabled) |
13962 |
+# |
13963 |
+# Sets or disables the interface flag |
13964 |
+iproute2_set_flag() { |
13965 |
+ local enable="$3" opt="on" |
13966 |
+ ${enable} || opt="off" |
13967 |
+ ip link set "$1" "$2" "${opt}" |
13968 |
+} |
13969 |
+ |
13970 |
+# void iproute2_get_address(char *interface) |
13971 |
+# |
13972 |
+# Fetch the address retrieved by DHCP. If successful, echoes the |
13973 |
+# address on stdout, otherwise echoes nothing. |
13974 |
+iproute2_get_address() { |
13975 |
+ ip -family inet addr show "$1" | sed -n -e 's/.*inet \([^ ]*\).*/\1/p' |
13976 |
+} |
13977 |
+ |
13978 |
+# bool iproute2_is_ethernet(char *interface) |
13979 |
+# |
13980 |
+# Return 0 if the link is ethernet, otherwise 1. |
13981 |
+iproute2_is_ethernet() { |
13982 |
+ ip link show "$1" | grep -q "^[[:space:]]*link/ether[[:space:]]*" |
13983 |
+} |
13984 |
+ |
13985 |
+# void iproute2_get_mac_address(char *interface) |
13986 |
+# |
13987 |
+# Fetch the mac address assingned to the network card |
13988 |
+iproute2_get_mac_address() { |
13989 |
+ local mac=$( ip link show "$1" | sed -n -e \ |
13990 |
+ '/link\// s/^.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' ) |
13991 |
+ [[ ${mac} != '00:00:00:00:00:00' \ |
13992 |
+ && ${mac} != '44:44:44:44:44:44' \ |
13993 |
+ && ${mac} != 'FF:FF:FF:FF:FF:FF' ]] \ |
13994 |
+ && echo "${mac}" |
13995 |
+} |
13996 |
+ |
13997 |
+# void iproute2_set_mac_address(char *interface, char *mac) |
13998 |
+# |
13999 |
+# Assigned the mac address to the network card |
14000 |
+iproute2_set_mac_address() { |
14001 |
+ ip link set address "$2" dev "$1" |
14002 |
+} |
14003 |
+ |
14004 |
+# int iproute2_set_name(char *interface, char *new_name) |
14005 |
+# |
14006 |
+# Renames the interface |
14007 |
+# This will not work if the interface is setup! |
14008 |
+iproute2_set_name() { |
14009 |
+ ip link set name "$2" dev "$1" |
14010 |
+} |
14011 |
+ |
14012 |
+# void iproute2_get_aliases_rev(char *interface) |
14013 |
+# |
14014 |
+# Fetch the list of aliases for an interface. |
14015 |
+# Outputs a space-separated list on stdout, in reverse order, for |
14016 |
+# example "eth0:2 eth0:1" |
14017 |
+iproute2_get_aliases_rev() { |
14018 |
+ local iface=$( interface_device "$1" ) |
14019 |
+ ip addr show dev "${iface}" | grep -o "${iface}:[0-9].*" | tac |
14020 |
+} |
14021 |
+ |
14022 |
+# bool iproute2_del_addresses(char *interface, bool onlyinet) |
14023 |
+# |
14024 |
+# Remove addresses from interface. |
14025 |
+# If onlyinet is true, then we only remove IPv4 / inet addresses. |
14026 |
+iproute2_del_addresses() { |
14027 |
+ local pre= |
14028 |
+ ${2:-false} && pre="-f inet" |
14029 |
+ ip ${pre} addr flush label "$1" scope global &>/dev/null |
14030 |
+ ip ${pre} addr flush label "$1" scope site &>/dev/null |
14031 |
+ ip ${pre} addr flush label "$1" scope host &>/dev/null |
14032 |
+ return 0 |
14033 |
+} |
14034 |
+ |
14035 |
+# bool iproute2_get_old_config(char *iface) |
14036 |
+# |
14037 |
+# Returns config and config_fallback for the given interface |
14038 |
+iproute2_get_old_config() { |
14039 |
+ local ifvar=$( bash_variable "$1" ) inet6= t= |
14040 |
+ |
14041 |
+ # iproute2-style config vars |
14042 |
+ t="ipaddr_${ifvar}[@]" |
14043 |
+ config=( "${!t}" ) |
14044 |
+ t="config_fallback_${ifvar}[@]" |
14045 |
+ config_fallback=( "${!t}" ) |
14046 |
+ t="inet6_${ifvar}[@]" |
14047 |
+ inet6=( "${!t}" ) |
14048 |
+ |
14049 |
+ # BACKWARD COMPATIBILITY: check for space-separated inet6 addresses |
14050 |
+ [[ ${#inet6[@]} == "1" && ${inet6} == *" "* ]] && inet6=( ${inet6} ) |
14051 |
+ |
14052 |
+ # Add inet6 addresses to our config if required |
14053 |
+ [[ -n ${inet6} ]] && config=( "${config[@]}" "${inet6[@]}" ) |
14054 |
+ |
14055 |
+ # Support old style iface_xxx syntax |
14056 |
+ if [[ -z ${config} ]] ; then |
14057 |
+ if is_function ifconfig_get_old_config ; then |
14058 |
+ ifconfig_get_old_config "${iface}" |
14059 |
+ fi |
14060 |
+ fi |
14061 |
+ |
14062 |
+ return 0 |
14063 |
+} |
14064 |
+ |
14065 |
+# bool iproute2_iface_stop(char *interface) |
14066 |
+# |
14067 |
+# Do final shutdown for an interface or alias. |
14068 |
+# |
14069 |
+# Returns 0 (true) when successful, non-zero (false) on failure |
14070 |
+iproute2_iface_stop() { |
14071 |
+ local label="$1" iface=$( interface_device "$1" ) |
14072 |
+ |
14073 |
+ # Shut down the link if this isn't an alias or vlan |
14074 |
+ if [[ ${label} == "${iface}" ]] ; then |
14075 |
+ iproute2_down "${iface}" |
14076 |
+ return $? |
14077 |
+ fi |
14078 |
+ return 0 |
14079 |
+} |
14080 |
+ |
14081 |
+# bool iproute2_add_address(char *interface, char *options ...) |
14082 |
+# |
14083 |
+# Adds an the specified address to the interface |
14084 |
+# returns 0 on success and non-zero on failure |
14085 |
+iproute2_add_address() { |
14086 |
+ local iface="$1" x= |
14087 |
+ |
14088 |
+ iproute2_exists "${iface}" true || return 1 |
14089 |
+ |
14090 |
+ # Extract the config |
14091 |
+ local -a config=( "$@" ) |
14092 |
+ config=( ${config[@]:1} ) |
14093 |
+ |
14094 |
+ # Convert an ifconfig line to iproute2 |
14095 |
+ local n="${#config[@]}" |
14096 |
+ for (( x=0; x<n; x++ )); do |
14097 |
+ case "${config[x]}" in |
14098 |
+ netmask) |
14099 |
+ config[0]="${config[0]}/$( netmask2cidr "${config[x+1]}" )" |
14100 |
+ unset config[x] config[x+1] |
14101 |
+ ;; |
14102 |
+ mtu) |
14103 |
+ ip link set mtu "${config[x+1]}" dev "${iface}" |
14104 |
+ unset config[x] config[x+1] |
14105 |
+ ;; |
14106 |
+ esac |
14107 |
+ done |
14108 |
+ config=( "${config[@]//pointopoint/peer}" ) |
14109 |
+ |
14110 |
+ # Always scope lo addresses as host unless specified otherwise |
14111 |
+ if [[ " ${config[@]} " != *" scope "* ]] ; then |
14112 |
+ is_loopback "${iface}" && config=( "${config[@]}" "scope host" ) |
14113 |
+ fi |
14114 |
+ |
14115 |
+ # IPv4 specifics |
14116 |
+ if [[ ${config[@]} == *.*.*.* ]] ; then |
14117 |
+ # Work out a broadcast if none supplied |
14118 |
+ [[ ${config[@]} != *" brd "* && ${config[@]} != *" broadcast "* ]] \ |
14119 |
+ && config=( "${config[@]}" "brd +" ) |
14120 |
+ fi |
14121 |
+ |
14122 |
+ # Ensure that the interface is up so we can add IPv6 addresses |
14123 |
+ interface_up "${iface}" |
14124 |
+ |
14125 |
+ # Some kernels like to apply lo with an address when they are brought up |
14126 |
+ if [[ ${config[@]} == "127.0.0.1/8 brd 127.255.255.255 scope host" ]] ; then |
14127 |
+ is_loopback "${iface}" && ip addr del dev "${iface}" 127.0.0.1/8 2>/dev/null |
14128 |
+ fi |
14129 |
+ |
14130 |
+ ip addr add dev "${iface}" ${config[@]} |
14131 |
+} |
14132 |
+ |
14133 |
+# bool iproute2_pre_start(char *interface) |
14134 |
+# |
14135 |
+# Runs any pre_start stuff on our interface - just the MTU atm |
14136 |
+# We set MTU twice as it may be needed for DHCP - a dhcp client could |
14137 |
+# change it in error, so we set MTU in post start too |
14138 |
+iproute2_pre_start() { |
14139 |
+ local iface="$1" |
14140 |
+ |
14141 |
+ interface_exists "${iface}" || return 0 |
14142 |
+ |
14143 |
+ local ifvar=$( bash_variable "$1" ) |
14144 |
+ |
14145 |
+ # MTU support |
14146 |
+ local mtu="mtu_${ifvar}" |
14147 |
+ [[ -n ${!mtu} ]] && ip link set mtu "${!mtu}" dev "${iface}" |
14148 |
+ |
14149 |
+ return 0 |
14150 |
+} |
14151 |
+ |
14152 |
+# bool iproute2_post_start(char *interface) |
14153 |
+# |
14154 |
+# Runs any post_start stuff on our interface and adds routes |
14155 |
+# Always returns 0 |
14156 |
+iproute2_post_start() { |
14157 |
+ local iface="$1" ifvar=$( bash_variable "$1" ) x= |
14158 |
+ |
14159 |
+ iproute2_exists "${iface}" || return 0 |
14160 |
+ |
14161 |
+ # Make sure interface is marked UP |
14162 |
+ iproute2_up "${iface}" |
14163 |
+ |
14164 |
+ # MTU support |
14165 |
+ local mtu="mtu_${ifvar}" |
14166 |
+ [[ -n ${!mtu} ]] && ip link set mtu "${!mtu}" dev "${iface}" |
14167 |
+ |
14168 |
+ local x="routes_${ifvar}[@]" |
14169 |
+ local -a routes=( "${!x}" ) |
14170 |
+ local metric="metric_${ifvar}" |
14171 |
+ |
14172 |
+ # Test for old style ipaddr variable |
14173 |
+ if [[ -z ${routes} ]] ; then |
14174 |
+ t="iproute_${ifvar}[@]" |
14175 |
+ routes=( "${!t}" ) |
14176 |
+ fi |
14177 |
+ |
14178 |
+ # Set routes with ip route -- this might also include default route |
14179 |
+ if [[ -n ${routes} ]] ; then |
14180 |
+ einfo "Adding routes" |
14181 |
+ eindent |
14182 |
+ for x in "${routes[@]}"; do |
14183 |
+ ebegin "${x}" |
14184 |
+ |
14185 |
+ # Support net-tools routing too |
14186 |
+ x="${x//gw/via}" |
14187 |
+ x="${x//-A inet6/}" |
14188 |
+ x="${x//-net/}" |
14189 |
+ [[ " ${x} " == *" -host "* ]] && x="${x//-host/} scope host" |
14190 |
+ |
14191 |
+ # Attempt to support net-tools route netmask option |
14192 |
+ netmask="${x##* netmask }" |
14193 |
+ if [[ -n ${netmask} && ${x} != "${netmask}" ]] ; then |
14194 |
+ netmask="${netmask%% *}" |
14195 |
+ x="${x// netmask ${netmask} / }" |
14196 |
+ local -a a=( ${x} ) |
14197 |
+ a[0]="${a[0]}/$( netmask2cidr "${netmask}")" |
14198 |
+ x="${a[@]}" |
14199 |
+ fi |
14200 |
+ |
14201 |
+ # Add a metric if we don't have one |
14202 |
+ [[ " ${x} " != *" metric "* ]] && x="${x} metric ${!metric}" |
14203 |
+ |
14204 |
+ ip route append ${x} dev "${iface}" |
14205 |
+ eend $? |
14206 |
+ done |
14207 |
+ eoutdent |
14208 |
+ fi |
14209 |
+ |
14210 |
+ # Flush the route cache |
14211 |
+ ip route flush cache dev "${iface}" |
14212 |
+ |
14213 |
+ return 0 |
14214 |
+} |
14215 |
+ |
14216 |
+# void iproute2_post_stop(char* interface) |
14217 |
+iproute2_post_stop() { |
14218 |
+ local iface="$1" rule= |
14219 |
+ |
14220 |
+ iproute2_exists "${iface}" || return |
14221 |
+ |
14222 |
+ # Flush the route cache |
14223 |
+ ip route flush cache dev "${iface}" |
14224 |
+} |
14225 |
+ |
14226 |
+# vim: set ts=4 : |
14227 |
|
14228 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/iptunnel.sh |
14229 |
=================================================================== |
14230 |
--- trunk/baselayout-prefix/lib/rcscripts/net/iptunnel.sh (rev 0) |
14231 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/iptunnel.sh 2011-03-31 14:11:17 UTC (rev 1682) |
14232 |
@@ -0,0 +1,55 @@ |
14233 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
14234 |
+# Distributed under the terms of the GNU General Public License v2 |
14235 |
+# Contributed by Roy Marples (uberlord@g.o) |
14236 |
+ |
14237 |
+# void iptunnel_depend(void) |
14238 |
+# |
14239 |
+# Sets up the dependancies for the module |
14240 |
+iptunnel_depend() { |
14241 |
+ before interface |
14242 |
+ functions interface_exists interface_tunnel |
14243 |
+} |
14244 |
+ |
14245 |
+# void iptunnel_expose(void) |
14246 |
+# |
14247 |
+# Expose variables that can be configured |
14248 |
+iptunnel_expose() { |
14249 |
+ variables iptunnel |
14250 |
+} |
14251 |
+ |
14252 |
+# bool iptunnel_pre_start(char *iface) |
14253 |
+# |
14254 |
+# Create the device, give it the right perms |
14255 |
+iptunnel_pre_start() { |
14256 |
+ local iface="$1" opts= ifvar=$(bash_variable "$1") |
14257 |
+ |
14258 |
+ # Get our options |
14259 |
+ eval opts="iptunnel_${ifvar}" |
14260 |
+ [[ -z ${!opts} ]] && return 0 |
14261 |
+ |
14262 |
+ # Set our base metric to 1000 |
14263 |
+ metric=1000 |
14264 |
+ |
14265 |
+ ebegin "Creating tunnel ${iface}" |
14266 |
+ interface_tunnel add "${iface}" ${!opts} |
14267 |
+ eend "$?" |
14268 |
+} |
14269 |
+ |
14270 |
+# bool iptunnel_stop(char *iface) |
14271 |
+# |
14272 |
+# Removes the device |
14273 |
+iptunnel_stop() { |
14274 |
+ local iface="$1" |
14275 |
+ |
14276 |
+ # Don't delete sit0 as it's a special tunnel |
14277 |
+ [[ ${iface} == "sit0" ]] && return 0 |
14278 |
+ |
14279 |
+ interface_exists "${iface}" || return 0 |
14280 |
+ [[ -z $(interface_tunnel show "${iface}" 2>/dev/null) ]] && return 0 |
14281 |
+ |
14282 |
+ ebegin "Destroying tunnel ${iface}" |
14283 |
+ interface_tunnel del "${iface}" |
14284 |
+ eend $? |
14285 |
+} |
14286 |
+ |
14287 |
+# vim: set ts=4 : |
14288 |
|
14289 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/iwconfig.sh |
14290 |
=================================================================== |
14291 |
--- trunk/baselayout-prefix/lib/rcscripts/net/iwconfig.sh (rev 0) |
14292 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/iwconfig.sh 2011-03-31 14:11:17 UTC (rev 1682) |
14293 |
@@ -0,0 +1,966 @@ |
14294 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
14295 |
+# Distributed under the terms of the GNU General Public License v2 |
14296 |
+# Contributed by Roy Marples (uberlord@g.o) |
14297 |
+# Many thanks to all the people in the Gentoo forums for their ideas and |
14298 |
+# motivation for me to make this and keep on improving it |
14299 |
+ |
14300 |
+# Fix any potential localisation problems |
14301 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
14302 |
+iwconfig() { |
14303 |
+ LC_ALL=C /sbin/iwconfig "$@" |
14304 |
+} |
14305 |
+iwgetid() { |
14306 |
+ LC_ALL=C /sbin/iwgetid "$@" |
14307 |
+} |
14308 |
+iwlist() { |
14309 |
+ LC_ALL=C /sbin/iwlist "$@" |
14310 |
+} |
14311 |
+iwpriv() { |
14312 |
+ LC_ALL=C /sbin/iwpriv "$@" |
14313 |
+} |
14314 |
+ |
14315 |
+# void iwconfig_depend(void) |
14316 |
+# |
14317 |
+# Sets up the dependancies for the module |
14318 |
+iwconfig_depend() { |
14319 |
+ after plug |
14320 |
+ before interface |
14321 |
+ provide wireless |
14322 |
+ functions interface_up interface_down interface_exists |
14323 |
+} |
14324 |
+ |
14325 |
+# void iwconfig_expose(void) |
14326 |
+# |
14327 |
+# Expose variables that can be configured |
14328 |
+iwconfig_expose() { |
14329 |
+ variables essid mode associate_timeout sleep_scan preferred_aps blacklist_aps |
14330 |
+} |
14331 |
+ |
14332 |
+# bool iwconfig_check_installed(void) |
14333 |
+# |
14334 |
+# Returns 1 if wireless-tools is installed, otherwise 0 |
14335 |
+iwconfig_check_installed() { |
14336 |
+ local report=${1:-false} |
14337 |
+ [[ -x /sbin/iwconfig ]] && return 0 |
14338 |
+ ${report} && eerror "For Wireless (802.11) support, emerge net-wireless/wireless-tools" |
14339 |
+ |
14340 |
+ if [[ ! -e /proc/net/wireless ]]; then |
14341 |
+ installed="1" |
14342 |
+ if ${report} ; then |
14343 |
+ eerror "iwconfig requires wireless support" |
14344 |
+ eerror "(CONFIG_NET_WIRELESS=y) enabled in the kernel" |
14345 |
+ fi |
14346 |
+ fi |
14347 |
+ |
14348 |
+ return 1 |
14349 |
+} |
14350 |
+ |
14351 |
+# bool iwconfig_exists(char *interface) |
14352 |
+# |
14353 |
+# Checks to see if wireless extensions are enabled on the interface |
14354 |
+iwconfig_exists() { |
14355 |
+ # Support new sysfs layout |
14356 |
+ [[ -L /sys/class/net/$1/wiphy || -d /sys/class/net/$1/wireless ]] \ |
14357 |
+ && return 0 |
14358 |
+ |
14359 |
+ [[ ! -e /proc/net/wireless ]] && return 1 |
14360 |
+ [[ $(</proc/net/wireless) =~ $'\n'"[ \t]*$1:" ]] |
14361 |
+} |
14362 |
+ |
14363 |
+# char* iwconfig_get_wep_status(char *interface) |
14364 |
+# |
14365 |
+# Echos a string showing whether WEP is enabled or disabled |
14366 |
+# for the given interface |
14367 |
+iwconfig_get_wep_status() { |
14368 |
+ local mode= status="disabled" |
14369 |
+ |
14370 |
+ if [[ $(iwconfig "$1") =~ $'\n'" +Encryption key:[0-9,A-F]" ]]; then |
14371 |
+ status="enabled" |
14372 |
+ mode=$(iwconfig "$1" | sed -n -e 's/^.*Security mode:\(.*[^ ]\).*/\1/p') |
14373 |
+ [[ -n ${mode} ]] && mode=" - ${mode}" |
14374 |
+ fi |
14375 |
+ |
14376 |
+ echo "(WEP ${status}${mode})" |
14377 |
+} |
14378 |
+ |
14379 |
+# char* iwconfig_get_essid(char *iface) |
14380 |
+# |
14381 |
+# Gets the current ESSID of the iface |
14382 |
+iwconfig_get_essid() { |
14383 |
+ local i= essid= |
14384 |
+ |
14385 |
+ for (( i=0; i<5; i++ )); do |
14386 |
+ essid=$( iwgetid --raw "$1" ) |
14387 |
+ if [[ -n ${essid} ]] ; then |
14388 |
+ echo "${essid}" |
14389 |
+ return 0 |
14390 |
+ fi |
14391 |
+ sleep 1 |
14392 |
+ done |
14393 |
+ |
14394 |
+ return 1 |
14395 |
+} |
14396 |
+ |
14397 |
+# char* iwconfig_get_ap_mac_address(char *interface) |
14398 |
+# |
14399 |
+# Returns the MAC address of the Access Point |
14400 |
+# the interface is connected to |
14401 |
+iwconfig_get_ap_mac_address() { |
14402 |
+ iwgetid --raw --ap "$1" |
14403 |
+} |
14404 |
+ |
14405 |
+# char* iwconfig_get_mode(char *interface) |
14406 |
+# |
14407 |
+# Returns the wireless mode in lower case |
14408 |
+iwconfig_get_mode() { |
14409 |
+ iwgetid --mode "$1" | sed -n -e 's/^.*Mode:\(.*\)/\L\1/p' |
14410 |
+} |
14411 |
+ |
14412 |
+iwconfig_set_mode() { |
14413 |
+ local iface="$1" mode="$2" |
14414 |
+ [[ ${mode} == $(iwconfig_get_mode "${iface}") ]] && return 0 |
14415 |
+ |
14416 |
+ # Devicescape stack requires the interface to be down |
14417 |
+ interface_down "${iface}" |
14418 |
+ if ! iwconfig "${iface}" mode "${mode}" ; then |
14419 |
+ eerror "${iface} does not support setting the mode to \"${mode}\"" |
14420 |
+ return 1 |
14421 |
+ fi |
14422 |
+ interface_up "${iface}" |
14423 |
+} |
14424 |
+ |
14425 |
+# char* iwconfig_get_type(char *interface) |
14426 |
+# |
14427 |
+# Returns the type of interface - the IEEE part |
14428 |
+iwconfig_get_type() { |
14429 |
+ iwconfig "$1" | sed -n -e 's/^'"$1"' *\([^ ]* [^ ]*\).*/\1/p' |
14430 |
+} |
14431 |
+ |
14432 |
+# void iwconfig_report(char *interface) |
14433 |
+# |
14434 |
+# Output how our wireless interface has been configured |
14435 |
+iwconfig_report() { |
14436 |
+ local iface="$1" essid= mac= m="connected to" |
14437 |
+ |
14438 |
+ essid=$(iwconfig_get_essid "${iface}") |
14439 |
+ |
14440 |
+ local wep_status=$(iwconfig_get_wep_status "${iface}") |
14441 |
+ local channel=$(iwgetid --raw --channel "${iface}") |
14442 |
+ [[ -n ${channel} ]] && channel="on channel ${channel} " |
14443 |
+ |
14444 |
+ essid="${essid//\\\\/\\\\}" |
14445 |
+ local mode=$(iwconfig_get_mode "${iface}") |
14446 |
+ if [[ ${mode} == "master" ]]; then |
14447 |
+ m="configured as" |
14448 |
+ else |
14449 |
+ mac=$(iwconfig_get_ap_mac_address "${iface}") |
14450 |
+ [[ -n ${mac} ]] && mac=" at ${mac}" |
14451 |
+ fi |
14452 |
+ |
14453 |
+ eindent |
14454 |
+ einfo "${iface} ${m} ESSID \"${essid}\"${mac}" |
14455 |
+ einfo "in ${mode} mode ${channel}${wep_status}" |
14456 |
+ eoutdent |
14457 |
+} |
14458 |
+ |
14459 |
+# char* iwconfig_get_wep_key(char *mac_address) |
14460 |
+# |
14461 |
+# Returns the configured WEP key for the given mac address |
14462 |
+# or the given ESSID. The mac address setting takes precendence |
14463 |
+iwconfig_get_wep_key() { |
14464 |
+ local mac="$1" key= |
14465 |
+ key="mac_key_${mac//:/}" |
14466 |
+ [[ -z ${!key} ]] && key="key_${ESSIDVAR}" |
14467 |
+ echo "${!key:-off}" |
14468 |
+} |
14469 |
+ |
14470 |
+# void iwconfig_user_config(char *iface, char *ifvar) |
14471 |
+# |
14472 |
+# Applies the user configuration to the interface |
14473 |
+iwconfig_user_config() { |
14474 |
+ local iface="$1" conf= aconf= ifvar="$2" |
14475 |
+ [[ -z ${ifvar} ]] && ifvar=$(bash_variable "$1") |
14476 |
+ |
14477 |
+ # Apply the user configuration |
14478 |
+ conf="iwconfig_${ifvar}" |
14479 |
+ if [[ -n ${!conf} ]]; then |
14480 |
+ aconf=( "${!conf}" ) |
14481 |
+ for conf in "${aconf[@]}" ; do |
14482 |
+ if ! iwconfig "${iface}" ${conf} ; then |
14483 |
+ ewarn "${iface} does not support the following configuration commands" |
14484 |
+ ewarn " ${conf}" |
14485 |
+ fi |
14486 |
+ done |
14487 |
+ fi |
14488 |
+ |
14489 |
+ conf="iwpriv_${ifvar}[@]" |
14490 |
+ if [[ -n ${!conf} ]]; then |
14491 |
+ aconf=( "${!conf}" ) |
14492 |
+ for conf in "${aconf[@]}" ; do |
14493 |
+ if ! iwpriv "${iface}" ${conf} ; then |
14494 |
+ ewarn "${iface} does not support the following private ioctls" |
14495 |
+ ewarn " ${conf}" |
14496 |
+ fi |
14497 |
+ done |
14498 |
+ fi |
14499 |
+} |
14500 |
+ |
14501 |
+# bool iwconfig_setup_specific(char *iface) |
14502 |
+# |
14503 |
+# Sets up our wireless interface to operate in ad-hoc or master mode |
14504 |
+iwconfig_setup_specific() { |
14505 |
+ local iface="$1" mode="$2" channel= key= dessid= |
14506 |
+ local ifvar=$(bash_variable "$1") |
14507 |
+ |
14508 |
+ if [[ -z ${ESSID} ]]; then |
14509 |
+ eerror "${iface} requires an ESSID to be set to operate in ${mode} mode" |
14510 |
+ eerror "adjust the essid_${iface} setting in /etc/conf.d/wireless" |
14511 |
+ return 1 |
14512 |
+ fi |
14513 |
+ dessid="${ESSID//\\\\/\\\\}" |
14514 |
+ ESSIDVAR=$(bash_variable "${ESSID}") |
14515 |
+ key=$(iwconfig_get_wep_key) |
14516 |
+ |
14517 |
+ iwconfig_set_mode "${iface}" "${mode}" |
14518 |
+ |
14519 |
+ # Now set the key |
14520 |
+ if ! iwconfig "${iface}" key ${key} ; then |
14521 |
+ if [[ ${key} != "off" ]]; then |
14522 |
+ ewarn "${iface} does not support setting keys" |
14523 |
+ ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect" |
14524 |
+ fi |
14525 |
+ fi |
14526 |
+ |
14527 |
+ # Then set the ESSID |
14528 |
+ if ! iwconfig "${iface}" essid "${ESSID}" ; then |
14529 |
+ eerror "${iface} does not support setting ESSID to \"${dessid}\"" |
14530 |
+ return 1 |
14531 |
+ fi |
14532 |
+ |
14533 |
+ channel="channel_${ifvar}" |
14534 |
+ # We default the channel to 3 |
14535 |
+ if ! iwconfig "${iface}" channel "${!channel:-3}" ; then |
14536 |
+ ewarn "${iface} does not support setting the channel to \"${!channel:-3}\"" |
14537 |
+ return 1 |
14538 |
+ fi |
14539 |
+ |
14540 |
+ # Finally apply the user Config |
14541 |
+ iwconfig_user_config "${iface}" "${ESSIDVAR}" |
14542 |
+ |
14543 |
+ iwconfig_report "${iface}" |
14544 |
+ |
14545 |
+ return 0 |
14546 |
+} |
14547 |
+ |
14548 |
+# bool iwconfig_associate_mac(char *iface) |
14549 |
+# |
14550 |
+# Returns true if the AP MAC address is valid or not |
14551 |
+iwconfig_associate_mac() { |
14552 |
+ # Checks if a MAC address has been assigned |
14553 |
+ local mac=$(iwconfig_get_ap_mac_address "$1") i= |
14554 |
+ local -a invalid_macs=( |
14555 |
+ "00:00:00:00:00:00" |
14556 |
+ "44:44:44:44:44:44" |
14557 |
+ "FF:00:00:00:00:00" |
14558 |
+ "FF:FF:FF:FF:FF:FF" |
14559 |
+ ) |
14560 |
+ |
14561 |
+ [[ -z ${mac} ]] && return 1 |
14562 |
+ for i in "${invalid_macs[@]}"; do |
14563 |
+ [[ ${mac} == "${i}" ]] && return 1 |
14564 |
+ done |
14565 |
+ return 0 |
14566 |
+} |
14567 |
+ |
14568 |
+# bool iwconfig_associate_quality(char *iface) |
14569 |
+# |
14570 |
+# Returns true if the link quality is not 0 or 0. |
14571 |
+iwconfig_associate_quality() { |
14572 |
+ local quality=$( \ |
14573 |
+ sed -n -e 's/^.*'"$1"': *[0-9]* *\([0-9]*\).*/\1/p' \ |
14574 |
+ /proc/net/wireless |
14575 |
+ ) |
14576 |
+ [[ ${quality} != "0" ]] |
14577 |
+ return "$?" |
14578 |
+} |
14579 |
+ |
14580 |
+# bool iwconfig_test_associated(char *iface) |
14581 |
+# |
14582 |
+# Returns true if the interface has associated with an Access Point |
14583 |
+iwconfig_test_associated() { |
14584 |
+ local iface="$1" ttype= ifvar=$(bash_variable "$1") x= |
14585 |
+ # Some drivers don't set MAC to a bogus value when assocation is lost/fails |
14586 |
+ # whereas they do set link quality to 0 |
14587 |
+ |
14588 |
+ # Use sysfs if we can |
14589 |
+ if [[ -e /sys/class/net/${iface}/carrier ]] ; then |
14590 |
+ [[ $(</sys/class/net/"${iface}"/carrier) == "1" ]] |
14591 |
+ return $? |
14592 |
+ fi |
14593 |
+ |
14594 |
+ x="associate_test_${ifvar}" |
14595 |
+ ttype=$(echo "${!x:-mac}" | tr '[:upper:]' '[:lower:]') |
14596 |
+ if [[ ${ttype} != "mac" && ${ttype} != "quality" && ${ttype} != "all" ]]; then |
14597 |
+ ewarn " associate_test_${iface} is not set to mac, quality or all" |
14598 |
+ ewarn " defaulting to \"mac\"" |
14599 |
+ test="mac" |
14600 |
+ fi |
14601 |
+ |
14602 |
+ case "${ttype}" in |
14603 |
+ mac) iwconfig_associate_mac "${iface}" && return 0 ;; |
14604 |
+ quality) iwconfig_associate_quality "${iface}" && return 0 ;; |
14605 |
+ all) iwconfig_associate_mac "${iface}" \ |
14606 |
+ && iwconfig_associate_quality "${iface}" && return 0 ;; |
14607 |
+ esac |
14608 |
+ |
14609 |
+ return 1 |
14610 |
+} |
14611 |
+ |
14612 |
+# bool iwconfig_wait_for_association(char *iface) |
14613 |
+# |
14614 |
+# Waits for a configured ammount of time until |
14615 |
+# we are assocaited with an Access Point |
14616 |
+iwconfig_wait_for_association() { |
14617 |
+ local iface="$1" i=0 timeout= ifvar=$(bash_variable "$1") |
14618 |
+ timeout="associate_timeout_${ifvar}" |
14619 |
+ [[ -z ${!timeout} ]] && timeout="sleep_associate_${ifvar}" |
14620 |
+ timeout="${!timeout:-10}" |
14621 |
+ |
14622 |
+ [[ ${timeout} == "0" ]] \ |
14623 |
+ && vewarn "WARNING: infinite timeout set for association on ${iface}" |
14624 |
+ |
14625 |
+ while true; do |
14626 |
+ iwconfig_test_associated "${iface}" && return 0 |
14627 |
+ sleep 1 |
14628 |
+ [[ ${timeout} == "0" ]] && continue |
14629 |
+ (( i++ )) |
14630 |
+ [[ ${i} == "${timeout}" || ${i} -gt ${timeout} ]] && break |
14631 |
+ done |
14632 |
+ return 1 |
14633 |
+} |
14634 |
+ |
14635 |
+# bool iwconfig_associate(char *interface, char *mac_address, char *wep_required) |
14636 |
+# |
14637 |
+# Tries to associate the interface with an Access Point |
14638 |
+# If we scanned the Access Point we know if we need WEP to associate or not |
14639 |
+# and if we have a WEP key for the ESSID or not |
14640 |
+# so we can fail gracefully without even trying to connect |
14641 |
+iwconfig_associate() { |
14642 |
+ local iface="$1" mode="${2:-managed}" |
14643 |
+ local mac="$3" wep_required="$4" freq="$5" chan="$6" w="(WEP Disabled)" |
14644 |
+ local dessid="${ESSID//\\\\/\\\\}" key= |
14645 |
+ |
14646 |
+ iwconfig_set_mode "${iface}" "${mode}" |
14647 |
+ |
14648 |
+ if [[ ${ESSID} == "any" ]]; then |
14649 |
+ iwconfig "${iface}" ap any 2>/dev/null |
14650 |
+ dessid="any" |
14651 |
+ unset ESSIDVAR |
14652 |
+ else |
14653 |
+ ESSIDVAR=$(bash_variable "${ESSID}") |
14654 |
+ key=$(iwconfig_get_wep_key "${mac}") |
14655 |
+ if [[ ${wep_required} == "on" && ${key} == "off" ]]; then |
14656 |
+ ewarn "WEP key is not set for \"${dessid}\" - not connecting" |
14657 |
+ return 1 |
14658 |
+ fi |
14659 |
+ if [[ ${wep_required} == "off" && ${key} != "off" ]]; then |
14660 |
+ key="off" |
14661 |
+ ewarn "\"${dessid}\" is not WEP enabled - ignoring setting" |
14662 |
+ fi |
14663 |
+ |
14664 |
+ if ! iwconfig "${iface}" key ${key} ; then |
14665 |
+ if [[ ${key} != "off" ]]; then |
14666 |
+ ewarn "${iface} does not support setting keys" |
14667 |
+ ewarn "or the parameter \"mac_key_${ESSIDVAR}\" or \"key_${ESSIDVAR}\" is incorrect" |
14668 |
+ return 1 |
14669 |
+ fi |
14670 |
+ fi |
14671 |
+ [[ ${key} != "off" ]] && w=$(iwconfig_get_wep_status "${iface}") |
14672 |
+ fi |
14673 |
+ |
14674 |
+ if ! iwconfig "${iface}" essid "${ESSID}" ; then |
14675 |
+ if [[ ${ESSID} != "any" ]]; then |
14676 |
+ ewarn "${iface} does not support setting ESSID to \"${dessid}\"" |
14677 |
+ fi |
14678 |
+ fi |
14679 |
+ |
14680 |
+ # Only use channel or frequency |
14681 |
+ if [[ -n ${chan} ]] ; then |
14682 |
+ iwconfig "${iface}" channel "${chan}" |
14683 |
+ elif [[ -n ${freq} ]] ; then |
14684 |
+ iwconfig "${iface}" freq "${freq}" |
14685 |
+ fi |
14686 |
+ [[ -n ${mac} ]] && iwconfig "${iface}" ap "${mac}" |
14687 |
+ |
14688 |
+ # Finally apply the user Config |
14689 |
+ iwconfig_user_config "${iface}" "${ESSIDVAR}" |
14690 |
+ |
14691 |
+ vebegin "Connecting to \"${dessid}\" in ${mode} mode ${w}" |
14692 |
+ |
14693 |
+ if [[ ${ESSID} != "any" ]] && is_function preassociate ; then |
14694 |
+ veinfo "Running preassociate function" |
14695 |
+ eindent |
14696 |
+ ( preassociate "${iface}" ) |
14697 |
+ e="$?" |
14698 |
+ eoutdent |
14699 |
+ if [[ ${e} != 0 ]]; then |
14700 |
+ veend 1 "preassociate \"${dessid}\" on ${iface} failed" |
14701 |
+ return 1 |
14702 |
+ fi |
14703 |
+ fi |
14704 |
+ |
14705 |
+ if ! iwconfig_wait_for_association "${iface}" ; then |
14706 |
+ veend 1 |
14707 |
+ return 1 |
14708 |
+ fi |
14709 |
+ veend 0 |
14710 |
+ |
14711 |
+ if [[ ${ESSID} == "any" ]]; then |
14712 |
+ ESSID=$(iwconfig_get_essid "${iface}") |
14713 |
+ iwconfig_associate "${iface}" |
14714 |
+ return $? |
14715 |
+ fi |
14716 |
+ |
14717 |
+ iwconfig_report "${iface}" |
14718 |
+ |
14719 |
+ if is_function postassociate ; then |
14720 |
+ veinfo "Running postassociate function" |
14721 |
+ eindent |
14722 |
+ ( postassociate "${iface}" ) |
14723 |
+ eoutdent |
14724 |
+ fi |
14725 |
+ |
14726 |
+ return 0 |
14727 |
+} |
14728 |
+ |
14729 |
+# bool iwconfig_scan(char *iface) |
14730 |
+# |
14731 |
+# Fills 3 arrays with information from a wireless scan |
14732 |
+iwconfig_scan() { |
14733 |
+ local iface="$1" mode= x= ifvar=$(bash_variable "$1") |
14734 |
+ |
14735 |
+ # Set any private driver ioctls needed |
14736 |
+ x="iwpriv_scan_pre_${ifvar}" |
14737 |
+ if [[ -n ${!x} ]]; then |
14738 |
+ if ! eval iwpriv "${iface}" "${!x}" ; then |
14739 |
+ ewarn "${iface} does not support the following private ioctls" \ |
14740 |
+ ewarn " ${!x}" |
14741 |
+ fi |
14742 |
+ fi |
14743 |
+ |
14744 |
+ veinfo "Scanning for access points" |
14745 |
+ |
14746 |
+ # Sleep if required |
14747 |
+ x="sleep_scan_${ifvar}" |
14748 |
+ [[ -z ${!x} || ${!x} -gt 0 ]] && sleep "${!x:-1}" |
14749 |
+ |
14750 |
+ local error=true i=-1 line= |
14751 |
+ local -a mac=() essid=() enc=() qual=() mode=() freq=() chan=() |
14752 |
+ |
14753 |
+ while read line; do |
14754 |
+ error=false |
14755 |
+ case "${line}" in |
14756 |
+ *Address:*) |
14757 |
+ (( i++ )) |
14758 |
+ mac[i]=$(echo "${line#*: }" | tr '[:lower:]' '[:upper:]') |
14759 |
+ qual[i]=0 |
14760 |
+ ;; |
14761 |
+ *ESSID:*) |
14762 |
+ essid[i]="${line#*\"}" |
14763 |
+ essid[i]="${essid[i]%*\"}" |
14764 |
+ ;; |
14765 |
+ *Mode:*) |
14766 |
+ mode[i]=$(echo "${line#*:}" | tr '[:upper:]' '[:lower:]') |
14767 |
+ [[ ${mode[i]} == "master" ]] && mode[i]="managed" |
14768 |
+ ;; |
14769 |
+ *'Encryption key:'*) |
14770 |
+ enc[i]="${line#*:}" |
14771 |
+ ;; |
14772 |
+ *Frequency:*) |
14773 |
+ freq[i]="${line#*:}" |
14774 |
+ x="${freq[i]#* }" |
14775 |
+ freq[i]="${freq[i]%% *}${x:0:1}" |
14776 |
+ ;; |
14777 |
+ *Channel:*) |
14778 |
+ chan[i]="${line#*:}" |
14779 |
+ chan[i]="${chan[i]%% *}" |
14780 |
+ ;; |
14781 |
+ *Quality*) |
14782 |
+ qual[i]="${line#*:}" |
14783 |
+ qual[i]="${qual[i]%/*}" |
14784 |
+ qual[i]="${qual[i]//[![:digit:]]/}" |
14785 |
+ qual[i]="${qual[i]:-0}" |
14786 |
+ ;; |
14787 |
+ esac |
14788 |
+ done < <(iwlist "${iface}" scan 2>/dev/null) |
14789 |
+ |
14790 |
+ if ${error}; then |
14791 |
+ ewarn "${iface} does not support scanning" |
14792 |
+ x="adhoc_essid_${ifvar}" |
14793 |
+ [[ -n ${!x} ]] && return 0 |
14794 |
+ if [[ -n ${preferred_aps} ]]; then |
14795 |
+ [[ ${associate_order} == "forcepreferred" \ |
14796 |
+ || ${associate_order} == "forcepreferredonly" ]] && return 0 |
14797 |
+ fi |
14798 |
+ eerror "You either need to set a preferred_aps list in /etc/conf.d/wireless" |
14799 |
+ eerror " preferred_aps=( \"ESSID1\" \"ESSID2\" )" |
14800 |
+ eerror " and set associate_order_${iface}=\"forcepreferred\"" |
14801 |
+ eerror " or set associate_order_${iface}=\"forcepreferredonly\"" |
14802 |
+ eerror "or hardcode the ESSID to \"any\" and let the driver find an Access Point" |
14803 |
+ eerror " essid_${iface}=\"any\"" |
14804 |
+ eerror "or configure defaulting to Ad-Hoc when Managed fails" |
14805 |
+ eerror " adhoc_essid_${iface}=\"WLAN\"" |
14806 |
+ eerror "or hardcode the ESSID against the interface (not recommended)" |
14807 |
+ eerror " essid_${iface}=\"ESSID\"" |
14808 |
+ return 1 |
14809 |
+ fi |
14810 |
+ |
14811 |
+ # We may need to unset the previous private driver ioctls |
14812 |
+ x="iwpriv_scan_post_${ifvar}" |
14813 |
+ if [[ -n ${!x} ]]; then |
14814 |
+ if ! eval iwpriv "${iface}" "${!x}" ; then |
14815 |
+ ewarn "${iface} does not support the following private ioctls" \ |
14816 |
+ ewarn " ${!x}" |
14817 |
+ fi |
14818 |
+ fi |
14819 |
+ |
14820 |
+ # Strip any duplicates |
14821 |
+ local i= j= x="${#mac[@]}" y= |
14822 |
+ for (( i=0; i<x-1; i++ )) ; do |
14823 |
+ [[ -z ${mac[i]} ]] && continue |
14824 |
+ for (( j=i+1; j<x; j++)) ; do |
14825 |
+ if [[ ${mac[i]} == "${mac[j]}" ]] ; then |
14826 |
+ if [[ ${qual[i]} -gt ${qual[j]} ]] ; then |
14827 |
+ y="${j}" |
14828 |
+ else |
14829 |
+ y="${j}" |
14830 |
+ fi |
14831 |
+ unset mac[y] |
14832 |
+ unset qual[y] |
14833 |
+ unset essid[y] |
14834 |
+ unset mode[y] |
14835 |
+ unset enc[y] |
14836 |
+ unset freq[y] |
14837 |
+ unset chan[y] |
14838 |
+ fi |
14839 |
+ done |
14840 |
+ done |
14841 |
+ mac=( "${mac[@]}" ) |
14842 |
+ qual=( "${qual[@]}" ) |
14843 |
+ essid=( "${essid[@]}" ) |
14844 |
+ mode=( "${mode[@]}" ) |
14845 |
+ enc=( "${enc[@]}" ) |
14846 |
+ freq=( "${freq[@]}" ) |
14847 |
+ chan=( "${chan[@]}" ) |
14848 |
+ |
14849 |
+ for (( i=0; i<${#mac[@]}; i++ )); do |
14850 |
+ # Don't like ad-hoc nodes by default |
14851 |
+ [[ ${mode[i]} == "ad-hoc" ]] && (( qual[i]-=10000 )) |
14852 |
+ sortline="${sortline}${qual[i]} ${i}\n" |
14853 |
+ done |
14854 |
+ sortline=( $(echo -e "${sortline}" | sort -nr) ) |
14855 |
+ |
14856 |
+ for (( i=0; i<${#mac[@]}; i++ )); do |
14857 |
+ (( x=(i * 2) + 1 )) |
14858 |
+ mac_APs[i]="${mac[${sortline[x]}]}" |
14859 |
+ essid_APs[i]="${essid[${sortline[x]}]}" |
14860 |
+ mode_APs[i]="${mode[${sortline[x]}]}" |
14861 |
+ enc_APs[i]="${enc[${sortline[x]}]}" |
14862 |
+ freq_APs[i]="${freq[${sortline[x]}]}" |
14863 |
+ chan_APs[i]="${chan[${sortline[x]}]}" |
14864 |
+ done |
14865 |
+ |
14866 |
+ return 0 |
14867 |
+} |
14868 |
+ |
14869 |
+# void iwconfig_scan_report(void) |
14870 |
+# |
14871 |
+# Report the results of the scan and re-map any ESSIDs if they |
14872 |
+# have been configured for the MAC address found |
14873 |
+iwconfig_scan_report() { |
14874 |
+ local i= k= m= remove= |
14875 |
+ local -a u=() |
14876 |
+ |
14877 |
+ [[ -z ${mac_APs} ]] && ewarn " no access points found" |
14878 |
+ |
14879 |
+ # We need to do the for loop like this so we can |
14880 |
+ # dynamically remove from the array |
14881 |
+ eindent |
14882 |
+ for ((i=0; i<${#mac_APs[@]}; i++)); do |
14883 |
+ k="(${mode_APs[i]}" |
14884 |
+ [[ ${enc_APs[i]} != "off" ]] && k="${k}, encrypted" |
14885 |
+ k="${k})" |
14886 |
+ |
14887 |
+ if [[ -z ${essid_APs[i]} ]]; then |
14888 |
+ veinfo "Found ${mac_APs[i]} ${k}" |
14889 |
+ else |
14890 |
+ veinfo "Found \"${essid_APs[i]//\\\\/\\\\}\" at ${mac_APs[i]} ${k}" |
14891 |
+ fi |
14892 |
+ |
14893 |
+ eindent |
14894 |
+ |
14895 |
+ m="mac_essid_${mac_APs[i]//:/}" |
14896 |
+ if [[ -n ${!m} ]]; then |
14897 |
+ essid_APs[i]="${!m}" |
14898 |
+ veinfo "mapping to \"${!m//\\\\/\\\\}\"" |
14899 |
+ fi |
14900 |
+ |
14901 |
+ remove=false |
14902 |
+ # If we don't know the essid then we cannot connect to them |
14903 |
+ # so we remove them from our array |
14904 |
+ if [[ -z ${essid_APs[i]} ]]; then |
14905 |
+ remove=true |
14906 |
+ else |
14907 |
+ for k in "${blacklist_aps[@]}"; do |
14908 |
+ if [[ ${k} == "${essid_APs[i]}" ]]; then |
14909 |
+ vewarn "\"${k//\\\\/\\\\}\" has been blacklisted - not connecting" |
14910 |
+ remove=true |
14911 |
+ break |
14912 |
+ fi |
14913 |
+ done |
14914 |
+ fi |
14915 |
+ |
14916 |
+ eoutdent |
14917 |
+ |
14918 |
+ ${remove} && u=( "${u[@]}" "${i}" ) |
14919 |
+ done |
14920 |
+ |
14921 |
+ eoutdent |
14922 |
+ |
14923 |
+ # Now we remove any duplicates |
14924 |
+ for ((i=0; i < ${#essid_APs[@]} - 1; i++)); do |
14925 |
+ for ((j=${i} + 1; j <${#essid_APs[@]}; j++)); do |
14926 |
+ [[ ${essid_APs[i]} == "${essid_APs[j]}" ]] && u=( "${u[@]}" "${j}" ) |
14927 |
+ done |
14928 |
+ done |
14929 |
+ |
14930 |
+ for i in ${u[@]}; do |
14931 |
+ unset essid_APs[i] |
14932 |
+ unset mode_APs[i] |
14933 |
+ unset mac_APs[i] |
14934 |
+ unset enc_APs[i] |
14935 |
+ unset freq_APs[i] |
14936 |
+ unset chan_APs[i] |
14937 |
+ done |
14938 |
+ |
14939 |
+ # We need to squash our arrays so indexes work again |
14940 |
+ essid_APs=( "${essid_APs[@]}" ) |
14941 |
+ mode_APs=( "${mode_APs[@]}" ) |
14942 |
+ mac_APs=( "${mac_APs[@]}" ) |
14943 |
+ enc_APs=( "${enc_APs[@]}" ) |
14944 |
+ freq_APs=( "${freq_APs[@]}" ) |
14945 |
+ chan_APs=( "${chan_APs[@]}" ) |
14946 |
+} |
14947 |
+ |
14948 |
+# bool iwconfig_force_preferred(char *iface) |
14949 |
+# |
14950 |
+# Forces the preferred_aps list to associate in order |
14951 |
+# but only if they were not picked up by our scan |
14952 |
+iwconfig_force_preferred() { |
14953 |
+ local iface=$1 essid= i= |
14954 |
+ |
14955 |
+ [[ -z ${preferred_aps} ]] && return 1 |
14956 |
+ |
14957 |
+ ewarn "Trying to force preferred in case they are hidden" |
14958 |
+ for essid in "${preferred_aps[@]}"; do |
14959 |
+ local found_AP=false |
14960 |
+ for ((i = 0; i < ${#mac_APs[@]}; i++)); do |
14961 |
+ if [[ ${essid} == "${essid_APs[i]}" ]]; then |
14962 |
+ found_AP=true |
14963 |
+ break |
14964 |
+ fi |
14965 |
+ done |
14966 |
+ if ! ${found_AP} ; then |
14967 |
+ ESSID="${essid}" |
14968 |
+ iwconfig_associate "${iface}" && return 0 |
14969 |
+ fi |
14970 |
+ done |
14971 |
+ |
14972 |
+ ewarn "Failed to associate with any preferred access points on ${iface}" |
14973 |
+ return 1 |
14974 |
+} |
14975 |
+ |
14976 |
+# bool iwconfig_connect_preferred(char *iface) |
14977 |
+# |
14978 |
+# Connects to preferred_aps in order if they were picked up |
14979 |
+# by our scan |
14980 |
+iwconfig_connect_preferred() { |
14981 |
+ local iface="$1" essid= i= |
14982 |
+ |
14983 |
+ for essid in "${preferred_aps[@]}"; do |
14984 |
+ for ((i=0; i<${#essid_APs[@]}; i++)); do |
14985 |
+ if [[ ${essid} == "${essid_APs[i]}" ]]; then |
14986 |
+ ESSID="${essid}" |
14987 |
+ iwconfig_associate "${iface}" "${mode_APs[i]}" "${mac_APs[i]}" \ |
14988 |
+ "${enc_APs[i]}" "${freq_APs[i]}" "${chan_APs[i]}" && return 0 |
14989 |
+ break |
14990 |
+ fi |
14991 |
+ done |
14992 |
+ done |
14993 |
+ |
14994 |
+ return 1 |
14995 |
+} |
14996 |
+ |
14997 |
+# bool iwconfig_connect_not_preferred(char *iface) |
14998 |
+# |
14999 |
+# Connects to any AP's found that are not in |
15000 |
+# our preferred list |
15001 |
+iwconfig_connect_not_preferred() { |
15002 |
+ local iface=$1 i= ap= has_preferred= |
15003 |
+ |
15004 |
+ for ((i=0; i<${#mac_APs[@]}; i++)); do |
15005 |
+ has_preferred=false |
15006 |
+ for ap in "${preferred_aps[@]}"; do |
15007 |
+ if [[ ${ap} == "${essid_APs[i]}" ]]; then |
15008 |
+ has_preferred=true |
15009 |
+ break |
15010 |
+ fi |
15011 |
+ done |
15012 |
+ if ! ${has_preferred} ; then |
15013 |
+ ESSID="${essid_APs[i]}" |
15014 |
+ iwconfig_associate "${iface}" "${mode_APs[i]}" "${mac_APs[i]}" \ |
15015 |
+ "${enc_APs[i]}" "${freq_APs[i]}" "${chan_APs[i]}" && return 0 |
15016 |
+ fi |
15017 |
+ done |
15018 |
+ |
15019 |
+ return 1 |
15020 |
+} |
15021 |
+ |
15022 |
+# void iwconfig_defaults(char *iface) |
15023 |
+# |
15024 |
+# Apply some sane defaults to the wireless interface |
15025 |
+# incase the user already applied some changes |
15026 |
+iwconfig_defaults() { |
15027 |
+ local iface="$1" |
15028 |
+ |
15029 |
+ # Set some defaults |
15030 |
+ iwconfig "${iface}" txpower auto 2>/dev/null |
15031 |
+ iwconfig "${iface}" rate auto 2>/dev/null |
15032 |
+ iwconfig "${iface}" rts auto 2>/dev/null |
15033 |
+ iwconfig "${iface}" frag auto 2>/dev/null |
15034 |
+ |
15035 |
+ # Release the AP forced |
15036 |
+ # Must do ap and then essid otherwise scanning borks |
15037 |
+ iwconfig "${iface}" ap off 2>/dev/null |
15038 |
+ iwconfig "${iface}" essid off 2>/dev/null |
15039 |
+} |
15040 |
+ |
15041 |
+# void iwconfig_strip_associated(char *iface) |
15042 |
+# |
15043 |
+# We check to see which ifaces have associated AP's except for the iface |
15044 |
+# given and remove those AP's from the scan list |
15045 |
+# We also remove from the preferred list |
15046 |
+iwconfig_strip_associated() { |
15047 |
+ local iface="$1" e= a= j= |
15048 |
+ local essid=$(iwconfig_get_essid "${iface}") |
15049 |
+ local -a ifaces=( $( iwconfig 2>/dev/null | grep -o "^\w*" ) ) |
15050 |
+ |
15051 |
+ for i in "${ifaces[@]}"; do |
15052 |
+ [[ ${i} == ${iface} ]] && continue |
15053 |
+ interface_is_up "${i}" || continue |
15054 |
+ iwconfig_test_associated "${i}" || continue |
15055 |
+ e=$(iwconfig_get_essid "${i}") |
15056 |
+ local -a u=() |
15057 |
+ for ((j=0; j<${#mac_APs[@]}; j++)); do |
15058 |
+ if [[ ${essid_APs[j]} == "${e}" ]]; then |
15059 |
+ ewarn "${e} has already been associated with ${i}" |
15060 |
+ unset essid_APs[j] |
15061 |
+ unset mode_Aps[j] |
15062 |
+ unset mac_APs[j] |
15063 |
+ unset enc_APs[j] |
15064 |
+ unset freq_APs[j] |
15065 |
+ unset chan_APs[j] |
15066 |
+ # We need to squash our arrays so that indexes work |
15067 |
+ essid_APs=( "${essid_APs[@]}" ) |
15068 |
+ mode_APs=( "${mode_APs[@]}" ) |
15069 |
+ mac_APs=( "${mac_APs[@]}" ) |
15070 |
+ enc_APs=( "${enc_APs[@]}" ) |
15071 |
+ freq_APs=( "${freq_APs[@]}" ) |
15072 |
+ chan_APs=( "${chan_APs[@]}" ) |
15073 |
+ break |
15074 |
+ fi |
15075 |
+ done |
15076 |
+ for ((j=0; j<${#preferred_aps[@]}; j++)); do |
15077 |
+ if [[ ${preferred_aps[j]} == "${e}" ]]; then |
15078 |
+ unset preferred_aps[j] |
15079 |
+ preferred_aps=( "${preferred_aps[@]}" ) |
15080 |
+ break |
15081 |
+ fi |
15082 |
+ done |
15083 |
+ done |
15084 |
+} |
15085 |
+ |
15086 |
+# bool iwconfig_configure(char *iface) |
15087 |
+# |
15088 |
+# The main startup code |
15089 |
+# First we bring the interface up, apply defaults, apply user configuration |
15090 |
+# Then we test to see if ad-hoc mode has been requested and branch if needed |
15091 |
+# Then we scan for access points and try to connect to them in a predetermined order |
15092 |
+# Once we're connected we show a report and then configure any interface |
15093 |
+# variables for the ESSID |
15094 |
+iwconfig_configure() { |
15095 |
+ local iface="$1" e= x= ifvar=$(bash_variable "$1") |
15096 |
+ local -a essid_APs=() mac_APs=() mode_APs=() |
15097 |
+ local -a enc_APs=() freq_APs=() chan_APs=() |
15098 |
+ |
15099 |
+ ESSID="essid_${ifvar}" |
15100 |
+ ESSID="${!ESSID}" |
15101 |
+ |
15102 |
+ # Setup ad-hoc mode? |
15103 |
+ x="mode_${ifvar}" |
15104 |
+ x=$(echo "${!x:-managed}" | tr '[:upper:]' '[:lower:]') |
15105 |
+ if [[ ${x} == "ad-hoc" || ${x} == "master" ]]; then |
15106 |
+ iwconfig_setup_specific "${iface}" "${x}" |
15107 |
+ return $? |
15108 |
+ fi |
15109 |
+ |
15110 |
+ if [[ ${x} != "managed" && ${x} != "auto" ]]; then |
15111 |
+ eerror "Only managed, ad-hoc, master and auto modes are supported" |
15112 |
+ return 1 |
15113 |
+ fi |
15114 |
+ |
15115 |
+ # Has an ESSID been forced? |
15116 |
+ if [[ -n ${ESSID} ]]; then |
15117 |
+ iwconfig_set_mode "${iface}" "${x}" |
15118 |
+ iwconfig_associate "${iface}" && return 0 |
15119 |
+ [[ ${ESSID} == "any" ]] && iwconfig_force_preferred "${iface}" && return 0 |
15120 |
+ |
15121 |
+ ESSID="adhoc_essid_${ifvar}" |
15122 |
+ ESSID="${!ESSID}" |
15123 |
+ if [[ -n ${ESSID} ]]; then |
15124 |
+ iwconfig_setup_specific "${iface}" ad-hoc |
15125 |
+ return $? |
15126 |
+ fi |
15127 |
+ return 1 |
15128 |
+ fi |
15129 |
+ |
15130 |
+ # Do we have a preferred Access Point list specific to the interface? |
15131 |
+ x="preferred_aps_${ifvar}[@]" |
15132 |
+ [[ -n ${!x} ]] && preferred_aps=( "${!x}" ) |
15133 |
+ |
15134 |
+ # Do we have a blacklist Access Point list specific to the interface? |
15135 |
+ x="blacklist_aps_${ifvar}[@]" |
15136 |
+ [[ -n ${!x} ]] && blacklist_aps=( "${!x}" ) |
15137 |
+ |
15138 |
+ # Are we forcing preferred only? |
15139 |
+ x="associate_order_${ifvar}" |
15140 |
+ [[ -n ${!x} ]] && associate_order="${!x}" |
15141 |
+ associate_order=$(echo "${associate_order:-any}" \ |
15142 |
+ | tr '[:upper:]' '[:lower:]') |
15143 |
+ |
15144 |
+ if [[ ${associate_order} == "forcepreferredonly" ]]; then |
15145 |
+ iwconfig_force_preferred "${iface}" && return 0 |
15146 |
+ else |
15147 |
+ iwconfig_scan "${iface}" || return 1 |
15148 |
+ iwconfig_scan_report |
15149 |
+ |
15150 |
+ # Strip AP's from the list that have already been associated with |
15151 |
+ # other wireless cards in the system if requested |
15152 |
+ x="unique_ap_${ifvar}" |
15153 |
+ [[ -n ${!x} ]] && unique_ap="${!x}" |
15154 |
+ unique_ap=$(echo "${unique_ap:-no}" | tr '[:upper:]' '[:lower:]') |
15155 |
+ [[ ${unique_ap} != "no" ]] && iwconfig_strip_associated "${iface}" |
15156 |
+ |
15157 |
+ iwconfig_connect_preferred "${iface}" && return 0 |
15158 |
+ [[ ${associate_order} == "forcepreferred" \ |
15159 |
+ || ${associate_order} == "forceany" ]] \ |
15160 |
+ && iwconfig_force_preferred "${iface}" && return 0 |
15161 |
+ [[ ${associate_order} == "any" || ${associate_order} == "forceany" ]] \ |
15162 |
+ && iwconfig_connect_not_preferred "${iface}" && return 0 |
15163 |
+ fi |
15164 |
+ |
15165 |
+ e="associate with" |
15166 |
+ [[ -z ${mac_APs} ]] && e="find" |
15167 |
+ [[ ${preferred_only} == "force" || ${preferred_aps} == "forceonly" ]] \ |
15168 |
+ && e="force" |
15169 |
+ e="Couldn't ${e} any access points on ${iface}" |
15170 |
+ |
15171 |
+ ESSID="adhoc_essid_${ifvar}" |
15172 |
+ ESSID="${!ESSID}" |
15173 |
+ if [[ -n ${ESSID} ]]; then |
15174 |
+ ewarn "${e}" |
15175 |
+ iwconfig_setup_specific "${iface}" ad-hoc |
15176 |
+ return $? |
15177 |
+ fi |
15178 |
+ |
15179 |
+ eerror "${e}" |
15180 |
+ return 1 |
15181 |
+} |
15182 |
+ |
15183 |
+# bool iwconfig_pre_start(char *iface) |
15184 |
+# |
15185 |
+# Start entry point |
15186 |
+# First we check if wireless extensions exist on the interface |
15187 |
+# If they are then we configue wireless |
15188 |
+iwconfig_pre_start() { |
15189 |
+ local iface="$1" r=0 |
15190 |
+ |
15191 |
+ # We don't configure wireless if we're being called from |
15192 |
+ # the background |
15193 |
+ ${IN_BACKGROUND} && return 0 |
15194 |
+ |
15195 |
+ save_options "ESSID" "" |
15196 |
+ interface_exists "${iface}" || return 0 |
15197 |
+ |
15198 |
+ # We need to bring the interface up, as some cards do not register |
15199 |
+ # in /proc/wireless until they are brought up. |
15200 |
+ interface_up "${iface}" |
15201 |
+ |
15202 |
+ if ! iwconfig_exists "${iface}" ; then |
15203 |
+ veinfo "Wireless extensions not found for ${iface}" |
15204 |
+ return 0 |
15205 |
+ fi |
15206 |
+ |
15207 |
+ iwconfig_defaults "${iface}" |
15208 |
+ iwconfig_user_config "${iface}" |
15209 |
+ |
15210 |
+ # Set the base metric to be 2000 |
15211 |
+ metric=2000 |
15212 |
+ |
15213 |
+ # Check for rf_kill - only ipw supports this at present, but other |
15214 |
+ # cards may in the future. |
15215 |
+ if [[ -e "/sys/class/net/${iface}/device/rf_kill" ]]; then |
15216 |
+ if [[ $( < "/sys/class/net/${iface}/device/rf_kill" ) != 0 ]]; then |
15217 |
+ eerror "Wireless radio has been killed for interface ${iface}" |
15218 |
+ return 1 |
15219 |
+ fi |
15220 |
+ fi |
15221 |
+ |
15222 |
+ einfo "Configuring wireless network for ${iface}" |
15223 |
+ |
15224 |
+ # Are we a proper IEEE device? |
15225 |
+ # Most devices reutrn IEEE 802.11b/g - but intel cards return IEEE |
15226 |
+ # in lower case and RA cards return RAPCI or similar |
15227 |
+ # which really sucks :( |
15228 |
+ # For the time being, we will test prism54 not loading firmware |
15229 |
+ # which reports NOT READY! |
15230 |
+ x=$(iwconfig_get_type "${iface}") |
15231 |
+ if [[ ${x} == "NOT READY!" ]]; then |
15232 |
+ eerror "Looks like there was a probem loading the firmware for ${iface}" |
15233 |
+ return 1 |
15234 |
+ fi |
15235 |
+ |
15236 |
+ # Setup IFS incase parent script has modified it |
15237 |
+ local IFS=$' '$'\n'$'\t' |
15238 |
+ |
15239 |
+ if iwconfig_configure "${iface}" ; then |
15240 |
+ save_options "ESSID" "${ESSID}" |
15241 |
+ return 0 |
15242 |
+ fi |
15243 |
+ |
15244 |
+ eerror "Failed to configure wireless for ${iface}" |
15245 |
+ iwconfig_defaults "${iface}" |
15246 |
+ iwconfig "${iface}" txpower off 2>/dev/null |
15247 |
+ unset ESSID ESSIDVAR |
15248 |
+ interface_down "${iface}" |
15249 |
+ return 1 |
15250 |
+} |
15251 |
+ |
15252 |
+iwconfig_post_stop() { |
15253 |
+ ${IN_BACKGROUND} && return 0 |
15254 |
+ interface_exists "${iface}" || return 0 |
15255 |
+ iwconfig_defaults "${iface}" |
15256 |
+ iwconfig "${iface}" txpower off 2>/dev/null |
15257 |
+} |
15258 |
+ |
15259 |
+# vim: set ts=4 : |
15260 |
|
15261 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/macchanger.sh |
15262 |
=================================================================== |
15263 |
--- trunk/baselayout-prefix/lib/rcscripts/net/macchanger.sh (rev 0) |
15264 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/macchanger.sh 2011-03-31 14:11:17 UTC (rev 1682) |
15265 |
@@ -0,0 +1,102 @@ |
15266 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
15267 |
+# Distributed under the terms of the GNU General Public License v2 |
15268 |
+# Contributed by Roy Marples (uberlord@g.o) |
15269 |
+ |
15270 |
+# void macchanger_depend(void) |
15271 |
+# |
15272 |
+# Sets up the dependancies for the module |
15273 |
+macchanger_depend() { |
15274 |
+ before macnet |
15275 |
+ functions interface_get_mac_address interface_set_mac_address |
15276 |
+} |
15277 |
+ |
15278 |
+# void macchanger_expose(void) |
15279 |
+# |
15280 |
+# Expose variables that can be configured |
15281 |
+macchanger_expose() { |
15282 |
+ variables mac |
15283 |
+} |
15284 |
+ |
15285 |
+# bool macchanger_pre_start(char *iface) |
15286 |
+# |
15287 |
+# Configures the MAC address for iface |
15288 |
+macchanger_pre_start() { |
15289 |
+ # We don't change MAC addresses from background |
15290 |
+ ${IN_BACKGROUND} && return 0 |
15291 |
+ |
15292 |
+ local iface="$1" mac= opts= ifvar=$(bash_variable "$1") |
15293 |
+ |
15294 |
+ mac="mac_${ifvar}" |
15295 |
+ [[ -z ${!mac} ]] && return 0 |
15296 |
+ |
15297 |
+ interface_exists "${iface}" true || return 1 |
15298 |
+ |
15299 |
+ ebegin "Changing MAC address of ${iface}" |
15300 |
+ |
15301 |
+ # The interface needs to be up for macchanger to work most of the time |
15302 |
+ interface_down "${iface}" |
15303 |
+ |
15304 |
+ mac=$(echo "${!mac}" | tr '[:upper:]' '[:lower:]') |
15305 |
+ case "${mac}" in |
15306 |
+ # specific mac-addr, i wish there were a shorter way to specify this |
15307 |
+ [0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]:[0-9a-f][0-9a-f]) |
15308 |
+ # We don't need macchanger to change to a specific mac address |
15309 |
+ interface_set_mac_address "${iface}" "${mac}" |
15310 |
+ eend "$?" |
15311 |
+ if [[ $? == "0" ]] ; then |
15312 |
+ mac=$(interface_get_mac_address "${iface}") |
15313 |
+ eindent |
15314 |
+ einfo "changed to ${mac}" |
15315 |
+ eoutdent |
15316 |
+ return 0 |
15317 |
+ fi |
15318 |
+ ;; |
15319 |
+ |
15320 |
+ # increment MAC address, default macchanger behavior |
15321 |
+ increment) opts="${opts}" ;; |
15322 |
+ |
15323 |
+ # randomize just the ending bytes |
15324 |
+ random-ending) opts="${opts} -e" ;; |
15325 |
+ |
15326 |
+ # keep the same kind of physical layer (eg fibre, copper) |
15327 |
+ random-samekind) opts="${opts} -a" ;; |
15328 |
+ |
15329 |
+ # randomize to any known vendor of any physical layer type |
15330 |
+ random-anykind) opts="${opts} -A" ;; |
15331 |
+ |
15332 |
+ # fully random bytes |
15333 |
+ random-full) opts="${opts} -r" ;; |
15334 |
+ |
15335 |
+ # default case is just to pass on all the options |
15336 |
+ *) opts="${opts} ${mac}" ;; |
15337 |
+ esac |
15338 |
+ |
15339 |
+ if [[ ! -x /sbin/macchanger ]] ; then |
15340 |
+ eerror "For changing MAC addresses, emerge net-analyzer/macchanger" |
15341 |
+ return 1 |
15342 |
+ fi |
15343 |
+ |
15344 |
+ mac=$(/sbin/macchanger ${opts} "${iface}" \ |
15345 |
+ | sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' ) |
15346 |
+ |
15347 |
+ # Sometimes the interface needs to be up .... |
15348 |
+ if [[ -z ${mac} ]] ; then |
15349 |
+ interface_up "${iface}" |
15350 |
+ mac=$(/sbin/macchanger ${opts} "${iface}" \ |
15351 |
+ | sed -n -e 's/^Faked MAC:.*\<\(..:..:..:..:..:..\)\>.*/\U\1/p' ) |
15352 |
+ fi |
15353 |
+ |
15354 |
+ if [[ -z ${mac} ]] ; then |
15355 |
+ eend 1 "Failed to set MAC address" |
15356 |
+ return 1 |
15357 |
+ fi |
15358 |
+ |
15359 |
+ eend 0 |
15360 |
+ eindent |
15361 |
+ einfo "changed to ${mac}" |
15362 |
+ eoutdent |
15363 |
+ |
15364 |
+ return 0 #important |
15365 |
+} |
15366 |
+ |
15367 |
+# vim: set ts=4 : |
15368 |
|
15369 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/macnet.sh |
15370 |
=================================================================== |
15371 |
--- trunk/baselayout-prefix/lib/rcscripts/net/macnet.sh (rev 0) |
15372 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/macnet.sh 2011-03-31 14:11:17 UTC (rev 1682) |
15373 |
@@ -0,0 +1,43 @@ |
15374 |
+# Copyright (c) 2005-2006 Gentoo Foundation |
15375 |
+# Distributed under the terms of the GNU General Public License v2 |
15376 |
+# Contributed by Roy Marples (uberlord@g.o) |
15377 |
+# Many thanks to all the people in the Gentoo forums for their ideas and |
15378 |
+# motivation for me to make this and keep on improving it |
15379 |
+ |
15380 |
+# void macnet_depend(void) |
15381 |
+# |
15382 |
+# Sets up the dependancies for the module |
15383 |
+macnet_depend() { |
15384 |
+ before rename interface wireless |
15385 |
+ after macchanger |
15386 |
+ installed macchanger |
15387 |
+ functions interface_get_mac_address |
15388 |
+} |
15389 |
+ |
15390 |
+# bool macnet_start(char *iface) |
15391 |
+# |
15392 |
+# All interfaces and module scripts can depend on the variables function |
15393 |
+# which returns a space seperated list of user configuration variables |
15394 |
+# We can override each variable here from a given MAC address of the interface |
15395 |
+# Always returns 0 |
15396 |
+macnet_pre_start() { |
15397 |
+ local iface="$1" |
15398 |
+ |
15399 |
+ interface_exists "${iface}" || return 0 |
15400 |
+ |
15401 |
+ # We need to bring the interface up for some interfaces, otherwise the MAC |
15402 |
+ # address isn't consistent - mainly wireless cards with firmware uploading. |
15403 |
+ interface_up "${iface}" |
15404 |
+ |
15405 |
+ local mac=$(interface_get_mac_address "${iface}") |
15406 |
+ [[ -z ${mac} ]] && return 0 |
15407 |
+ |
15408 |
+ vebegin "Configuring ${iface} for MAC address ${mac}" 2>/dev/null |
15409 |
+ mac="${mac//:/}" |
15410 |
+ configure_variables "${iface}" "${mac}" |
15411 |
+ veend 0 2>/dev/null |
15412 |
+ |
15413 |
+ return 0 |
15414 |
+} |
15415 |
+ |
15416 |
+# vim: set ts=4 : |
15417 |
|
15418 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/netplugd.sh |
15419 |
=================================================================== |
15420 |
--- trunk/baselayout-prefix/lib/rcscripts/net/netplugd.sh (rev 0) |
15421 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/netplugd.sh 2011-03-31 14:11:17 UTC (rev 1682) |
15422 |
@@ -0,0 +1,125 @@ |
15423 |
+# Copyright (c) 2005-2006 Gentoo Foundation |
15424 |
+# Distributed under the terms of the GNU General Public License v2 |
15425 |
+# Contributed by Roy Marples (uberlord@g.o) |
15426 |
+ |
15427 |
+# void netplugd_depend(void) |
15428 |
+# |
15429 |
+# Sets up the dependancies for the module |
15430 |
+netplugd_depend() { |
15431 |
+ after macnet rename |
15432 |
+ before interface |
15433 |
+ provide plug |
15434 |
+ functions interface_exists interface_get_mac_address |
15435 |
+} |
15436 |
+ |
15437 |
+# void netplugd_expose(void) |
15438 |
+# |
15439 |
+# Expose variables that can be configured |
15440 |
+netplugd_expose() { |
15441 |
+ variables plug_timeout |
15442 |
+} |
15443 |
+ |
15444 |
+# bool netplugd_check_installed(void) |
15445 |
+# |
15446 |
+# Returns 0 if netplug is installed, otherwise 1 |
15447 |
+netplugd_check_installed() { |
15448 |
+ if [[ ! -x /sbin/netplugd ]]; then |
15449 |
+ ${1:-false} && eerror "For netplug support, emerge sys-apps/netplug" |
15450 |
+ return 1 |
15451 |
+ fi |
15452 |
+ return 0 |
15453 |
+} |
15454 |
+ |
15455 |
+# bool netplugd_pre_start(char *interface) |
15456 |
+# |
15457 |
+# Start netplug on an interface |
15458 |
+netplugd_pre_start() { |
15459 |
+ local iface="$1" timeout= |
15460 |
+ local pidfile="/var/run/netplugd.${iface}.pid" |
15461 |
+ local opts="netplugd_$(bash_variable "${iface}")" |
15462 |
+ |
15463 |
+ # We don't start netplug if we're being called from the background |
15464 |
+ ${IN_BACKGROUND} && return 0 |
15465 |
+ |
15466 |
+ interface_exists "${iface}" || return 0 |
15467 |
+ |
15468 |
+ # We need a valid MAC address |
15469 |
+ # It's a basic test to ensure it's not a virtual interface |
15470 |
+ local mac=$(interface_get_mac_address "${iface}") |
15471 |
+ if [[ -z ${mac} ]] ; then |
15472 |
+ vewarn "netplug only works on interfaces with a valid MAC address" |
15473 |
+ return 0 |
15474 |
+ fi |
15475 |
+ |
15476 |
+ # We don't work on bonded, bridges, tun/tap, vlan or wireless |
15477 |
+ for f in bonding bridge tuntap vlan wireless ; do |
15478 |
+ if is_function "${f}_exists" ; then |
15479 |
+ if ${f}_exists "${iface}" ; then |
15480 |
+ veinfo "netplug does not work with ${f}" |
15481 |
+ return 0 |
15482 |
+ fi |
15483 |
+ fi |
15484 |
+ done |
15485 |
+ |
15486 |
+ ebegin "Starting netplug on ${iface}" |
15487 |
+ |
15488 |
+ # We need the interface up for netplug to listen to netlink events |
15489 |
+ interface_up "${iface}" |
15490 |
+ |
15491 |
+ # Mark the us as inactive so netplug can restart us |
15492 |
+ mark_service_inactive "net.${iface}" |
15493 |
+ |
15494 |
+ # Start netplug |
15495 |
+ start-stop-daemon --start --exec /sbin/netplugd \ |
15496 |
+ --pidfile "${pidfile}" \ |
15497 |
+ -- ${!opts} -i "${iface}" -P -p "${pidfile}" -c /dev/null |
15498 |
+ eend "$?" || return 1 |
15499 |
+ |
15500 |
+ eindent |
15501 |
+ |
15502 |
+ timeout="plug_timeout_${ifvar}" |
15503 |
+ timeout="${!timeout:--1}" |
15504 |
+ if [[ ${timeout} == "0" ]] ; then |
15505 |
+ ewarn "WARNING: infinite timeout set for ${iface} to come up" |
15506 |
+ elif [[ ${timeout} -lt 0 ]] ; then |
15507 |
+ einfo "Backgrounding ..." |
15508 |
+ exit 0 |
15509 |
+ fi |
15510 |
+ |
15511 |
+ veinfo "Waiting for ${iface} to be marked as started" |
15512 |
+ |
15513 |
+ local i=0 |
15514 |
+ while true ; do |
15515 |
+ if service_started "net.${iface}" ; then |
15516 |
+ local addr=$(interface_get_address "${iface}") |
15517 |
+ einfo "${iface} configured with address ${addr}" |
15518 |
+ exit 0 |
15519 |
+ fi |
15520 |
+ sleep 1 |
15521 |
+ [[ ${timeout} == "0" ]] && continue |
15522 |
+ (( i++ )) |
15523 |
+ [[ ${i} == "${timeout}" || ${i} -gt "${timeout}" ]] && break |
15524 |
+ done |
15525 |
+ |
15526 |
+ eend 1 "Failed to configure ${iface} in the background" |
15527 |
+ exit 0 |
15528 |
+} |
15529 |
+ |
15530 |
+# bool netplugd_stop(char *iface) |
15531 |
+# |
15532 |
+# Stops netplug on an interface |
15533 |
+# Returns 0 (true) when successful, non-zero otherwise |
15534 |
+netplugd_stop() { |
15535 |
+ ${IN_BACKGROUND} && return 0 |
15536 |
+ local iface="$1" |
15537 |
+ local pidfile="/var/run/netplugd.${iface}.pid" |
15538 |
+ |
15539 |
+ [[ ! -e ${pidfile} ]] && return 0 |
15540 |
+ |
15541 |
+ ebegin "Stopping netplug on ${iface}" |
15542 |
+ start-stop-daemon --stop --exec /sbin/netplugd \ |
15543 |
+ --pidfile "${pidfile}" |
15544 |
+ eend $? |
15545 |
+} |
15546 |
+ |
15547 |
+# vim: set ts=4 : |
15548 |
|
15549 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/pppd.sh |
15550 |
=================================================================== |
15551 |
--- trunk/baselayout-prefix/lib/rcscripts/net/pppd.sh (rev 0) |
15552 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/pppd.sh 2011-03-31 14:11:17 UTC (rev 1682) |
15553 |
@@ -0,0 +1,235 @@ |
15554 |
+# Copyright (c) 2005-2006 Gentoo Foundation |
15555 |
+# Distributed under the terms of the GNU General Public License v2 |
15556 |
+ |
15557 |
+# Contributed by Alin Nastac (mrness@g.o) |
15558 |
+ |
15559 |
+# void pppd_depend(void) |
15560 |
+# |
15561 |
+# Sets up the dependancies for the module |
15562 |
+pppd_depend() { |
15563 |
+ after interface |
15564 |
+ before dhcp |
15565 |
+ provide ppp |
15566 |
+} |
15567 |
+ |
15568 |
+# bool pppd_check_installed(void) |
15569 |
+# |
15570 |
+# Returns 1 if pppd is installed, otherwise 0 |
15571 |
+pppd_check_installed() { |
15572 |
+ if [[ ! -x /usr/sbin/pppd ]] ; then |
15573 |
+ ${1:-false} && eerror "For PPP support, emerge net-dialup/ppp" |
15574 |
+ return 1 |
15575 |
+ fi |
15576 |
+ return 0 |
15577 |
+} |
15578 |
+ |
15579 |
+# bool pppd_exists(char *interface) |
15580 |
+# |
15581 |
+# Returns 0 if the interface is ppp controlled, otherwise 1 |
15582 |
+pppd_exists() { |
15583 |
+ [[ -e /var/run/ppp-$1.pid ]] |
15584 |
+} |
15585 |
+ |
15586 |
+# bool pppd_start(char *iface) |
15587 |
+# |
15588 |
+# Start PPP on an interface by calling pppd |
15589 |
+# |
15590 |
+# Returns 0 (true) when successful, otherwise 1 |
15591 |
+pppd_start() { |
15592 |
+ ${IN_BACKGROUND} && return 0 |
15593 |
+ |
15594 |
+ local iface="$1" ifvar=$(bash_variable "$1") opts= link= i= |
15595 |
+ if [[ ${iface%%[0-9]*} != "ppp" ]] ; then |
15596 |
+ eerror "PPP can only be invoked from net.ppp[0-9]" |
15597 |
+ return 1 |
15598 |
+ fi |
15599 |
+ |
15600 |
+ local unit="${iface#ppp}" |
15601 |
+ if [[ -z ${unit} ]] ; then |
15602 |
+ eerror "PPP requires a unit - use net.ppp[0-9] instead of net.ppp" |
15603 |
+ return 1 |
15604 |
+ fi |
15605 |
+ |
15606 |
+ # PPP requires a link to communicate over - normally a serial port |
15607 |
+ # PPPoE communicates over Ethernet |
15608 |
+ # PPPoA communicates over ATM |
15609 |
+ # In all cases, the link needs to be available before we start PPP |
15610 |
+ link="link_${ifvar}" |
15611 |
+ if [[ -z ${!link} ]] ; then |
15612 |
+ eerror "${link} has not been set in /etc/conf.d/net" |
15613 |
+ return 1 |
15614 |
+ fi |
15615 |
+ |
15616 |
+ if [[ ${!link} == "/"* && ! -e ${!link} ]] ; then |
15617 |
+ eerror "${link} does not exist" |
15618 |
+ eerror "Please verify hardware or kernel module (driver)" |
15619 |
+ return 1 |
15620 |
+ fi |
15621 |
+ |
15622 |
+ # Load any commandline options |
15623 |
+ opts="pppd_${ifvar}[@]" |
15624 |
+ opts="${!opts}" |
15625 |
+ |
15626 |
+ # We don't work with these options set by the user |
15627 |
+ for i in unit nodetach linkname ; do |
15628 |
+ if [[ " ${opts} " == *" ${i} "* ]] ; then |
15629 |
+ eerror "The option \"${i}\" is not allowed in pppd_${ifvar}" |
15630 |
+ return 1 |
15631 |
+ fi |
15632 |
+ done |
15633 |
+ |
15634 |
+ # Might be set in conf.d/net |
15635 |
+ local username= password= |
15636 |
+ username="username_${ifvar}" |
15637 |
+ password="password_${ifvar}" |
15638 |
+ if [[ -n ${!username} ]] \ |
15639 |
+ && [[ -n ${!password} || -z ${!password-x} ]] ; then |
15640 |
+ local fd=3 |
15641 |
+ # fd 3 maybe in use, so find another one |
15642 |
+ while [[ -e /proc/$$/fd/${fd} ]] ; do |
15643 |
+ ((fd++)) |
15644 |
+ # Don't use fd 5 |
15645 |
+ [[ ${fd} == 5 ]] && ((fd++)) |
15646 |
+ done |
15647 |
+ |
15648 |
+ password="${!password//\\/\\\\}" |
15649 |
+ password="${password//\"/\\\"}" |
15650 |
+ opts="${opts} plugin passwordfd.so passwordfd ${fd}" |
15651 |
+ eval exec "${fd}< <(echo -e -n \"${password}\")" |
15652 |
+ fi |
15653 |
+ |
15654 |
+ # Check for mtu/mru |
15655 |
+ local mtu="mtu_${ifvar}" |
15656 |
+ if [[ -n ${!mtu} ]] ; then |
15657 |
+ [[ " ${opts} " != *" mtu "* ]] && opts="${opts} mtu ${!mtu}" |
15658 |
+ [[ " ${opts} " != *" mru "* ]] && opts="${opts} mru ${!mtu}" |
15659 |
+ fi |
15660 |
+ |
15661 |
+ # Set linkname because we need /var/run/ppp-${linkname}.pid |
15662 |
+ # This pidfile has the advantage of being there, even if ${iface} interface was never started |
15663 |
+ opts="linkname ${iface} ${opts}" |
15664 |
+ |
15665 |
+ # Setup auth info |
15666 |
+ [[ -n ${!username} ]] && opts="user '"${!username}"' ${opts}" |
15667 |
+ opts="remotename ${iface} ${opts}" |
15668 |
+ |
15669 |
+ # Load a custom interface configuration file if it exists |
15670 |
+ [[ -f "/etc/ppp/options.${iface}" ]] \ |
15671 |
+ && opts="${opts} file /etc/ppp/options.${iface}" |
15672 |
+ |
15673 |
+ # Set unit |
15674 |
+ opts="unit ${unit} ${opts}" |
15675 |
+ |
15676 |
+ # Default maxfail to 0 unless specified |
15677 |
+ [[ " ${opts} " != *" maxfail "* ]] && opts="${opts} maxfail 0" |
15678 |
+ |
15679 |
+ # Append persist |
15680 |
+ [[ " ${opts} " != *" persist "* ]] && opts="${opts} persist" |
15681 |
+ |
15682 |
+ # Setup connect script |
15683 |
+ local chat="chat_${ifvar}[@]" |
15684 |
+ if [[ -n "${!chat}" ]] ; then |
15685 |
+ local chatopts="/usr/sbin/chat -e -E -v" |
15686 |
+ local -a phone_number="phone_number_${ifvar}[@]" |
15687 |
+ phone_number=( "${!phone_number}" ) |
15688 |
+ if [[ ${#phone_number[@]} -ge 1 ]] ; then |
15689 |
+ chatopts="${chatopts} -T '${phone_number[0]}'" |
15690 |
+ if [[ ${#phone_number[@]} -ge 2 ]] ; then |
15691 |
+ chatopts="${chatopts} -U '${phone_number[1]}'" |
15692 |
+ fi |
15693 |
+ fi |
15694 |
+ opts="${opts} connect $(requote "${chatopts} $(requote "${!chat}")")" # " |
15695 |
+ fi |
15696 |
+ |
15697 |
+ # Add plugins |
15698 |
+ local plugins="plugins_${ifvar}[@]" |
15699 |
+ for i in "${!plugins}" ; do |
15700 |
+ local -a plugin=( ${i} ) |
15701 |
+ # Bound to be some users who do this |
15702 |
+ [[ ${plugin[0]} == "passwordfd" ]] && continue # Disable |
15703 |
+ [[ ${plugin[0]} == "pppoe" ]] && plugin[0]="rp-pppoe" |
15704 |
+ [[ ${plugin[0]} == "pppoa" ]] && plugin[0]="pppoatm" |
15705 |
+ [[ ${plugin[0]} == "capi" ]] && plugin[0]="capiplugin" |
15706 |
+ |
15707 |
+ if [[ ${plugin[0]} == "rp-pppoe" || ( ${plugin[0]} == "pppoatm" && ${!link} != '/dev/null' ) ]] ; then |
15708 |
+ opts="${opts} connect true plugin ${plugin[0]}.so ${plugin[@]:1} ${!link}" |
15709 |
+ else |
15710 |
+ opts="${opts} plugin ${plugin[0]}.so ${plugin[@]:1}" |
15711 |
+ fi |
15712 |
+ done |
15713 |
+ |
15714 |
+ #Specialized stuff. Insert here actions particular to connection type (pppoe,pppoa,capi) |
15715 |
+ local insert_link_in_opts=1 |
15716 |
+ if [[ " ${opts} " == *" plugin rp-pppoe.so "* ]] ; then |
15717 |
+ if [[ ! -e /proc/net/pppoe ]] ; then |
15718 |
+ # Load the PPPoE kernel module |
15719 |
+ if ! modprobe pppoe ; then |
15720 |
+ eerror "kernel does not support PPPoE" |
15721 |
+ return 1 |
15722 |
+ fi |
15723 |
+ fi |
15724 |
+ |
15725 |
+ # Ensure that the link exists and is up |
15726 |
+ interface_exists "${!link}" true || return 1 |
15727 |
+ interface_up "${!link}" |
15728 |
+ |
15729 |
+ insert_link_in_opts=0 |
15730 |
+ fi |
15731 |
+ |
15732 |
+ if [[ " ${opts} " == *" plugin pppoatm.so "* ]] ; then |
15733 |
+ if [[ ${!link} =~ '^[ \t]*([1-9]*[0-9]\.){1,2}[1-9]*[0-9][ \t]*$' ]] ; then |
15734 |
+ insert_link_in_opts=0 |
15735 |
+ else |
15736 |
+ ewarn "WARNING: An [itf.]vpi.vci ATM address was expected in ${link}" |
15737 |
+ fi |
15738 |
+ |
15739 |
+ if [[ ! -d /proc/net/atm ]] ; then |
15740 |
+ # Load the PPPoA kernel module |
15741 |
+ if ! modprobe pppoatm ; then |
15742 |
+ eerror "kernel does not support PPPoATM" |
15743 |
+ return 1 |
15744 |
+ fi |
15745 |
+ fi |
15746 |
+ fi |
15747 |
+ [[ ${insert_link_in_opts} -eq 0 ]] || opts="${!link} ${opts}" |
15748 |
+ |
15749 |
+ ebegin "Running pppd" |
15750 |
+ mark_service_inactive "net.${iface}" |
15751 |
+ eval start-stop-daemon --start --exec /usr/sbin/pppd \ |
15752 |
+ --pidfile "/var/run/ppp-${iface}.pid" -- "${opts}" >/dev/null |
15753 |
+ |
15754 |
+ if [[ $? != "0" ]] ; then |
15755 |
+ eend $? "Failed to start PPP" |
15756 |
+ mark_service_starting "net.${iface}" |
15757 |
+ return $? |
15758 |
+ fi |
15759 |
+ |
15760 |
+ if [[ " ${opts} " == *" updetach "* ]] ; then |
15761 |
+ local addr=$(interface_get_address "${iface}") |
15762 |
+ einfo "${iface} received address ${addr}" |
15763 |
+ else |
15764 |
+ einfo "Backgrounding ..." |
15765 |
+ fi |
15766 |
+ |
15767 |
+ # pppd will re-call us when we bring the interface up |
15768 |
+ exit 0 |
15769 |
+} |
15770 |
+ |
15771 |
+# bool pppd_stop(char *iface) |
15772 |
+# |
15773 |
+# Stop PPP link by killing the associated pppd process |
15774 |
+# |
15775 |
+# Returns 0 (true) if no process to kill or it terminates successfully, |
15776 |
+# otherwise non-zero (false) |
15777 |
+pppd_stop() { |
15778 |
+ ${IN_BACKGROUND} && return 0 |
15779 |
+ local iface="$1" pidfile="/var/run/ppp-$1.pid" |
15780 |
+ |
15781 |
+ [[ ! -s ${pidfile} ]] && return 0 |
15782 |
+ |
15783 |
+ einfo "Stopping pppd on ${iface}" |
15784 |
+ start-stop-daemon --stop --exec /usr/sbin/pppd --pidfile "${pidfile}" |
15785 |
+ eend $? |
15786 |
+} |
15787 |
+ |
15788 |
+# vim: set ts=4 : |
15789 |
|
15790 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/pump.sh |
15791 |
=================================================================== |
15792 |
--- trunk/baselayout-prefix/lib/rcscripts/net/pump.sh (rev 0) |
15793 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/pump.sh 2011-03-31 14:11:17 UTC (rev 1682) |
15794 |
@@ -0,0 +1,102 @@ |
15795 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
15796 |
+# Distributed under the terms of the GNU General Public License v2 |
15797 |
+# Contributed by Roy Marples (uberlord@g.o) |
15798 |
+ |
15799 |
+# Fix any potential localisation problems |
15800 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
15801 |
+pump() { |
15802 |
+ LC_ALL=C /sbin/pump "$@" |
15803 |
+} |
15804 |
+ |
15805 |
+# void pump_depend(void) |
15806 |
+# |
15807 |
+# Sets up the dependancies for the module |
15808 |
+pump_depend() { |
15809 |
+ after interface |
15810 |
+ provide dhcp |
15811 |
+ functions interface_exists interface_get_address |
15812 |
+} |
15813 |
+ |
15814 |
+# void pump_expose(void) |
15815 |
+# |
15816 |
+# Expose variables that can be configured |
15817 |
+pump_expose() { |
15818 |
+ variables pump dhcp |
15819 |
+} |
15820 |
+ |
15821 |
+# bool pump_check_installed(void) |
15822 |
+# |
15823 |
+# Returns 1 if pump is installed, otherwise 0 |
15824 |
+pump_check_installed() { |
15825 |
+ [[ -x /sbin/pump ]] && return 0 |
15826 |
+ ${1:-false} && eerror "For DHCP (pump) support, emerge net-misc/pump" |
15827 |
+ return 1 |
15828 |
+} |
15829 |
+ |
15830 |
+# bool pump_stop(char *iface) |
15831 |
+# |
15832 |
+# Stop pump on an interface |
15833 |
+# Return 0 if pump is not running or we stop it successfully |
15834 |
+# Otherwise 1 |
15835 |
+pump_stop() { |
15836 |
+ local iface="$1" count= e= |
15837 |
+ |
15838 |
+ # We check for a pump process first as querying for status |
15839 |
+ # causes pump to spawn a process |
15840 |
+ pidof /sbin/pump &>/dev/null || return 0 |
15841 |
+ |
15842 |
+ # Check that pump is running on the interface |
15843 |
+ pump --status --interface "${iface}" 2>/dev/null \ |
15844 |
+ | grep -q "^Device ${iface}" || return 0 |
15845 |
+ |
15846 |
+ # Pump always releases the lease |
15847 |
+ ebegin "Stopping pump on ${iface}" |
15848 |
+ pump --release --interface "${iface}" |
15849 |
+ eend $? "Failed to stop pump" |
15850 |
+} |
15851 |
+ |
15852 |
+# bool pump_start(char *iface) |
15853 |
+# |
15854 |
+# Start pump on an interface by calling pumpcd $iface $options |
15855 |
+# |
15856 |
+# Returns 0 (true) when a dhcp address is obtained, otherwise |
15857 |
+# the return value from pump |
15858 |
+pump_start() { |
15859 |
+ local iface="$1" opts= d= ifvar=$(bash_variable "$1") search= |
15860 |
+ |
15861 |
+ interface_exists "${iface}" true || return 1 |
15862 |
+ |
15863 |
+ opts="pump_${ifvar}" |
15864 |
+ opts="${!opts} ${pump}" |
15865 |
+ |
15866 |
+ # Map some generic options to pump |
15867 |
+ d="dhcp_${ifvar}" |
15868 |
+ d=" ${!d} " |
15869 |
+ [[ ${d} == " " ]] && d=" ${dhcp} " |
15870 |
+ [[ ${d} == *" nodns "* ]] && opts="${opts} --no-dns" |
15871 |
+ [[ ${d} == *" nogateway "* ]] && opts="${opts} --no-gateway" |
15872 |
+ [[ ${d} == *" nontp "* ]] && opts="${opts} --no-ntp" |
15873 |
+ |
15874 |
+ search="dns_search_${ifvar}" |
15875 |
+ [[ -n ${!search} ]] && opts="${opts} --search-path='"${!search}"'" |
15876 |
+ |
15877 |
+ # Add our route metric |
15878 |
+ metric="metric_${ifvar}" |
15879 |
+ [[ -n ${!metric} ]] && opts="${opts} --route-metric ${!metric}" |
15880 |
+ |
15881 |
+ opts="${opts} --win-client-ident" |
15882 |
+ opts="${opts} --keep-up --interface ${iface}" |
15883 |
+ |
15884 |
+ # Bring up DHCP for this interface (or alias) |
15885 |
+ ebegin "Running pump" |
15886 |
+ eval pump "${opts}" |
15887 |
+ eend $? || return $? |
15888 |
+ |
15889 |
+ # pump succeeded, show address retrieved |
15890 |
+ local addr=$(interface_get_address "${iface}") |
15891 |
+ einfo "${iface} received address ${addr}" |
15892 |
+ |
15893 |
+ return 0 |
15894 |
+} |
15895 |
+ |
15896 |
+# vim: set ts=4 : |
15897 |
|
15898 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/rename.sh |
15899 |
=================================================================== |
15900 |
--- trunk/baselayout-prefix/lib/rcscripts/net/rename.sh (rev 0) |
15901 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/rename.sh 2011-03-31 14:11:17 UTC (rev 1682) |
15902 |
@@ -0,0 +1,62 @@ |
15903 |
+# Copyright (c) 2005-2006 Gentoo Foundation |
15904 |
+# Distributed under the terms of the GNU General Public License v2 |
15905 |
+# Contributed by Roy Marples (uberlord@g.o) |
15906 |
+ |
15907 |
+# void rename_depend(void) |
15908 |
+# |
15909 |
+# Sets up the dependancies for the module |
15910 |
+rename_depend() { |
15911 |
+ after macchanger |
15912 |
+ before wireless interface |
15913 |
+ functions interface_exists interface_down interface_del_addresses |
15914 |
+} |
15915 |
+ |
15916 |
+# void rename_expose(void) |
15917 |
+# |
15918 |
+# Expose variables that can be configured |
15919 |
+rename_expose() { |
15920 |
+ variables rename |
15921 |
+} |
15922 |
+ |
15923 |
+# bool rename_pre_start(char *iface) |
15924 |
+# |
15925 |
+# Checks to see if we have to rename the interface |
15926 |
+rename_pre_start() { |
15927 |
+ local iface="$1" newname= mac= ifvar=$(bash_variable "$1") |
15928 |
+ interface_exists "${iface}" || return 0 |
15929 |
+ |
15930 |
+ newname="rename_${ifvar}" |
15931 |
+ [[ -z ${!newname} || ${iface} == "${!newname}" ]] && return 0 |
15932 |
+ |
15933 |
+ # We cannot rename vlan interfaces as /proc/net/vlan/config always |
15934 |
+ # returns the old interface name. We don't bail out though as it's |
15935 |
+ # not critical that the interface gets renamed. |
15936 |
+ if [[ -d /proc/net/vlan/config ]] ; then |
15937 |
+ if grep -q "^${iface} " /proc/net/vlan/config ; then |
15938 |
+ eerror "Cannot rename VLAN interfaces" |
15939 |
+ return 0 |
15940 |
+ fi |
15941 |
+ fi |
15942 |
+ |
15943 |
+ ebegin "Renaming \"${iface}\" to \"${!newname}\"" |
15944 |
+ |
15945 |
+ # Ensure that we have an init script |
15946 |
+ [[ ! -e "/etc/init.d/net.${!newname}" ]] \ |
15947 |
+ && ( cd /etc/init.d ; ln -s net.lo "net.${!newname}" ) |
15948 |
+ |
15949 |
+ # Ensure that the interface is down and without any addresses or we |
15950 |
+ # will not work |
15951 |
+ interface_del_addresses "${iface}" |
15952 |
+ interface_down "${iface}" |
15953 |
+ interface_set_name "${iface}" "${!newname}" |
15954 |
+ eend $? "Failed to rename interface" || return 1 |
15955 |
+ |
15956 |
+ # Mark us as stopped, start the new interface and bail cleanly |
15957 |
+ mark_service_stopped "net.${iface}" |
15958 |
+ einfo "Stopped configuration of ${iface} due to renaming" |
15959 |
+ service_stopped "net.${!newname}" && start_service "net.${!newname}" |
15960 |
+ |
15961 |
+ exit 1 |
15962 |
+} |
15963 |
+ |
15964 |
+# vim: set ts=4 : |
15965 |
|
15966 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/system.sh |
15967 |
=================================================================== |
15968 |
--- trunk/baselayout-prefix/lib/rcscripts/net/system.sh (rev 0) |
15969 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/system.sh 2011-03-31 14:11:17 UTC (rev 1682) |
15970 |
@@ -0,0 +1,125 @@ |
15971 |
+# Copyright (c) 2005-2006 Gentoo Foundation |
15972 |
+# Distributed under the terms of the GNU General Public License v2 |
15973 |
+# Contributed by Roy Marples (uberlord@g.o) |
15974 |
+ |
15975 |
+# void system_depend(void) |
15976 |
+# |
15977 |
+# Sets up the dependancies for the module |
15978 |
+system_depend() { |
15979 |
+ after interface |
15980 |
+ before dhcp |
15981 |
+} |
15982 |
+ |
15983 |
+# void system_expose(void) |
15984 |
+# |
15985 |
+# Expose variables that can be configured |
15986 |
+system_expose() { |
15987 |
+ variables dns_servers dns_domain dns_options dns_search dns_sortlist \ |
15988 |
+ ntp_servers nis_domain nis_servers |
15989 |
+} |
15990 |
+ |
15991 |
+system_dns() { |
15992 |
+ local iface="$1" ifvar=$(bash_variable "$1") x= domain= search= |
15993 |
+ local buffer= |
15994 |
+ local -a servers=() |
15995 |
+ |
15996 |
+ servers="dns_servers_${ifvar}[@]" |
15997 |
+ [[ -z ${!servers} ]] && servers="dns_servers[@]" |
15998 |
+ |
15999 |
+ domain="dns_domain_${ifvar}" |
16000 |
+ [[ -z ${!domain} ]] && domain="dns_domain" |
16001 |
+ |
16002 |
+ search="dns_search_${ifvar}" |
16003 |
+ [[ -z ${!search} ]] && search="dns_search" |
16004 |
+ |
16005 |
+ [[ -z ${!servers} && -z ${!domain} && -z ${!search} ]] && return 0 |
16006 |
+ |
16007 |
+ buffer="# Generated by net-scripts for interface ${iface}\n" |
16008 |
+ [[ -n ${!domain} ]] && buffer="${buffer}domain ${!domain}\n" |
16009 |
+ [[ -n ${!search} ]] && buffer="${buffer}search ${!search}\n" |
16010 |
+ |
16011 |
+ for x in ${!servers} ; do |
16012 |
+ buffer="${buffer}nameserver ${x}\n" |
16013 |
+ done |
16014 |
+ |
16015 |
+ # Support resolvconf if we have it. |
16016 |
+ if [[ -x /sbin/resolvconf ]] ; then |
16017 |
+ echo -e "${buffer}" | resolvconf -a "${iface}" |
16018 |
+ else |
16019 |
+ echo -e "${buffer}" > /etc/resolv.conf |
16020 |
+ chmod 644 /etc/resolv.conf |
16021 |
+ fi |
16022 |
+} |
16023 |
+ |
16024 |
+system_ntp() { |
16025 |
+ local iface="$1" ifvar=$(bash_variable "$1") x= buffer= |
16026 |
+ local -a servers=() |
16027 |
+ |
16028 |
+ servers="ntp_servers_${ifvar}[@]" |
16029 |
+ [[ -z ${!servers} ]] && servers="ntp_servers[@]" |
16030 |
+ [[ -z ${!servers} ]] && return 0 |
16031 |
+ |
16032 |
+ buffer="# Generated by net-scripts for interface ${iface}\n" |
16033 |
+ buffer="${buffer}restrict default noquery notrust nomodify\n" |
16034 |
+ buffer="${buffer}restrict 127.0.0.1\n" |
16035 |
+ |
16036 |
+ for x in ${!servers} ; do |
16037 |
+ buffer="${buffer}restrict ${x} nomodify notrap noquery\n" |
16038 |
+ buffer="${buffer}server ${x}\n" |
16039 |
+ done |
16040 |
+ |
16041 |
+ buffer="${buffer}driftfile /var/lib/ntp/ntp.drift\n" |
16042 |
+ buffer="${buffer}logfile /var/log/ntp.log\n" |
16043 |
+ |
16044 |
+ echo -e "${buffer}" > /etc/ntp.conf |
16045 |
+ chmod 644 /etc/ntp.conf |
16046 |
+} |
16047 |
+ |
16048 |
+system_nis() { |
16049 |
+ local iface="$1" ifvar=$(bash_variable "$1") domain= x= buffer= |
16050 |
+ local -a servers=() |
16051 |
+ |
16052 |
+ servers="nis_servers_${ifvar}[@]" |
16053 |
+ [[ -z ${!servers} ]] && servers="nis_servers[@]" |
16054 |
+ |
16055 |
+ domain="nis_domain_${ifvar}" |
16056 |
+ [[ -z ${!domain} ]] && domain="nis_domain" |
16057 |
+ |
16058 |
+ [[ -z ${!servers} && -z ${!domain} ]] && return 0 |
16059 |
+ |
16060 |
+ buffer="# Generated by net-scripts for interface ${iface}\n" |
16061 |
+ |
16062 |
+ if [[ -n ${!domain} ]] ; then |
16063 |
+ hostname -y "${!domain}" |
16064 |
+ if [[ -n ${!servers} ]] ; then |
16065 |
+ for x in ${!servers} ; do |
16066 |
+ buffer="${buffer}domain ${!domain} server ${x}\n" |
16067 |
+ done |
16068 |
+ else |
16069 |
+ buffer="${buffer}domain ${!domain} broadcast\n" |
16070 |
+ fi |
16071 |
+ else |
16072 |
+ for x in ${!servers} ; do |
16073 |
+ buffer="${buffer}ypserver ${x}\n" |
16074 |
+ done |
16075 |
+ fi |
16076 |
+ |
16077 |
+ echo -e "${buffer}" > /etc/yp.conf |
16078 |
+ chmod 644 /etc/yp.conf |
16079 |
+} |
16080 |
+ |
16081 |
+# bool system_post_start(char *iface) |
16082 |
+# |
16083 |
+# Configures the host system for dns, ntp and nis information |
16084 |
+# Always returns 0 |
16085 |
+system_pre_start() { |
16086 |
+ local iface="$1" |
16087 |
+ |
16088 |
+ system_dns "${iface}" |
16089 |
+ system_ntp "${iface}" |
16090 |
+ system_nis "${iface}" |
16091 |
+ |
16092 |
+ return 0 |
16093 |
+} |
16094 |
+ |
16095 |
+# vim: set ts=4 : |
16096 |
|
16097 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/tuntap.sh |
16098 |
=================================================================== |
16099 |
--- trunk/baselayout-prefix/lib/rcscripts/net/tuntap.sh (rev 0) |
16100 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/tuntap.sh 2011-03-31 14:11:17 UTC (rev 1682) |
16101 |
@@ -0,0 +1,99 @@ |
16102 |
+#!/bin/bash |
16103 |
+# Copyright (c) 2004-2005 Gentoo Foundation |
16104 |
+# Distributed under the terms of the GNU General Public License v2 |
16105 |
+ |
16106 |
+# Contributed by Roy Marples (uberlord@g.o) |
16107 |
+ |
16108 |
+# Fix any potential localisation problems |
16109 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
16110 |
+openvpn() { |
16111 |
+ LC_ALL=C /usr/sbin/openvpn "$@" |
16112 |
+} |
16113 |
+tunctl() { |
16114 |
+ LC_ALL=C /usr/bin/tunctl "$@" |
16115 |
+} |
16116 |
+ |
16117 |
+# void tuntap_depend(void) |
16118 |
+# |
16119 |
+# Sets up the dependancies for the module |
16120 |
+tuntap_depend() { |
16121 |
+ before interface macchanger |
16122 |
+ functions interface_exists interface_type |
16123 |
+ variables tunctl |
16124 |
+} |
16125 |
+ |
16126 |
+# bool tuntap_check_installed(void) |
16127 |
+# |
16128 |
+# Returns 1 if tuntap is installed, otherwise 0 |
16129 |
+tuntap_check_installed() { |
16130 |
+ [[ -x /usr/sbin/openvpn ]] && return 0 |
16131 |
+ [[ -x /usr/bin/tunctl ]] && return 0 |
16132 |
+ ${1:-false} && eerror "For TunTap support, emerge net-misc/openvpn or sys-apps/usermode-utilities" |
16133 |
+ return 1 |
16134 |
+} |
16135 |
+ |
16136 |
+# bool tuntap_check_kernel(void) |
16137 |
+# |
16138 |
+# Checks to see if the tun is present - if not try and load it |
16139 |
+# Returns 1 if there is a problem |
16140 |
+tuntap_check_kernel() { |
16141 |
+ [[ -a /dev/net/tun ]] && return 0 |
16142 |
+ /sbin/modprobe tun && sleep 1 |
16143 |
+ [[ -a /dev/net/tun ]] && return 0 |
16144 |
+ eerror "TUN/TAP support is not present in this kernel" |
16145 |
+ return 1 |
16146 |
+} |
16147 |
+ |
16148 |
+# bool tuntap_exists(char *interface) |
16149 |
+# |
16150 |
+# Returns 0 if the tun/tap interface exists, otherwise 1 |
16151 |
+tuntap_exists() { |
16152 |
+ [[ -n $(get_options tuntap "net.$1") ]] |
16153 |
+} |
16154 |
+ |
16155 |
+# bool tuntap_pre_start(char *iface) |
16156 |
+# |
16157 |
+# Create the device, give it the right perms |
16158 |
+tuntap_pre_start() { |
16159 |
+ local iface="$1" ifvar=$(bash_variable "$1") |
16160 |
+ local tuntap="tuntap_${ifvar}" |
16161 |
+ |
16162 |
+ [[ -z ${!tuntap} ]] && return 0 |
16163 |
+ tuntap_check_kernel || return 1 |
16164 |
+ |
16165 |
+ ebegin "Creating Tun/Tap interface ${iface}" |
16166 |
+ |
16167 |
+ # Set the base metric to 1000 |
16168 |
+ metric=1000 |
16169 |
+ |
16170 |
+ if [[ -x /usr/sbin/openvpn ]] ; then |
16171 |
+ openvpn --mktun --dev-type "${!tuntap}" --dev "${iface}" \ |
16172 |
+ > /dev/null |
16173 |
+ else |
16174 |
+ local opts="tunctl_${ifvar}" |
16175 |
+ tunctl ${!opts} -t "${iface}" >/dev/null |
16176 |
+ fi |
16177 |
+ eend $? && save_options tuntap "${!tuntap}" |
16178 |
+} |
16179 |
+ |
16180 |
+# bool tuntap_stop(char *iface) |
16181 |
+# |
16182 |
+# Removes the device |
16183 |
+tuntap_stop() { |
16184 |
+ local iface="$1" |
16185 |
+ |
16186 |
+ tuntap_check_installed || return 0 |
16187 |
+ tuntap_exists "${iface}" || return 0 |
16188 |
+ |
16189 |
+ ebegin "Destroying Tun/Tap interface ${iface}" |
16190 |
+ if [[ -x /usr/sbin/openvpn ]] ; then |
16191 |
+ openvpn --rmtun \ |
16192 |
+ --dev-type "$(get_options tuntap)" \ |
16193 |
+ --dev "${iface}" > /dev/null |
16194 |
+ else |
16195 |
+ tunctl -d "${fiace}" >/dev/null |
16196 |
+ fi |
16197 |
+ eend $? |
16198 |
+} |
16199 |
+ |
16200 |
+# vim:ts=4 |
16201 |
|
16202 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/udhcpc.sh |
16203 |
=================================================================== |
16204 |
--- trunk/baselayout-prefix/lib/rcscripts/net/udhcpc.sh (rev 0) |
16205 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/udhcpc.sh 2011-03-31 14:11:17 UTC (rev 1682) |
16206 |
@@ -0,0 +1,147 @@ |
16207 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
16208 |
+# Distributed under the terms of the GNU General Public License v2 |
16209 |
+# Contributed by Roy Marples (uberlord@g.o) |
16210 |
+ |
16211 |
+# Fix any potential localisation problems |
16212 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
16213 |
+udhcpc() { |
16214 |
+ LC_ALL=C /sbin/udhcpc "$@" |
16215 |
+} |
16216 |
+ |
16217 |
+# void udhcpc_depend(void) |
16218 |
+# |
16219 |
+# Sets up the dependancies for the module |
16220 |
+udhcpc_depend() { |
16221 |
+ after interface |
16222 |
+ provide dhcp |
16223 |
+ functions interface_exists interface_get_address |
16224 |
+} |
16225 |
+ |
16226 |
+# void udhcpc_expose(void) |
16227 |
+# |
16228 |
+# Expose variables that can be configured |
16229 |
+udhcpc_expose() { |
16230 |
+ variables udhcpc dhcp |
16231 |
+} |
16232 |
+ |
16233 |
+# bool udhcpc_check_installed(void) |
16234 |
+# |
16235 |
+# Returns 1 if udhcpc is installed, otherwise 0 |
16236 |
+udhcpc_check_installed() { |
16237 |
+ [[ -x /sbin/udhcpc ]] && return 0 |
16238 |
+ ${1:-false} && eerror "For DHCP (udhcpc) support, emerge net-misc/udhcp" |
16239 |
+ return 1 |
16240 |
+} |
16241 |
+ |
16242 |
+# bool udhcpc_stop(char *iface) |
16243 |
+# |
16244 |
+# Stops udhcpc running on an interface |
16245 |
+# Return 1 if we fail to stop udhcpc (if it's running) otherwise 0 |
16246 |
+udhcpc_stop() { |
16247 |
+ local iface="$1" pidfile="/var/run/udhcpc-$1.pid" d= |
16248 |
+ |
16249 |
+ [[ ! -f ${pidfile} ]] && return 0 |
16250 |
+ |
16251 |
+ ebegin "Stopping udhcpc on ${iface}" |
16252 |
+ local pid=$(<"${pidfile}") e=true |
16253 |
+ |
16254 |
+ local ifvar=$(bash_variable "${iface}") |
16255 |
+ d="dhcp_${ifvar}" |
16256 |
+ [[ -z ${!d} ]] && d="dhcp" |
16257 |
+ |
16258 |
+ if [[ " ${!d} " == *" release "* ]]; then |
16259 |
+ kill -s USR2 "${pid}" &>/dev/null |
16260 |
+ [[ -f "/var/cache/udhcpc-${iface}.lease" ]] \ |
16261 |
+ && rm "/var/cache/udhcpc-${iface}.lease" |
16262 |
+ fi |
16263 |
+ |
16264 |
+ start-stop-daemon --stop --exec /sbin/udhcpc --pidfile "${pidfile}" |
16265 |
+ eend $? || return 1 |
16266 |
+ |
16267 |
+ [[ -e /var/run/udhcpc-"${iface}".conf ]] \ |
16268 |
+ && rm -f /var/run/udhcpc-"${iface}".conf |
16269 |
+ return 0 |
16270 |
+} |
16271 |
+ |
16272 |
+# bool udhcpc_start(char *iface) |
16273 |
+# |
16274 |
+# Start DHCP on an interface by calling udhcpc $iface $options |
16275 |
+# |
16276 |
+# Returns 0 (true) when a DHCP address is obtained, otherwise 1 |
16277 |
+udhcpc_start() { |
16278 |
+ local iface="$1" opts= pidfile="/var/run/udhcpc-$1.pid" |
16279 |
+ local cachefile="/var/cache/udhcpc-$1.lease" d |
16280 |
+ |
16281 |
+ interface_exists "${iface}" true || return 1 |
16282 |
+ |
16283 |
+ local ifvar=$(bash_variable "${iface}" ) opts= |
16284 |
+ opts="udhcpc_${ifvar} ${udhcpc}" |
16285 |
+ opts="${!opts}" |
16286 |
+ |
16287 |
+ d="dhcp_${ifvar}" |
16288 |
+ [[ -z ${!d} ]] && d="dhcp" |
16289 |
+ |
16290 |
+ if [[ " ${!d} " != *" nosendhost "* ]]; then |
16291 |
+ if [[ ! " ${opts}" =~ " -([hH] |-hostname=)" ]]; then |
16292 |
+ local hname=$(hostname) |
16293 |
+ [[ -n ${hname} && ${hname} != "(none)" && ${hname} != "localhost" ]] \ |
16294 |
+ && opts="${opts} --hostname=${hname}" |
16295 |
+ fi |
16296 |
+ fi |
16297 |
+ |
16298 |
+ # Setup options for the udhcpc script |
16299 |
+ # This requires a specfic Gentoo patch to udhcp which will not be |
16300 |
+ # accepted upstream. |
16301 |
+ if [[ " ${!d} " == *" nogateway "* ]] ; then |
16302 |
+ opts="${opts} --env PEER_ROUTERS=no" |
16303 |
+ else |
16304 |
+ opts="${opts} --env PEER_ROUTERS=yes" |
16305 |
+ fi |
16306 |
+ if [[ " ${!d} " == *" nodns "* ]] ; then |
16307 |
+ opts="${opts} --env PEER_DNS=no" |
16308 |
+ else |
16309 |
+ opts="${opts} --env PEER_DNS=yes" |
16310 |
+ fi |
16311 |
+ if [[ " ${!d} " == *" nontp "* ]] ; then |
16312 |
+ opts="${opts} --env PEER_NTP=no" |
16313 |
+ else |
16314 |
+ opts="${opts} --env PEER_NTP=yes" |
16315 |
+ fi |
16316 |
+ local metric="metric_${ifvar}" |
16317 |
+ if [[ -n ${!metric} ]] ; then |
16318 |
+ opts="${opts} --env IF_METRIC=${!metric}" |
16319 |
+ fi |
16320 |
+ |
16321 |
+ # Bring up DHCP for this interface (or alias) |
16322 |
+ ebegin "Running udhcpc" |
16323 |
+ |
16324 |
+ # Try and load the cache if it exists |
16325 |
+ if [[ -f ${cachefile} ]]; then |
16326 |
+ if [[ " ${opts}" != *" --request="* && " ${opts} " != *" -r "* ]]; then |
16327 |
+ local x=$(<"${cachefile}") |
16328 |
+ # Check for a valid ip |
16329 |
+ [[ ${x} == *.*.*.* ]] && opts="${opts} --request=${x}" |
16330 |
+ fi |
16331 |
+ fi |
16332 |
+ |
16333 |
+ # Don't use s-s-d if the user wants to quit on lease. |
16334 |
+ if [[ " ${opts} " == *" -q "* || " ${opts} " == *" --quit "* ]]; then |
16335 |
+ x="/sbin/udhcpc" |
16336 |
+ else |
16337 |
+ x="start-stop-daemon --start --exec /sbin/udhcpc \ |
16338 |
+ --pidfile \"${pidfile}\" --" |
16339 |
+ fi |
16340 |
+ |
16341 |
+ eval "${x}" "${opts}" --interface="${iface}" --now \ |
16342 |
+ --script=/lib/rcscripts/sh/udhcpc.sh \ |
16343 |
+ --pidfile="${pidfile}" >/dev/null |
16344 |
+ eend $? || return 1 |
16345 |
+ |
16346 |
+ # DHCP succeeded, show address retrieved |
16347 |
+ local addr=$(interface_get_address "${iface}") |
16348 |
+ einfo "${iface} received address ${addr}" |
16349 |
+ |
16350 |
+ return 0 |
16351 |
+} |
16352 |
+ |
16353 |
+# vim: set ts=4 : |
16354 |
|
16355 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/vlan.sh |
16356 |
=================================================================== |
16357 |
--- trunk/baselayout-prefix/lib/rcscripts/net/vlan.sh (rev 0) |
16358 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/vlan.sh 2011-03-31 14:11:17 UTC (rev 1682) |
16359 |
@@ -0,0 +1,162 @@ |
16360 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
16361 |
+# Distributed under the terms of the GNU General Public License v2 |
16362 |
+# Contributed by Roy Marples (uberlord@g.o) |
16363 |
+ |
16364 |
+# Fix any potential localisation problems |
16365 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
16366 |
+vconfig() { |
16367 |
+ LC_ALL=C /sbin/vconfig "$@" |
16368 |
+} |
16369 |
+ |
16370 |
+# void vlan_depend(void) |
16371 |
+# |
16372 |
+# Sets up the dependancies for the module |
16373 |
+vlan_depend() { |
16374 |
+ after interface |
16375 |
+ before dhcp |
16376 |
+ functions iface_start iface_stop |
16377 |
+} |
16378 |
+ |
16379 |
+# void vlan_expose(void) |
16380 |
+# |
16381 |
+# Expose variables that can be configured |
16382 |
+vlan_expose() { |
16383 |
+ variables vlans |
16384 |
+} |
16385 |
+ |
16386 |
+# bool vlan_check_installed(void) |
16387 |
+# |
16388 |
+# Returns 0 if vconfig is installed, otherwise 1 |
16389 |
+vlan_check_installed() { |
16390 |
+ [[ -x /sbin/vconfig ]] && return 0 |
16391 |
+ ${1:-false} && eerror "For VLAN (802.1q) support, emerge net-misc/vconfig" |
16392 |
+ return 1 |
16393 |
+} |
16394 |
+ |
16395 |
+# bool vlan_exists(char *interface) |
16396 |
+# |
16397 |
+# Returns 0 if the interface is a vlan, otherwise 1 |
16398 |
+vlan_exists() { |
16399 |
+ [[ ! -d /proc/net/vlan ]] && return 1 |
16400 |
+ egrep -q "^$1[[:space:]]+" /proc/net/vlan/config |
16401 |
+} |
16402 |
+ |
16403 |
+# char* vlan_get_vlans(char *interface) |
16404 |
+# |
16405 |
+# Fetch the configured vlans for an interface. Outputs a space |
16406 |
+# separated list on stdout. For example "eth0.1 eth0.2 eth0.3" |
16407 |
+vlan_get_vlans() { |
16408 |
+ sed -n -e 's/^\(.*[0-9]\) \(.* \) .*'"$1"'$/\1/p' \ |
16409 |
+ /proc/net/vlan/config 2>/dev/null |
16410 |
+} |
16411 |
+ |
16412 |
+# bool vlan_check_kernel(void) |
16413 |
+# |
16414 |
+# Checks to see if the 802.1q module is present - if not try and load it |
16415 |
+# Returns 1 if there is a problem |
16416 |
+vlan_check_kernel() { |
16417 |
+ [[ -d /proc/net/vlan ]] && return 0 |
16418 |
+ /sbin/modprobe 8021q &>/dev/null |
16419 |
+ [[ -d /proc/net/vlan ]] && return 0 |
16420 |
+ eerror "VLAN (802.1q) support is not present in this kernel" |
16421 |
+ return 1 |
16422 |
+} |
16423 |
+ |
16424 |
+#bool vlan_pre_start(char *iface) |
16425 |
+# |
16426 |
+# Setup vconfig |
16427 |
+vlan_pre_start() { |
16428 |
+ local iface="$1" opts= i= x= e= ifvar=$(bash_variable "$1") |
16429 |
+ |
16430 |
+ opts="vconfig_${ifvar}[@]" |
16431 |
+ [[ -z ${!opts} ]] && return 0 |
16432 |
+ opts=( "${!opts}" ) |
16433 |
+ |
16434 |
+ vlan_check_kernel || return 1 |
16435 |
+ interface_exists "${iface}" || return 1 |
16436 |
+ |
16437 |
+ for (( i=0; i<${#opts[@]}; i++ )) ; do |
16438 |
+ if [[ ${opts[i]} == "set_name_type "* ]]; then |
16439 |
+ x="${opts[i]}" |
16440 |
+ else |
16441 |
+ x="${opts[i]/ / ${iface} }" |
16442 |
+ [[ ${x} == "${opts[i]}" ]] && x="${x} ${iface}" |
16443 |
+ fi |
16444 |
+ e=$(vconfig ${x} 2>&1 1>/dev/null) |
16445 |
+ [[ -z ${e} ]] && continue |
16446 |
+ eerror "vconfig ${x}" |
16447 |
+ eerror "${e}" |
16448 |
+ return 1 |
16449 |
+ done |
16450 |
+ |
16451 |
+ return 0 |
16452 |
+} |
16453 |
+ |
16454 |
+# bool vlan_post_start(char *iface) |
16455 |
+# |
16456 |
+# Starts VLANs for a given interface |
16457 |
+# |
16458 |
+# Always returns 0 (true) |
16459 |
+vlan_post_start() { |
16460 |
+ local iface="$1" ifvar=$(bash_variable "$1") |
16461 |
+ local vlan= vlans= vlans_old= ifname= vlans="vlans_${ifvar}[@]" |
16462 |
+ local start="vlan_start_${ifvar}" |
16463 |
+ |
16464 |
+ # BACKWARD COMPATIBILITY: check for old vlan variable name |
16465 |
+ vlans_old="iface_${ifvar}_vlans" |
16466 |
+ [[ -n ${!vlans_old} && -z ${!vlans} ]] && vlans="vlans_old" |
16467 |
+ |
16468 |
+ [[ -z ${!vlans} ]] && return 0 |
16469 |
+ |
16470 |
+ vlan_check_kernel || return 1 |
16471 |
+ interface_exists "${iface}" true || return 1 |
16472 |
+ |
16473 |
+ # Start vlans for this interface |
16474 |
+ for vlan in ${!vlans} ; do |
16475 |
+ einfo "Adding VLAN ${vlan} to ${iface}" |
16476 |
+ e=$(vconfig add "${iface}" "${vlan}" 2>&1 1>/dev/null) |
16477 |
+ if [[ -n ${e} ]] ; then |
16478 |
+ eend 1 "${e}" |
16479 |
+ continue |
16480 |
+ fi |
16481 |
+ eend 0 |
16482 |
+ |
16483 |
+ # We may not want to start the vlan ourselves, but |
16484 |
+ # as a seperate init script. This allows the vlan to be |
16485 |
+ # renamed if needed. |
16486 |
+ [[ -n ${!start} && ${!start} != "yes" ]] && continue |
16487 |
+ |
16488 |
+ # We need to work out the interface name of our new vlan id |
16489 |
+ ifname=$( \ |
16490 |
+ sed -n -e 's/^\([^ \t]*\) *| '"${vlan}"' *| .*'"${iface}"'$/\1/p' \ |
16491 |
+ /proc/net/vlan/config |
16492 |
+ ) |
16493 |
+ mark_service_started "net.${ifname}" |
16494 |
+ iface_start "${ifname}" || mark_service_stopped "net.${ifname}" |
16495 |
+ done |
16496 |
+ |
16497 |
+ return 0 |
16498 |
+} |
16499 |
+ |
16500 |
+# bool vlan_stop(char *iface) |
16501 |
+# |
16502 |
+# Stops VLANs for a given interface |
16503 |
+# |
16504 |
+# Always returns 0 (true) |
16505 |
+vlan_stop() { |
16506 |
+ local iface="$1" vlan= |
16507 |
+ |
16508 |
+ vlan_check_installed || return 0 |
16509 |
+ |
16510 |
+ for vlan in $(vlan_get_vlans "${iface}"); do |
16511 |
+ einfo "Removing VLAN ${vlan##*.} from ${iface}" |
16512 |
+ if iface_stop "${vlan}" ; then |
16513 |
+ mark_service_stopped "net.${vlan}" |
16514 |
+ vconfig rem "${vlan}" >/dev/null |
16515 |
+ fi |
16516 |
+ done |
16517 |
+ |
16518 |
+ return 0 |
16519 |
+} |
16520 |
+ |
16521 |
+# vim: set ts=4 : |
16522 |
|
16523 |
Added: trunk/baselayout-prefix/lib/rcscripts/net/wpa_supplicant.sh |
16524 |
=================================================================== |
16525 |
--- trunk/baselayout-prefix/lib/rcscripts/net/wpa_supplicant.sh (rev 0) |
16526 |
+++ trunk/baselayout-prefix/lib/rcscripts/net/wpa_supplicant.sh 2011-03-31 14:11:17 UTC (rev 1682) |
16527 |
@@ -0,0 +1,378 @@ |
16528 |
+# Copyright (c) 2004-2006 Gentoo Foundation |
16529 |
+# Distributed under the terms of the GNU General Public License v2 |
16530 |
+# Contributed by Roy Marples (uberlord@g.o) |
16531 |
+ |
16532 |
+# Fix any potential localisation problems |
16533 |
+# Note that LC_ALL trumps LC_anything_else according to locale(7) |
16534 |
+wpa_supplicant() { |
16535 |
+ LC_ALL=C /sbin/wpa_supplicant "$@" |
16536 |
+} |
16537 |
+ |
16538 |
+wpa_cli() { |
16539 |
+ if [[ -n ${ctrl_dir} ]] ; then |
16540 |
+ LC_ALL=C /bin/wpa_cli -p "${ctrl_dir}" "$@" |
16541 |
+ else |
16542 |
+ LC_ALL=C /bin/wpa_cli "$@" |
16543 |
+ fi |
16544 |
+} |
16545 |
+ |
16546 |
+# void wpa_supplicant_depend(void) |
16547 |
+# |
16548 |
+# Sets up the dependancies for the module |
16549 |
+wpa_supplicant_depend() { |
16550 |
+ after macnet plug |
16551 |
+ before interface |
16552 |
+ provide wireless |
16553 |
+ functions interface_exists |
16554 |
+} |
16555 |
+ |
16556 |
+# void wpa_supplicant_expose(void) |
16557 |
+# |
16558 |
+# Expose variables that can be configured |
16559 |
+wpa_supplicant_expose() { |
16560 |
+ variables associate_timeout wpa_supplicant |
16561 |
+} |
16562 |
+ |
16563 |
+# bool wpa_supplicant_check_installed(void) |
16564 |
+# |
16565 |
+# Returns 0 if wpa_supplicant is installed, otherwise 1 |
16566 |
+wpa_supplicant_check_installed() { |
16567 |
+ [[ -x /sbin/wpa_supplicant ]] && return 0 |
16568 |
+ ${1:-false} && eerror "For WPA support (wpa_supplicant) support, emerge net-wireless/wpa_supplicant" |
16569 |
+ return 1 |
16570 |
+} |
16571 |
+ |
16572 |
+# bool wpa_supplicant_exists(char *interface) |
16573 |
+# |
16574 |
+# Checks to see if wireless extensions are enabled on the interface |
16575 |
+wpa_supplicant_exists() { |
16576 |
+ # Support new sysfs layout |
16577 |
+ [[ -L /sys/class/net/$1/wiphy || -d /sys/class/net/$1/wireless ]] \ |
16578 |
+ && return 0 |
16579 |
+ |
16580 |
+ [[ ! -e /proc/net/wireless ]] && return 1 |
16581 |
+ grep -q "^[ \t]*$1:" /proc/net/wireless |
16582 |
+} |
16583 |
+ |
16584 |
+# char* wpa_supplicant_get_essid(char *interface) |
16585 |
+# |
16586 |
+# Gets the current ESSID of iface |
16587 |
+wpa_supplicant_get_essid() { |
16588 |
+ local i= essid= |
16589 |
+ |
16590 |
+ for (( i=0; i<5; i++ )); do |
16591 |
+ essid=$( wpa_cli -i"$1" status | sed -n -e 's/^ssid=//p' ) |
16592 |
+ if [[ -n ${essid} ]] ; then |
16593 |
+ echo "${essid}" |
16594 |
+ return 0 |
16595 |
+ fi |
16596 |
+ sleep 1 |
16597 |
+ done |
16598 |
+ |
16599 |
+ return 1 |
16600 |
+} |
16601 |
+ |
16602 |
+# char* wpa_supplicant_get_ap_mac_address(char *interface) |
16603 |
+# |
16604 |
+# Returns the MAC address of the Access Point |
16605 |
+# the interface is connected to |
16606 |
+wpa_supplicant_get_ap_mac_address() { |
16607 |
+ wpa_cli -i"$1" status | sed -n -e 's/^bssid=\([^=]\+\).*/\U\1/p' |
16608 |
+} |
16609 |
+ |
16610 |
+# bool wpa_supplicant_associated(char *interface) |
16611 |
+# |
16612 |
+# Returns 0 if we're associated correctly or 1 if not |
16613 |
+# Note that just because we are associated does not mean we are using the |
16614 |
+# correct encryption keys |
16615 |
+wpa_supplicant_associated() { |
16616 |
+ local -a status=() |
16617 |
+ eval status=( $(wpa_cli -i"$1" status \ |
16618 |
+ | sed -n -e 's/^\(key_mgmt\|wpa_state\|EAP state\)=\([^=]\+\).*/\U\"\2\"/p') |
16619 |
+ ) |
16620 |
+ |
16621 |
+ case "${status[0]}" in |
16622 |
+ "NONE") |
16623 |
+ [[ ${status[1]} == "ASSOCIATED" || ${status[1]} == "COMPLETED" ]] |
16624 |
+ ;; |
16625 |
+ "IEEE 802.1X (no WPA)") |
16626 |
+ [[ ${status[2]} == "SUCCESS" ]] |
16627 |
+ ;; |
16628 |
+ *) |
16629 |
+ [[ ${status[1]} == "COMPLETED" ]] |
16630 |
+ ;; |
16631 |
+ esac |
16632 |
+ |
16633 |
+ return $? |
16634 |
+} |
16635 |
+ |
16636 |
+# void wpa_supplicant_kill(char *interface, bool report) |
16637 |
+# |
16638 |
+# Kills any existing wpa_supplicant process on the interface |
16639 |
+wpa_supplicant_kill() { |
16640 |
+ local iface="$1" report="${2:-false}" pidfile= |
16641 |
+ |
16642 |
+ # Shutdown wpa_cli first, if it's running |
16643 |
+ # This is important as future versions of wpa_supplicant |
16644 |
+ # may send a disconnect message to wpa_cli when it shutsdown |
16645 |
+ pidfile="/var/run/wpa_cli-${iface}.pid" |
16646 |
+ if [[ -f ${pidfile} ]] ; then |
16647 |
+ ${report} && ebegin "Stopping wpa_cli on ${iface}" |
16648 |
+ start-stop-daemon --stop --exec /bin/wpa_cli --pidfile "${pidfile}" |
16649 |
+ ${report} && eend "$?" |
16650 |
+ fi |
16651 |
+ |
16652 |
+ # Now shutdown wpa_supplicant |
16653 |
+ pidfile="/var/run/wpa_supplicant-${iface}.pid" |
16654 |
+ if [[ -f ${pidfile} ]] ; then |
16655 |
+ ${report} && ebegin "Stopping wpa_supplicant on ${iface}" |
16656 |
+ start-stop-daemon --stop --exec /sbin/wpa_supplicant \ |
16657 |
+ --pidfile "${pidfile}" |
16658 |
+ ${report} && eend "$?" |
16659 |
+ fi |
16660 |
+ |
16661 |
+ # If wpa_supplicant exits uncleanly, we need to remove the stale dir |
16662 |
+ [[ -S "/var/run/wpa_supplicant/${iface}" ]] \ |
16663 |
+ && rm -f "/var/run/wpa_supplicant/${iface}" |
16664 |
+} |
16665 |
+ |
16666 |
+# bool wpa_supplicant_associate(char *interface) |
16667 |
+# |
16668 |
+# Returns 0 if wpa_supplicant associates and authenticates to an AP |
16669 |
+# otherwise, 1 |
16670 |
+wpa_supplicant_associate() { |
16671 |
+ local iface="$1" ifvar=$(bash_variable "$1") timeout= |
16672 |
+ timeout="associate_timeout_${ifvar}" |
16673 |
+ timeout="${!timeout:--1}" |
16674 |
+ |
16675 |
+ [[ -z ${actfile} && ${timeout} -lt 0 ]] && timeout="60" |
16676 |
+ |
16677 |
+ if [[ ${timeout} == "0" ]] ; then |
16678 |
+ ewarn "WARNING: infinite timeout set for association on ${iface}" |
16679 |
+ elif [[ ${timeout} -lt 0 ]] ; then |
16680 |
+ einfo "Backgrounding ..." |
16681 |
+ exit 0 |
16682 |
+ fi |
16683 |
+ |
16684 |
+ local i=0 |
16685 |
+ while true ; do |
16686 |
+ if [[ -n ${actfile} ]] ; then |
16687 |
+ service_started "net.${iface}" && return 0 |
16688 |
+ else |
16689 |
+ if ! wpa_cli -i"${iface}" status &>/dev/null ; then |
16690 |
+ eend 1 "wpa_supplicant has exited unexpectedly" |
16691 |
+ return 1 |
16692 |
+ fi |
16693 |
+ wpa_supplicant_associated "${iface}" && return 0 |
16694 |
+ fi |
16695 |
+ sleep 1 |
16696 |
+ [[ ${timeout} == "0" ]] && continue |
16697 |
+ (( i++ )) |
16698 |
+ [[ ${i} == "${timeout}" || ${i} -gt "${timeout}" ]] && break |
16699 |
+ done |
16700 |
+ |
16701 |
+ # Spit out an appropriate error |
16702 |
+ if [[ -n ${actfile} ]] ; then |
16703 |
+ eend 1 "Failed to configure ${iface} in the background" |
16704 |
+ else |
16705 |
+ |
16706 |
+ eend 1 "Timed out" |
16707 |
+ fi |
16708 |
+ |
16709 |
+ # exit without error with wpa_supplicant-0.4.x as we may get kickstarted |
16710 |
+ # when an AP comes in range |
16711 |
+ [[ -n ${actfile} ]] && exit 0 |
16712 |
+ |
16713 |
+ # Kill wpa_supplicant for 0.3.x |
16714 |
+ wpa_supplicant_kill "${iface}" |
16715 |
+ return 1 |
16716 |
+} |
16717 |
+ |
16718 |
+# bool wpa_supplicant_pre_start(char *interface) |
16719 |
+# |
16720 |
+# Start wpa_supplicant on an interface and wait for association |
16721 |
+# Returns 0 (true) when successful, non-zero otherwise |
16722 |
+wpa_supplicant_pre_start() { |
16723 |
+ local iface="$1" opts= timeout= actfile= cfgfile= |
16724 |
+ |
16725 |
+ # We don't configure wireless if we're being called from |
16726 |
+ # the background unless we're not currently running |
16727 |
+ if ${IN_BACKGROUND} ; then |
16728 |
+ if service_started_daemon "net.${iface}" /sbin/wpa_supplicant ; then |
16729 |
+ if wpa_supplicant_exists "${iface}" ; then |
16730 |
+ ESSID=$(wpa_supplicant_get_essid "${iface}") |
16731 |
+ ESSIDVAR=$(bash_variable "${ESSID}") |
16732 |
+ save_options "ESSID" "${ESSID}" |
16733 |
+ metric=2000 |
16734 |
+ fi |
16735 |
+ return 0 |
16736 |
+ fi |
16737 |
+ fi |
16738 |
+ |
16739 |
+ save_options "ESSID" "" |
16740 |
+ |
16741 |
+ local ifvar=$(bash_variable "${iface}") |
16742 |
+ opts="wpa_supplicant_${ifvar}" |
16743 |
+ opts=" ${!opts} " |
16744 |
+ [[ ${opts} != *" -D"* ]] \ |
16745 |
+ && vewarn "wpa_supplicant_${ifvar} does not define a driver" |
16746 |
+ |
16747 |
+ # We only work on wirelesss interfaces unless a driver for wired |
16748 |
+ # has been defined |
16749 |
+ if [[ ${opts} != *" -Dwired "* && ${opts} != *" -D wired "* ]] ; then |
16750 |
+ if ! wpa_supplicant_exists "${iface}" ; then |
16751 |
+ veinfo "wpa_supplicant only works on wireless interfaces" |
16752 |
+ veinfo "unless the -D wired option is specified" |
16753 |
+ return 0 |
16754 |
+ fi |
16755 |
+ fi |
16756 |
+ |
16757 |
+ # If wireless-tools is installed, try and apply our user config |
16758 |
+ # This is needed for some drivers - such as hostap because they start |
16759 |
+ # the card in Master mode which causes problems with wpa_supplicant. |
16760 |
+ if is_function iwconfig_defaults ; then |
16761 |
+ if wpa_supplicant_exists "${iface}" ; then |
16762 |
+ iwconfig_defaults "${iface}" |
16763 |
+ iwconfig_user_config "${iface}" |
16764 |
+ fi |
16765 |
+ fi |
16766 |
+ |
16767 |
+ # Check for rf_kill - only ipw supports this at present, but other |
16768 |
+ # cards may in the future |
16769 |
+ if [[ -e "/sys/class/net/${iface}/device/rf_kill" ]] ; then |
16770 |
+ if [[ $( < "/sys/class/net/${iface}/device/rf_kill" ) != 0 ]] ; then |
16771 |
+ ewarn "Wireless radio has been killed for interface ${iface}" |
16772 |
+ local asc="associate_timeout_${ifvar}" |
16773 |
+ if [[ -n ${!asc} && ${!asc} -ge 0 ]] ; then |
16774 |
+ eerror "As you have ${asc} set to 0 or greater" |
16775 |
+ eerror "we will abort as we cannot associate" |
16776 |
+ return 1 |
16777 |
+ fi |
16778 |
+ ewarn "wpa_supplicant will launch, but not associate until" |
16779 |
+ ewarn "wireles radio is re-enabled for interface ${iface}" |
16780 |
+ fi |
16781 |
+ fi |
16782 |
+ |
16783 |
+ ebegin "Starting wpa_supplicant on ${iface}" |
16784 |
+ |
16785 |
+ cfgfile="${opts##* -c}" |
16786 |
+ if [[ -n ${cfgfile} && ${cfgfile} != "${opts}" ]] ; then |
16787 |
+ [[ ${cfgfile:0:1} == " " ]] && cfgfile="${cfgfile# *}" |
16788 |
+ cfgfile="${cfgfile%% *}" |
16789 |
+ else |
16790 |
+ # Support new and old style locations |
16791 |
+ cfgfile="/etc/wpa_supplicant/wpa_supplicant-${iface}.conf" |
16792 |
+ [[ ! -e ${cfgfile} ]] \ |
16793 |
+ && cfgfile="/etc/wpa_supplicant/wpa_supplicant.conf" |
16794 |
+ [[ ! -e ${cfgfile} ]] \ |
16795 |
+ && cfgfile="/etc/wpa_supplicant.conf" |
16796 |
+ opts="${opts} -c${cfgfile}" |
16797 |
+ fi |
16798 |
+ |
16799 |
+ if [[ ! -f ${cfgfile} ]] ; then |
16800 |
+ eend 1 "configuration file ${cfgfile} not found!" |
16801 |
+ return 1 |
16802 |
+ fi |
16803 |
+ |
16804 |
+ # Work out where the ctrl_interface dir is if it's not specified |
16805 |
+ local ctrl_dir=$(sed -n -e 's/[ \t]*#.*//g;s/[ \t]*$//g;s/^ctrl_interface=//p' "${cfgfile}") |
16806 |
+ if [[ -z ${ctrl_dir} ]] ; then |
16807 |
+ ctrl_dir="${opts##* -C}" |
16808 |
+ if [[ -n ${ctrl_dir} && ${ctrl_dir} != "${opts}" ]] ; then |
16809 |
+ [[ ${ctrl_dir:0:1} == " " ]] && ctrl_dir="${ctrl_dir# *}" |
16810 |
+ ctrl_dir="${ctrl_dir%% *}" |
16811 |
+ else |
16812 |
+ ctrl_dir="/var/run/wpa_supplicant" |
16813 |
+ opts="${opts} -C${ctrl_dir}" |
16814 |
+ fi |
16815 |
+ fi |
16816 |
+ save_options ctrl_dir "${ctrl_dir}" |
16817 |
+ |
16818 |
+ # Some drivers require the interface to be up |
16819 |
+ interface_up "${iface}" |
16820 |
+ |
16821 |
+ # wpa_supplicant 0.4.0 and greater supports wpa_cli actions |
16822 |
+ # This is very handy as if and when different association mechanisms are |
16823 |
+ # introduced to wpa_supplicant we don't have to recode for them as |
16824 |
+ # wpa_cli is now responsible for informing us of success/failure. |
16825 |
+ # The downside of this is that we don't see the interface being configured |
16826 |
+ # for DHCP/static. |
16827 |
+ actfile="/etc/wpa_supplicant/wpa_cli.sh" |
16828 |
+ # Support old file location |
16829 |
+ [[ ! -x ${actfile} ]] && actfile="/sbin/wpa_cli.action" |
16830 |
+ [[ ! -x ${actfile} ]] && unset actfile |
16831 |
+ [[ -n ${actfile} ]] && opts="${opts} -W" |
16832 |
+ |
16833 |
+ eval start-stop-daemon --start --exec /sbin/wpa_supplicant \ |
16834 |
+ --pidfile "/var/run/wpa_supplicant-${iface}.pid" \ |
16835 |
+ -- "${opts}" -B -i"${iface}" \ |
16836 |
+ -P"/var/run/wpa_supplicant-${iface}.pid" |
16837 |
+ eend "$?" || return 1 |
16838 |
+ |
16839 |
+ # Starting wpa_supplication-0.4.0, we can get wpa_cli to |
16840 |
+ # start/stop our scripts from wpa_supplicant messages |
16841 |
+ if [[ -n ${actfile} ]] ; then |
16842 |
+ mark_service_inactive "net.${iface}" |
16843 |
+ ebegin "Starting wpa_cli on ${iface}" |
16844 |
+ start-stop-daemon --start --exec /bin/wpa_cli \ |
16845 |
+ --pidfile "/var/run/wpa_cli-${iface}.pid" \ |
16846 |
+ -- -a"${actfile}" -p"${ctrl_dir}" -i"${iface}" \ |
16847 |
+ -P"/var/run/wpa_cli-${iface}.pid" -B |
16848 |
+ eend "$?" || return 1 |
16849 |
+ fi |
16850 |
+ |
16851 |
+ eindent |
16852 |
+ veinfo "Waiting for association" |
16853 |
+ eend 0 |
16854 |
+ |
16855 |
+ wpa_supplicant_associate "${iface}" || return 1 |
16856 |
+ |
16857 |
+ # Only report wireless info for wireless interfaces |
16858 |
+ if wpa_supplicant_exists "${iface}" ; then |
16859 |
+ # Set ESSID for essidnet and report |
16860 |
+ ESSID=$(wpa_supplicant_get_essid "${iface}" ) |
16861 |
+ ESSIDVAR=$(bash_variable "${ESSID}") |
16862 |
+ save_options "ESSID" "${ESSID}" |
16863 |
+ |
16864 |
+ local -a status=() |
16865 |
+ eval status=( $(wpa_cli -i"${iface}" status | sed -n -e 's/^\(bssid\|pairwise_cipher\|key_mgmt\)=\([^=]\+\).*/\"\U\2\"/p' | tr '[:lower:]' '[:upper:]') ) |
16866 |
+ einfo "${iface} connected to \"${ESSID//\\\\/\\\\}\" at ${status[0]}" |
16867 |
+ |
16868 |
+ if [[ ${status[2]} == "NONE" ]] ; then |
16869 |
+ if [[ ${status[1]} == "NONE" ]] ; then |
16870 |
+ ewarn "not using any encryption" |
16871 |
+ else |
16872 |
+ veinfo "using ${status[1]}" |
16873 |
+ fi |
16874 |
+ else |
16875 |
+ veinfo "using ${status[2]}/${status[1]}" |
16876 |
+ fi |
16877 |
+ eoutdent |
16878 |
+ else |
16879 |
+ einfo "${iface} connected" |
16880 |
+ fi |
16881 |
+ |
16882 |
+ if [[ -n ${actfile} ]] ; then |
16883 |
+ local addr=$(interface_get_address "${iface}") |
16884 |
+ einfo "${iface} configured with address ${addr}" |
16885 |
+ exit 0 |
16886 |
+ fi |
16887 |
+ |
16888 |
+ metric=2000 |
16889 |
+ return 0 |
16890 |
+} |
16891 |
+ |
16892 |
+# bool wpa_supplicant_post_stop(char *iface) |
16893 |
+# |
16894 |
+# Stops wpa_supplicant on an interface |
16895 |
+# Returns 0 (true) when successful, non-zero otherwise |
16896 |
+wpa_supplicant_post_stop() { |
16897 |
+ if ${IN_BACKGROUND} ; then |
16898 |
+ # Only stop wpa_supplicant if it's not the controlling daemon |
16899 |
+ ! service_started_daemon "net.$1" /sbin/wpa_supplicant 0 |
16900 |
+ fi |
16901 |
+ [[ $? == 0 ]] && wpa_supplicant_kill "$1" true |
16902 |
+ return 0 |
16903 |
+} |
16904 |
+ |
16905 |
+# vim: set ts=4 : |
16906 |
|
16907 |
Added: trunk/baselayout-prefix/man/MAKEDEV.8 |
16908 |
=================================================================== |
16909 |
--- trunk/baselayout-prefix/man/MAKEDEV.8 (rev 0) |
16910 |
+++ trunk/baselayout-prefix/man/MAKEDEV.8 2011-03-31 14:11:17 UTC (rev 1682) |
16911 |
@@ -0,0 +1,392 @@ |
16912 |
+.\" $Id: MAKEDEV.8 2240 2006-09-14 10:13:11Z uberlord $ |
16913 |
+.TH MAKEDEV 8 "14th August 1994" Linux "Linux Programmer's Manual" |
16914 |
+.SH NAME |
16915 |
+MAKEDEV \- create devices |
16916 |
+.SH SYNOPSIS |
16917 |
+.B "cd dev; ./MAKEDEV -V" |
16918 |
+.br |
16919 |
+.B "cd dev; ./MAKEDEV [ -n ] [ -v ] update" |
16920 |
+.br |
16921 |
+.BI "cd dev; ./MAKEDEV [ -n ] [ -v ] [ -d ]" " device ..." |
16922 |
+.SH DESCRIPTION |
16923 |
+.B MAKEDEV |
16924 |
+is a script that will create the devices in \fC/dev\fP used to interface |
16925 |
+with drivers in the kernel. |
16926 |
+.PP |
16927 |
+This man page is woefully out of date. A large number of devices are supported |
16928 |
+that are not documented here. |
16929 |
+.PP |
16930 |
+Note that programs giving the error ``ENOENT: No such file or |
16931 |
+directory'' normally means that the device file is missing, whereas |
16932 |
+``ENODEV: No such device'' normally means the kernel does not have the |
16933 |
+driver configured or loaded. |
16934 |
+.SH OPTIONS |
16935 |
+.TP |
16936 |
+.B \-V |
16937 |
+Print out version (actually RCS version information) and exit. |
16938 |
+.TP |
16939 |
+.B \-n |
16940 |
+Do not actually update the devices, just print the actions that would be |
16941 |
+performed. |
16942 |
+.TP |
16943 |
+.B \-d |
16944 |
+Delete the devices. The main use for this flag is by |
16945 |
+.B MAKEDEV |
16946 |
+itself. |
16947 |
+.TP |
16948 |
+.B \-v |
16949 |
+Be verbose. Print out the actions as they are performed. This is the |
16950 |
+same output as produced by |
16951 |
+.BR \-n . |
16952 |
+.SH CUSTOMISATION |
16953 |
+Since there is currently no standardisation in what names are used for |
16954 |
+system users and groups, it is possible that you may need to modify |
16955 |
+.B MAKEDEV |
16956 |
+to reflect your site's settings. Near the top of the file is a mapping |
16957 |
+from device type to user, group and permissions (e.g. all CD-ROM devices |
16958 |
+are set from the \fC$cdrom\fP variable). If you wish to change the |
16959 |
+defaults, this is the section to edit. |
16960 |
+.SH DEVICES |
16961 |
+.TP |
16962 |
+.B General Options |
16963 |
+.TP |
16964 |
+.B update |
16965 |
+This only works on kernels which have \fC/proc/interrupts\fP (introduced |
16966 |
+during 1.1.x). This file is scanned to see what devices are currently |
16967 |
+configured into the kernel, and this is compared with the previous |
16968 |
+settings stored in the file called \fCDEVICES\fP. |
16969 |
+Devices which are new since then or have a different major number are |
16970 |
+created, and those which are no longer configured are deleted. |
16971 |
+.TP |
16972 |
+.B generic |
16973 |
+Create a generic subset of devices. This is the standard devices, plus |
16974 |
+floppy drives, various hard drives, pseudo-terminals, console devices, |
16975 |
+basic serial devices, busmice, and printer ports. |
16976 |
+.TP |
16977 |
+.B |
16978 |
+std |
16979 |
+Standard devices. |
16980 |
+These are: |
16981 |
+.B mem |
16982 |
+\- acess to physical memory; |
16983 |
+.B kmem |
16984 |
+\- access to kernel virtual memory; |
16985 |
+.B null |
16986 |
+\- null device (infinite sink); |
16987 |
+.B port |
16988 |
+\- access to I/O ports; |
16989 |
+.B zero |
16990 |
+\- null byte source (infinite source); |
16991 |
+.B core |
16992 |
+\- symlink to /proc/kcore (for kernel debugging); |
16993 |
+.B full |
16994 |
+\- always returns ENOSPACE on write; |
16995 |
+.B ram |
16996 |
+\- ramdisk; |
16997 |
+.B tty |
16998 |
+\- to access the controlling tty of a process. |
16999 |
+.TP |
17000 |
+.B local |
17001 |
+This simply runs |
17002 |
+.BR MAKEDEV.local . |
17003 |
+This is a script that can create any local devices. |
17004 |
+.TP |
17005 |
+.B Virtual Terminals |
17006 |
+.TP |
17007 |
+.I console |
17008 |
+This creates the devices associated with the console. This is the virtual |
17009 |
+terminals |
17010 |
+.RI tty x , |
17011 |
+where |
17012 |
+.I x |
17013 |
+can be from 0 though 63. The device tty0 is the currently active vt, and |
17014 |
+is also known as \fCconsole\fP. For each vt, there are two devices |
17015 |
+.RI vcs x |
17016 |
+and |
17017 |
+.RI vcsa x , |
17018 |
+which are used to generate screen-dumps of the vt (the |
17019 |
+.BI vcs x |
17020 |
+is just the text, |
17021 |
+and |
17022 |
+.BI vcsa x |
17023 |
+includes the attributes). |
17024 |
+.TP |
17025 |
+.B Serial Devices |
17026 |
+.TP |
17027 |
+.I ttyS{0..63} |
17028 |
+Serial ports and corresponding dialout device. For device |
17029 |
+.BI ttyS x , |
17030 |
+there is also the device |
17031 |
+.BI cua x |
17032 |
+which is used to dial out with. This can avoid the need for cooperative |
17033 |
+locks in simple situations. |
17034 |
+.TP |
17035 |
+.I cyclades |
17036 |
+Dial-in and dial-out devices for the cyclades intelligent I/O serial card. |
17037 |
+The dial in device is |
17038 |
+.BI ttyC x |
17039 |
+and the corresponding dial-out device is |
17040 |
+.BI cub x |
17041 |
+Devices for 32 lines are created. |
17042 |
+.TP |
17043 |
+.B Pseudo Terminals |
17044 |
+.TP |
17045 |
+.I pty[p-s] |
17046 |
+Each possible argument will create a bank of 16 master and slave |
17047 |
+pairs. The current kernel (1.2) is limited to 64 such pairs. |
17048 |
+The master pseudo-terminals are |
17049 |
+.BR pty[p-s][0-9a-f] , |
17050 |
+and the slaves are |
17051 |
+.BR tty[p-s][0-9a-f] . |
17052 |
+.TP |
17053 |
+.B Parallel Ports |
17054 |
+.TP |
17055 |
+.I lp |
17056 |
+Standard parallel ports. The devices are created |
17057 |
+.BR lp0 , |
17058 |
+.BR lp1 , |
17059 |
+and |
17060 |
+.BR lp2 . |
17061 |
+These correspond to ports at 0x3bc, 0x378 and 0x278. |
17062 |
+Hence, on some machines, the first printer port may actually be |
17063 |
+.BR lp1 . |
17064 |
+.TP |
17065 |
+.I par |
17066 |
+Alternative to |
17067 |
+.IR lp . |
17068 |
+Ports are named |
17069 |
+.BI par x |
17070 |
+instead of |
17071 |
+.BI lp x . |
17072 |
+.TP |
17073 |
+.B Bus Mice |
17074 |
+.TP |
17075 |
+.I busmice |
17076 |
+The various bus mice devices. This creates the following devices: |
17077 |
+.B logimouse |
17078 |
+(Logitech bus mouse), |
17079 |
+.B psmouse |
17080 |
+(PS/2-style mouse), |
17081 |
+.B msmouse |
17082 |
+(Microsoft Inport bus mouse) and |
17083 |
+.B atimouse |
17084 |
+(ATI XL bus mouse) and |
17085 |
+.B jmouse |
17086 |
+(J-mouse). |
17087 |
+.TP |
17088 |
+.B Joystick Devices |
17089 |
+.TP |
17090 |
+.I js |
17091 |
+Joystick. Creates |
17092 |
+.B js0 |
17093 |
+and |
17094 |
+.BR js1 . |
17095 |
+.TP |
17096 |
+.B Disk Devices |
17097 |
+.TP |
17098 |
+.I fd[0-7] |
17099 |
+Floppy disk devices. The device |
17100 |
+.BI fd x |
17101 |
+is the device which autodetects the format, and the additional devices are |
17102 |
+fixed format (whose size is indicated in the name). |
17103 |
+The other devices are named as |
17104 |
+.BI fd xLn . |
17105 |
+The single letter |
17106 |
+.I L |
17107 |
+identifies the type of floppy disk (d = 5.25" DD, h = 5.25" HD, D = 3.5" |
17108 |
+DD, H = 3.5" HD, E = 3.5" ED). The number |
17109 |
+.I n |
17110 |
+represents the capacity of that format in K. Thus the standard formats |
17111 |
+are |
17112 |
+.BI fd x d360 , |
17113 |
+.BI fd x h1200 , |
17114 |
+.BI fd x D720 , |
17115 |
+.BI fd x H1440 , |
17116 |
+and |
17117 |
+.RI fd x E2880 . |
17118 |
+.IP |
17119 |
+For more information see Alain Knaff's fdutils package. |
17120 |
+.IP |
17121 |
+Devices |
17122 |
+.BI fd0 * |
17123 |
+through |
17124 |
+.BI fd3 * |
17125 |
+are floppy disks on the first controller, and devices |
17126 |
+.BI fd4 * |
17127 |
+through |
17128 |
+.BI fd7 * |
17129 |
+are floppy disks on the second controller. |
17130 |
+.TP |
17131 |
+.I hd[a-d] |
17132 |
+AT hard disks. The device |
17133 |
+.BI hd x |
17134 |
+provides access to the whole disk, with the partitions being |
17135 |
+.BI hd x [0-20]. |
17136 |
+The four primary partitions are |
17137 |
+.BI hd x 1 |
17138 |
+through |
17139 |
+.BI hd x 4, |
17140 |
+with the logical partitions being numbered from |
17141 |
+.BI hd x 5 |
17142 |
+though |
17143 |
+.BI hd x 20. |
17144 |
+(A primary partition can be made into an extended partition, which can hold |
17145 |
+4 logical partitions). |
17146 |
+By default, only the devices for 4 logical partitions are made. The |
17147 |
+others can be made by uncommenting them. |
17148 |
+.IP |
17149 |
+Drives hda and hdb are the two on the first controller. If using the new |
17150 |
+IDE driver (rather than the old HD driver), then hdc and hdd are the two |
17151 |
+drives on the secondary controller. These devices can also be used to |
17152 |
+acess IDE CDROMs if using the new IDE driver. |
17153 |
+.TP |
17154 |
+.I xd[a-d] |
17155 |
+XT hard disks. Partitions are the same as IDE disks. |
17156 |
+.TP |
17157 |
+.I sd[a-h] |
17158 |
+SCSI hard disks. The partitions are similar to the IDE disks, but there |
17159 |
+is a limit of 11 logical partitions |
17160 |
+.RI (sd x 5 |
17161 |
+through |
17162 |
+.RI sd x 15). |
17163 |
+This is to allow there to be 8 SCSI disks. |
17164 |
+.TP |
17165 |
+.I loop |
17166 |
+Loopback disk devices. These allow you to use a regular file as a |
17167 |
+block device. This means that images of filesystems can be mounted, |
17168 |
+and used as normal. This creates 8 devices loop0 through loop7. |
17169 |
+.TP |
17170 |
+.B Tape Devices |
17171 |
+.TP |
17172 |
+.I st[0-7] |
17173 |
+SCSI tapes. This creates the rewinding tape device |
17174 |
+.BI st x |
17175 |
+and the non-rewinding tape device |
17176 |
+.BI nst x . |
17177 |
+.TP |
17178 |
+.I qic |
17179 |
+QIC-80 tapes. The devices created are |
17180 |
+.BR rmt8 , |
17181 |
+.BR rmt16 , |
17182 |
+.BR tape-d , |
17183 |
+and |
17184 |
+.BR tape-reset . |
17185 |
+.TP |
17186 |
+.I ftape |
17187 |
+Floppy driver tapes (QIC-117). There are 4 methods of access depending on |
17188 |
+the floppy tape drive. For each of access methods 0, 1, 2 and 3, the |
17189 |
+devices |
17190 |
+.BI rft x |
17191 |
+(rewinding) and |
17192 |
+.BI nrft x |
17193 |
+(non-rewinding) are created. For compatability, devices |
17194 |
+.B ftape |
17195 |
+and |
17196 |
+.B nftape |
17197 |
+are symlinks to |
17198 |
+.B rft0 |
17199 |
+and |
17200 |
+.B nrft0 |
17201 |
+respectively. |
17202 |
+.TP |
17203 |
+.B CDROM Devices |
17204 |
+.TP |
17205 |
+.I scd[0-7] |
17206 |
+SCSI CD players. |
17207 |
+.TP |
17208 |
+.I sonycd |
17209 |
+Sony CDU-31A CD player. |
17210 |
+.TP |
17211 |
+.I mcd |
17212 |
+Mitsumi CD player. |
17213 |
+.TP |
17214 |
+.I cdu535 |
17215 |
+Sony CDU-535 CD player. |
17216 |
+.TP |
17217 |
+.I lmscd |
17218 |
+LMS/Philips CD player. |
17219 |
+.TP |
17220 |
+.I sbpcd{,1,2,3} |
17221 |
+Sound Blaster CD player. The kernel is capable of supporting 16 CDROMs, |
17222 |
+each of which is accessed as |
17223 |
+.BR sbpcd[0-9a-f] . |
17224 |
+These are assigned in groups of 4 to each controller. |
17225 |
+.B sbpcd |
17226 |
+is a symlink to |
17227 |
+.BR sbpcd0 . |
17228 |
+.\" .TP |
17229 |
+.\" .I idecd |
17230 |
+.\" NEC CDR-260 (note: this will probably be obsoleted by the new IDE driver). |
17231 |
+.TP |
17232 |
+.B Scanner |
17233 |
+.TP |
17234 |
+.I logiscan |
17235 |
+Logitech ScanMan32 & ScanMan 256. |
17236 |
+.TP |
17237 |
+.I m105scan |
17238 |
+Mustek M105 Handscanner. |
17239 |
+.TP |
17240 |
+.I ac4096 |
17241 |
+A4Tek Color Handscanner. |
17242 |
+.TP |
17243 |
+.B Audio |
17244 |
+.TP |
17245 |
+.I audio |
17246 |
+This creates the audio devices used by the sound driver. These include |
17247 |
+.BR mixer , |
17248 |
+.BR sequencer , |
17249 |
+.BR dsp , |
17250 |
+and |
17251 |
+.BR audio . |
17252 |
+.TP |
17253 |
+.I pcaudio |
17254 |
+Devices for the PC Speaker sound driver. These are |
17255 |
+.BR pcmixer . |
17256 |
+.BR pxsp , |
17257 |
+and |
17258 |
+.BR pcaudio . |
17259 |
+.TP |
17260 |
+.B Miscellaneous |
17261 |
+.TP |
17262 |
+.I sg |
17263 |
+Generic SCSI devices. The devices created are |
17264 |
+.B sg0 through |
17265 |
+.BR sg7 . |
17266 |
+These |
17267 |
+allow arbitary commands to be sent to any SCSI device. This allows for |
17268 |
+querying information about the device, or controlling SCSI devices that |
17269 |
+are not one of disk, tape or CDROM (e.g. scanner, writeable CDROM). |
17270 |
+.TP |
17271 |
+.I fd |
17272 |
+To allow an arbitary program to be fed input from file descriptor |
17273 |
+.IR x , |
17274 |
+use |
17275 |
+.BI /dev/fd/ x |
17276 |
+as the file name. This also creates |
17277 |
+BR /dev/stdin , |
17278 |
+BR /dev/stdout , |
17279 |
+and |
17280 |
+BR /dev/stderr . |
17281 |
+(Note, these are just symlinks into /proc/self/fd). |
17282 |
+.TP |
17283 |
+.I ibcs2 |
17284 |
+Devices (and symlinks) needed by the IBCS2 emulation. |
17285 |
+.TP |
17286 |
+.I apm |
17287 |
+Devices for power management. |
17288 |
+.TP |
17289 |
+.I dcf |
17290 |
+Driver for DCF-77 radio clock. |
17291 |
+.TP |
17292 |
+.I helloworld |
17293 |
+Kernel modules demonstration device. See the modules source. |
17294 |
+.TP |
17295 |
+.B "Network Devices" |
17296 |
+Linux used to have devices in /dev for controlling network devices, but |
17297 |
+that is no longer the case. To see what network devices are known by the |
17298 |
+kernel, look at /proc/net/dev. |
17299 |
+.SH "SEE ALSO" |
17300 |
+Linux Allocated Devices, maintained by H.\ Peter Anvin, |
17301 |
+<Peter.Anvin@×××××.org>. |
17302 |
+.SH AUTHOR |
17303 |
+Nick Holloway |
17304 |
|
17305 |
Added: trunk/baselayout-prefix/man/consoletype.1 |
17306 |
=================================================================== |
17307 |
--- trunk/baselayout-prefix/man/consoletype.1 (rev 0) |
17308 |
+++ trunk/baselayout-prefix/man/consoletype.1 2011-03-31 14:11:17 UTC (rev 1682) |
17309 |
@@ -0,0 +1,28 @@ |
17310 |
+.TH CONSOLETYPE 1 "Red Hat, Inc" "RH" \" -*- nroff -*- |
17311 |
+.SH NAME |
17312 |
+.B consoletype |
17313 |
+\- print type of the console connected to standard input |
17314 |
+.SH SYNOPSIS |
17315 |
+.B consoletype |
17316 |
+.SH DESCRIPTION |
17317 |
+.B consoletype |
17318 |
+prints the type of console connected to standard input. It prints |
17319 |
+.I vt |
17320 |
+if console is a virtual terminal (/dev/tty* or /dev/console device if not on |
17321 |
+a serial console), |
17322 |
+.I serial |
17323 |
+if standard input is a serial console (/dev/console or /dev/ttyS*) and |
17324 |
+.I pty |
17325 |
+if standard input is a pseudo terminal. |
17326 |
+.SH RETURN VALUE |
17327 |
+.B consoletype |
17328 |
+returns |
17329 |
+.TP |
17330 |
+.I 0 |
17331 |
+if on virtual terminal |
17332 |
+.TP |
17333 |
+.I 1 |
17334 |
+if on serial console |
17335 |
+.TP |
17336 |
+.I 2 |
17337 |
+if on a pseudo terminal. |
17338 |
|
17339 |
Added: trunk/baselayout-prefix/man/modules-update.8 |
17340 |
=================================================================== |
17341 |
--- trunk/baselayout-prefix/man/modules-update.8 (rev 0) |
17342 |
+++ trunk/baselayout-prefix/man/modules-update.8 2011-03-31 14:11:17 UTC (rev 1682) |
17343 |
@@ -0,0 +1,51 @@ |
17344 |
+.TH MODULES-UPDATE 8 "Gentoo Linux" "2001" |
17345 |
+.SH NAME |
17346 |
+modules\-update \- (re)generate /etc/modules.conf |
17347 |
+.SH SYNOPSIS |
17348 |
+.B modules\-update |
17349 |
+[force] |
17350 |
+.SH DESCRIPTION |
17351 |
+.B modules\-update |
17352 |
+is a simple tool to manage |
17353 |
+.IR /etc/modules.conf . |
17354 |
+The Linux module utilities use a single file for all their |
17355 |
+configuration. This makes it difficult for packages to dynamically add |
17356 |
+information about their own modules. |
17357 |
+.PP |
17358 |
+.B modules-update |
17359 |
+makes the dynamic addition of information easier by generating the |
17360 |
+single configuration file from the many files located in |
17361 |
+.IR /etc/modules.d/ . |
17362 |
+All files in that directory are assembled together to form |
17363 |
+.IR /etc/modules.conf . |
17364 |
+.PP |
17365 |
+After generation, a backup of the old file can be found at |
17366 |
+.IR /etc/modules.conf.old . |
17367 |
+.SH "FILES" |
17368 |
+There are two types of file you can put in |
17369 |
+.IR /etc/modules.d/ : |
17370 |
+normal files and exectuable files. Normal files contain standard modules |
17371 |
+configuration information, as described in |
17372 |
+.BR modules.conf (5). |
17373 |
+Executable files are executed and their output is used as extra configuration |
17374 |
+information. Error messages are sent to stderr and thus do not become |
17375 |
+part of the configuration file. |
17376 |
+.SH OPTIONS |
17377 |
+.TP |
17378 |
+.I force |
17379 |
+.B modules\-update |
17380 |
+will check if the current |
17381 |
+.I /etc/modules.conf |
17382 |
+is a generated file by checking for a special tag on the first line. If this |
17383 |
+tag is not found generation is aborted. By supplying |
17384 |
+.I force |
17385 |
+as parameter only a warning is printed. |
17386 |
+.SH "REPORTING BUGS" |
17387 |
+Please report bugs via http://bugs.gentoo.org/ |
17388 |
+.SH "SEE ALSO" |
17389 |
+.BR depmod (1), |
17390 |
+.BR modules.conf (5) |
17391 |
+.SH AUTHOR |
17392 |
+This manual page was written by Wichert Akkerman <wakkerma@××××××.org> |
17393 |
+for the Debian GNU/Linux system. Modified for |
17394 |
+.I Gentoo Linux. |
17395 |
|
17396 |
Added: trunk/baselayout-prefix/man/modules.autoload.5 |
17397 |
=================================================================== |
17398 |
--- trunk/baselayout-prefix/man/modules.autoload.5 (rev 0) |
17399 |
+++ trunk/baselayout-prefix/man/modules.autoload.5 2011-03-31 14:11:17 UTC (rev 1682) |
17400 |
@@ -0,0 +1,19 @@ |
17401 |
+.TH MODULES.AUTOLOAD 5 "Gentoo Linux" "Nov 2001" |
17402 |
+.SH NAME |
17403 |
+\fI/etc/modules.autoload\fR - kernel modules to load at boot time |
17404 |
+.SH DESCRIPTION |
17405 |
+.PP |
17406 |
+The \fI/etc/modules.autoload\fR |
17407 |
+file contains the names of kernel modules that are to be loaded at boot |
17408 |
+time, one per line. Arguments can be given on the same line as the module |
17409 |
+name. Comments begin with a `#', and everything on the line after it is |
17410 |
+ignored. This file is read by the \fI/etc/init.d/modules\fR initscript, |
17411 |
+which is usually linked in the \fI/etc/runlevels/boot\fR directory. |
17412 |
+.SH "SEE ALSO" |
17413 |
+.BR modules-update (8), |
17414 |
+.BR modprobe (8), |
17415 |
+.BR modules.conf (5) |
17416 |
+.TP |
17417 |
+The \fI/sbin/modules-update\fR script. |
17418 |
+.TP |
17419 |
+The files in \fI/etc/modules.d\fR. |
17420 |
|
17421 |
Added: trunk/baselayout-prefix/man/rc-status.8 |
17422 |
=================================================================== |
17423 |
--- trunk/baselayout-prefix/man/rc-status.8 (rev 0) |
17424 |
+++ trunk/baselayout-prefix/man/rc-status.8 2011-03-31 14:11:17 UTC (rev 1682) |
17425 |
@@ -0,0 +1,39 @@ |
17426 |
+.TH "BASELAYOUT" "8" "May 2004" "baselayout" "baselayout" |
17427 |
+.SH NAME |
17428 |
+rc-status \- show status info about runlevels |
17429 |
+.SH SYNOPSIS |
17430 |
+\fBrc-status\fR \fI[command [runlevel]]\fR |
17431 |
+.SH DESCRIPTION |
17432 |
+\fBrc-status\fR gathers and displays information about the status of init |
17433 |
+scripts in different runlevels. The default behavior is to show information |
17434 |
+about the current runlevel, but any runlevel can be quickly examined. |
17435 |
+directory. They must also conform to the Gentoo runscript standard. |
17436 |
+.SH OPTIONS |
17437 |
+.TP |
17438 |
+\fB\-\-all (\-a)\fR |
17439 |
+Show all runlevels and their services |
17440 |
+.TP |
17441 |
+\fB\-\-list (\-l)\fR |
17442 |
+List all defined runlevels |
17443 |
+.TP |
17444 |
+\fB\-\-nocolor (\-nc)\fR |
17445 |
+Disable color output |
17446 |
+.TP |
17447 |
+\fB\-\-servicelist (\-s)\fR |
17448 |
+Show all services |
17449 |
+.TP |
17450 |
+\fB\-\-unused (\-u)\fR |
17451 |
+Show services not assigned to any runlevel |
17452 |
+.TP |
17453 |
+\fB[runlevel]\fR |
17454 |
+Show information only for the named \fBrunlevel\fR |
17455 |
+.SH "REPORTING BUGS" |
17456 |
+Please report bugs via http://bugs.gentoo.org/ |
17457 |
+.SH "SEE ALSO" |
17458 |
+.BR rc-update (8) |
17459 |
+ |
17460 |
+http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4 |
17461 |
+.SH AUTHORS |
17462 |
+Mike Frysinger <vapier@g.o> |
17463 |
+.SH "CVS HEADER" |
17464 |
+$Header$ |
17465 |
|
17466 |
Added: trunk/baselayout-prefix/man/rc-update.8 |
17467 |
=================================================================== |
17468 |
--- trunk/baselayout-prefix/man/rc-update.8 (rev 0) |
17469 |
+++ trunk/baselayout-prefix/man/rc-update.8 2011-03-31 14:11:17 UTC (rev 1682) |
17470 |
@@ -0,0 +1,47 @@ |
17471 |
+.TH "BASELAYOUT" "8" "May 2004" "baselayout" "baselayout" |
17472 |
+.SH NAME |
17473 |
+rc-update \- add and remove init scripts to a runlevel |
17474 |
+.SH SYNOPSIS |
17475 |
+\fBrc-update\fR \fIadd\fR \fIscript\fR \fI<runlevels>\fR |
17476 |
+.br |
17477 |
+\fBrc-update\fR \fIdel\fR \fIscript\fR \fI[runlevels]\fR |
17478 |
+.br |
17479 |
+\fBrc-update\fR \fIshow\fR \fI[\-\-verbose]\fR \fI[runlevels]\fR |
17480 |
+.SH DESCRIPTION |
17481 |
+Gentoo's init system uses named runlevels. Rather than editing some obscure |
17482 |
+file or managing a directory of symlinks, \fBrc-update\fR exists to quickly |
17483 |
+add or delete init scripts from different runlevels. |
17484 |
+ |
17485 |
+All scripts specified with this utility must reside in the \fI/etc/init.d\fR |
17486 |
+directory. They must also conform to the Gentoo runscript standard. |
17487 |
+.SH OPTIONS |
17488 |
+.TP |
17489 |
+\fBadd (\-a)\fR \fIscript\fR \fI<runlevels>\fR |
17490 |
+Add the specified \fIinit script\fR to the specified \fIrunlevels\fR. You |
17491 |
+must specify at least one runlevel. |
17492 |
+ |
17493 |
+Example: rc-update add net.eth0 default |
17494 |
+.TP |
17495 |
+\fBdel (\-d)\fR \fIscript\fR \fI[runlevels]\fR |
17496 |
+Delete the specified \fIinit script\fR from the specified \fIrunlevels\fR. |
17497 |
+If you do not specify the \fIrunlevels\fR from which to delete, the script |
17498 |
+will be removed from all exists runlevels. |
17499 |
+ |
17500 |
+Example: rc-update del sysklogd |
17501 |
+.TP |
17502 |
+\fBshow (\-s)\fR \fI[\-v|\-\-verbose]\fR \fI[runlevels]\fR |
17503 |
+Show all enabled scripts and the runlevels they belong to. If you specify |
17504 |
+\fIrunlevels\fR to show, then only those will be included in the output. To |
17505 |
+view all init scripts, run with the \fI\-\-verbose\fR option. |
17506 |
+ |
17507 |
+Example: rc-update show |
17508 |
+.SH "REPORTING BUGS" |
17509 |
+Please report bugs via http://bugs.gentoo.org/ |
17510 |
+.SH "SEE ALSO" |
17511 |
+.BR rc-status (8) |
17512 |
+ |
17513 |
+http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4 |
17514 |
+.SH AUTHORS |
17515 |
+Mike Frysinger <vapier@g.o> |
17516 |
+.SH "CVS HEADER" |
17517 |
+$Header$ |
17518 |
|
17519 |
Added: trunk/baselayout-prefix/man/start-stop-daemon.8 |
17520 |
=================================================================== |
17521 |
--- trunk/baselayout-prefix/man/start-stop-daemon.8 (rev 0) |
17522 |
+++ trunk/baselayout-prefix/man/start-stop-daemon.8 2011-03-31 14:11:17 UTC (rev 1682) |
17523 |
@@ -0,0 +1,241 @@ |
17524 |
+.\" Hey, Emacs! This is an -*- nroff -*- source file. |
17525 |
+.TH START\-STOP\-DAEMON 8 "15th March 1997" "Debian Project" "Debian GNU/Linux" |
17526 |
+.SH NAME |
17527 |
+start\-stop\-daemon \- start and stop system daemon programs |
17528 |
+.SH SYNOPSIS |
17529 |
+.B start-stop-daemon |
17530 |
+.BR -S | --start |
17531 |
+.IR options |
17532 |
+.RB [ \-\- ] |
17533 |
+.IR arguments |
17534 |
+.HP |
17535 |
+.B start-stop-daemon |
17536 |
+.BR -K | --stop |
17537 |
+.IR options |
17538 |
+.HP |
17539 |
+.B start-stop-daemon |
17540 |
+.BR -H | --help |
17541 |
+.HP |
17542 |
+.B start-stop-daemon |
17543 |
+.BR -V | --version |
17544 |
+.SH DESCRIPTION |
17545 |
+.B start\-stop\-daemon |
17546 |
+is used to control the creation and termination of system-level processes. |
17547 |
+Using the |
17548 |
+.BR --exec ", " --pidfile ", " --user ", and " --name " options," |
17549 |
+.B start\-stop\-daemon |
17550 |
+can be configured to find existing instances of a running process. |
17551 |
+ |
17552 |
+With |
17553 |
+.BR --start , |
17554 |
+.B start\-stop\-daemon |
17555 |
+checks for the existence of a specified process. |
17556 |
+If such a process exists, |
17557 |
+.B start\-stop\-daemon |
17558 |
+does nothing, and exits with error status 1 (0 if |
17559 |
+.BR --oknodo |
17560 |
+is specified). |
17561 |
+If such a process does not exist, it starts an |
17562 |
+instance, using either the executable specified by |
17563 |
+.BR --exec , |
17564 |
+(or, if specified, by |
17565 |
+.BR --startas ). |
17566 |
+Any arguments given after |
17567 |
+.BR -- |
17568 |
+on the command line are passed unmodified to the program being |
17569 |
+started. If |
17570 |
+.B --retry |
17571 |
+is specified then start-stop-daemon will check that the process(es) |
17572 |
+have terminated. |
17573 |
+ |
17574 |
+With |
17575 |
+.BR --stop , |
17576 |
+.B start\-stop\-daemon |
17577 |
+also checks for the existence of a specified process. |
17578 |
+If such a process exists, |
17579 |
+.B start\-stop\-daemon |
17580 |
+sends it the signal specified by |
17581 |
+.BR --signal , |
17582 |
+and exits with error status 0. |
17583 |
+If such a process does not exist, |
17584 |
+.B start\-stop\-daemon |
17585 |
+exits with error status 1 |
17586 |
+(0 if |
17587 |
+.BR --oknodo |
17588 |
+is specified). |
17589 |
+ |
17590 |
+.SH OPTIONS |
17591 |
+ |
17592 |
+.TP |
17593 |
+\fB-x\fP|\fB--exec\fP \fIexecutable\fP |
17594 |
+Check for processes that are instances of this executable (according to |
17595 |
+.B /proc/ |
17596 |
+.I pid |
17597 |
+.B /exe |
17598 |
+). |
17599 |
+.TP |
17600 |
+\fB-p\fP|\fB--pidfile\fP \fIpid-file\fP |
17601 |
+Check for processes whose process-id is specified in |
17602 |
+.I pid-file. |
17603 |
+.TP |
17604 |
+\fB-u\fP|\fB--user\fP \fIusername\fP|\fIuid\fP |
17605 |
+Check for processes owned by the user specified by |
17606 |
+.I username |
17607 |
+or |
17608 |
+.I uid. |
17609 |
+.TP |
17610 |
+\fB-n\fP|\fB--name\fP \fIprocess-name\fP |
17611 |
+Check for processes with the name |
17612 |
+.I process-name |
17613 |
+(according to |
17614 |
+.B /proc/ |
17615 |
+.I pid |
17616 |
+.B /stat |
17617 |
+). |
17618 |
+.TP |
17619 |
+\fB-s\fP|\fB--signal\fP \fIsignal\fP |
17620 |
+With |
17621 |
+.BR --stop |
17622 |
+, specifies the signal to send to processes being stopped (default 15). |
17623 |
+.TP |
17624 |
+\fB-R\fP|\fB--retry\fP \fItimeout\fP|\fIschedule\fP |
17625 |
+With |
17626 |
+.BR --stop , |
17627 |
+specifies that |
17628 |
+.B start-stop-daemon |
17629 |
+is to check whether the process(es) |
17630 |
+do finish. It will check repeatedly whether any matching processes |
17631 |
+are running, until none are. If the processes do not exit it will |
17632 |
+then take further action as determined by the schedule. |
17633 |
+ |
17634 |
+If |
17635 |
+.I timeout |
17636 |
+is specified instead of |
17637 |
+.I schedule |
17638 |
+then the schedule |
17639 |
+.IB signal / timeout /KILL/ timeout |
17640 |
+is used, where |
17641 |
+.I signal |
17642 |
+is the signal specified with |
17643 |
+.BR --signal . |
17644 |
+ |
17645 |
+.I schedule |
17646 |
+is a list of at least two items separated by slashes |
17647 |
+.RB ( / ); |
17648 |
+each item may be |
17649 |
+.BI - signal-number |
17650 |
+or [\fB\-\fP]\fIsignal-name\fP, |
17651 |
+which means to send that signal, |
17652 |
+or |
17653 |
+.IR timeout , |
17654 |
+which means to wait that many seconds for processes to |
17655 |
+exit, |
17656 |
+or |
17657 |
+.BR forever , |
17658 |
+which means to repeat the rest of the schedule forever if |
17659 |
+necessary. |
17660 |
+ |
17661 |
+If the end of the schedule is reached and |
17662 |
+.BR forever |
17663 |
+is not specified, then |
17664 |
+.B start-stop-daemon |
17665 |
+exits with error status 2. |
17666 |
+If a schedule is specified, then any signal specified |
17667 |
+with |
17668 |
+.B --signal |
17669 |
+is ignored. |
17670 |
+.TP |
17671 |
+\fB-a\fP|\fB--startas\fP \fIpathname\fP |
17672 |
+With |
17673 |
+.BR --start , |
17674 |
+start the process specified by |
17675 |
+.IR pathname . |
17676 |
+If not specified, defaults to the argument given to |
17677 |
+.BR --exec . |
17678 |
+.TP |
17679 |
+.BR -t | --test |
17680 |
+Print actions that would be taken and set appropriate return value, |
17681 |
+but take no action. |
17682 |
+.TP |
17683 |
+.BR -o | --oknodo |
17684 |
+Return exit status 0 instead of 1 if no actions are (would be) taken. |
17685 |
+.TP |
17686 |
+.BR -q | --quiet |
17687 |
+Do not print informational messages; only display error messages. |
17688 |
+.TP |
17689 |
+\fB-c\fP|\fB--chuid\fP \fIusername\fR|\fIuid\fP |
17690 |
+Change to this username/uid before starting the process. You can also |
17691 |
+specify a group by appending a |
17692 |
+.BR : , |
17693 |
+then the group or gid in the same way |
17694 |
+as you would for the `chown' command (\fIuser\fP\fB:\fP\fIgroup\fP). |
17695 |
+When using this option |
17696 |
+you must realize that the primary and supplemental groups are set as well, |
17697 |
+even if the |
17698 |
+.B --group |
17699 |
+option is not specified. The |
17700 |
+.B --group |
17701 |
+option is only for |
17702 |
+groups that the user isn't normally a member of (like adding per/process |
17703 |
+group membership for generic users like |
17704 |
+.BR nobody ). |
17705 |
+.TP |
17706 |
+\fB-r\fP|\fB--chroot\fP \fIroot\fP |
17707 |
+Chdir and chroot to |
17708 |
+.I root |
17709 |
+before starting the process. Please note that the pidfile is also written |
17710 |
+after the chroot. |
17711 |
+.TP |
17712 |
+\fB-e\fP|\fB--env\fP \fIenv-name\fP |
17713 |
+Set an environment variable whose name and value is |
17714 |
+.I env-name |
17715 |
+before starting |
17716 |
+.I executable. |
17717 |
+Example: -e HOME="/home/user" exports an environment variable whose name |
17718 |
+is HOME with value "/home/user". |
17719 |
+.TP |
17720 |
+.BR -b | --background |
17721 |
+Typically used with programs that don't detach on their own. This option |
17722 |
+will force |
17723 |
+.B start-stop-daemon |
17724 |
+to fork before starting the process, and force it into the background. |
17725 |
+.B WARNING: start-stop-daemon |
17726 |
+cannot check the exit status if the process fails to execute for |
17727 |
+.B any |
17728 |
+reason. This is a last resort, and is only meant for programs that either |
17729 |
+make no sense forking on their own, or where it's not feasible to add the |
17730 |
+code for it to do this itself. |
17731 |
+.TP |
17732 |
+.BR -N | --nicelevel |
17733 |
+This alters the prority of the process before starting it. |
17734 |
+.TP |
17735 |
+.BR -m | --make-pidfile |
17736 |
+Used when starting a program that does not create its own pid file. This |
17737 |
+option will make |
17738 |
+.B start-stop-daemon |
17739 |
+create the file referenced with |
17740 |
+.B --pidfile |
17741 |
+and place the pid into it just before executing the process. Note, it will |
17742 |
+not be removed when stopping the program. |
17743 |
+.B NOTE: |
17744 |
+This feature may not work in all cases. Most notably when the program |
17745 |
+being executed forks from its main process. Because of this it is usually |
17746 |
+only useful when combined with the |
17747 |
+.B --background |
17748 |
+option. |
17749 |
+.TP |
17750 |
+.BR -v | --verbose |
17751 |
+Print verbose informational messages. |
17752 |
+.TP |
17753 |
+.BR -H | --help |
17754 |
+Print help information; then exit. |
17755 |
+.TP |
17756 |
+.BR -V | --version |
17757 |
+Print version information; then exit. |
17758 |
+ |
17759 |
+.SH AUTHORS |
17760 |
+Marek Michalkiewicz <marekm@×××××××××××××××××××××××.pl> based on |
17761 |
+a previous version by Ian Jackson <ian@×××××××××××××××××××.uk>. |
17762 |
+ |
17763 |
+Manual page by Klee Dienes <klee@×××.edu>, partially reformatted |
17764 |
+by Ian Jackson. |
17765 |
|
17766 |
Added: trunk/baselayout-prefix/rc-lists/boot |
17767 |
=================================================================== |
17768 |
--- trunk/baselayout-prefix/rc-lists/boot (rev 0) |
17769 |
+++ trunk/baselayout-prefix/rc-lists/boot 2011-03-31 14:11:17 UTC (rev 1682) |
17770 |
@@ -0,0 +1,13 @@ |
17771 |
+bootmisc |
17772 |
+checkroot |
17773 |
+consolefont |
17774 |
+keymaps |
17775 |
+modules |
17776 |
+rmnologin |
17777 |
+urandom |
17778 |
+checkfs |
17779 |
+clock |
17780 |
+domainname |
17781 |
+hostname |
17782 |
+localmount |
17783 |
+net.lo |
17784 |
|
17785 |
Added: trunk/baselayout-prefix/rc-lists/default |
17786 |
=================================================================== |
17787 |
--- trunk/baselayout-prefix/rc-lists/default (rev 0) |
17788 |
+++ trunk/baselayout-prefix/rc-lists/default 2011-03-31 14:11:17 UTC (rev 1682) |
17789 |
@@ -0,0 +1,3 @@ |
17790 |
+hdparm |
17791 |
+local |
17792 |
+netmount |
17793 |
|
17794 |
Added: trunk/baselayout-prefix/rc-lists/nonetwork |
17795 |
=================================================================== |
17796 |
--- trunk/baselayout-prefix/rc-lists/nonetwork (rev 0) |
17797 |
+++ trunk/baselayout-prefix/rc-lists/nonetwork 2011-03-31 14:11:17 UTC (rev 1682) |
17798 |
@@ -0,0 +1 @@ |
17799 |
+local |
17800 |
|
17801 |
Added: trunk/baselayout-prefix/rc-lists/single |
17802 |
=================================================================== |
17803 |
Added: trunk/baselayout-prefix/sbin/MAKEDEV |
17804 |
=================================================================== |
17805 |
--- trunk/baselayout-prefix/sbin/MAKEDEV (rev 0) |
17806 |
+++ trunk/baselayout-prefix/sbin/MAKEDEV 2011-03-31 14:11:17 UTC (rev 1682) |
17807 |
@@ -0,0 +1,2123 @@ |
17808 |
+#! /bin/sh - |
17809 |
+# $Id: MAKEDEV 2240 2006-09-14 10:13:11Z uberlord $ |
17810 |
+ |
17811 |
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---# |
17812 |
+# Customisation: |
17813 |
+# The devices fall into various classes. This section contains the mapping |
17814 |
+# from a class name into a group name and permission. |
17815 |
+# You will almost certainly need to edit the group name to match your |
17816 |
+# system, and you may change the permissions to suit your preference. These |
17817 |
+# lines _must_ be of the format "user group perm". |
17818 |
+ |
17819 |
+ public=" root root 0666" |
17820 |
+private=" root root 0600" |
17821 |
+ system=" root root 0660" |
17822 |
+ kmem=" root kmem 0640" |
17823 |
+ tty=" root tty 0666" |
17824 |
+ cons=" root tty 0600" |
17825 |
+dialout=" root dialout 0660" |
17826 |
+ dip=" root dip 0660" |
17827 |
+ mouse=" root root 0660" |
17828 |
+printer=" root lp 0660" |
17829 |
+ floppy=" root floppy 0660" |
17830 |
+ disk=" root disk 0660" |
17831 |
+ scsi=" root root 0600" |
17832 |
+ cdrom=" root cdrom 0660" |
17833 |
+ tape=" root tape 0660" |
17834 |
+ audio=" root audio 0660" |
17835 |
+ video=" root video 0660" |
17836 |
+ ibcs2=" root root 0666" |
17837 |
+scanner=" root root 0666" |
17838 |
+ coda=" root root 0600" |
17839 |
+ ipsec=" root root 0200" |
17840 |
+readable=" root root 0444" |
17841 |
+ |
17842 |
+MAXVT=63 |
17843 |
+ |
17844 |
+# defaults for $major_* |
17845 |
+major_ide0=3 |
17846 |
+major_ide1=22 |
17847 |
+major_sd=8 |
17848 |
+major_lp=6 |
17849 |
+ |
17850 |
+# Remark: OSS/Linux becomes major_OSSLinux |
17851 |
+ |
17852 |
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---# |
17853 |
+ |
17854 |
+# try to do the right things if udev is running |
17855 |
+if [ "$WRITE_ON_UDEV" ]; then |
17856 |
+ : |
17857 |
+elif [ -d /dev/.static/dev/ ] && [ "`pwd`" = /dev ] && [ -e /proc/mounts ] \ |
17858 |
+ && grep -qE '^[^ ]+ /dev/\.static/dev' /proc/mounts; then |
17859 |
+ cd /dev/.static/dev/ |
17860 |
+elif [ -d /.dev/ ] && [ "`pwd`" = /dev ] && [ -e /proc/mounts ] \ |
17861 |
+ && grep -qE '^[^ ]+ /\.dev' /proc/mounts; then |
17862 |
+ cd /.dev/ |
17863 |
+elif [ -d .udevdb/ ] && [ "`pwd`" = /dev ]; then |
17864 |
+ echo ".udevdb presence implies active udev. Aborting MAKEDEV invocation." |
17865 |
+ # use exit 0, not 1, so postinst scripts don't fail on this |
17866 |
+ exit 0 |
17867 |
+fi |
17868 |
+ |
17869 |
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---# |
17870 |
+ |
17871 |
+# don't stomp on devfs users |
17872 |
+if [ -c .devfsd ] |
17873 |
+then |
17874 |
+ echo ".devfsd presence implies active DevFS. Aborting MAKEDEV invocation." |
17875 |
+ # use exit 0, not 1, so postinst scripts don't fail on this |
17876 |
+ exit 0 |
17877 |
+fi |
17878 |
+ |
17879 |
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---# |
17880 |
+ |
17881 |
+# don't stomp on non-Linux users |
17882 |
+if [ "$(uname -s)" != "Linux" ] |
17883 |
+then |
17884 |
+ echo "Results undefined on non-Linux systems, aborting MAKEDEV invocation." |
17885 |
+ # use exit 0, not 1, so postinst scripts don't fail on this |
17886 |
+ exit 0 |
17887 |
+fi |
17888 |
+ |
17889 |
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---# |
17890 |
+ |
17891 |
+procfs=/proc |
17892 |
+ |
17893 |
+opt_v= |
17894 |
+opt_d= |
17895 |
+opt_n= |
17896 |
+ |
17897 |
+while [ $# -ge 1 ] |
17898 |
+do |
17899 |
+ case $1 in |
17900 |
+ --) shift; break ;; |
17901 |
+ -v) shift; opt_v=1 ;; |
17902 |
+ -d) shift; opt_d=1 ;; |
17903 |
+ -n) shift; opt_n=1; opt_v=1 ;; |
17904 |
+ -V) shift; opt_V=1 ;; |
17905 |
+ -*) echo "$0: unknown flag \"$1\"" >&2; exit 1 ;; |
17906 |
+ *) break ;; |
17907 |
+ esac |
17908 |
+done |
17909 |
+ |
17910 |
+if [ "$opt_V" ] |
17911 |
+then |
17912 |
+ echo "This is MAKEDEV based on Debian's makedev_2.3.1-78." |
17913 |
+ echo "See the MAKEDEV(8) manpage for more information." |
17914 |
+ exit 0 |
17915 |
+fi |
17916 |
+ |
17917 |
+opts="${opt_n:+-n} ${opt_v:+-v} ${opt_d:+-d}" |
17918 |
+ |
17919 |
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---# |
17920 |
+ |
17921 |
+devicename () { # translate device names to something safe |
17922 |
+ echo "$*" | sed -e 's/[^A-Za-z0-9_]/_/g' |
17923 |
+} |
17924 |
+ |
17925 |
+makedev () { # usage: makedev name [bcu] major minor owner group mode |
17926 |
+ if [ "$opt_v" ] |
17927 |
+ then if [ "$opt_d" ] |
17928 |
+ then echo "delete $1" |
17929 |
+ else echo "create $1 $2 $3 $4 $5:$6 $7" |
17930 |
+ fi |
17931 |
+ fi |
17932 |
+ # missing parameters are a bug - bail - should we do an exit 1 here? |
17933 |
+ case :$1:$2:$3:$4:$5:$6:$7: in |
17934 |
+ *::*) echo "Warning: MAKEDEV $@ is missing parameter(s)." >&2;; |
17935 |
+ esac |
17936 |
+ if [ ! "$opt_n" ] |
17937 |
+ then |
17938 |
+ if [ "$opt_d" ] |
17939 |
+ then |
17940 |
+ rm -f $1 |
17941 |
+ else |
17942 |
+ rm -f $1- |
17943 |
+ if mknod $1- $2 $3 $4 && |
17944 |
+ chown $5:$6 $1- && |
17945 |
+ chmod $7 $1- && |
17946 |
+ mv $1- $1 |
17947 |
+ then |
17948 |
+ : # it worked |
17949 |
+ else |
17950 |
+ # Didn't work, clean up any mess... |
17951 |
+ echo "makedev $@: failed" |
17952 |
+ rm -f $1- |
17953 |
+ fi |
17954 |
+ fi |
17955 |
+ fi |
17956 |
+} |
17957 |
+symlink () { # usage: symlink name target |
17958 |
+ if [ "$opt_v" ] |
17959 |
+ then if [ "$opt_d" ] |
17960 |
+ then echo "delete $1" |
17961 |
+ else echo "create $1 -> $2" |
17962 |
+ fi |
17963 |
+ fi |
17964 |
+ [ ! "$opt_n" ] && rm -f $1 && |
17965 |
+ [ ! "$opt_d" ] && ln -s $2 $1 |
17966 |
+} |
17967 |
+ |
17968 |
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---# |
17969 |
+ |
17970 |
+# Debian allows us to assume /bin/sh is a POSIX compliant shell, so go for it! |
17971 |
+ |
17972 |
+math () { |
17973 |
+ eval echo "\$(($*))" |
17974 |
+} |
17975 |
+index () { # index string c |
17976 |
+ eval "I=\${1%$2*}" |
17977 |
+ eval echo "\${#I}" |
17978 |
+} |
17979 |
+suffix () { |
17980 |
+ eval echo "\${1#$2}" |
17981 |
+} |
17982 |
+strip () { |
17983 |
+ eval echo "\${1% $2 *} \${1#* $2 }" |
17984 |
+} |
17985 |
+first () { |
17986 |
+ echo "${1%%?}" |
17987 |
+} |
17988 |
+second () { |
17989 |
+ echo "${1##?}" |
17990 |
+} |
17991 |
+substr () { |
17992 |
+ echo $1 | dd bs=1 count=1 skip=$(( $2 - 1 )) 2> /dev/null |
17993 |
+} |
17994 |
+ |
17995 |
+#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---#---# |
17996 |
+ |
17997 |
+devices= |
17998 |
+if [ ! -f $procfs/devices ] |
17999 |
+then |
18000 |
+ echo "$0: warning: can't read $procfs/devices" >&2 |
18001 |
+else |
18002 |
+ exec 3<$procfs/devices |
18003 |
+ while read major device extra <&3 |
18004 |
+ do |
18005 |
+ device=`echo $device | sed 's#/.*##'` |
18006 |
+ case "$major" in |
18007 |
+ Character|Block|'') |
18008 |
+ ;; |
18009 |
+ *) |
18010 |
+ safedevname=`devicename $device` |
18011 |
+ eval "major_$safedevname=$major" |
18012 |
+ devices="$devices $device" |
18013 |
+ ;; |
18014 |
+ esac |
18015 |
+ done |
18016 |
+ exec 3<&- |
18017 |
+fi |
18018 |
+ |
18019 |
+Major () { |
18020 |
+ device=$2 |
18021 |
+ devname=`devicename $1` |
18022 |
+ if [ "$opt_d" ] |
18023 |
+ then |
18024 |
+ echo -1 # don't care |
18025 |
+ else |
18026 |
+ eval echo \${major_$devname:-\${device:?\"unknown major number for $1\"}} |
18027 |
+ fi |
18028 |
+} |
18029 |
+ |
18030 |
+cvt () { |
18031 |
+ while [ $# -ne 0 ] |
18032 |
+ do |
18033 |
+ case "$1" in |
18034 |
+ mem|tty|ttyp|cua|cub|cui) ;; |
18035 |
+ hd) (for d in a b c d e f g h ; do |
18036 |
+ echo -n hd$d " " |
18037 |
+ done) ; echo |
18038 |
+ ;; |
18039 |
+ ide0) echo hda hdb ;; |
18040 |
+ ide1) echo hdc hdd ;; |
18041 |
+ ide2) echo hde hdf ;; |
18042 |
+ ide3) echo hdg hdh ;; |
18043 |
+ ide4) echo hdi hdj ;; |
18044 |
+ ide5) echo hdk hdl ;; |
18045 |
+ ide6) echo hdm hdn ;; |
18046 |
+ ide7) echo hdo hdp ;; |
18047 |
+ ide8) echo hdq hdr ;; |
18048 |
+ ide9) echo hds hdt ;; |
18049 |
+ sd) echo sda sdb sdc sdd ;; |
18050 |
+ dasd) (for d in a b c d e f g h i j k l m \ |
18051 |
+ n o p q r s t u v w x y z ; do |
18052 |
+ echo -n dasd$d " " |
18053 |
+ done) ; echo |
18054 |
+ ;; |
18055 |
+ raw) echo raw ;; |
18056 |
+ sg) echo sg ;; |
18057 |
+ sr) echo scd ;; |
18058 |
+ st) echo st0 ;; |
18059 |
+ xd) echo xda xdb ;; |
18060 |
+ ad) echo ada adb ;; |
18061 |
+ fd) echo fd0 fd1 ;; |
18062 |
+ lp) echo lp ;; |
18063 |
+ mt) echo ftape ;; |
18064 |
+ qft) echo ftape ;; |
18065 |
+ loop) echo loop ;; |
18066 |
+ md) echo md ;; |
18067 |
+ ibcs2) echo ibcs2 ;; |
18068 |
+ tpqic02) echo qic ;; |
18069 |
+ sound) echo audio ;; |
18070 |
+ logiscan) echo logiscan ;; |
18071 |
+ ac4096) echo ac4096 ;; |
18072 |
+ hw) echo helloworld ;; |
18073 |
+ sbpcd | sbpcd[123]) echo $1 ;; |
18074 |
+ joystick) echo js ;; |
18075 |
+ input) echo input ;; |
18076 |
+ apm_bios) echo apm ;; |
18077 |
+ dcf) echo dcf ;; |
18078 |
+ aztcd) echo aztcd ;; |
18079 |
+ cm206cd) echo cm206cd ;; |
18080 |
+ gscd) echo gscd ;; |
18081 |
+ pcmcia) ;; # taken care of by its own driver |
18082 |
+ ttyC) echo cyclades ;; |
18083 |
+ isdn) echo isdnmodem isdnbri dcbri ;; |
18084 |
+ vcs) ;; |
18085 |
+ pty) echo pty ;; |
18086 |
+ misc) echo misc ;; |
18087 |
+ 3dfx) echo 3dfx ;; |
18088 |
+ agpgart) echo agpgart ;; |
18089 |
+ microcode) echo microcode ;; |
18090 |
+ ipmi|ipmikcs) echo ipmi ;; |
18091 |
+ fb) echo fb ;; |
18092 |
+ nb|drbd) echo nb0 nb1 nb2 nb3 nb4 nb5 nb6 nb7;; |
18093 |
+ netlink) echo netlink ;; |
18094 |
+ tap) echo netlink ;; |
18095 |
+ hamradio) echo hamradio ;; |
18096 |
+ snd) ;; |
18097 |
+ ptm) ;; |
18098 |
+ pts) ;; |
18099 |
+ ttyB) (for l in 0 1 2 3 4 5 6 7 ; do |
18100 |
+ echo -n ttyB$l " " |
18101 |
+ done) ; echo |
18102 |
+ ;; |
18103 |
+ ttyS) echo ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 ;; |
18104 |
+ ttyI) echo ttyI0 ttyI1 ttyI2 ttyI3 ;; |
18105 |
+ ircomm|irlpt) irda ;; |
18106 |
+ ppp) echo ppp ;; |
18107 |
+ usb) echo usb ;; |
18108 |
+ dpt_i2o) echo dpti ;; |
18109 |
+ bluetooth) echo bluetooth ;; |
18110 |
+ lvm) ;; # taken care of by LVM userspace tools |
18111 |
+ ramdisk) echo ram ;; |
18112 |
+ *) echo "$0: don't know what \"$1\" is" >&2 ;; |
18113 |
+ esac |
18114 |
+ shift |
18115 |
+ done |
18116 |
+} |
18117 |
+ |
18118 |
+get_arch() { |
18119 |
+ case `uname -m` in |
18120 |
+ arm*) echo arm;; |
18121 |
+ i?86) echo i386;; |
18122 |
+ ppc*) echo powerpc;; |
18123 |
+ s390*) echo s390;; |
18124 |
+ sh*) echo sh;; |
18125 |
+ x86_64) echo i386;; |
18126 |
+ # alpha|hppa|ia64|m68k|mips|sparc |
18127 |
+ *) echo $a;; |
18128 |
+ esac |
18129 |
+} |
18130 |
+ |
18131 |
+for arg in $* |
18132 |
+do |
18133 |
+# case `cvt $arg` in |
18134 |
+ case $arg in |
18135 |
+ generic) |
18136 |
+ $0 $opts generic-`get_arch` |
18137 |
+ ;; |
18138 |
+ generic-alpha) |
18139 |
+ $0 $opts std |
18140 |
+ $0 $opts fd |
18141 |
+ $0 $opts fd0 fd1 |
18142 |
+ $0 $opts hda hdb hdc hdd |
18143 |
+ $0 $opts xda xdb |
18144 |
+ $0 $opts sda sdb sdc sdd |
18145 |
+ $0 $opts scd0 scd1 |
18146 |
+ $0 $opts st0 st1 |
18147 |
+ $0 $opts sg |
18148 |
+ $0 $opts pty |
18149 |
+ $0 $opts console |
18150 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18151 |
+ $0 $opts busmice |
18152 |
+ $0 $opts lp |
18153 |
+ $0 $opts par |
18154 |
+ $0 $opts audio |
18155 |
+ $0 $opts fb |
18156 |
+ $0 $opts dac960 |
18157 |
+ ;; |
18158 |
+ generic-arm) |
18159 |
+ $0 $opts std |
18160 |
+ $0 $opts fd |
18161 |
+ $0 $opts fd0 fd1 |
18162 |
+ $0 $opts hda hdb hdc hdd |
18163 |
+ $0 $opts xda xdb |
18164 |
+ $0 $opts sda sdb sdc sdd |
18165 |
+ $0 $opts scd0 scd1 |
18166 |
+ $0 $opts st0 st1 |
18167 |
+ $0 $opts sg |
18168 |
+ $0 $opts pty |
18169 |
+ $0 $opts console |
18170 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18171 |
+ $0 $opts busmice |
18172 |
+ makedev sunmouse c 10 6 $mouse |
18173 |
+ $0 $opts lp |
18174 |
+ $0 $opts par |
18175 |
+ $0 $opts audio |
18176 |
+ $0 $opts fb |
18177 |
+ ;; |
18178 |
+ generic-hppa) |
18179 |
+ $0 $opts std |
18180 |
+ $0 $opts fd |
18181 |
+ $0 $opts fd0 fd1 |
18182 |
+ $0 $opts hda hdb hdc hdd |
18183 |
+ $0 $opts sda sdb sdc sdd |
18184 |
+ $0 $opts scd0 scd1 |
18185 |
+ $0 $opts st0 st1 |
18186 |
+ $0 $opts sg |
18187 |
+ $0 $opts pty |
18188 |
+ $0 $opts console |
18189 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18190 |
+ $0 $opts ttyB0 ttyB1 ttyB2 ttyB3 ttyB4 ttyB5 ttyB6 ttyB7 |
18191 |
+ $0 $opts busmice |
18192 |
+ $0 $opts lp |
18193 |
+ $0 $opts par |
18194 |
+ $0 $opts audio |
18195 |
+ $0 $opts fb |
18196 |
+ $0 $opts rtc |
18197 |
+ ;; |
18198 |
+ generic-i386) |
18199 |
+ $0 $opts std |
18200 |
+ $0 $opts fd |
18201 |
+ $0 $opts fd0 fd1 |
18202 |
+ $0 $opts hda hdb hdc hdd |
18203 |
+ $0 $opts xda xdb |
18204 |
+ $0 $opts sda sdb sdc sdd |
18205 |
+ $0 $opts scd0 scd1 |
18206 |
+ $0 $opts st0 st1 |
18207 |
+ $0 $opts sg |
18208 |
+ $0 $opts pty |
18209 |
+ $0 $opts console |
18210 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18211 |
+ $0 $opts busmice |
18212 |
+ $0 $opts input |
18213 |
+ $0 $opts lp |
18214 |
+ $0 $opts par |
18215 |
+ $0 $opts audio |
18216 |
+ $0 $opts fb |
18217 |
+ $0 $opts isdn-io eda edb sonycd mcd mcdx cdu535 |
18218 |
+ $0 $opts optcd sjcd cm206cd gscd |
18219 |
+ $0 $opts lmscd sbpcd aztcd bpcd dac960 dpti ida ataraid cciss |
18220 |
+ $0 $opts i2o.hda i2o.hdb i2o.hdc i2o.hdd |
18221 |
+ ;; |
18222 |
+ generic-ia64) |
18223 |
+ $0 $opts std |
18224 |
+ $0 $opts fd |
18225 |
+ $0 $opts fd0 fd1 |
18226 |
+ $0 $opts hda hdb hdc hdd |
18227 |
+ $0 $opts sda sdb sdc sdd |
18228 |
+ $0 $opts scd0 scd1 |
18229 |
+ $0 $opts st0 st1 |
18230 |
+ $0 $opts sg |
18231 |
+ $0 $opts pty |
18232 |
+ $0 $opts console |
18233 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 ttyS5 |
18234 |
+ $0 $opts busmice |
18235 |
+ $0 $opts input |
18236 |
+ $0 $opts lp |
18237 |
+ $0 $opts par |
18238 |
+ $0 $opts audio |
18239 |
+ $0 $opts fb |
18240 |
+ $0 $opts efirtc |
18241 |
+ ;; |
18242 |
+ generic-m68k) |
18243 |
+ $0 $opts std |
18244 |
+ $0 $opts fd |
18245 |
+ $0 $opts fd0 fd1 |
18246 |
+ $0 $opts hda hdb hdc hdd |
18247 |
+ $0 $opts sda sdb sdc sdd |
18248 |
+ $0 $opts scd0 scd1 |
18249 |
+ $0 $opts sg |
18250 |
+ $0 $opts ada adb adc add ade adf |
18251 |
+ $0 $opts pty |
18252 |
+ $0 $opts console |
18253 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 ttyS5 |
18254 |
+ $0 $opts m68k-mice |
18255 |
+ $0 $opts lp |
18256 |
+ $0 $opts par |
18257 |
+ $0 $opts nvram |
18258 |
+ $0 $opts audio |
18259 |
+ $0 $opts fb |
18260 |
+ ;; |
18261 |
+ generic-mips) |
18262 |
+ $0 $opts std |
18263 |
+ $0 $opts fd |
18264 |
+ $0 $opts fd0 fd1 |
18265 |
+ $0 $opts hda hdb |
18266 |
+ $0 $opts sda sdb sdc sdd |
18267 |
+ $0 $opts scd0 scd1 |
18268 |
+ $0 $opts st0 st1 |
18269 |
+ $0 $opts sg |
18270 |
+ $0 $opts pty |
18271 |
+ $0 $opts console |
18272 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18273 |
+ $0 $opts lp |
18274 |
+ $0 $opts par |
18275 |
+ $0 $opts audio |
18276 |
+ $0 $opts fb |
18277 |
+ $0 $opts busmice |
18278 |
+ ;; |
18279 |
+ generic-mipsel) |
18280 |
+ $0 $opts std |
18281 |
+ $0 $opts fd |
18282 |
+ $0 $opts fd0 fd1 |
18283 |
+ $0 $opts hda hdb |
18284 |
+ $0 $opts sda sdb sdc sdd |
18285 |
+ $0 $opts scd0 scd1 |
18286 |
+ $0 $opts st0 st1 |
18287 |
+ $0 $opts sg |
18288 |
+ $0 $opts pty |
18289 |
+ $0 $opts console |
18290 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18291 |
+ $0 $opts lp |
18292 |
+ $0 $opts par |
18293 |
+ $0 $opts audio |
18294 |
+ $0 $opts fb |
18295 |
+ $0 $opts rtc |
18296 |
+ ;; |
18297 |
+ generic-powerpc) |
18298 |
+ $0 $opts std |
18299 |
+ $0 $opts fd |
18300 |
+ $0 $opts fd0 fd1 |
18301 |
+ $0 $opts hda hdb hdc hdd |
18302 |
+ $0 $opts sda sdb sdc sdd |
18303 |
+ $0 $opts scd0 scd1 |
18304 |
+ $0 $opts st0 st1 |
18305 |
+ $0 $opts sg |
18306 |
+ $0 $opts pty |
18307 |
+ $0 $opts console |
18308 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18309 |
+ $0 $opts busmice |
18310 |
+ $0 $opts m68k-mice |
18311 |
+ $0 $opts input |
18312 |
+ $0 $opts lp |
18313 |
+ $0 $opts par |
18314 |
+ $0 $opts nvram |
18315 |
+ $0 $opts audio |
18316 |
+ $0 $opts adb |
18317 |
+ $0 $opts fb |
18318 |
+ $0 $opts rtc |
18319 |
+ $0 $opts isdn-io |
18320 |
+ ;; |
18321 |
+ generic-s390) |
18322 |
+ $0 $opts std |
18323 |
+ $0 $opts fd |
18324 |
+ $0 $opts dasda dasdb dasdc dasdd dasde dasdf dasdg dasdh \ |
18325 |
+ dasdi dasdj dasdk dasdl dasdm dasdn dasdo dasdp \ |
18326 |
+ dasdq dasdr dasds dasdt dasdu dasdv dasdw dasdx \ |
18327 |
+ dasdy dasdz |
18328 |
+ $0 $opts pty |
18329 |
+ $0 $opts consoleonly |
18330 |
+ $0 $opts rtc |
18331 |
+ ;; |
18332 |
+ generic-sh) |
18333 |
+ $0 $opts std |
18334 |
+ $0 $opts fd |
18335 |
+ $0 $opts fd0 fd1 |
18336 |
+ $0 $opts hda hdb |
18337 |
+ $0 $opts sda sdb sdc sdd |
18338 |
+ $0 $opts scd0 scd1 |
18339 |
+ $0 $opts st0 st1 |
18340 |
+ $0 $opts sg |
18341 |
+ $0 $opts pty |
18342 |
+ $0 $opts console |
18343 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18344 |
+ $0 $opts ttySC0 ttySC1 ttySC2 ttySC3 |
18345 |
+ $0 $opts lp |
18346 |
+ $0 $opts par |
18347 |
+ $0 $opts audio |
18348 |
+ $0 $opts fb |
18349 |
+ $0 $opts rtc |
18350 |
+ ;; |
18351 |
+ generic-sparc) |
18352 |
+ $0 $opts std |
18353 |
+ $0 $opts fd |
18354 |
+ $0 $opts fd0 fd1 |
18355 |
+ $0 $opts hda hdb hdc hdd |
18356 |
+ $0 $opts sda sdb sdc sdd |
18357 |
+ $0 $opts scd0 scd1 |
18358 |
+ $0 $opts st0 st1 |
18359 |
+ $0 $opts sg |
18360 |
+ $0 $opts pty |
18361 |
+ $0 $opts console |
18362 |
+ $0 $opts ttyS0 ttyS1 ttyS2 ttyS3 ttyS4 |
18363 |
+ $0 $opts busmice |
18364 |
+ $0 $opts fb |
18365 |
+ $0 $opts rtc |
18366 |
+ makedev kbd c 11 0 $cons |
18367 |
+ makedev sunmouse c 10 6 $mouse |
18368 |
+ symlink mouse sunmouse |
18369 |
+ makedev openprom c 10 139 root root 0664 |
18370 |
+ ;; |
18371 |
+ generic-*) |
18372 |
+ echo "$0: no support for generic on this arch" >&2 |
18373 |
+ exit 1 |
18374 |
+ ;; |
18375 |
+ local) |
18376 |
+ $0.local $opts |
18377 |
+ ;; |
18378 |
+ std) |
18379 |
+ makedev mem c 1 1 $kmem |
18380 |
+ makedev kmem c 1 2 $kmem |
18381 |
+ makedev null c 1 3 $public |
18382 |
+ makedev port c 1 4 $kmem |
18383 |
+ makedev zero c 1 5 $public |
18384 |
+ symlink core $procfs/kcore |
18385 |
+ makedev full c 1 7 $public |
18386 |
+ makedev random c 1 8 $public |
18387 |
+ makedev urandom c 1 9 $readable |
18388 |
+ makedev tty c 5 0 $tty |
18389 |
+ $0 $opts ram |
18390 |
+ $0 $opts loop |
18391 |
+ ;; |
18392 |
+ hamradio) |
18393 |
+ $0 $opts scc |
18394 |
+ $0 $opts bc |
18395 |
+ ;; |
18396 |
+ scc) |
18397 |
+ for unit in 0 1 2 3 4 5 6 7 |
18398 |
+ do |
18399 |
+ makedev scc$unit c 34 $unit $system |
18400 |
+ done |
18401 |
+ ;; |
18402 |
+ bc) |
18403 |
+ for unit in 0 1 2 3 |
18404 |
+ do |
18405 |
+ makedev bc$unit c 51 $unit $system |
18406 |
+ done |
18407 |
+ ;; |
18408 |
+ random) |
18409 |
+ makedev random c 1 8 $public |
18410 |
+ ;; |
18411 |
+ urandom) |
18412 |
+ makedev urandom c 1 9 $readable |
18413 |
+ ;; |
18414 |
+ ram) |
18415 |
+ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do |
18416 |
+ makedev ram$i b 1 $i $disk |
18417 |
+ done |
18418 |
+ symlink ram ram1 |
18419 |
+ ;; |
18420 |
+ ram[0-9]|ram1[0-6]) |
18421 |
+ unit=`suffix $arg ram` |
18422 |
+ makedev ram$unit b 1 $unit $disk |
18423 |
+ ;; |
18424 |
+ initrd) |
18425 |
+ makedev initrd b 1 250 $disk |
18426 |
+ ;; |
18427 |
+ raw) |
18428 |
+ makedev rawctl c 162 0 $disk |
18429 |
+ mkdir -p raw |
18430 |
+ for i in 1 2 3 4 5 6 7 8; do |
18431 |
+ makedev raw/raw$i c 162 $i $disk |
18432 |
+ done |
18433 |
+ ;; |
18434 |
+ consoleonly) |
18435 |
+ makedev tty0 c 4 0 $cons |
18436 |
+ # new kernels need a device, old ones a symlink... sigh |
18437 |
+ kern_rev1=`uname -r | sed -e 's@^\([^.]*\)\..*@\1@'` |
18438 |
+ kern_rev2=`uname -r | sed -e 's@^[^.]*\.\([^.]*\)\..*@\1@'` |
18439 |
+ if [ $kern_rev1 -gt 2 ] |
18440 |
+ then |
18441 |
+ makedev console c 5 1 $cons |
18442 |
+ else |
18443 |
+ if [ $kern_rev1 -eq 2 ] && [ $kern_rev2 -ge 1 ] |
18444 |
+ then |
18445 |
+ makedev console c 5 1 $cons |
18446 |
+ else |
18447 |
+ symlink console tty0 |
18448 |
+ fi |
18449 |
+ fi |
18450 |
+ ;; |
18451 |
+ console) |
18452 |
+ $0 $opts consoleonly |
18453 |
+ major=`Major vcs 7` # not fatal |
18454 |
+ [ "$major" ] && makedev vcs0 c $major 0 $cons |
18455 |
+ symlink vcs vcs0 |
18456 |
+ [ "$major" ] && makedev vcsa0 c $major 128 $cons |
18457 |
+ symlink vcsa vcsa0 |
18458 |
+ # individual vts |
18459 |
+ line=1 |
18460 |
+ while [ $line -le $MAXVT ] && [ $line -le 63 ] |
18461 |
+ do |
18462 |
+ makedev tty$line c 4 $line $cons |
18463 |
+ [ "$major" ] && makedev vcs$line c $major $line $cons |
18464 |
+ [ "$major" ] && makedev vcsa$line c $major `math $line + 128` $cons |
18465 |
+ line=`math $line + 1` |
18466 |
+ done |
18467 |
+ ;; |
18468 |
+ adb) |
18469 |
+ case `get_arch` in |
18470 |
+ powerpc) |
18471 |
+ # ADB bus devices (char) |
18472 |
+ makedev adb c 56 0 $mouse |
18473 |
+ makedev adbmouse c 10 10 $mouse |
18474 |
+ ;; |
18475 |
+ m68k) |
18476 |
+ # ACSI disk 2, whole device (block) |
18477 |
+ makedev adb b 28 16 $disk |
18478 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
18479 |
+ do |
18480 |
+ minor=$(( 16 + $part )) |
18481 |
+ makedev adb$part b 28 $minor $disk |
18482 |
+ done |
18483 |
+ ;; |
18484 |
+ *) |
18485 |
+ echo "no support for adb on this arch" >&2 |
18486 |
+ exit 1 |
18487 |
+ ;; |
18488 |
+ esac |
18489 |
+ ;; |
18490 |
+ raw1394) |
18491 |
+ makedev raw1394 c 171 0 $disk |
18492 |
+ ;; |
18493 |
+ video1394) |
18494 |
+ rm -f video1394 |
18495 |
+ mkdir -p video1394 |
18496 |
+ for i in `seq 0 15` |
18497 |
+ do |
18498 |
+ makedev video1394/$i c 171 `math 16 + $i` $video |
18499 |
+ done |
18500 |
+ ;; |
18501 |
+ nvram) |
18502 |
+ makedev nvram c 10 144 $mouse |
18503 |
+ ;; |
18504 |
+ tty[1-9]|tty[1-5][0-9]|tty[6][0-3]) |
18505 |
+ line=`suffix $arg tty` |
18506 |
+ makedev tty$line c 4 $line $cons |
18507 |
+ ;; |
18508 |
+ ttyS[0-9]|ttyS[1-5][0-9]|ttyS[6][0-3]) |
18509 |
+ line=`suffix $arg ttyS` |
18510 |
+ minor=`math 64 + $line` |
18511 |
+ makedev ttyS$line c 4 $minor $dialout |
18512 |
+ ;; |
18513 |
+ ttySC[0-3]) |
18514 |
+ line=`suffix $arg ttySC` |
18515 |
+ minor=`math 8 + $line` |
18516 |
+ makedev ttySC$line c 204 $minor $dialout |
18517 |
+ ;; |
18518 |
+ ttyB[0-7]) |
18519 |
+ minor=`suffix $arg ttyB` |
18520 |
+ makedev ttyB$minor c 11 $minor $dialout |
18521 |
+ ;; |
18522 |
+ pty[a-ep-z]) |
18523 |
+ bank=`suffix $arg pty` |
18524 |
+ base=`index pqrstuvwxyzabcde $bank` |
18525 |
+ base=`math $base \* 16` |
18526 |
+ for i in 0 1 2 3 4 5 6 7 8 9 a b c d e f |
18527 |
+ do |
18528 |
+ j=`index 0123456789abcdef $i` |
18529 |
+ makedev pty$bank$i c 2 `math $base + $j` $tty |
18530 |
+ makedev tty$bank$i c 3 `math $base + $j` $tty |
18531 |
+ done |
18532 |
+ ;; |
18533 |
+ pty) |
18534 |
+ ptysufs="" |
18535 |
+ for i in p q r s t u v w x y z a b c d e |
18536 |
+ do |
18537 |
+ ptysufs="$ptysufs pty$i" |
18538 |
+ done |
18539 |
+ $0 $opts $ptysufs ptmx |
18540 |
+ ;; |
18541 |
+ ptmx) |
18542 |
+ # master pty multiplexer for 2.1 kernels |
18543 |
+ makedev ptmx c 5 2 $tty |
18544 |
+ ;; |
18545 |
+ cyclades|ttyC) |
18546 |
+ major1=`Major ttyC 19` || continue |
18547 |
+ #major2=`Major cub 20` || continue |
18548 |
+ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 \ |
18549 |
+ 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
18550 |
+ do |
18551 |
+ makedev ttyC$i c $major1 $i $dialout |
18552 |
+ #makedev cub$i c $major2 $i $dialout |
18553 |
+ done |
18554 |
+ ;; |
18555 |
+ stallion|ttyE) |
18556 |
+ major1=`Major ttyE 24` || continue |
18557 |
+ #major2=`Major cue 25` || continue |
18558 |
+ majorc=28 |
18559 |
+ minor=0 |
18560 |
+ until [ $minor -gt 256 ] |
18561 |
+ do |
18562 |
+ makedev ttyE$minor c $major1 $minor $dialout |
18563 |
+ #makedev cue$minor c $major2 $minor $dialout |
18564 |
+ minor=`math $minor + 1` |
18565 |
+ done |
18566 |
+ for i in 0 1 2 3 |
18567 |
+ do |
18568 |
+ makedev staliomem$i c $majorc $i $private |
18569 |
+ done |
18570 |
+ ;; |
18571 |
+ chase|ttyH) |
18572 |
+ major1=`Major ttyH 17` || continue |
18573 |
+ #major2=`Major cuh 18` || continue |
18574 |
+ minor=0 |
18575 |
+ until [ $minor -gt 16 ] # tell me if 16 is wrong |
18576 |
+ do |
18577 |
+ makedev ttyH$minor c $major1 $minor $dialout |
18578 |
+ #makedev cuh$minor c $major2 $minor $dialout |
18579 |
+ minor=`math $minor + 1` |
18580 |
+ done |
18581 |
+ ;; |
18582 |
+ rocketport|ttyR) |
18583 |
+ major1=`Major ttyR 46` || continue |
18584 |
+ #major2=`Major cur 47` || continue |
18585 |
+ minor=0 |
18586 |
+ until [ $minor -gt 64 ] # tell me if 64 is wrong |
18587 |
+ do |
18588 |
+ makedev ttyR$minor c $major1 $minor $dialout |
18589 |
+ #makedev cur$minor c $major2 $minor $dialout |
18590 |
+ minor=`math $minor + 1` |
18591 |
+ done |
18592 |
+ ;; |
18593 |
+ ttyV) |
18594 |
+ major1=`Major ttyV 105` || continue |
18595 |
+ #major2=`Major cuv 106` || continue |
18596 |
+ minor=0 |
18597 |
+ until [ $minor -gt 16 ] # tell me if 16 is wrong |
18598 |
+ do |
18599 |
+ makedev ttyV$minor c $major1 $minor $dialout |
18600 |
+ #makedev cuv$minor c $major2 $minor $dialout |
18601 |
+ minor=`math $minor + 1` |
18602 |
+ done |
18603 |
+ ;; |
18604 |
+ digi|ttyD) |
18605 |
+ major1=`Major ttyD 22` || continue |
18606 |
+ #major2=`Major cud 23` || continue |
18607 |
+ minor=0 |
18608 |
+ until [ $minor -gt 16 ] # tell me if 16 is wrong |
18609 |
+ do |
18610 |
+ makedev ttyD$minor c $major1 $minor $dialout |
18611 |
+ #makedev cud$minor c $major2 $minor $dialout |
18612 |
+ minor=`math $minor + 1` |
18613 |
+ done |
18614 |
+ ;; |
18615 |
+ specialix|ttyX) |
18616 |
+ major1=`Major ttyX 32` || continue |
18617 |
+ #major2=`Major cux 33` || continue |
18618 |
+ minor=0 |
18619 |
+ until [ $minor -gt 16 ] # tell me if 16 is wrong |
18620 |
+ do |
18621 |
+ makedev ttyX$minor c $major1 $minor $dialout |
18622 |
+ #makedev cux$minor c $major2 $minor $dialout |
18623 |
+ minor=`math $minor + 1` |
18624 |
+ done |
18625 |
+ ;; |
18626 |
+ specialixIO8|ttyW) |
18627 |
+ major1=`Major ttyW 75` || continue |
18628 |
+ #major2=`Major cuw 76` || continue |
18629 |
+ minor=0 |
18630 |
+ until [ $minor -gt 16 ] # tell me if 16 is wrong |
18631 |
+ do |
18632 |
+ makedev ttyW$minor c $major1 $minor $dialout |
18633 |
+ #makedev cuw$minor c $major2 $minor $dialout |
18634 |
+ minor=`math $minor + 1` |
18635 |
+ done |
18636 |
+ ;; |
18637 |
+ PAM|ttyM) |
18638 |
+ major1=`Major ttyM 79` || continue |
18639 |
+ #major2=`Major cum 80` || continue |
18640 |
+ minor=0 |
18641 |
+ until [ $minor -gt 16 ] # tell me if 16 is wrong |
18642 |
+ do |
18643 |
+ makedev ttyM$minor c $major1 $minor $dialout |
18644 |
+ #makedev cum$minor c $major2 $minor $dialout |
18645 |
+ minor=`math $minor + 1` |
18646 |
+ done |
18647 |
+ ;; |
18648 |
+ riscom|ttyL) |
18649 |
+ major=`Major ttyL 48` || continue |
18650 |
+ minor=0 |
18651 |
+ until [ $minor -gt 16 ] # tell me if 16 is wrong |
18652 |
+ do |
18653 |
+ makedev ttyL$minor c $major $minor $dialout |
18654 |
+ minor=`math $minor + 1` |
18655 |
+ done |
18656 |
+ ;; |
18657 |
+ computone|ttyF) |
18658 |
+ major=`Major ttyF 71` || continue |
18659 |
+ #major2=`Major cuf 72` || continue |
18660 |
+ minor=0 |
18661 |
+ until [ $minor -gt 255 ] |
18662 |
+ do |
18663 |
+ makedev ttyF$minor c $major $minor $dialout |
18664 |
+ #makedev cuf$minor c $major2 $minor $dialout |
18665 |
+ minor=`math $minor + 1` |
18666 |
+ done |
18667 |
+ major=73 |
18668 |
+ for i in 0 4 8 12 |
18669 |
+ do |
18670 |
+ makedev ip2ipl$i c $major $i $private |
18671 |
+ makedev ip2stat$i c $major `math $i + 1` $private |
18672 |
+ done |
18673 |
+ ;; |
18674 |
+ ESP|ttyP) |
18675 |
+ major=`Major ttyP 57` || continue |
18676 |
+ #major2=`Major cup 58` || continue |
18677 |
+ minor=0 |
18678 |
+ until [ $minor -gt 4 ] # tell me if 4 is wrong |
18679 |
+ do |
18680 |
+ makedev ttyP$minor c $major $minor $dialout |
18681 |
+ #makedev cup$minor c $major2 $minor $dialout |
18682 |
+ minor=`math $minor + 1` |
18683 |
+ done |
18684 |
+ ;; |
18685 |
+ COMX|comx) |
18686 |
+ major=`Major comx 88` || continue |
18687 |
+ minor=0 |
18688 |
+ until [ $minor -gt 4 ] # tell me if 4 is wrong |
18689 |
+ do |
18690 |
+ makedev comx$minor c $major $minor $private |
18691 |
+ minor=`math $minor + 1` |
18692 |
+ done |
18693 |
+ ;; |
18694 |
+ isdnmodem|ttyI) |
18695 |
+ major1=`Major ttyI 43` || continue |
18696 |
+ #major2=`Major cui 44` || continue |
18697 |
+ minor=0 |
18698 |
+ until [ $minor -gt 63 ] |
18699 |
+ do |
18700 |
+ makedev ttyI$minor c $major1 $minor $dialout |
18701 |
+ #makedev cui$minor c $major2 $minor $dialout |
18702 |
+ minor=`math $minor + 1` |
18703 |
+ done |
18704 |
+ ;; |
18705 |
+ isdnbri) |
18706 |
+ major=45 |
18707 |
+ minor=0 |
18708 |
+ until [ $minor -gt 63 ] |
18709 |
+ do |
18710 |
+ makedev isdn$minor c $major $minor $dialout |
18711 |
+ makedev isdnctrl$minor c $major `math $minor + 64` $dialout |
18712 |
+ makedev ippp$minor c $major `math $minor + 128` $dialout |
18713 |
+ minor=`math $minor + 1` |
18714 |
+ done |
18715 |
+ makedev isdninfo c $major 255 $private |
18716 |
+ ;; |
18717 |
+ dcbri) |
18718 |
+ major=52 |
18719 |
+ for i in 0 1 2 3 |
18720 |
+ do |
18721 |
+ makedev dcbri$i c $major $i $dialout |
18722 |
+ done |
18723 |
+ ;; |
18724 |
+ capi) |
18725 |
+ major=68 |
18726 |
+ makedev capi20 c $major 0 $dialout |
18727 |
+ for i in 0 1 2 3 4 5 6 7 8 9 |
18728 |
+ do |
18729 |
+ makedev capi20.0$i c $major `math $i + 1` $dialout |
18730 |
+ done |
18731 |
+ for i in 10 11 12 13 14 15 16 17 18 19 |
18732 |
+ do |
18733 |
+ makedev capi20.$i c $major `math $i + 1` $dialout |
18734 |
+ done |
18735 |
+ ;; |
18736 |
+ ubd) |
18737 |
+ major=98 |
18738 |
+ for devicenum in 0 1 2 3 4 5 6 7 |
18739 |
+ do |
18740 |
+ device=ubd`substr abcdefgh $(($devicenum + 1))` |
18741 |
+ baseminor=`math $devicenum \* 16` |
18742 |
+ makedev $device b $major $baseminor $disk |
18743 |
+ for partition in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
18744 |
+ do |
18745 |
+ minor=`math $baseminor + $partition` |
18746 |
+ makedev $device$partition b $major $minor $disk |
18747 |
+ done |
18748 |
+ done |
18749 |
+ ;; |
18750 |
+ fb) |
18751 |
+ for i in 0 1 2 3 4 5 6 7 |
18752 |
+ do |
18753 |
+ makedev fb$i c 29 $i $video |
18754 |
+ done |
18755 |
+ ;; |
18756 |
+ fb[0-7]) |
18757 |
+ dev=`suffix $arg fb` |
18758 |
+ makedev fb$dev c 29 $dev $video |
18759 |
+ ;; |
18760 |
+ netlink|tap|tap[0-9]|tap1[0-5]) |
18761 |
+ makedev route c 36 0 $coda |
18762 |
+ makedev skip c 36 1 $coda |
18763 |
+ makedev fwmonitor c 36 3 $coda |
18764 |
+ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
18765 |
+ do |
18766 |
+ makedev tap$i c 36 `math $i + 16` $coda |
18767 |
+ done |
18768 |
+ ;; |
18769 |
+ tun) |
18770 |
+ mkdir -p net |
18771 |
+ makedev net/tun c 10 200 $system |
18772 |
+ ;; |
18773 |
+ lp) |
18774 |
+ major=`Major lp 6` || continue |
18775 |
+ makedev ${arg}0 c $major 0 $printer |
18776 |
+ makedev ${arg}1 c $major 1 $printer |
18777 |
+ makedev ${arg}2 c $major 2 $printer |
18778 |
+ ;; |
18779 |
+ par) |
18780 |
+ major=`Major lp 6` || continue |
18781 |
+ makedev ${arg}0 c $major 0 $printer |
18782 |
+ makedev ${arg}1 c $major 1 $printer |
18783 |
+ makedev ${arg}2 c $major 2 $printer |
18784 |
+ ;; |
18785 |
+ parport) |
18786 |
+ major=`Major parport 99` || continue |
18787 |
+ makedev ${arg}0 c $major 0 $printer |
18788 |
+ makedev ${arg}1 c $major 1 $printer |
18789 |
+ makedev ${arg}2 c $major 2 $printer |
18790 |
+ ;; |
18791 |
+ slm) |
18792 |
+ major=`Major slm 28` || continue |
18793 |
+ for i in 0 1 2 3 |
18794 |
+ do |
18795 |
+ makedev slm c $major $i $printer |
18796 |
+ done |
18797 |
+ ;; |
18798 |
+ input) |
18799 |
+ major=`Major pcsp 13` || continue |
18800 |
+ mkdir -p input |
18801 |
+ for i in 0 1 2 3 |
18802 |
+ do |
18803 |
+ makedev input/js$i c $major $i $mouse |
18804 |
+ makedev input/mouse$i c $major `math $i + 32` $mouse |
18805 |
+ makedev input/event$i c $major `math $i + 64` $mouse |
18806 |
+ done |
18807 |
+ makedev input/mice c $major 63 $mouse |
18808 |
+ ;; |
18809 |
+ busmice) |
18810 |
+ major=`Major mouse 10` || continue |
18811 |
+ makedev logibm c $major 0 $mouse |
18812 |
+ makedev psaux c $major 1 $mouse |
18813 |
+ makedev inportbm c $major 2 $mouse |
18814 |
+ makedev atibm c $major 3 $mouse |
18815 |
+ makedev jbm c $major 4 $mouse |
18816 |
+ ;; |
18817 |
+ m68k-mice) |
18818 |
+ major=`Major mouse 10` || continue |
18819 |
+ makedev amigamouse c $major 4 $mouse |
18820 |
+ makedev atarimouse c $major 5 $mouse |
18821 |
+ makedev amigamouse1 c $major 7 $mouse |
18822 |
+ makedev adbmouse c $major 10 $mouse |
18823 |
+ ;; |
18824 |
+ 3dfx) |
18825 |
+ major=`Major $arg 107` || continue |
18826 |
+ makedev $arg c $major 0 $video |
18827 |
+ ;; |
18828 |
+ agpgart) |
18829 |
+ major=`Major $arg 10` || continue |
18830 |
+ makedev $arg c $major 175 $video |
18831 |
+ ;; |
18832 |
+ hwrng) |
18833 |
+ major=`Major $arg 10` || continue |
18834 |
+ makedev $arg c $major 183 $private |
18835 |
+ ;; |
18836 |
+ cpu|microcode) |
18837 |
+ mkdir -p cpu |
18838 |
+ makedev cpu/microcode c 10 184 $private |
18839 |
+ for i in 0 1 2 3 |
18840 |
+ do |
18841 |
+ mkdir -p cpu/$i |
18842 |
+ makedev cpu/$i/msr c 202 $i $private |
18843 |
+ makedev cpu/$i/cpuid c 203 $i $private |
18844 |
+ done |
18845 |
+ ;; |
18846 |
+ ipmi|ipmikcs) |
18847 |
+ major=`Major ipmikcs 10` || continue |
18848 |
+ makedev ipmikcs c $major 173 $private |
18849 |
+ ;; |
18850 |
+ irda) |
18851 |
+ for i in 0 1 |
18852 |
+ do |
18853 |
+ makedev ircomm$i c 161 $i $dialout |
18854 |
+ makedev irlpt$i c 161 `math $i + 16` $printer |
18855 |
+ done |
18856 |
+ ;; |
18857 |
+ irnet) |
18858 |
+ makedev irnet c 10 187 $system |
18859 |
+ ;; |
18860 |
+ misc) |
18861 |
+ major=`Major mouse 10` || continue |
18862 |
+ makedev logibm c $major 0 $mouse |
18863 |
+ makedev psaux c $major 1 $mouse |
18864 |
+ makedev inportbm c $major 2 $mouse |
18865 |
+ makedev atibm c $major 3 $mouse |
18866 |
+ makedev jbm c $major 4 $mouse |
18867 |
+ makedev amigamouse c $major 4 $mouse |
18868 |
+ makedev atarimouse c $major 5 $mouse |
18869 |
+ makedev sunmouse c $major 6 $mouse |
18870 |
+ makedev amigamouse1 c $major 7 $mouse |
18871 |
+ makedev smouse c $major 8 $mouse |
18872 |
+ makedev pc110pad c $major 9 $mouse |
18873 |
+ makedev adbmouse c $major 10 $mouse |
18874 |
+ makedev beep c $major 128 $mouse |
18875 |
+ makedev modreq c $major 129 $mouse |
18876 |
+ makedev watchdog c $major 130 $mouse |
18877 |
+ makedev temperature c $major 131 $mouse |
18878 |
+ makedev hwtrap c $major 132 $mouse |
18879 |
+ makedev exttrp c $major 133 $mouse |
18880 |
+ makedev apm_bios c $major 134 $mouse |
18881 |
+ makedev rtc c $major 135 $mouse |
18882 |
+ makedev openprom c $major 139 root root 0664 |
18883 |
+ makedev relay8 c $major 140 $mouse |
18884 |
+ makedev relay16 c $major 141 $mouse |
18885 |
+ makedev msr c $major 142 $mouse |
18886 |
+ makedev pciconf c $major 143 $mouse |
18887 |
+ makedev nvram c $major 144 $mouse |
18888 |
+ makedev hfmodem c $major 145 $mouse |
18889 |
+ makedev led c $major 151 $mouse |
18890 |
+ makedev mergemem c $major 153 $mouse |
18891 |
+ makedev pmu c $major 154 $mouse |
18892 |
+ ;; |
18893 |
+ pmu) |
18894 |
+ major=`Major mouse 10` || continue |
18895 |
+ makedev pmu c $major 154 $mouse |
18896 |
+ ;; |
18897 |
+ thinkpad) |
18898 |
+ major=`Major mouse 10` || continue |
18899 |
+ mkdir -p thinkpad |
18900 |
+ makedev thinkpad/thinkpad c $major 170 $mouse |
18901 |
+ ;; |
18902 |
+ rtc) |
18903 |
+ major=`Major mouse 10` || continue |
18904 |
+ makedev rtc c $major 135 $mouse |
18905 |
+ ;; |
18906 |
+ efirtc) |
18907 |
+ major=`Major mouse 10` || continue |
18908 |
+ makedev efirtc c $major 136 $mouse |
18909 |
+ ;; |
18910 |
+ mwave) |
18911 |
+ makedev mwave c 10 219 $mouse |
18912 |
+ ;; |
18913 |
+ systrace) |
18914 |
+ makedev systrace c 10 226 $private |
18915 |
+ ;; |
18916 |
+ uinput) |
18917 |
+ makedev input/uinput c 10 223 $mouse |
18918 |
+ ;; |
18919 |
+ js) |
18920 |
+ major=`Major Joystick 13` || continue |
18921 |
+ for unit in 0 1 2 3 |
18922 |
+ do |
18923 |
+ makedev js$unit c $major $unit $readable |
18924 |
+ makedev djs$unit c $major `math $unit + 128` $readable |
18925 |
+ done |
18926 |
+ ;; |
18927 |
+ fd[0-7]) |
18928 |
+ major=`Major fd 2` || continue |
18929 |
+ base=`suffix $arg fd` |
18930 |
+ if [ $base -ge 4 ] |
18931 |
+ then |
18932 |
+ base=`math $base + 124` |
18933 |
+ fi |
18934 |
+ makedev ${arg} b $major $base $floppy |
18935 |
+ makedev ${arg}d360 b $major `math $base + 4` $floppy |
18936 |
+ makedev ${arg}h1200 b $major `math $base + 8` $floppy |
18937 |
+ makedev ${arg}u360 b $major `math $base + 12` $floppy |
18938 |
+ makedev ${arg}u720 b $major `math $base + 16` $floppy |
18939 |
+ makedev ${arg}h360 b $major `math $base + 20` $floppy |
18940 |
+ makedev ${arg}h720 b $major `math $base + 24` $floppy |
18941 |
+ makedev ${arg}u1440 b $major `math $base + 28` $floppy |
18942 |
+ makedev ${arg}u2880 b $major `math $base + 32` $floppy |
18943 |
+ makedev ${arg}CompaQ b $major `math $base + 36` $floppy |
18944 |
+ |
18945 |
+ makedev ${arg}h1440 b $major `math $base + 40` $floppy |
18946 |
+ makedev ${arg}u1680 b $major `math $base + 44` $floppy |
18947 |
+ makedev ${arg}h410 b $major `math $base + 48` $floppy |
18948 |
+ makedev ${arg}u820 b $major `math $base + 52` $floppy |
18949 |
+ makedev ${arg}h1476 b $major `math $base + 56` $floppy |
18950 |
+ makedev ${arg}u1722 b $major `math $base + 60` $floppy |
18951 |
+ makedev ${arg}h420 b $major `math $base + 64` $floppy |
18952 |
+ makedev ${arg}u830 b $major `math $base + 68` $floppy |
18953 |
+ makedev ${arg}h1494 b $major `math $base + 72` $floppy |
18954 |
+ makedev ${arg}u1743 b $major `math $base + 76` $floppy |
18955 |
+ makedev ${arg}h880 b $major `math $base + 80` $floppy |
18956 |
+ makedev ${arg}u1040 b $major `math $base + 84` $floppy |
18957 |
+ makedev ${arg}u1120 b $major `math $base + 88` $floppy |
18958 |
+ makedev ${arg}h1600 b $major `math $base + 92` $floppy |
18959 |
+ makedev ${arg}u1760 b $major `math $base + 96` $floppy |
18960 |
+ makedev ${arg}u1920 b $major `math $base + 100` $floppy |
18961 |
+ makedev ${arg}u3200 b $major `math $base + 104` $floppy |
18962 |
+ makedev ${arg}u3520 b $major `math $base + 108` $floppy |
18963 |
+ makedev ${arg}u3840 b $major `math $base + 112` $floppy |
18964 |
+ makedev ${arg}u1840 b $major `math $base + 116` $floppy |
18965 |
+ makedev ${arg}u800 b $major `math $base + 120` $floppy |
18966 |
+ makedev ${arg}u1600 b $major `math $base + 124` $floppy |
18967 |
+ ;; |
18968 |
+ ed[a-b]) |
18969 |
+ major=`Major ed 36` || continue |
18970 |
+ unit=`suffix $arg ed` |
18971 |
+ base=`index ab $unit` |
18972 |
+ base=`math $base \* 64` |
18973 |
+ makedev ed$unit b $major $base $disk |
18974 |
+ for part in 1 2 3 4 5 6 7 8 # 9 10 11 12 13 14 15 16 17 18 19 20 |
18975 |
+ do |
18976 |
+ makedev ed$unit$part b $major `math $base + $part` $disk |
18977 |
+ done |
18978 |
+ ;; |
18979 |
+ hd[a-b]) |
18980 |
+ major=`Major ide0` || major=`Major hd 3` || continue |
18981 |
+ unit=`suffix $arg hd` |
18982 |
+ base=`index ab $unit` |
18983 |
+ base=`math $base \* 64` |
18984 |
+ makedev hd$unit b $major $base $disk |
18985 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
18986 |
+ do |
18987 |
+ makedev hd$unit$part b $major `math $base + $part` $disk |
18988 |
+ done |
18989 |
+ ;; |
18990 |
+ hd[c-d]) |
18991 |
+ major=`Major ide1 22` || continue |
18992 |
+ unit=`suffix $arg hd` |
18993 |
+ base=`index cd $unit` |
18994 |
+ base=`math $base \* 64` |
18995 |
+ makedev hd$unit b $major $base $disk |
18996 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
18997 |
+ do |
18998 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
18999 |
+ done |
19000 |
+ ;; |
19001 |
+ hd[e-f]) |
19002 |
+ major=`Major ide2 33` || continue |
19003 |
+ unit=`suffix $arg hd` |
19004 |
+ base=`index ef $unit` |
19005 |
+ base=`math $base \* 64` |
19006 |
+ makedev hd$unit b $major $base $disk |
19007 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
19008 |
+ do |
19009 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
19010 |
+ done |
19011 |
+ ;; |
19012 |
+ hd[g-h]) |
19013 |
+ major=`Major ide3 34` || continue |
19014 |
+ unit=`suffix $arg hd` |
19015 |
+ base=`index gh $unit` |
19016 |
+ base=`math $base \* 64` |
19017 |
+ makedev hd$unit b $major $base $disk |
19018 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
19019 |
+ do |
19020 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
19021 |
+ done |
19022 |
+ ;; |
19023 |
+ hd[i-j]) |
19024 |
+ major=`Major ide4 56` || continue |
19025 |
+ unit=`suffix $arg hd` |
19026 |
+ base=`index ij $unit` |
19027 |
+ base=`math $base \* 64` |
19028 |
+ makedev hd$unit b $major $base $disk |
19029 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
19030 |
+ do |
19031 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
19032 |
+ done |
19033 |
+ ;; |
19034 |
+ hd[k-l]) |
19035 |
+ major=`Major ide5 57` || continue |
19036 |
+ unit=`suffix $arg hd` |
19037 |
+ base=`index kl $unit` |
19038 |
+ base=`math $base \* 64` |
19039 |
+ makedev hd$unit b $major $base $disk |
19040 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
19041 |
+ do |
19042 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
19043 |
+ done |
19044 |
+ ;; |
19045 |
+ hd[m-n]) |
19046 |
+ major=`Major ide6 88` || continue |
19047 |
+ unit=`suffix $arg hd` |
19048 |
+ base=`index mn $unit` |
19049 |
+ base=`math $base \* 64` |
19050 |
+ makedev hd$unit b $major $base $disk |
19051 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
19052 |
+ do |
19053 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
19054 |
+ done |
19055 |
+ ;; |
19056 |
+ hd[o-p]) |
19057 |
+ major=`Major ide7 89` || continue |
19058 |
+ unit=`suffix $arg hd` |
19059 |
+ base=`index op $unit` |
19060 |
+ base=`math $base \* 64` |
19061 |
+ makedev hd$unit b $major $base $disk |
19062 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
19063 |
+ do |
19064 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
19065 |
+ done |
19066 |
+ ;; |
19067 |
+ hd[q-r]) |
19068 |
+ major=`Major ide8 90` || continue |
19069 |
+ unit=`suffix $arg hd` |
19070 |
+ base=`index qr $unit` |
19071 |
+ base=`math $base \* 64` |
19072 |
+ makedev hd$unit b $major $base $disk |
19073 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
19074 |
+ do |
19075 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
19076 |
+ done |
19077 |
+ ;; |
19078 |
+ hd[s-t]) |
19079 |
+ major=`Major ide9 91` || continue |
19080 |
+ unit=`suffix $arg hd` |
19081 |
+ base=`index st $unit` |
19082 |
+ base=`math $base \* 64` |
19083 |
+ makedev hd$unit b $major $base $disk |
19084 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
19085 |
+ do |
19086 |
+ makedev hd$unit$part b $major $(( $base + $part )) $disk |
19087 |
+ done |
19088 |
+ ;; |
19089 |
+ ub|uba) |
19090 |
+ major=180 |
19091 |
+ makedev uba b $major 0 $disk |
19092 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19093 |
+ do |
19094 |
+ makedev uba$part b $major $part $disk |
19095 |
+ done |
19096 |
+ ;; |
19097 |
+ ht0) |
19098 |
+ major=`Major ht0 37` || continue |
19099 |
+ # Only one IDE tape drive is currently supported; ht0. |
19100 |
+ makedev ht0 c $major 0 $tape |
19101 |
+ makedev nht0 c $major 128 $tape |
19102 |
+ ;; |
19103 |
+ pt) |
19104 |
+ major=`Major pt 96` || continue |
19105 |
+ for i in 0 1 2 3 |
19106 |
+ do |
19107 |
+ makedev pt$i c $major $i $tape |
19108 |
+ makedev npt$i c $major `math $i + 128` $tape |
19109 |
+ done |
19110 |
+ ;; |
19111 |
+ xd[a-d]) |
19112 |
+ major=`Major xd 13` || continue |
19113 |
+ unit=`suffix $arg xd` |
19114 |
+ base=`index abcd $unit` |
19115 |
+ base=`math $base \* 64` |
19116 |
+ makedev xd$unit b $major $base $disk |
19117 |
+ for part in 1 2 3 4 5 6 7 8 # 9 10 11 12 13 14 15 16 17 18 19 20 |
19118 |
+ do |
19119 |
+ makedev xd$unit$part b $major $(( $base + $part )) $disk |
19120 |
+ done |
19121 |
+ ;; |
19122 |
+ sd[a-z]) |
19123 |
+ major=`Major sd 8` || continue |
19124 |
+ unit=`suffix $arg sd` |
19125 |
+ base=`index abcdefghijklmnopqrstuvwxyz $unit` |
19126 |
+ base=$(( $base * 16 )) |
19127 |
+ if [ $base -lt 256 ]; then |
19128 |
+ major=8 |
19129 |
+ else |
19130 |
+ major=65 |
19131 |
+ base=$(( $base - 256 )) |
19132 |
+ fi |
19133 |
+ makedev sd$unit b $major $base $disk |
19134 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19135 |
+ do |
19136 |
+ minor=$(( $base + $part )) |
19137 |
+ makedev sd$unit$part b $major $minor $disk |
19138 |
+ done |
19139 |
+ ;; |
19140 |
+ sd[a-d][a-z]) |
19141 |
+ unit=`suffix $arg sd` |
19142 |
+ unitmaj=`first $unit` |
19143 |
+ unitmin=`second $unit` |
19144 |
+ basemaj=`index Xabcd $unitmaj` |
19145 |
+ basemin=`index abcdefghijklmnopqrstuvwxyz $unitmin` |
19146 |
+ basemaj=`math $basemaj \* 416` |
19147 |
+ basemin=`math $basemin \* 16` |
19148 |
+ base=`math $basemaj + $basemin` |
19149 |
+ basemaj=`math $base / 256` |
19150 |
+ base=`math $base % 256` |
19151 |
+ major=`math basemaj \+ 64` |
19152 |
+ if [ $major -gt 71 ]; then |
19153 |
+ echo "$0: don't know how to make device \"$arg\"" >&2 |
19154 |
+ exit 0 |
19155 |
+ fi |
19156 |
+ makedev sd$unit b $major $base $disk |
19157 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19158 |
+ do |
19159 |
+ minor=$(( $base + $part )) |
19160 |
+ makedev sd$unit$part b $major $minor $disk |
19161 |
+ done |
19162 |
+ ;; |
19163 |
+ i2o.hd[a-z]) |
19164 |
+ [ -d i2o ] || { |
19165 |
+ mkdir i2o |
19166 |
+ chown root:root i2o |
19167 |
+ chmod 755 i2o |
19168 |
+ [ -e i2o/ctl ] || makedev i2o/ctl c 10 166 $disk |
19169 |
+ } |
19170 |
+ unit=`suffix $arg i2o.hd` |
19171 |
+ base=`index abcdefghijklmnopqrstuvwxyz $unit` |
19172 |
+ base=$(( $base * 16 )) |
19173 |
+ if [ $base -lt 256 ]; then |
19174 |
+ major=80 |
19175 |
+ else |
19176 |
+ major=81 |
19177 |
+ base=$(( $base - 256 )) |
19178 |
+ fi |
19179 |
+ makedev i2o/hd$unit b $major $base $disk |
19180 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19181 |
+ do |
19182 |
+ minor=$(( $base + $part )) |
19183 |
+ makedev i2o/hd$unit$part b $major $minor $disk |
19184 |
+ done |
19185 |
+ ;; |
19186 |
+ i2o.hd[a-d][a-z]) |
19187 |
+ [ -d i2o ] || { |
19188 |
+ mkdir i2o |
19189 |
+ chown root:root i2o |
19190 |
+ chmod 755 i2o |
19191 |
+ [ -e i2o/ctl ] || makedev i2o/ctl c 10 166 $disk |
19192 |
+ } |
19193 |
+ unit=`suffix $arg i2o.hd` |
19194 |
+ unitmaj=`first $unit` |
19195 |
+ unitmin=`second $unit` |
19196 |
+ basemaj=`index Xabcd $unitmaj` |
19197 |
+ basemin=`index abcdefghijklmnopqrstuvwxyz $unitmin` |
19198 |
+ basemaj=`math $basemaj \* 416` |
19199 |
+ basemin=`math $basemin \* 16` |
19200 |
+ base=`math $basemaj + $basemin` |
19201 |
+ basemaj=`math $base / 256` |
19202 |
+ base=`math $base % 256` |
19203 |
+ major=`math basemaj \+ 80` |
19204 |
+ if [ $major -gt 87 ]; then |
19205 |
+ echo "$0: don't know how to make device \"$arg\"" >&2 |
19206 |
+ exit 0 |
19207 |
+ fi |
19208 |
+ makedev i2o/hd$unit b $major $base $disk |
19209 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19210 |
+ do |
19211 |
+ minor=$(( $base + $part )) |
19212 |
+ makedev i2o/hd$unit$part b $major $minor $disk |
19213 |
+ done |
19214 |
+ ;; |
19215 |
+ dasd[a-z]) |
19216 |
+ major=`Major dasd 94` || continue |
19217 |
+ unit=`suffix $arg dasd` |
19218 |
+ base=`index abcdefghijklmnopqrstuvwxyz $unit` |
19219 |
+ base=$(( $base * 4 )) |
19220 |
+ if [ $base -lt 256 ]; then |
19221 |
+ major=94 |
19222 |
+ else |
19223 |
+ major=65 |
19224 |
+ base=$(( $base - 256 )) |
19225 |
+ fi |
19226 |
+ makedev dasd$unit b $major $base $disk |
19227 |
+ for part in 1 2 3 |
19228 |
+ do |
19229 |
+ minor=$(( $base + $part )) |
19230 |
+ makedev dasd$unit$part b $major $minor $disk |
19231 |
+ done |
19232 |
+ ;; |
19233 |
+ ad[a-p]) |
19234 |
+ major=`Major ad 28` || continue |
19235 |
+ unit=`suffix $arg ad` |
19236 |
+ base=`index abcdefghijklmnop $unit` |
19237 |
+ base=`math $base \* 16` |
19238 |
+ makedev ad$unit b $major $base $disk |
19239 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19240 |
+ do |
19241 |
+ minor=$(( $base + $part )) |
19242 |
+ makedev ad$unit$part b $major $minor $disk |
19243 |
+ done |
19244 |
+ ;; |
19245 |
+ dac960) |
19246 |
+ for ctr in 0 1 2 3 4 5 6 7 |
19247 |
+ do |
19248 |
+ $0 $opts dac960.$ctr |
19249 |
+ done |
19250 |
+ makedev dac960_gam c 10 252 $disk |
19251 |
+ ;; |
19252 |
+ dac960.[0-7]) |
19253 |
+ [ -d rd ] || { |
19254 |
+ mkdir rd |
19255 |
+ chown root:root rd |
19256 |
+ chmod 755 rd |
19257 |
+ } |
19258 |
+ unit=`suffix $arg dac960.` |
19259 |
+ major=`math 48 + $unit` |
19260 |
+ minor=0 |
19261 |
+ for ld in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \ |
19262 |
+ 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
19263 |
+ do |
19264 |
+ makedev rd/c${unit}d${ld} b $major $minor $disk |
19265 |
+ minor=`math $minor + 1` |
19266 |
+ for part in 1 2 3 4 5 6 7 |
19267 |
+ do |
19268 |
+ makedev rd/c${unit}d${ld}p$part b $major $minor $disk |
19269 |
+ minor=`math $minor + 1` |
19270 |
+ done |
19271 |
+ done |
19272 |
+ ;; |
19273 |
+ dpti) |
19274 |
+ major=151 |
19275 |
+ for ld in 1 2 3 4 5 6 7 |
19276 |
+ do |
19277 |
+ minor=`math $ld -1` |
19278 |
+ makedev dpti${ld} c $major $minor $disk |
19279 |
+ done |
19280 |
+ ;; |
19281 |
+ ataraid) |
19282 |
+ for ctr in 0 1 2 # 3 4 5 6 7 |
19283 |
+ do |
19284 |
+ $0 $opts ataraid.$ctr |
19285 |
+ done |
19286 |
+ ;; |
19287 |
+ ataraid.[0-7]) |
19288 |
+ [ -d ataraid ] || { |
19289 |
+ mkdir ataraid |
19290 |
+ chown root:root ataraid |
19291 |
+ chmod 755 ataraid |
19292 |
+ } |
19293 |
+ unit=`suffix $arg ataraid.` |
19294 |
+ major=114 |
19295 |
+ minor=`math $unit \* 16` |
19296 |
+ makedev ataraid/d${unit} b $major $minor $disk |
19297 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19298 |
+ do |
19299 |
+ minor=`math $minor + 1` |
19300 |
+ makedev ataraid/d${unit}p$part b $major $minor $disk |
19301 |
+ done |
19302 |
+ ;; |
19303 |
+ ida) |
19304 |
+ for ctr in 0 1 2 # 3 4 5 6 7 |
19305 |
+ do |
19306 |
+ $0 $opts ida.$ctr |
19307 |
+ done |
19308 |
+ ;; |
19309 |
+ ida.[0-7]) |
19310 |
+ [ -d ida ] || { |
19311 |
+ mkdir ida |
19312 |
+ chown root:root ida |
19313 |
+ chmod 755 ida |
19314 |
+ } |
19315 |
+ unit=`suffix $arg ida.` |
19316 |
+ major=`math 72 + $unit` |
19317 |
+ minor=0 |
19318 |
+ for ld in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19319 |
+ do |
19320 |
+ makedev ida/c${unit}d${ld} b $major $minor $disk |
19321 |
+ minor=`math $minor + 1` |
19322 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19323 |
+ do |
19324 |
+ makedev ida/c${unit}d${ld}p$part b $major $minor $disk |
19325 |
+ minor=`math $minor + 1` |
19326 |
+ done |
19327 |
+ done |
19328 |
+ ;; |
19329 |
+ cciss) |
19330 |
+ for ctr in 0 1 2 # 3 4 5 6 7 |
19331 |
+ do |
19332 |
+ $0 $opts cciss.$ctr |
19333 |
+ done |
19334 |
+ ;; |
19335 |
+ cciss.[0-7]) |
19336 |
+ [ -d cciss ] || { |
19337 |
+ mkdir cciss |
19338 |
+ chown root:root cciss |
19339 |
+ chmod 755 cciss |
19340 |
+ } |
19341 |
+ unit=`suffix $arg cciss.` |
19342 |
+ major=`math 104 + $unit` |
19343 |
+ minor=0 |
19344 |
+ for ld in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19345 |
+ do |
19346 |
+ makedev cciss/c${unit}d${ld} b $major $minor $disk |
19347 |
+ minor=`math $minor + 1` |
19348 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19349 |
+ do |
19350 |
+ makedev cciss/c${unit}d${ld}p$part b $major $minor $disk |
19351 |
+ minor=`math $minor + 1` |
19352 |
+ done |
19353 |
+ done |
19354 |
+ ;; |
19355 |
+ rom) |
19356 |
+ major=`Major rom 31` |
19357 |
+ for i in 0 1 2 3 4 5 6 7 |
19358 |
+ do |
19359 |
+ makedev rom$i b $major $i $disk |
19360 |
+ makedev rrom$i b $major `math $i +8` $disk |
19361 |
+ makedev flash$i b $major `math $i +16` $disk |
19362 |
+ makedev rflash$i b $major `math $i +24` $disk |
19363 |
+ done |
19364 |
+ ;; |
19365 |
+ nb[0-7]) |
19366 |
+ major=`Major nbd 43` || continue |
19367 |
+ minor=`suffix $arg nb` |
19368 |
+ makedev nb$minor b $major $minor $disk |
19369 |
+ ;; |
19370 |
+ loop) |
19371 |
+ for part in 0 1 2 3 4 5 6 7 |
19372 |
+ do |
19373 |
+ makedev loop$part b 7 $part $disk |
19374 |
+ done |
19375 |
+ ;; |
19376 |
+ loop[0-9]|loop[1-9][0-9]|loop1[0-9][0-9]|loop2[0-4][0-9]|loop25[0-5]) |
19377 |
+ minor=`suffix $arg loop` |
19378 |
+ makedev loop$minor b 7 $minor $disk |
19379 |
+ ;; |
19380 |
+ md) |
19381 |
+ major=`Major md 9` || continue |
19382 |
+ for part in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19383 |
+ do |
19384 |
+ makedev md$part b $major $part $disk |
19385 |
+ done |
19386 |
+ ;; |
19387 |
+ st[0-7]) |
19388 |
+ major=`Major st 9` |
19389 |
+ unit=`suffix $arg st` |
19390 |
+ makedev st${unit} c $major $unit $tape |
19391 |
+ makedev nst${unit} c $major `math 128 + $unit` $tape |
19392 |
+ |
19393 |
+ makedev st${unit}l c $major `math 32 + $unit` $tape |
19394 |
+ makedev nst${unit}l c $major `math 160 + $unit` $tape |
19395 |
+ |
19396 |
+ makedev st${unit}m c $major `math 64 + $unit` $tape |
19397 |
+ makedev nst${unit}m c $major `math 192 + $unit` $tape |
19398 |
+ |
19399 |
+ makedev st${unit}a c $major `math 96 + $unit` $tape |
19400 |
+ makedev nst${unit}a c $major `math 224 + $unit` $tape |
19401 |
+ ;; |
19402 |
+ qic) |
19403 |
+ major=`Major tpqic02 12` |
19404 |
+ makedev ntpqic11 c $major 2 $tape |
19405 |
+ makedev tpqic11 c $major 3 $tape |
19406 |
+ makedev ntpqic24 c $major 4 $tape |
19407 |
+ makedev tpqic24 c $major 5 $tape |
19408 |
+ makedev ntpqic120 c $major 6 $tape |
19409 |
+ makedev tpqic120 c $major 7 $tape |
19410 |
+ makedev ntpqic150 c $major 8 $tape |
19411 |
+ makedev tpqic150 c $major 9 $tape |
19412 |
+ makedev rmt8 c $major 6 $tape |
19413 |
+ makedev rmt16 c $major 8 $tape |
19414 |
+ makedev tape-d c $major 136 $tape |
19415 |
+ makedev tape-reset c $major 255 $tape |
19416 |
+ $0 $opts qft |
19417 |
+ ;; |
19418 |
+ ftape) |
19419 |
+ major=`Major qft 27` || continue |
19420 |
+ for unit in 0 1 2 3 |
19421 |
+ do |
19422 |
+ makedev qft$unit c $major $unit $tape |
19423 |
+ makedev nqft$unit c $major `math $unit + 4` $tape |
19424 |
+ makedev zqft$unit c $major `math $unit + 16` $tape |
19425 |
+ makedev nzqft$unit c $major `math $unit + 20` $tape |
19426 |
+ makedev rawqft$unit c $major `math $unit + 32` $tape |
19427 |
+ makedev nrawqft$unit c $major `math $unit + 36` $tape |
19428 |
+ done |
19429 |
+ symlink ftape qft0 |
19430 |
+ symlink nftape nqft0 |
19431 |
+ ;; |
19432 |
+ sr|scd|scd-all) |
19433 |
+ major=`Major sr 11` || continue |
19434 |
+ for unit in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
19435 |
+ do |
19436 |
+ makedev scd$unit b $major $unit $cdrom |
19437 |
+ symlink sr$unit scd$unit |
19438 |
+ done |
19439 |
+ ;; |
19440 |
+ pktcdvd) |
19441 |
+ major=97 |
19442 |
+ for unit in 0 1 2 3 |
19443 |
+ do |
19444 |
+ makedev pktcdvd$unit b $major $unit $cdrom |
19445 |
+ done |
19446 |
+ ;; |
19447 |
+ cfs0) |
19448 |
+ makedev cfs0 c 67 0 $coda |
19449 |
+ ;; |
19450 |
+ scd[0-9]|scd[0-1][0-9]) |
19451 |
+ major=`Major sr 11` || continue |
19452 |
+ unit=`suffix $arg scd` |
19453 |
+ makedev scd$unit b $major $unit $cdrom |
19454 |
+ symlink sr$unit scd$unit |
19455 |
+ ;; |
19456 |
+ ttyI[0-9]|ttyI[1-5][0-9]|ttyI[6][0-3]) |
19457 |
+ major=43 |
19458 |
+ unit=`suffix $arg ttyI` |
19459 |
+ makedev ttyI$unit c $major $unit $dialout |
19460 |
+ ;; |
19461 |
+ ppp) |
19462 |
+ major=108 |
19463 |
+ makedev ppp c $major 0 $dip |
19464 |
+ ;; |
19465 |
+ ippp[0-9]|ippp[1-5][0-9]|ippp[6][0-3]) |
19466 |
+ major=45 |
19467 |
+ unit=`suffix $arg ippp` |
19468 |
+ minor=`math $unit + 128` |
19469 |
+ makedev ippp$unit c $major $minor $dialout |
19470 |
+ ;; |
19471 |
+ isdn[0-9]|isdn[1-5][0-9]|isdn[6][0-3]) |
19472 |
+ major=45 |
19473 |
+ unit=`suffix $arg isdn` |
19474 |
+ minor=`math $unit + 0` |
19475 |
+ makedev isdn$unit c $major $minor $dialout |
19476 |
+ ;; |
19477 |
+ isdnctrl[0-9]|isdnctrl[1-5][0-9]|isdnctrl[6][0-3]) |
19478 |
+ major=45 |
19479 |
+ unit=`suffix $arg isdnctrl` |
19480 |
+ minor=`math $unit + 64` |
19481 |
+ makedev isdnctrl$unit c $major $minor $dialout |
19482 |
+ ;; |
19483 |
+ isdninfo) |
19484 |
+ makedev isdninfo c 45 255 $private |
19485 |
+ ;; |
19486 |
+ isdn-tty) |
19487 |
+ major=43 |
19488 |
+ for unit in 0 1 2 3 4 5 6 7 |
19489 |
+ do |
19490 |
+ makedev ttyI$unit c $major $unit $dialout |
19491 |
+ done |
19492 |
+ ;; |
19493 |
+ isdn-ippp) |
19494 |
+ major=45 |
19495 |
+ for unit in 0 1 2 3 4 5 6 7 |
19496 |
+ do |
19497 |
+ makedev ippp$unit c $major `math $unit + 128` $dialout |
19498 |
+ done |
19499 |
+ ;; |
19500 |
+ isdn-io) |
19501 |
+ for unit in 0 1 2 3 4 5 6 7 |
19502 |
+ do |
19503 |
+ makedev isdn$unit c 45 $unit $dialout |
19504 |
+ makedev isdnctrl$unit c 45 `math $unit + 64` $dialout |
19505 |
+ makedev ippp$unit c 45 `math $unit + 128` $dialout |
19506 |
+ done |
19507 |
+ makedev isdninfo c 45 255 $dialout |
19508 |
+ ;; |
19509 |
+ sonycd) |
19510 |
+ major=`Major sonycd 15` || continue |
19511 |
+ makedev $arg b $major 0 $cdrom |
19512 |
+ ;; |
19513 |
+ mcd) |
19514 |
+ major=`Major mcd 23` || continue |
19515 |
+ makedev $arg b $major 0 $cdrom |
19516 |
+ ;; |
19517 |
+ mcdx|mcdx[0-4]) |
19518 |
+ major=`Major $arg 20` || continue |
19519 |
+ for unit in 0 1 2 3 4 |
19520 |
+ do |
19521 |
+ makedev mcdx$unit b $major $unit $cdrom |
19522 |
+ done |
19523 |
+ test -r mcdx || symlink mcdx mcdx0 |
19524 |
+ ;; |
19525 |
+ cdu535) |
19526 |
+ makedev $arg b 24 0 $cdrom |
19527 |
+ ;; |
19528 |
+ lmscd) |
19529 |
+ makedev $arg b 24 0 $cdrom |
19530 |
+ ;; |
19531 |
+ sbpcd|sbpcd[123]) |
19532 |
+ major=`Major $arg 25` || continue |
19533 |
+ base=`suffix ${arg}0 sbpcd` |
19534 |
+ for minor in 0 1 2 3 |
19535 |
+ do |
19536 |
+ # XXX |
19537 |
+ unit=$(substr 0123456789abcdef $(( $base * 4 + $minor + 1 )) ) |
19538 |
+ makedev sbpcd$unit b $major $minor $cdrom |
19539 |
+ done |
19540 |
+ [ $arg = sbpcd ] && symlink $arg ${arg}0 |
19541 |
+ ;; |
19542 |
+ aztcd) |
19543 |
+ major=`Major $arg 29` || continue |
19544 |
+ makedev ${arg}0 b $major 0 $cdrom |
19545 |
+ ;; |
19546 |
+ cm206cd) |
19547 |
+ major=`Major $arg 30` || continue |
19548 |
+ makedev ${arg}0 b $major 0 $cdrom |
19549 |
+ ;; |
19550 |
+ gscd) |
19551 |
+ major=`Major $arg 16` || continue |
19552 |
+ makedev ${arg}0 b $major 0 $cdrom |
19553 |
+ ;; |
19554 |
+ pcd) |
19555 |
+ for unit in 0 1 2 3 |
19556 |
+ do |
19557 |
+ makedev pcd$unit b 46 $unit $cdrom |
19558 |
+ done |
19559 |
+ ;; |
19560 |
+ bpcd) |
19561 |
+ makedev $arg b 41 0 $cdrom |
19562 |
+ ;; |
19563 |
+ optcd) |
19564 |
+ makedev $arg b 17 0 $cdrom |
19565 |
+ ;; |
19566 |
+ sjcd) |
19567 |
+ makedev $arg b 18 0 $cdrom |
19568 |
+ ;; |
19569 |
+ cfs|coda) |
19570 |
+ makedev cfs0 c 67 0 $private |
19571 |
+ ;; |
19572 |
+ xfs|nnpfs|arla) |
19573 |
+ makedev xfs0 c 103 0 $private |
19574 |
+ makedev nnpfs0 c 103 0 $private |
19575 |
+ ;; |
19576 |
+ logiscan) |
19577 |
+ major=`Major logiscan` || continue |
19578 |
+ makedev $arg c $major 0 $scanner |
19579 |
+ ;; |
19580 |
+ toshiba) |
19581 |
+ major=`Major $arg 10` || continue |
19582 |
+ makedev $arg c $major 181 root root 0666 |
19583 |
+ ;; |
19584 |
+ m105scan) |
19585 |
+ major=`Major m105` || continue |
19586 |
+ makedev $arg c $major 0 $scanner |
19587 |
+ ;; |
19588 |
+ ac4096) |
19589 |
+ major=`Major ac4096` || continue |
19590 |
+ makedev $arg c $major 0 $scanner |
19591 |
+ ;; |
19592 |
+ audio) |
19593 |
+ major=`Major sound 14` |
19594 |
+ makedev mixer c $major 0 $audio |
19595 |
+ makedev mixer1 c $major 16 $audio |
19596 |
+ makedev mixer2 c $major 32 $audio |
19597 |
+ makedev mixer3 c $major 48 $audio |
19598 |
+ makedev sequencer c $major 1 $audio |
19599 |
+ makedev midi00 c $major 2 $audio |
19600 |
+ makedev midi01 c $major 18 $audio |
19601 |
+ makedev midi02 c $major 34 $audio |
19602 |
+ makedev midi03 c $major 50 $audio |
19603 |
+ makedev dsp c $major 3 $audio |
19604 |
+ makedev dsp1 c $major 19 $audio |
19605 |
+ makedev dsp2 c $major 35 $audio |
19606 |
+ makedev dsp3 c $major 51 $audio |
19607 |
+ makedev audio c $major 4 $audio |
19608 |
+ makedev audio1 c $major 20 $audio |
19609 |
+ makedev audio2 c $major 36 $audio |
19610 |
+ makedev audio3 c $major 52 $audio |
19611 |
+ makedev sndstat c $major 6 $audio |
19612 |
+ makedev audioctl c $major 7 $audio |
19613 |
+ major=31 |
19614 |
+ makedev mpu401data c $major 0 $audio |
19615 |
+ makedev mpu401stat c $major 1 $audio |
19616 |
+ major=35 |
19617 |
+ for i in 0 1 2 3 |
19618 |
+ do |
19619 |
+ makedev midi$i c $major $i $audio |
19620 |
+ makedev rmidi$i c $major `math $i + 64` $audio |
19621 |
+ makedev smpte$i c $major `math $i + 128` $audio |
19622 |
+ done |
19623 |
+ ;; |
19624 |
+ pcaudio) |
19625 |
+ major=`Major pcsp 13` || continue |
19626 |
+ makedev pcmixer c $major 0 $audio |
19627 |
+ makedev pcsp c $major 3 $audio |
19628 |
+ makedev pcaudio c $major 4 $audio |
19629 |
+ ;; |
19630 |
+ video|video4linux|v4l|radio) |
19631 |
+ # video4linux api includes radio, teletext, etc. |
19632 |
+ major=`Major video 81` || continue |
19633 |
+ minor=0 |
19634 |
+ until [ $minor -gt 63 ] |
19635 |
+ do |
19636 |
+ makedev video$minor c $major $minor $video |
19637 |
+ makedev radio$minor c $major `math $minor + 64` $video |
19638 |
+ minor=`math $minor + 1` |
19639 |
+ done |
19640 |
+ symlink radio radio0 |
19641 |
+ minor=0 |
19642 |
+ until [ $minor -gt 31 ] |
19643 |
+ do |
19644 |
+ makedev vtx$minor c $major `math $minor + 192` $video |
19645 |
+ makedev vbi$minor c $major `math $minor + 224` $video |
19646 |
+ minor=`math $minor + 1` |
19647 |
+ done |
19648 |
+ symlink video video0 |
19649 |
+ symlink vbi vbi0 |
19650 |
+ major=82 |
19651 |
+ minor=0 |
19652 |
+ until [ $minor -gt 1 ] |
19653 |
+ do |
19654 |
+ makedev winradio$minor c $major $minor $video |
19655 |
+ minor=`math $minor + 1` |
19656 |
+ done |
19657 |
+ major=83 |
19658 |
+ makedev vtx c $major 0 $video |
19659 |
+ makedev vttuner c $major 16 $video |
19660 |
+ ;; |
19661 |
+ i2c) |
19662 |
+ # making it possible to create an arbitrary number of i2c |
19663 |
+ # devices might be good, but 8 should suffice for now |
19664 |
+ major=`Major i2c 89` || continue |
19665 |
+ minor=0 |
19666 |
+ until [ $minor -gt 7 ] |
19667 |
+ do |
19668 |
+ makedev i2c-$minor c $major $minor $private |
19669 |
+ minor=`math $minor + 1` |
19670 |
+ done |
19671 |
+ ;; |
19672 |
+ tlk) |
19673 |
+ major=102 |
19674 |
+ minor=0 |
19675 |
+ until [ $minor -gt 3 ] # tell me if 3 is wrong... |
19676 |
+ do |
19677 |
+ makedev tlk$minor c $major $minor $video |
19678 |
+ minor=`math $minor + 1` |
19679 |
+ done |
19680 |
+ ;; |
19681 |
+ srnd) |
19682 |
+ makedev srnd0 c 110 0 $video |
19683 |
+ makedev srnd1 c 110 1 $video |
19684 |
+ ;; |
19685 |
+ fgrab) |
19686 |
+ makedev mmetfgrab c 40 0 $video |
19687 |
+ makedev wvisfgrab c 26 0 $video |
19688 |
+ for i in 0 1 # more? |
19689 |
+ do |
19690 |
+ makedev iscc$i c 93 $i $video |
19691 |
+ makedev isccctl$i c 93 `math $i + 128` $video |
19692 |
+ done |
19693 |
+ for i in 0 1 # more? |
19694 |
+ do |
19695 |
+ makedev dcxx$i c 94 $i $video |
19696 |
+ done |
19697 |
+ ;; |
19698 |
+ sg|sg-all) |
19699 |
+ major=`Major sg 21` |
19700 |
+ for unit in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
19701 |
+ do |
19702 |
+ makedev sg$unit c $major $unit $scsi |
19703 |
+ done |
19704 |
+ ;; |
19705 |
+ pg) |
19706 |
+ major=`Major pg 97` |
19707 |
+ for unit in 0 1 2 3 |
19708 |
+ do |
19709 |
+ makedev pg$unit c $major $unit $scsi |
19710 |
+ done |
19711 |
+ ;; |
19712 |
+ fd) |
19713 |
+ # not really devices, we use the /proc filesystem |
19714 |
+ symlink fd $procfs/self/fd |
19715 |
+ symlink stdin fd/0 |
19716 |
+ symlink stdout fd/1 |
19717 |
+ symlink stderr fd/2 |
19718 |
+ ;; |
19719 |
+ ibcs2) |
19720 |
+ major=`Major ibcs2 30` || continue |
19721 |
+ makedev socksys c $major 0 $ibcs2 |
19722 |
+ symlink nfsd socksys |
19723 |
+ makedev spx c $major 1 $ibcs2 |
19724 |
+ symlink X0R null |
19725 |
+ ;; |
19726 |
+ netlink) |
19727 |
+ major=36 |
19728 |
+ makedev route c $major 0 $private |
19729 |
+ makedev skip c $major 1 $private |
19730 |
+ ;; |
19731 |
+ enskip) |
19732 |
+ major=64 |
19733 |
+ makedev enskip c $major 0 $private |
19734 |
+ ;; |
19735 |
+ ipfilt*) |
19736 |
+ major=95 |
19737 |
+ makedev ipl c $major 0 $private |
19738 |
+ makedev ipnat c $major 1 $private |
19739 |
+ makedev ipstate c $major 2 $private |
19740 |
+ makedev ipauth c $major 3 $private |
19741 |
+ ;; |
19742 |
+ qng) |
19743 |
+ makedev qng c 77 0 $private |
19744 |
+ ;; |
19745 |
+ apm) |
19746 |
+ major=`Major mouse 10` || continue |
19747 |
+ makedev apm_bios c $major 134 $mouse |
19748 |
+ ;; |
19749 |
+ dcf) |
19750 |
+ major=`Major dcf` || continue |
19751 |
+ makedev $arg c $major 0 $system |
19752 |
+ ;; |
19753 |
+ helloworld) |
19754 |
+ major=`Major hw` || continue |
19755 |
+ makedev helloworld c $major 0 $public |
19756 |
+ ;; |
19757 |
+ ipsec) |
19758 |
+ # For the Free S/WAN (http://www.xs4all.nl/~freeswan/) |
19759 |
+ # implementation of IPSEC |
19760 |
+ makedev ipsec c 36 10 $ipsec |
19761 |
+ ;; |
19762 |
+ comedi) |
19763 |
+ major=98 |
19764 |
+ for minor in 0 1 2 3 |
19765 |
+ do |
19766 |
+ makedev comedi$minor c $major $minor $public |
19767 |
+ done |
19768 |
+ ;; |
19769 |
+ tilp) |
19770 |
+ for i in `seq 0 7` |
19771 |
+ do |
19772 |
+ makedev tipar$i c 115 $i $printer |
19773 |
+ makedev tiser$i c 115 `math 8 + $i` $dialout |
19774 |
+ done |
19775 |
+ for i in `seq 0 31` |
19776 |
+ do |
19777 |
+ makedev tiusb$i c 115 `math 16 + $i` $dialout |
19778 |
+ done |
19779 |
+ ;; |
19780 |
+ dvb) |
19781 |
+ # check if kernel-version is >= 2.6.8, if yes, create dvb-devices with |
19782 |
+ # major-number 212, in the other case 250 |
19783 |
+ |
19784 |
+ kern_rev1=`uname -r | sed -e 's@^\([^.]*\)\..*@\1@'` |
19785 |
+ kern_rev2=`uname -r | sed -e 's@^[^.]*\.\([^.]*\)\..*@\1@'` |
19786 |
+ kern_rev3=`uname -r | sed -e 's@^[^.]*\.[^.]*\.\([^.][0-9]*\).*@\1@'` |
19787 |
+ |
19788 |
+ dvb_major=250 |
19789 |
+ |
19790 |
+ if [ $kern_rev1 -gt 2 ] || ([ $kern_rev1 -eq 2 ] && [ $kern_rev2 -gt 6 ]) \ |
19791 |
+ || ([ $kern_rev1 -eq 2 ] && [ $kern_rev2 -eq 6 ] && [ $kern_rev3 -ge 8 ]) |
19792 |
+ then |
19793 |
+ dvb_major=212 |
19794 |
+ fi |
19795 |
+ |
19796 |
+ mkdir -p dvb |
19797 |
+ for i in 0 1 2 3 |
19798 |
+ do |
19799 |
+ mkdir -p dvb/adapter$i |
19800 |
+ makedev dvb/adapter$i/video0 c $dvb_major `math 64 \* $i + 0` $video |
19801 |
+ makedev dvb/adapter$i/audio0 c $dvb_major `math 64 \* $i + 1` $video |
19802 |
+ makedev dvb/adapter$i/frontend0 c $dvb_major `math 64 \* $i + 3` $video |
19803 |
+ makedev dvb/adapter$i/demux0 c $dvb_major `math 64 \* $i + 4` $video |
19804 |
+ makedev dvb/adapter$i/dvr0 c $dvb_major `math 64 \* $i + 5` $video |
19805 |
+ makedev dvb/adapter$i/ca0 c $dvb_major `math 64 \* $i + 6` $video |
19806 |
+ makedev dvb/adapter$i/net0 c $dvb_major `math 64 \* $i + 7` $video |
19807 |
+ makedev dvb/adapter$i/osd0 c $dvb_major `math 64 \* $i + 8` $video |
19808 |
+ done |
19809 |
+ ;; |
19810 |
+ usb) |
19811 |
+ mkdir -p usb |
19812 |
+ major=180 |
19813 |
+ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19814 |
+ do |
19815 |
+ makedev usb/lp$i c $major $i $printer |
19816 |
+ makedev usb/mouse$i c $major `math $i + 16` $mouse |
19817 |
+ makedev usb/ez$i c $major `math $i + 32` $system |
19818 |
+ makedev usb/scanner$i c $major `math $i + 48` $scanner |
19819 |
+ makedev usb/hiddev$i c $major `math $i + 96` $system |
19820 |
+ makedev ttyACM$i c 166 $i $dialout |
19821 |
+ makedev ttyUSB$i c 188 $i $dialout |
19822 |
+ done |
19823 |
+ makedev usb/rio500 c $major 64 $audio |
19824 |
+ makedev usb/usblcd c $major 65 $audio |
19825 |
+ makedev usb/cpad0 c $major 66 $audio |
19826 |
+ ;; |
19827 |
+ bluetooth) |
19828 |
+ major=216 |
19829 |
+ for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 \ |
19830 |
+ 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
19831 |
+ do |
19832 |
+ makedev rfcomm$i c $major $i $dialout |
19833 |
+ done |
19834 |
+ makedev vhci c 10 250 $dialout |
19835 |
+ for i in 0 1 2 3; do |
19836 |
+ makedev ttyUB$i c 216 $i $dialout |
19837 |
+ makedev ccub$i c 217 $i $dialout |
19838 |
+ done |
19839 |
+ ;; |
19840 |
+ paride) |
19841 |
+ major=45 |
19842 |
+ for unit in a b c d |
19843 |
+ do |
19844 |
+ base=`index abcd $unit` |
19845 |
+ base=`math $base \* 16` |
19846 |
+ makedev pd$unit b $major $base $disk |
19847 |
+ for part in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
19848 |
+ do |
19849 |
+ makedev pd$unit$part b $major $(( $base + $part )) $disk |
19850 |
+ done |
19851 |
+ done |
19852 |
+ for i in 0 1 2 3 |
19853 |
+ do |
19854 |
+ makedev pcd$i b 46 $i $cdrom |
19855 |
+ makedev pf$i b 47 $i $floppy |
19856 |
+ done |
19857 |
+ ;; |
19858 |
+ update) |
19859 |
+ devices= |
19860 |
+ if [ ! -f $procfs/devices ] |
19861 |
+ then |
19862 |
+ echo "$0: warning: can't read $procfs/devices" >&2 |
19863 |
+ else |
19864 |
+ exec 3<$procfs/devices |
19865 |
+ while read major device extra <&3 |
19866 |
+ do |
19867 |
+ device=`echo $device | sed 's#/.*##'` |
19868 |
+ case "$major" in |
19869 |
+ Character|Block|'') |
19870 |
+ ;; |
19871 |
+ *) |
19872 |
+ eval "major_$device=$major" |
19873 |
+ devices="$devices $device" |
19874 |
+ ;; |
19875 |
+ esac |
19876 |
+ done |
19877 |
+ exec 3<&- |
19878 |
+ fi |
19879 |
+ |
19880 |
+ if [ ! "$devices" ] |
19881 |
+ then |
19882 |
+ echo "$0: don't appear to have any devices" >&2 |
19883 |
+ continue |
19884 |
+ fi |
19885 |
+ if [ "$opt_d" ] |
19886 |
+ then |
19887 |
+ echo "$0: can't delete an update" >&2 |
19888 |
+ continue |
19889 |
+ fi |
19890 |
+ create= |
19891 |
+ delete= |
19892 |
+ devs="$devices" |
19893 |
+ if [ -f DEVICES ] |
19894 |
+ then |
19895 |
+ exec 3<DEVICES |
19896 |
+ while read device major <&3 |
19897 |
+ do |
19898 |
+ eval now=\$major_$device |
19899 |
+ if [ "$now" = "" ] |
19900 |
+ then |
19901 |
+ delete="$delete `cvt $device`" |
19902 |
+ continue |
19903 |
+ elif [ "$now" != $major ] |
19904 |
+ then |
19905 |
+ create="$create "`cvt $device` |
19906 |
+ fi |
19907 |
+ devs=`strip " $devs " $device` |
19908 |
+ done |
19909 |
+ exec 3<&- |
19910 |
+ fi |
19911 |
+ create="$create "`cvt $devs` |
19912 |
+ [ "$delete" != "" ] && $0 $opts -d $delete |
19913 |
+ [ "$create" != " " ] && $0 $opts $create |
19914 |
+ [ "$opt_n" ] && continue |
19915 |
+ for device in $devices |
19916 |
+ do |
19917 |
+ if [ "`cvt $device`" ] |
19918 |
+ then |
19919 |
+ eval echo $device \$major_$device |
19920 |
+ fi |
19921 |
+ done > DEVICES |
19922 |
+ ;; |
19923 |
+ *) |
19924 |
+ echo "$0: don't know how to make device \"$arg\"" >&2 |
19925 |
+ exit 1 |
19926 |
+ ;; |
19927 |
+ esac |
19928 |
+done |
19929 |
+ |
19930 |
+exit 0 |
19931 |
|
19932 |
|
19933 |
Property changes on: trunk/baselayout-prefix/sbin/MAKEDEV |
19934 |
___________________________________________________________________ |
19935 |
Added: svn:executable |
19936 |
+ * |
19937 |
|
19938 |
Added: trunk/baselayout-prefix/sbin/MAKEDEV-gentoo.patch |
19939 |
=================================================================== |
19940 |
--- trunk/baselayout-prefix/sbin/MAKEDEV-gentoo.patch (rev 0) |
19941 |
+++ trunk/baselayout-prefix/sbin/MAKEDEV-gentoo.patch 2011-03-31 14:11:17 UTC (rev 1682) |
19942 |
@@ -0,0 +1,109 @@ |
19943 |
+--- MAKEDEV |
19944 |
++++ MAKEDEV |
19945 |
+@@ -102,8 +102,8 @@ |
19946 |
+ |
19947 |
+ if [ "$opt_V" ] |
19948 |
+ then |
19949 |
+- echo "This is Debian MAKEDEV. For version info, try 'dpkg --list makedev'" |
19950 |
+- echo "See /usr/share/doc/makedev/ for more information on Debian MAKEDEV." |
19951 |
++ echo "This is MAKEDEV based on Debian's makedev_2.3.1-78." |
19952 |
++ echo "See the MAKEDEV(8) manpage for more information." |
19953 |
+ exit 0 |
19954 |
+ fi |
19955 |
+ |
19956 |
+@@ -308,60 +308,25 @@ |
19957 |
+ done |
19958 |
+ } |
19959 |
+ |
19960 |
++get_arch() { |
19961 |
++ case `uname -m` in |
19962 |
++ arm*) echo arm;; |
19963 |
++ i?86) echo i386;; |
19964 |
++ ppc*) echo powerpc;; |
19965 |
++ s390*) echo s390;; |
19966 |
++ sh*) echo sh;; |
19967 |
++ x86_64) echo i386;; |
19968 |
++ # alpha|hppa|ia64|m68k|mips|sparc |
19969 |
++ *) echo $a;; |
19970 |
++ esac |
19971 |
++} |
19972 |
++ |
19973 |
+ for arg in $* |
19974 |
+ do |
19975 |
+ # case `cvt $arg` in |
19976 |
+ case $arg in |
19977 |
+ generic) |
19978 |
+- # pick the right generic-<arch> using dpkg's knowledge |
19979 |
+- case `dpkg --print-installation-architecture` in |
19980 |
+- alpha) |
19981 |
+- $0 $opts generic-alpha |
19982 |
+- ;; |
19983 |
+- arm) |
19984 |
+- $0 $opts generic-arm |
19985 |
+- ;; |
19986 |
+- hppa) |
19987 |
+- $0 $opts generic-hppa |
19988 |
+- ;; |
19989 |
+- i386) |
19990 |
+- $0 $opts generic-i386 |
19991 |
+- ;; |
19992 |
+- amd64) |
19993 |
+- $0 $opts generic-i386 |
19994 |
+- ;; |
19995 |
+- ia64) |
19996 |
+- $0 $opts generic-ia64 |
19997 |
+- ;; |
19998 |
+- m68k) |
19999 |
+- $0 $opts generic-m68k |
20000 |
+- ;; |
20001 |
+- mips) |
20002 |
+- $0 $opts generic-mips |
20003 |
+- ;; |
20004 |
+- mipsel) |
20005 |
+- $0 $opts generic-mipsel |
20006 |
+- ;; |
20007 |
+- powerpc) |
20008 |
+- $0 $opts generic-powerpc |
20009 |
+- ;; |
20010 |
+- ppc64) |
20011 |
+- $0 $opts generic-powerpc |
20012 |
+- ;; |
20013 |
+- s390) |
20014 |
+- $0 $opts generic-s390 |
20015 |
+- ;; |
20016 |
+- sh*) |
20017 |
+- $0 $opts generic-sh |
20018 |
+- ;; |
20019 |
+- sparc) |
20020 |
+- $0 $opts generic-sparc |
20021 |
+- ;; |
20022 |
+- *) |
20023 |
+- echo "$0: no support for generic on this arch" >&2 |
20024 |
+- exit 1 |
20025 |
+- ;; |
20026 |
+- esac |
20027 |
++ $0 $opts generic-`get_arch` |
20028 |
+ ;; |
20029 |
+ generic-alpha) |
20030 |
+ $0 $opts std |
20031 |
+@@ -596,6 +562,10 @@ |
20032 |
+ symlink mouse sunmouse |
20033 |
+ makedev openprom c 10 139 root root 0664 |
20034 |
+ ;; |
20035 |
++ generic-*) |
20036 |
++ echo "$0: no support for generic on this arch" >&2 |
20037 |
++ exit 1 |
20038 |
++ ;; |
20039 |
+ local) |
20040 |
+ $0.local $opts |
20041 |
+ ;; |
20042 |
+@@ -690,8 +660,7 @@ |
20043 |
+ done |
20044 |
+ ;; |
20045 |
+ adb) |
20046 |
+- # pick the right arch device using dpkg's knowledge |
20047 |
+- case `dpkg --print-installation-architecture` in |
20048 |
++ case `get_arch` in |
20049 |
+ powerpc) |
20050 |
+ # ADB bus devices (char) |
20051 |
+ makedev adb c 56 0 $mouse |
20052 |
|
20053 |
|
20054 |
Property changes on: trunk/baselayout-prefix/sbin/MAKEDEV-gentoo.patch |
20055 |
___________________________________________________________________ |
20056 |
Added: svn:executable |
20057 |
+ * |
20058 |
|
20059 |
Added: trunk/baselayout-prefix/sbin/depscan.sh |
20060 |
=================================================================== |
20061 |
--- trunk/baselayout-prefix/sbin/depscan.sh (rev 0) |
20062 |
+++ trunk/baselayout-prefix/sbin/depscan.sh 2011-03-31 14:11:17 UTC (rev 1682) |
20063 |
@@ -0,0 +1,148 @@ |
20064 |
+#!/bin/bash |
20065 |
+# Copyright 1999-2006 Gentoo Foundation |
20066 |
+# Distributed under the terms of the GNU General Public License v2 |
20067 |
+ |
20068 |
+if [[ ${BOOT} == "yes" ]] ; then |
20069 |
+ trap ":" INT QUIT TSTP |
20070 |
+fi |
20071 |
+ |
20072 |
+argv0=${0##*/} |
20073 |
+source /etc/init.d/functions.sh || { |
20074 |
+ echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2 |
20075 |
+ exit 1 |
20076 |
+} |
20077 |
+esyslog() { :; } |
20078 |
+ |
20079 |
+usage() { |
20080 |
+ cat <<-EOF |
20081 |
+ Usage: ${argv0} [options] |
20082 |
+ |
20083 |
+ Rebuild Gentoo init.d service dependency tree. |
20084 |
+ |
20085 |
+ Options: |
20086 |
+ -d, --debug Turn on debug output |
20087 |
+ -s, --svcdir Specify svcdir (default: ${svcdir}) |
20088 |
+ -u, --update Force update even if mtimes are OK |
20089 |
+ -h, --help Show this help cruft |
20090 |
+ EOF |
20091 |
+ [[ -z $@ ]] && exit 0 |
20092 |
+ echo |
20093 |
+ eerror "$*" |
20094 |
+ exit 1 |
20095 |
+} |
20096 |
+ |
20097 |
+mysvcdir=${svcdir} |
20098 |
+update=false |
20099 |
+ |
20100 |
+while [[ -n $1 ]] ; do |
20101 |
+ case "$1" in |
20102 |
+ --debug|-d) |
20103 |
+ set -x |
20104 |
+ ;; |
20105 |
+ --svcdir|-s) |
20106 |
+ if [[ -z $2 || $2 == -* ]] ; then |
20107 |
+ eerror "No svcdir specified" |
20108 |
+ else |
20109 |
+ shift |
20110 |
+ mysvcdir="$1" |
20111 |
+ fi |
20112 |
+ ;; |
20113 |
+ --update|-u) |
20114 |
+ update=true |
20115 |
+ ;; |
20116 |
+ --help|-h) |
20117 |
+ usage |
20118 |
+ ;; |
20119 |
+ *) |
20120 |
+ usage "Invalid option '$1'" |
20121 |
+ ;; |
20122 |
+ esac |
20123 |
+ shift |
20124 |
+done |
20125 |
+ |
20126 |
+if [[ ! -d ${mysvcdir} ]] ; then |
20127 |
+ if ! mkdir -p -m 0755 "${mysvcdir}" 2>/dev/null ; then |
20128 |
+ eerror "Could not create needed directory '${mysvcdir}'!" |
20129 |
+ fi |
20130 |
+fi |
20131 |
+ |
20132 |
+for x in softscripts snapshot options daemons \ |
20133 |
+ started starting inactive wasinactive stopping failed \ |
20134 |
+ exclusive exitcodes scheduled coldplugged ; do |
20135 |
+ if [[ ! -d "${mysvcdir}/${x}" ]] ; then |
20136 |
+ if ! mkdir -p -m 0755 "${mysvcdir}/${x}" 2>/dev/null ; then |
20137 |
+ eerror "Could not create needed directory '${mysvcdir}/${x}'!" |
20138 |
+ fi |
20139 |
+ fi |
20140 |
+done |
20141 |
+ |
20142 |
+# Only update if files have actually changed |
20143 |
+if ! ${update} ; then |
20144 |
+ clock_screw=0 |
20145 |
+ mtime_test="${mysvcdir}/mtime-test.$$" |
20146 |
+ |
20147 |
+ # If its not there, we have to update, and make sure its present |
20148 |
+ # for next mtime testing |
20149 |
+ if [[ ! -e "${mysvcdir}/depcache" ]] ; then |
20150 |
+ update=true |
20151 |
+ touch "${mysvcdir}/depcache" |
20152 |
+ fi |
20153 |
+ |
20154 |
+ touch "${mtime_test}" |
20155 |
+ for config in /etc/conf.d/* /etc/init.d/* /etc/rc.conf |
20156 |
+ do |
20157 |
+ ! ${update} \ |
20158 |
+ && is_older_than "${mysvcdir}/depcache" "${config}" \ |
20159 |
+ && update=true |
20160 |
+ |
20161 |
+ if is_older_than "${mtime_test}" "${config}" ; then |
20162 |
+ # Update the file modification time |
20163 |
+ touch "${config}" &>/dev/null |
20164 |
+ clock_screw=1 |
20165 |
+ fi |
20166 |
+ done |
20167 |
+ rm -f "${mtime_test}" |
20168 |
+ |
20169 |
+ if [[ ${clock_screw} == 1 ]] ; then |
20170 |
+ ewarn "One of the files in /etc/{conf.d,init.d} or /etc/rc.conf" |
20171 |
+ ewarn "has a modification time in the future!" |
20172 |
+ fi |
20173 |
+ |
20174 |
+ shift |
20175 |
+fi |
20176 |
+ |
20177 |
+! ${update} && [[ -e "${mysvcdir}/deptree" ]] && exit 0 |
20178 |
+ |
20179 |
+ebegin "Caching service dependencies" |
20180 |
+ |
20181 |
+# Clean out the non volatile directories ... |
20182 |
+rm -rf "${mysvcdir}"/dep{cache,tree} "${mysvcdir}"/{broken,snapshot}/* |
20183 |
+ |
20184 |
+retval=0 |
20185 |
+SVCDIR="${mysvcdir}" |
20186 |
+DEPTYPES="${deptypes}" |
20187 |
+ORDTYPES="${ordtypes}" |
20188 |
+ |
20189 |
+export SVCDIR DEPTYPES ORDTYPES |
20190 |
+ |
20191 |
+cd /etc/init.d |
20192 |
+ |
20193 |
+/bin/gawk \ |
20194 |
+ -f /lib/rcscripts/awk/functions.awk \ |
20195 |
+ -f /lib/rcscripts/awk/cachedepends.awk || \ |
20196 |
+ retval=1 |
20197 |
+ |
20198 |
+bash "${mysvcdir}/depcache" | \ |
20199 |
+/bin/gawk \ |
20200 |
+ -f /lib/rcscripts/awk/functions.awk \ |
20201 |
+ -f /lib/rcscripts/awk/gendepends.awk || \ |
20202 |
+ retval=1 |
20203 |
+ |
20204 |
+touch "${mysvcdir}"/dep{cache,tree} |
20205 |
+chmod 0644 "${mysvcdir}"/dep{cache,tree} |
20206 |
+ |
20207 |
+eend ${retval} "Failed to cache service dependencies" |
20208 |
+ |
20209 |
+exit ${retval} |
20210 |
+ |
20211 |
+# vim:ts=4 |
20212 |
|
20213 |
|
20214 |
Property changes on: trunk/baselayout-prefix/sbin/depscan.sh |
20215 |
___________________________________________________________________ |
20216 |
Added: svn:executable |
20217 |
+ * |
20218 |
|
20219 |
Added: trunk/baselayout-prefix/sbin/env-update.sh |
20220 |
=================================================================== |
20221 |
--- trunk/baselayout-prefix/sbin/env-update.sh (rev 0) |
20222 |
+++ trunk/baselayout-prefix/sbin/env-update.sh 2011-03-31 14:11:17 UTC (rev 1682) |
20223 |
@@ -0,0 +1,38 @@ |
20224 |
+#!/bin/bash |
20225 |
+# Copyright 1999-2004 Gentoo Foundation |
20226 |
+# Distributed under the terms of the GNU General Public License v2 |
20227 |
+ |
20228 |
+source /sbin/functions.sh || exit 1 |
20229 |
+ |
20230 |
+if [[ ${EUID} != "0" ]] ; then |
20231 |
+ eerror "$0: must be root." |
20232 |
+ exit 1 |
20233 |
+fi |
20234 |
+ |
20235 |
+usage() { |
20236 |
+echo "usage: env-update.sh |
20237 |
+ |
20238 |
+note: |
20239 |
+ This utility generates /etc/profile.env and /etc/csh.env |
20240 |
+ from the contents of /etc/env.d/ |
20241 |
+" |
20242 |
+ exit 1 |
20243 |
+} |
20244 |
+ |
20245 |
+export SVCDIR="${svcdir}" |
20246 |
+ |
20247 |
+# Only update if files have actually changed |
20248 |
+if [[ $1 == "-u" ]] ; then |
20249 |
+ is_older_than "${svcdir}/envcache" /etc/env.d && exit 0 |
20250 |
+ shift |
20251 |
+fi |
20252 |
+ |
20253 |
+if [[ $# != "0" ]] ; then |
20254 |
+ usage |
20255 |
+else |
20256 |
+ /bin/gawk \ |
20257 |
+ -f /lib/rcscripts/awk/functions.awk \ |
20258 |
+ -f /lib/rcscripts/awk/genenviron.awk |
20259 |
+fi |
20260 |
+ |
20261 |
+# vim:ts=4 |
20262 |
|
20263 |
|
20264 |
Property changes on: trunk/baselayout-prefix/sbin/env-update.sh |
20265 |
___________________________________________________________________ |
20266 |
Added: svn:executable |
20267 |
+ * |
20268 |
|
20269 |
Added: trunk/baselayout-prefix/sbin/functions.sh |
20270 |
=================================================================== |
20271 |
--- trunk/baselayout-prefix/sbin/functions.sh (rev 0) |
20272 |
+++ trunk/baselayout-prefix/sbin/functions.sh 2011-03-31 14:11:17 UTC (rev 1682) |
20273 |
@@ -0,0 +1,854 @@ |
20274 |
+# Copyright 1999-2006 Gentoo Foundation |
20275 |
+# Distributed under the terms of the GNU General Public License v2 |
20276 |
+ |
20277 |
+RC_GOT_FUNCTIONS="yes" |
20278 |
+ |
20279 |
+# Override defaults with user settings ... |
20280 |
+[[ -f /etc/conf.d/rc ]] && source /etc/conf.d/rc |
20281 |
+ |
20282 |
+# Check /etc/conf.d/rc for a description of these ... |
20283 |
+declare -r svclib="/lib/rcscripts" |
20284 |
+declare -r svcdir="${svcdir:-/var/lib/init.d}" |
20285 |
+svcmount="${svcmount:-no}" |
20286 |
+svcfstype="${svcfstype:-tmpfs}" |
20287 |
+svcsize="${svcsize:-1024}" |
20288 |
+ |
20289 |
+# Different types of dependencies |
20290 |
+deptypes="need use" |
20291 |
+# Different types of order deps |
20292 |
+ordtypes="before after" |
20293 |
+ |
20294 |
+# |
20295 |
+# Internal variables |
20296 |
+# |
20297 |
+ |
20298 |
+# Dont output to stdout? |
20299 |
+RC_QUIET_STDOUT="${RC_QUIET_STDOUT:-no}" |
20300 |
+RC_VERBOSE="${RC_VERBOSE:-no}" |
20301 |
+ |
20302 |
+# Should we use color? |
20303 |
+RC_NOCOLOR="${RC_NOCOLOR:-no}" |
20304 |
+# Can the terminal handle endcols? |
20305 |
+RC_ENDCOL="yes" |
20306 |
+ |
20307 |
+# |
20308 |
+# Default values for rc system |
20309 |
+# |
20310 |
+RC_TTY_NUMBER="${RC_TTY_NUMBER:-11}" |
20311 |
+RC_PARALLEL_STARTUP="${RC_PARALLEL_STARTUP:-no}" |
20312 |
+RC_NET_STRICT_CHECKING="${RC_NET_STRICT_CHECKING:-no}" |
20313 |
+RC_USE_FSTAB="${RC_USE_FSTAB:-no}" |
20314 |
+RC_USE_CONFIG_PROFILE="${RC_USE_CONFIG_PROFILE:-yes}" |
20315 |
+RC_FORCE_AUTO="${RC_FORCE_AUTO:-no}" |
20316 |
+RC_DEVICES="${RC_DEVICES:-auto}" |
20317 |
+RC_DOWN_INTERFACE="${RC_DOWN_INTERFACE:-yes}" |
20318 |
+RC_VOLUME_ORDER="${RC_VOLUME_ORDER:-raid evms lvm dm}" |
20319 |
+ |
20320 |
+# |
20321 |
+# Default values for e-message indentation and dots |
20322 |
+# |
20323 |
+RC_INDENTATION='' |
20324 |
+RC_DEFAULT_INDENT=2 |
20325 |
+#RC_DOT_PATTERN=' .' |
20326 |
+RC_DOT_PATTERN='' |
20327 |
+ |
20328 |
+# bool has_addon(addon) |
20329 |
+# |
20330 |
+# See if addon exists. |
20331 |
+# |
20332 |
+has_addon() { |
20333 |
+ [[ -e ${svclib}/addons/$1 ]] |
20334 |
+} |
20335 |
+ |
20336 |
+# void import_addon(char *addon) |
20337 |
+# |
20338 |
+# Import code from the specified addon if it exists |
20339 |
+# |
20340 |
+import_addon() { |
20341 |
+ local addon="${svclib}/addons/$1" |
20342 |
+ if has_addon $1 ; then |
20343 |
+ source "${addon}" |
20344 |
+ return 0 |
20345 |
+ fi |
20346 |
+ return 1 |
20347 |
+} |
20348 |
+ |
20349 |
+# void splash(...) |
20350 |
+# |
20351 |
+# Notify bootsplash/splashutils/gensplash/whatever about |
20352 |
+# important events. |
20353 |
+# |
20354 |
+splash() { |
20355 |
+ return 0 |
20356 |
+} |
20357 |
+# This will override the splash() function... |
20358 |
+if ! import_addon splash-functions.sh ; then |
20359 |
+ [[ -f /sbin/splash-functions.sh ]] && source /sbin/splash-functions.sh |
20360 |
+fi |
20361 |
+ |
20362 |
+# void profiling(...) |
20363 |
+# |
20364 |
+# Notify bootsplash/whatever about important events. |
20365 |
+# |
20366 |
+profiling() { |
20367 |
+ return 0 |
20368 |
+} |
20369 |
+import_addon profiling-functions.sh |
20370 |
+ |
20371 |
+# void bootlog(...) |
20372 |
+# |
20373 |
+# Notify bootlogger about important events. |
20374 |
+bootlog() { |
20375 |
+ return 0 |
20376 |
+} |
20377 |
+[[ ${RC_BOOTLOG} == "yes" ]] && import_addon bootlogger.sh |
20378 |
+ |
20379 |
+# void get_bootconfig() |
20380 |
+# |
20381 |
+# Get the BOOTLEVEL and SOFTLEVEL by setting |
20382 |
+# 'bootlevel' and 'softlevel' via kernel |
20383 |
+# parameters. |
20384 |
+# |
20385 |
+get_bootconfig() { |
20386 |
+ local copt= |
20387 |
+ local newbootlevel= |
20388 |
+ local newsoftlevel= |
20389 |
+ |
20390 |
+ if [[ -r /proc/cmdline ]] ; then |
20391 |
+ for copt in $(</proc/cmdline) ; do |
20392 |
+ case "${copt%=*}" in |
20393 |
+ bootlevel) |
20394 |
+ newbootlevel="${copt##*=}" |
20395 |
+ ;; |
20396 |
+ softlevel) |
20397 |
+ newsoftlevel="${copt##*=}" |
20398 |
+ ;; |
20399 |
+ esac |
20400 |
+ done |
20401 |
+ fi |
20402 |
+ |
20403 |
+ if [[ -n ${newbootlevel} ]] ; then |
20404 |
+ export BOOTLEVEL="${newbootlevel}" |
20405 |
+ else |
20406 |
+ export BOOTLEVEL="boot" |
20407 |
+ fi |
20408 |
+ |
20409 |
+ if [[ -n ${newsoftlevel} ]] ; then |
20410 |
+ export DEFAULTLEVEL="${newsoftlevel}" |
20411 |
+ else |
20412 |
+ export DEFAULTLEVEL="default" |
20413 |
+ fi |
20414 |
+ |
20415 |
+ return 0 |
20416 |
+} |
20417 |
+ |
20418 |
+setup_defaultlevels() { |
20419 |
+ get_bootconfig |
20420 |
+ |
20421 |
+ if get_bootparam "noconfigprofile" ; then |
20422 |
+ export RC_USE_CONFIG_PROFILE="no" |
20423 |
+ |
20424 |
+ elif get_bootparam "configprofile" ; then |
20425 |
+ export RC_USE_CONFIG_PROFILE="yes" |
20426 |
+ fi |
20427 |
+ |
20428 |
+ if [[ ${RC_USE_CONFIG_PROFILE} == "yes" && -n ${DEFAULTLEVEL} ]] && \ |
20429 |
+ [[ -d "/etc/runlevels/${BOOTLEVEL}.${DEFAULTLEVEL}" || \ |
20430 |
+ -L "/etc/runlevels/${BOOTLEVEL}.${DEFAULTLEVEL}" ]] ; then |
20431 |
+ export BOOTLEVEL="${BOOTLEVEL}.${DEFAULTLEVEL}" |
20432 |
+ fi |
20433 |
+ |
20434 |
+ if [[ -z ${SOFTLEVEL} ]] ; then |
20435 |
+ if [[ -f "${svcdir}/softlevel" ]] ; then |
20436 |
+ export SOFTLEVEL=$(< "${svcdir}/softlevel") |
20437 |
+ else |
20438 |
+ export SOFTLEVEL="${BOOTLEVEL}" |
20439 |
+ fi |
20440 |
+ fi |
20441 |
+ |
20442 |
+ return 0 |
20443 |
+} |
20444 |
+ |
20445 |
+# void get_libdir(void) |
20446 |
+# |
20447 |
+# prints the current libdir {lib,lib32,lib64} |
20448 |
+# |
20449 |
+get_libdir() { |
20450 |
+ if [[ -n ${CONF_LIBDIR_OVERRIDE} ]] ; then |
20451 |
+ CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}" |
20452 |
+ elif [[ -x /usr/bin/portageq ]] ; then |
20453 |
+ CONF_LIBDIR="$(/usr/bin/portageq envvar CONF_LIBDIR)" |
20454 |
+ fi |
20455 |
+ echo "${CONF_LIBDIR:=lib}" |
20456 |
+} |
20457 |
+ |
20458 |
+# void esyslog(char* priority, char* tag, char* message) |
20459 |
+# |
20460 |
+# use the system logger to log a message |
20461 |
+# |
20462 |
+esyslog() { |
20463 |
+ local pri= |
20464 |
+ local tag= |
20465 |
+ |
20466 |
+ if [[ -x /usr/bin/logger ]] ; then |
20467 |
+ pri="$1" |
20468 |
+ tag="$2" |
20469 |
+ |
20470 |
+ shift 2 |
20471 |
+ [[ -z "$*" ]] && return 0 |
20472 |
+ |
20473 |
+ /usr/bin/logger -p "${pri}" -t "${tag}" -- "$*" |
20474 |
+ fi |
20475 |
+ |
20476 |
+ return 0 |
20477 |
+} |
20478 |
+ |
20479 |
+# void eindent(int num) |
20480 |
+# |
20481 |
+# increase the indent used for e-commands. |
20482 |
+# |
20483 |
+eindent() { |
20484 |
+ local i="$1" |
20485 |
+ (( i > 0 )) || (( i = RC_DEFAULT_INDENT )) |
20486 |
+ esetdent $(( ${#RC_INDENTATION} + i )) |
20487 |
+} |
20488 |
+ |
20489 |
+# void eoutdent(int num) |
20490 |
+# |
20491 |
+# decrease the indent used for e-commands. |
20492 |
+# |
20493 |
+eoutdent() { |
20494 |
+ local i="$1" |
20495 |
+ (( i > 0 )) || (( i = RC_DEFAULT_INDENT )) |
20496 |
+ esetdent $(( ${#RC_INDENTATION} - i )) |
20497 |
+} |
20498 |
+ |
20499 |
+# void esetdent(int num) |
20500 |
+# |
20501 |
+# hard set the indent used for e-commands. |
20502 |
+# num defaults to 0 |
20503 |
+# |
20504 |
+esetdent() { |
20505 |
+ local i="$1" |
20506 |
+ (( i < 0 )) && (( i = 0 )) |
20507 |
+ RC_INDENTATION=$(printf "%${i}s" '') |
20508 |
+} |
20509 |
+ |
20510 |
+# void einfo(char* message) |
20511 |
+# |
20512 |
+# show an informative message (with a newline) |
20513 |
+# |
20514 |
+einfo() { |
20515 |
+ einfon "$*\n" |
20516 |
+ LAST_E_CMD="einfo" |
20517 |
+ return 0 |
20518 |
+} |
20519 |
+ |
20520 |
+# void einfon(char* message) |
20521 |
+# |
20522 |
+# show an informative message (without a newline) |
20523 |
+# |
20524 |
+einfon() { |
20525 |
+ [[ ${RC_QUIET_STDOUT} == "yes" ]] && return 0 |
20526 |
+ [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo |
20527 |
+ echo -ne " ${GOOD}*${NORMAL} ${RC_INDENTATION}$*" |
20528 |
+ LAST_E_CMD="einfon" |
20529 |
+ return 0 |
20530 |
+} |
20531 |
+ |
20532 |
+# void ewarn(char* message) |
20533 |
+# |
20534 |
+# show a warning message + log it |
20535 |
+# |
20536 |
+ewarn() { |
20537 |
+ if [[ ${RC_QUIET_STDOUT} == "yes" ]] ; then |
20538 |
+ echo " $*" |
20539 |
+ else |
20540 |
+ [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo |
20541 |
+ echo -e " ${WARN}*${NORMAL} ${RC_INDENTATION}$*" |
20542 |
+ fi |
20543 |
+ |
20544 |
+ local name="rc-scripts" |
20545 |
+ [[ $0 != "/sbin/runscript.sh" ]] && name="${0##*/}" |
20546 |
+ # Log warnings to system log |
20547 |
+ esyslog "daemon.warning" "${name}" "$*" |
20548 |
+ |
20549 |
+ LAST_E_CMD="ewarn" |
20550 |
+ return 0 |
20551 |
+} |
20552 |
+ |
20553 |
+# void eerror(char* message) |
20554 |
+# |
20555 |
+# show an error message + log it |
20556 |
+# |
20557 |
+eerror() { |
20558 |
+ if [[ ${RC_QUIET_STDOUT} == "yes" ]] ; then |
20559 |
+ echo " $*" >/dev/stderr |
20560 |
+ else |
20561 |
+ [[ ${RC_ENDCOL} != "yes" && ${LAST_E_CMD} == "ebegin" ]] && echo |
20562 |
+ echo -e " ${BAD}*${NORMAL} ${RC_INDENTATION}$*" |
20563 |
+ fi |
20564 |
+ |
20565 |
+ local name="rc-scripts" |
20566 |
+ [[ $0 != "/sbin/runscript.sh" ]] && name="${0##*/}" |
20567 |
+ # Log errors to system log |
20568 |
+ esyslog "daemon.err" "rc-scripts" "$*" |
20569 |
+ |
20570 |
+ LAST_E_CMD="eerror" |
20571 |
+ return 0 |
20572 |
+} |
20573 |
+ |
20574 |
+# void ebegin(char* message) |
20575 |
+# |
20576 |
+# show a message indicating the start of a process |
20577 |
+# |
20578 |
+ebegin() { |
20579 |
+ local msg="$*" dots spaces="${RC_DOT_PATTERN//?/ }" |
20580 |
+ [[ ${RC_QUIET_STDOUT} == "yes" ]] && return 0 |
20581 |
+ |
20582 |
+ if [[ -n ${RC_DOT_PATTERN} ]] ; then |
20583 |
+ dots="$(printf "%$((COLS - 3 - ${#RC_INDENTATION} - ${#msg} - 7))s" '')" |
20584 |
+ dots="${dots//${spaces}/${RC_DOT_PATTERN}}" |
20585 |
+ msg="${msg}${dots}" |
20586 |
+ else |
20587 |
+ msg="${msg} ..." |
20588 |
+ fi |
20589 |
+ einfon "${msg}" |
20590 |
+ [[ ${RC_ENDCOL} == "yes" ]] && echo |
20591 |
+ |
20592 |
+ LAST_E_LEN="$(( 3 + ${#RC_INDENTATION} + ${#msg} ))" |
20593 |
+ LAST_E_CMD="ebegin" |
20594 |
+ return 0 |
20595 |
+} |
20596 |
+ |
20597 |
+# void _eend(int error, char *efunc, char* errstr) |
20598 |
+# |
20599 |
+# indicate the completion of process, called from eend/ewend |
20600 |
+# if error, show errstr via efunc |
20601 |
+# |
20602 |
+# This function is private to functions.sh. Do not call it from a |
20603 |
+# script. |
20604 |
+# |
20605 |
+_eend() { |
20606 |
+ local retval="${1:-0}" efunc="${2:-eerror}" msg |
20607 |
+ shift 2 |
20608 |
+ |
20609 |
+ if [[ ${retval} == "0" ]] ; then |
20610 |
+ [[ ${RC_QUIET_STDOUT} == "yes" ]] && return 0 |
20611 |
+ msg="${BRACKET}[ ${GOOD}ok${BRACKET} ]${NORMAL}" |
20612 |
+ else |
20613 |
+ if [[ -c /dev/null ]] ; then |
20614 |
+ rc_splash "stop" &>/dev/null & |
20615 |
+ else |
20616 |
+ rc_splash "stop" & |
20617 |
+ fi |
20618 |
+ if [[ -n $* ]] ; then |
20619 |
+ ${efunc} "$*" |
20620 |
+ fi |
20621 |
+ msg="${BRACKET}[ ${BAD}!!${BRACKET} ]${NORMAL}" |
20622 |
+ fi |
20623 |
+ |
20624 |
+ if [[ ${RC_ENDCOL} == "yes" ]] ; then |
20625 |
+ echo -e "${ENDCOL} ${msg}" |
20626 |
+ else |
20627 |
+ [[ ${LAST_E_CMD} == ebegin ]] || LAST_E_LEN=0 |
20628 |
+ printf "%$(( COLS - LAST_E_LEN - 6 ))s%b\n" '' "${msg}" |
20629 |
+ fi |
20630 |
+ |
20631 |
+ return ${retval} |
20632 |
+} |
20633 |
+ |
20634 |
+# void eend(int error, char* errstr) |
20635 |
+# |
20636 |
+# indicate the completion of process |
20637 |
+# if error, show errstr via eerror |
20638 |
+# |
20639 |
+eend() { |
20640 |
+ local retval="${1:-0}" |
20641 |
+ shift |
20642 |
+ |
20643 |
+ _eend "${retval}" eerror "$*" |
20644 |
+ |
20645 |
+ LAST_E_CMD="eend" |
20646 |
+ return ${retval} |
20647 |
+} |
20648 |
+ |
20649 |
+# void ewend(int error, char* errstr) |
20650 |
+# |
20651 |
+# indicate the completion of process |
20652 |
+# if error, show errstr via ewarn |
20653 |
+# |
20654 |
+ewend() { |
20655 |
+ local retval="${1:-0}" |
20656 |
+ shift |
20657 |
+ |
20658 |
+ _eend "${retval}" ewarn "$*" |
20659 |
+ |
20660 |
+ LAST_E_CMD="ewend" |
20661 |
+ return ${retval} |
20662 |
+} |
20663 |
+ |
20664 |
+# v-e-commands honor RC_VERBOSE which defaults to no. |
20665 |
+# The condition is negated so the return value will be zero. |
20666 |
+veinfo() { [[ ${RC_VERBOSE} != "yes" ]] || einfo "$@"; } |
20667 |
+veinfon() { [[ ${RC_VERBOSE} != "yes" ]] || einfon "$@"; } |
20668 |
+vewarn() { [[ ${RC_VERBOSE} != "yes" ]] || ewarn "$@"; } |
20669 |
+veerror() { [[ ${RC_VERBOSE} != "yes" ]] || eerror "$@"; } |
20670 |
+vebegin() { [[ ${RC_VERBOSE} != "yes" ]] || ebegin "$@"; } |
20671 |
+veend() { |
20672 |
+ [[ ${RC_VERBOSE} == "yes" ]] && { eend "$@"; return $?; } |
20673 |
+ return ${1:-0} |
20674 |
+} |
20675 |
+vewend() { |
20676 |
+ [[ ${RC_VERBOSE} == "yes" ]] && { ewend "$@"; return $?; } |
20677 |
+ return ${1:-0} |
20678 |
+} |
20679 |
+ |
20680 |
+# char *KV_major(string) |
20681 |
+# |
20682 |
+# Return the Major (X of X.Y.Z) kernel version |
20683 |
+# |
20684 |
+KV_major() { |
20685 |
+ [[ -z $1 ]] && return 1 |
20686 |
+ |
20687 |
+ local KV="$@" |
20688 |
+ echo "${KV%%.*}" |
20689 |
+} |
20690 |
+ |
20691 |
+# char *KV_minor(string) |
20692 |
+# |
20693 |
+# Return the Minor (Y of X.Y.Z) kernel version |
20694 |
+# |
20695 |
+KV_minor() { |
20696 |
+ [[ -z $1 ]] && return 1 |
20697 |
+ |
20698 |
+ local KV="$@" |
20699 |
+ KV="${KV#*.}" |
20700 |
+ echo "${KV%%.*}" |
20701 |
+} |
20702 |
+ |
20703 |
+# char *KV_micro(string) |
20704 |
+# |
20705 |
+# Return the Micro (Z of X.Y.Z) kernel version. |
20706 |
+# |
20707 |
+KV_micro() { |
20708 |
+ [[ -z $1 ]] && return 1 |
20709 |
+ |
20710 |
+ local KV="$@" |
20711 |
+ KV="${KV#*.*.}" |
20712 |
+ echo "${KV%%[^[:digit:]]*}" |
20713 |
+} |
20714 |
+ |
20715 |
+# int KV_to_int(string) |
20716 |
+# |
20717 |
+# Convert a string type kernel version (2.4.0) to an int (132096) |
20718 |
+# for easy compairing or versions ... |
20719 |
+# |
20720 |
+KV_to_int() { |
20721 |
+ [[ -z $1 ]] && return 1 |
20722 |
+ |
20723 |
+ local KV_MAJOR="$(KV_major "$1")" |
20724 |
+ local KV_MINOR="$(KV_minor "$1")" |
20725 |
+ local KV_MICRO="$(KV_micro "$1")" |
20726 |
+ local KV_int="$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))" |
20727 |
+ |
20728 |
+ # We make version 2.2.0 the minimum version we will handle as |
20729 |
+ # a sanity check ... if its less, we fail ... |
20730 |
+ if [[ ${KV_int} -ge 131584 ]] ; then |
20731 |
+ echo "${KV_int}" |
20732 |
+ return 0 |
20733 |
+ fi |
20734 |
+ |
20735 |
+ return 1 |
20736 |
+} |
20737 |
+ |
20738 |
+# int get_KV() |
20739 |
+# |
20740 |
+# Return the kernel version (major, minor and micro concated) as an integer. |
20741 |
+# Assumes X and Y of X.Y.Z are numbers. Also assumes that some leading |
20742 |
+# portion of Z is a number. |
20743 |
+# e.g. 2.4.25, 2.6.10, 2.6.4-rc3, 2.2.40-poop, 2.0.15+foo |
20744 |
+# |
20745 |
+_RC_GET_KV_CACHE="" |
20746 |
+get_KV() { |
20747 |
+ [[ -z ${_RC_GET_KV_CACHE} ]] \ |
20748 |
+ && _RC_GET_KV_CACHE="$(uname -r)" |
20749 |
+ |
20750 |
+ echo "$(KV_to_int "${_RC_GET_KV_CACHE}")" |
20751 |
+ |
20752 |
+ return $? |
20753 |
+} |
20754 |
+ |
20755 |
+# bool get_bootparam(param) |
20756 |
+# |
20757 |
+# return 0 if gentoo=param was passed to the kernel |
20758 |
+# |
20759 |
+# EXAMPLE: if get_bootparam "nodevfs" ; then .... |
20760 |
+# |
20761 |
+get_bootparam() { |
20762 |
+ local x copt params retval=1 |
20763 |
+ |
20764 |
+ [[ ! -r /proc/cmdline ]] && return 1 |
20765 |
+ |
20766 |
+ for copt in $(< /proc/cmdline) ; do |
20767 |
+ if [[ ${copt%=*} == "gentoo" ]] ; then |
20768 |
+ params=$(gawk -v PARAMS="${copt##*=}" ' |
20769 |
+ BEGIN { |
20770 |
+ split(PARAMS, nodes, ",") |
20771 |
+ for (x in nodes) |
20772 |
+ print nodes[x] |
20773 |
+ }') |
20774 |
+ |
20775 |
+ # Parse gentoo option |
20776 |
+ for x in ${params} ; do |
20777 |
+ if [[ ${x} == "$1" ]] ; then |
20778 |
+# echo "YES" |
20779 |
+ retval=0 |
20780 |
+ fi |
20781 |
+ done |
20782 |
+ fi |
20783 |
+ done |
20784 |
+ |
20785 |
+ return ${retval} |
20786 |
+} |
20787 |
+ |
20788 |
+# Safer way to list the contents of a directory, |
20789 |
+# as it do not have the "empty dir bug". |
20790 |
+# |
20791 |
+# char *dolisting(param) |
20792 |
+# |
20793 |
+# print a list of the directory contents |
20794 |
+# |
20795 |
+# NOTE: quote the params if they contain globs. |
20796 |
+# also, error checking is not that extensive ... |
20797 |
+# |
20798 |
+dolisting() { |
20799 |
+ local x= |
20800 |
+ local y= |
20801 |
+ local tmpstr= |
20802 |
+ local mylist= |
20803 |
+ local mypath="$*" |
20804 |
+ |
20805 |
+ if [[ ${mypath%/\*} != "${mypath}" ]] ; then |
20806 |
+ mypath=${mypath%/\*} |
20807 |
+ fi |
20808 |
+ |
20809 |
+ for x in ${mypath} ; do |
20810 |
+ [[ ! -e ${x} ]] && continue |
20811 |
+ |
20812 |
+ if [[ ! -d ${x} ]] && [[ -L ${x} || -f ${x} ]] ; then |
20813 |
+ mylist="${mylist} $(ls "${x}" 2> /dev/null)" |
20814 |
+ else |
20815 |
+ [[ ${x%/} != "${x}" ]] && x=${x%/} |
20816 |
+ |
20817 |
+ cd "${x}"; tmpstr=$(ls) |
20818 |
+ |
20819 |
+ for y in ${tmpstr} ; do |
20820 |
+ mylist="${mylist} ${x}/${y}" |
20821 |
+ done |
20822 |
+ fi |
20823 |
+ done |
20824 |
+ |
20825 |
+ echo "${mylist}" |
20826 |
+} |
20827 |
+ |
20828 |
+ |
20829 |
+# char *add_suffix(char * configfile) |
20830 |
+# |
20831 |
+# Returns a config file name with the softlevel suffix |
20832 |
+# appended to it. For use with multi-config services. |
20833 |
+add_suffix() { |
20834 |
+ if [[ ${RC_USE_CONFIG_PROFILE} != "yes" ]] ; then |
20835 |
+ echo "$1" |
20836 |
+ return 0 |
20837 |
+ fi |
20838 |
+ |
20839 |
+ local suffix="${SOFTLEVEL}" |
20840 |
+ [[ ${SOFTLEVEL} == "${BOOTLEVEL}" \ |
20841 |
+ || ${SOFTLEVEL} == "reboot" \ |
20842 |
+ || ${SOFTLEVEL} == "shutdown" \ |
20843 |
+ || ${SOFTLEVEL} == "single" ]] \ |
20844 |
+ && suffix="${DEFAULTLEVEL}" |
20845 |
+ if [[ -e "$1.${suffix}" ]] ; then |
20846 |
+ echo "$1.${suffix}" |
20847 |
+ else |
20848 |
+ echo "$1" |
20849 |
+ fi |
20850 |
+ |
20851 |
+ return 0 |
20852 |
+} |
20853 |
+ |
20854 |
+# char *get_base_ver() |
20855 |
+# |
20856 |
+# get the version of baselayout that this system is running |
20857 |
+# |
20858 |
+get_base_ver() { |
20859 |
+ [[ ! -r /etc/gentoo-release ]] && return 0 |
20860 |
+ local ver="$(</etc/gentoo-release)" |
20861 |
+ echo "${ver##* }" |
20862 |
+} |
20863 |
+ |
20864 |
+# Network filesystems list for common use in rc-scripts. |
20865 |
+# This variable is used in is_net_fs and other places such as |
20866 |
+# localmount. |
20867 |
+NET_FS_LIST="afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs" |
20868 |
+ |
20869 |
+# bool is_net_fs(path) |
20870 |
+# |
20871 |
+# return 0 if path is the mountpoint of a networked filesystem |
20872 |
+# |
20873 |
+# EXAMPLE: if is_net_fs / ; then ... |
20874 |
+# |
20875 |
+is_net_fs() { |
20876 |
+ local fstype |
20877 |
+ # /proc/mounts is always accurate but may not always be available |
20878 |
+ if [[ -e /proc/mounts ]] ; then |
20879 |
+ fstype="$( sed -n -e '/^rootfs/!s:.* '"$1"' \([^ ]*\).*:\1:p' /proc/mounts )" |
20880 |
+ else |
20881 |
+ fstype="$( mount | sed -n -e 's:.* on '"$1"' type \([^ ]*\).*:\1:p' )" |
20882 |
+ fi |
20883 |
+ [[ " ${NET_FS_LIST} " == *" ${fstype} "* ]] |
20884 |
+ return $? |
20885 |
+} |
20886 |
+ |
20887 |
+# bool is_net_fs(path) |
20888 |
+# |
20889 |
+# return 0 if path is under unionfs control |
20890 |
+# |
20891 |
+# EXAMPLE: if is_union_fs / ; then ... |
20892 |
+# |
20893 |
+is_union_fs() { |
20894 |
+ [[ ! -x /sbin/unionctl ]] && return 1 |
20895 |
+ unionctl "$1" --list &>/dev/null |
20896 |
+} |
20897 |
+ |
20898 |
+# bool is_uml_sys() |
20899 |
+# |
20900 |
+# return 0 if the currently running system is User Mode Linux |
20901 |
+# |
20902 |
+# EXAMPLE: if is_uml_sys ; then ... |
20903 |
+# |
20904 |
+is_uml_sys() { |
20905 |
+ grep -qs 'UML' /proc/cpuinfo |
20906 |
+} |
20907 |
+ |
20908 |
+# bool is_vserver_sys() |
20909 |
+# |
20910 |
+# return 0 if the currently running system is a Linux VServer |
20911 |
+# |
20912 |
+# EXAMPLE: if is_vserver_sys ; then ... |
20913 |
+# |
20914 |
+is_vserver_sys() { |
20915 |
+ grep -qs '^s_context:[[:space:]]*[1-9]' /proc/self/status |
20916 |
+} |
20917 |
+ |
20918 |
+# bool is_xenU_sys() |
20919 |
+# |
20920 |
+# return 0 if the currently running system is an unprivileged Xen domain |
20921 |
+# |
20922 |
+# EXAMPLE: if is_xenU_sys ; then ... |
20923 |
+# |
20924 |
+is_xenU_sys() { |
20925 |
+ [[ ! -d /proc/xen ]] && return 1 |
20926 |
+ [[ ! -r /proc/xen/capabilities ]] && return 1 |
20927 |
+ grep -q "control_d" /proc/xen/capabilities && return 1 |
20928 |
+ return 0 |
20929 |
+} |
20930 |
+ |
20931 |
+# bool get_mount_fstab(path) |
20932 |
+# |
20933 |
+# return the parameters to pass to the mount command generated from fstab |
20934 |
+# |
20935 |
+# EXAMPLE: cmd=$( get_mount_fstab /proc ) |
20936 |
+# cmd=${cmd:--t proc none /proc} |
20937 |
+# mount -n ${cmd} |
20938 |
+# |
20939 |
+get_mount_fstab() { |
20940 |
+ gawk '$1 ~ "^#" { next } |
20941 |
+ $2 == "'$*'" { stab="-t "$3" -o "$4" "$1" "$2; } |
20942 |
+ END { print stab; } |
20943 |
+ ' /etc/fstab |
20944 |
+} |
20945 |
+ |
20946 |
+# char *reverse_list(list) |
20947 |
+# |
20948 |
+# Returns the reversed order of list |
20949 |
+# |
20950 |
+reverse_list() { |
20951 |
+ for (( i = $# ; i > 0 ; --i )) ; do |
20952 |
+ echo -n "${!i} " |
20953 |
+ done |
20954 |
+} |
20955 |
+ |
20956 |
+# void start_addon(addon) |
20957 |
+# |
20958 |
+# Starts addon. |
20959 |
+# |
20960 |
+start_addon() { |
20961 |
+ local addon="$1" |
20962 |
+ (import_addon "${addon}-start.sh") |
20963 |
+ return 0 |
20964 |
+} |
20965 |
+ |
20966 |
+# void stop_addon(addon) |
20967 |
+# |
20968 |
+# Stops addon. |
20969 |
+# |
20970 |
+stop_addon() { |
20971 |
+ local addon=$1 |
20972 |
+ (import_addon "${addon}-stop.sh") |
20973 |
+ return 0 |
20974 |
+} |
20975 |
+ |
20976 |
+# bool is_older_than(reference, files/dirs to check) |
20977 |
+# |
20978 |
+# return 0 if any of the files/dirs are newer than |
20979 |
+# the reference file |
20980 |
+# |
20981 |
+# EXAMPLE: if is_older_than a.out *.o ; then ... |
20982 |
+is_older_than() { |
20983 |
+ local x= |
20984 |
+ local ref="$1" |
20985 |
+ shift |
20986 |
+ |
20987 |
+ for x in "$@" ; do |
20988 |
+ if [[ -d ${x} ]] ; then |
20989 |
+ is_older_than "${ref}" "${x}"/* && return 0 |
20990 |
+ elif [[ ${x} -nt ${ref} ]] ; then |
20991 |
+ return 0 |
20992 |
+ fi |
20993 |
+ done |
20994 |
+ |
20995 |
+ return 1 |
20996 |
+} |
20997 |
+ |
20998 |
+# char* bash_variable(char *variable) |
20999 |
+# |
21000 |
+# Turns the given variable into something that bash can use |
21001 |
+# Basically replaces anything not a-z,A-Z into a _ |
21002 |
+# |
21003 |
+bash_variable() { |
21004 |
+ local args="$@" |
21005 |
+ LC_ALL=C echo "${args//[![:word:]]/_}" |
21006 |
+} |
21007 |
+ |
21008 |
+# void requote() |
21009 |
+# |
21010 |
+# Requotes params so they're suitable to be eval'd, just like this would: |
21011 |
+# set -- 1 2 "3 4" |
21012 |
+# /usr/bin/getopt -- '' "$@" | sed 's/^ -- //' |
21013 |
+# |
21014 |
+requote() { |
21015 |
+ local q=\' |
21016 |
+ set -- "${@//\'/$q\'$q}" # quote inner instances of ' |
21017 |
+ set -- "${@/#/$q}" # add ' to start of each param |
21018 |
+ set -- "${@/%/$q}" # add ' to end of each param |
21019 |
+ echo "$*" |
21020 |
+} |
21021 |
+ |
21022 |
+# char* uniqify(char *arg, ...) |
21023 |
+# |
21024 |
+# Ensure that params are unique |
21025 |
+# |
21026 |
+uniqify() { |
21027 |
+ local result= x= |
21028 |
+ while [[ -n "$1" ]] ; do |
21029 |
+ [[ " ${result} " != *" $1 "* ]] && result="${result} $1" |
21030 |
+ shift |
21031 |
+ done |
21032 |
+ echo "${result# *}" |
21033 |
+} |
21034 |
+ |
21035 |
+############################################################################## |
21036 |
+# # |
21037 |
+# This should be the last code in here, please add all functions above!! # |
21038 |
+# # |
21039 |
+# *** START LAST CODE *** # |
21040 |
+# # |
21041 |
+############################################################################## |
21042 |
+ |
21043 |
+if [[ -z ${EBUILD} ]] ; then |
21044 |
+ # Setup a basic $PATH. Just add system default to existing. |
21045 |
+ # This should solve both /sbin and /usr/sbin not present when |
21046 |
+ # doing 'su -c foo', or for something like: PATH= rcscript start |
21047 |
+ PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin:${PATH}" |
21048 |
+ |
21049 |
+ # Cache the CONSOLETYPE - this is important as backgrounded shells don't |
21050 |
+ # have a TTY. rc unsets it at the end of running so it shouldn't hang |
21051 |
+ # around |
21052 |
+ if [[ -z ${CONSOLETYPE} ]] ; then |
21053 |
+ export CONSOLETYPE="$( /sbin/consoletype 2>/dev/null )" |
21054 |
+ fi |
21055 |
+ if [[ ${CONSOLETYPE} == "serial" ]] ; then |
21056 |
+ RC_NOCOLOR="yes" |
21057 |
+ RC_ENDCOL="no" |
21058 |
+ fi |
21059 |
+ |
21060 |
+ for arg in "$@" ; do |
21061 |
+ case "${arg}" in |
21062 |
+ # Lastly check if the user disabled it with --nocolor argument |
21063 |
+ --nocolor|-nc) |
21064 |
+ RC_NOCOLOR="yes" |
21065 |
+ ;; |
21066 |
+ esac |
21067 |
+ done |
21068 |
+ |
21069 |
+ setup_defaultlevels |
21070 |
+ |
21071 |
+ # If we are not /sbin/rc then ensure that we cannot change level variables |
21072 |
+ if [[ -n ${BASH_SOURCE} \ |
21073 |
+ && ${BASH_SOURCE[${#BASH_SOURCE[@]}-1]} != "/sbin/rc" ]] ; then |
21074 |
+ declare -r BOOTLEVEL DEFAULTLEVEL SOFTLEVEL |
21075 |
+ fi |
21076 |
+else |
21077 |
+ # Should we use colors ? |
21078 |
+ if [[ $* != *depend* ]] ; then |
21079 |
+ # Check user pref in portage |
21080 |
+ RC_NOCOLOR="$(portageq envvar NOCOLOR 2>/dev/null)" |
21081 |
+ [[ ${RC_NOCOLOR} == "true" ]] && RC_NOCOLOR="yes" |
21082 |
+ else |
21083 |
+ # We do not want colors during emerge depend |
21084 |
+ RC_NOCOLOR="yes" |
21085 |
+ # No output is seen during emerge depend, so this is not needed. |
21086 |
+ RC_ENDCOL="no" |
21087 |
+ fi |
21088 |
+fi |
21089 |
+ |
21090 |
+if [[ -n ${EBUILD} && $* == *depend* ]] ; then |
21091 |
+ # We do not want stty to run during emerge depend |
21092 |
+ COLS=80 |
21093 |
+else |
21094 |
+ # Setup COLS and ENDCOL so eend can line up the [ ok ] |
21095 |
+ COLS="${COLUMNS:-0}" # bash's internal COLUMNS variable |
21096 |
+ (( COLS == 0 )) && COLS="$(set -- `stty size 2>/dev/null` ; echo "$2")" |
21097 |
+ (( COLS > 0 )) || (( COLS = 80 )) # width of [ ok ] == 7 |
21098 |
+fi |
21099 |
+ |
21100 |
+if [[ ${RC_ENDCOL} == "yes" ]] ; then |
21101 |
+ ENDCOL=$'\e[A\e['$(( COLS - 8 ))'C' |
21102 |
+else |
21103 |
+ ENDCOL='' |
21104 |
+fi |
21105 |
+ |
21106 |
+# Setup the colors so our messages all look pretty |
21107 |
+if [[ ${RC_NOCOLOR} == "yes" ]] ; then |
21108 |
+ unset GOOD WARN BAD NORMAL HILITE BRACKET |
21109 |
+else |
21110 |
+ GOOD=$'\e[32;01m' |
21111 |
+ WARN=$'\e[33;01m' |
21112 |
+ BAD=$'\e[31;01m' |
21113 |
+ HILITE=$'\e[36;01m' |
21114 |
+ BRACKET=$'\e[34;01m' |
21115 |
+ NORMAL=$'\e[0m' |
21116 |
+fi |
21117 |
+ |
21118 |
+############################################################################## |
21119 |
+# # |
21120 |
+# *** END LAST CODE *** # |
21121 |
+# # |
21122 |
+# This should be the last code in here, please add all functions above!! # |
21123 |
+# # |
21124 |
+############################################################################## |
21125 |
+ |
21126 |
+ |
21127 |
+# vim:ts=4 |
21128 |
|
21129 |
|
21130 |
Property changes on: trunk/baselayout-prefix/sbin/functions.sh |
21131 |
___________________________________________________________________ |
21132 |
Added: svn:executable |
21133 |
+ * |
21134 |
|
21135 |
Added: trunk/baselayout-prefix/sbin/modules-update |
21136 |
=================================================================== |
21137 |
--- trunk/baselayout-prefix/sbin/modules-update (rev 0) |
21138 |
+++ trunk/baselayout-prefix/sbin/modules-update 2011-03-31 14:11:17 UTC (rev 1682) |
21139 |
@@ -0,0 +1,395 @@ |
21140 |
+#!/bin/bash |
21141 |
+# vim:ts=4 |
21142 |
+# |
21143 |
+# modules-update script originally based on Debian's version. |
21144 |
+# This script will update all the fun config files in /etc for |
21145 |
+# kernel modules. |
21146 |
+# |
21147 |
+# For 2.4 (and older) kernels we have: |
21148 |
+# /etc/modules.conf |
21149 |
+# /etc/modules.d/ |
21150 |
+# /etc/modules.devfs |
21151 |
+# |
21152 |
+# For 2.6+ kernels we have: |
21153 |
+# /etc/modprobe.conf |
21154 |
+# /etc/modprobe.d/ |
21155 |
+# /etc/modprobe.devfs |
21156 |
+ |
21157 |
+ |
21158 |
+argv0=${0##*/} |
21159 |
+source /etc/init.d/functions.sh || { |
21160 |
+ echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2 |
21161 |
+ exit 1 |
21162 |
+} |
21163 |
+umask 022 |
21164 |
+esyslog() { :; } |
21165 |
+ |
21166 |
+if [[ ${EUID} != "0" ]] ; then |
21167 |
+ eerror "You must be root to do this" 1>&2 |
21168 |
+ exit 2 |
21169 |
+fi |
21170 |
+ |
21171 |
+ |
21172 |
+# |
21173 |
+# Setup some variables |
21174 |
+# |
21175 |
+ |
21176 |
+CFG_OLD_FILE="/etc/modules.conf" |
21177 |
+CFG_OLD_DIR="/etc/modules.d" |
21178 |
+CFG_OLD_DEVFS="/etc/modules.devfs" |
21179 |
+ |
21180 |
+CFG_NEW_FILE="/etc/modprobe.conf" |
21181 |
+CFG_NEW_DIR="/etc/modprobe.d" |
21182 |
+CFG_NEW_DEVFS="/etc/modprobe.devfs" |
21183 |
+ |
21184 |
+HEADER="### This file is automatically generated by modules-update" |
21185 |
+FULLHEADER="${HEADER} |
21186 |
+# |
21187 |
+# Please do not edit this file directly. If you want to change or add |
21188 |
+# anything please take a look at the files in @MODDIR@ and read |
21189 |
+# the manpage for modules-update(8). |
21190 |
+# |
21191 |
+" |
21192 |
+ |
21193 |
+ |
21194 |
+# |
21195 |
+# Parse command-line |
21196 |
+# |
21197 |
+ |
21198 |
+VERBOSE=0 |
21199 |
+DEBUG=0 |
21200 |
+FORCE="false" |
21201 |
+BACKUP="false" |
21202 |
+GENERATE_DEVFS="false" |
21203 |
+ASSUME_KV= |
21204 |
+while [[ -n $1 ]] ; do |
21205 |
+ case $1 in |
21206 |
+ -f|--force|force) FORCE="true";; |
21207 |
+ -b|--backup) BACKUP="true";; |
21208 |
+ -D|--devfs) GENERATE_DEVFS="true";; |
21209 |
+ --assume-kernel=*) ASSUME_KV=${1#*=};; |
21210 |
+ -v|--verbose) ((++VERBOSE));; |
21211 |
+ -d|--debug) ((++DEBUG));; |
21212 |
+ -V|--version) exec cat /etc/gentoo-release;; |
21213 |
+ -h|--help) |
21214 |
+ cat <<-EOF |
21215 |
+ Usage: modules-update [options] |
21216 |
+ |
21217 |
+ Options: |
21218 |
+ --assume-kernel=KV Assume the kernel is at least version KV |
21219 |
+ -b, --backup Backup existing config files (add .old ext) |
21220 |
+ -f, --force Force execution in face of bad things |
21221 |
+ -D, --devfs Force generation of devfs config files |
21222 |
+ -v, --verbose Be a bit more verbose in what we do |
21223 |
+ -d, --debug Helpful debug output |
21224 |
+ -V, --version Dump version info |
21225 |
+ -h, --help This help screen, duh |
21226 |
+ EOF |
21227 |
+ exit 0 |
21228 |
+ ;; |
21229 |
+ *) |
21230 |
+ eerror "Error: I don't understand $1" |
21231 |
+ exit 1 |
21232 |
+ ;; |
21233 |
+ esac |
21234 |
+ shift |
21235 |
+done |
21236 |
+ |
21237 |
+[[ ${DEBUG} -gt 0 ]] && set -x |
21238 |
+ |
21239 |
+vewarn() { [[ ${VERBOSE} -gt 0 ]] && ewarn "$*" ; return 0 ; } |
21240 |
+ |
21241 |
+if ! ${GENERATE_DEVFS} && [[ -d /etc/devfs.d ]] ; then |
21242 |
+ GENERATE_DEVFS="true" |
21243 |
+fi |
21244 |
+ |
21245 |
+if type -p modprobe.old > /dev/null || \ |
21246 |
+ [[ $(modprobe -V 2>/dev/null) == "modprobe version"* ]] |
21247 |
+then |
21248 |
+ GENERATE_OLD="true" |
21249 |
+else |
21250 |
+ GENERATE_OLD="false" |
21251 |
+fi |
21252 |
+ |
21253 |
+# Set kernel version, either from --assume-kernel or uname -r |
21254 |
+KV=${ASSUME_KV:-$(uname -r)} |
21255 |
+if [[ $(KV_to_int ${KV}) -ge "$(KV_to_int 2.5.48)" ]] ; then |
21256 |
+ KERNEL_2_6="true" |
21257 |
+else |
21258 |
+ KERNEL_2_6="false" |
21259 |
+fi |
21260 |
+ |
21261 |
+# Reset the sorting order since we depend on it |
21262 |
+export LC_ALL="C" |
21263 |
+ |
21264 |
+ |
21265 |
+# |
21266 |
+# Build list of config files to generate and verify none |
21267 |
+# have been modified in any way |
21268 |
+# |
21269 |
+ |
21270 |
+CFGFILES="" |
21271 |
+if ${GENERATE_OLD} ; then |
21272 |
+ CFGFILES="${CFGFILES} ${CFG_OLD_FILE}" |
21273 |
+ ${GENERATE_DEVFS} && CFGFILES="${CFGFILES} ${CFG_OLD_DEVFS}" |
21274 |
+fi |
21275 |
+if ${KERNEL_2_6} ; then |
21276 |
+ CFGFILES="${CFGFILES} ${CFG_NEW_FILE}" |
21277 |
+ ${GENERATE_DEVFS} && CFGFILES="${CFGFILES} ${CFG_NEW_DEVFS}" |
21278 |
+fi |
21279 |
+ |
21280 |
+for x in ${CFGFILES} ; do |
21281 |
+ [[ -r ${x} ]] || continue |
21282 |
+ |
21283 |
+ if [[ $(sed -ne 1p "${x}") != "${HEADER}" ]] ; then |
21284 |
+ ewarn "Warning: the current ${x} has not been automatically generated" |
21285 |
+ |
21286 |
+ if ${FORCE} ; then |
21287 |
+ ewarn "--force specified, (re)generating file anyway" |
21288 |
+ else |
21289 |
+ eerror "Use \"modules-update force\" to force (re)generation" |
21290 |
+ exit 1 |
21291 |
+ fi |
21292 |
+ fi |
21293 |
+done |
21294 |
+ |
21295 |
+ |
21296 |
+# |
21297 |
+# Desc: backup a config file if need be and replace with new one |
21298 |
+# Usage: backup <old config file to backup> <new config file to replace with> |
21299 |
+# Ex: backup /etc/modules.conf /etc/modules.conf.tempfile |
21300 |
+# |
21301 |
+backup() { |
21302 |
+ if ${BACKUP} && [[ -e $1 ]] ; then |
21303 |
+ mv -f "$1" "$1".old |
21304 |
+ fi |
21305 |
+ mv -f "$2" "$1" |
21306 |
+} |
21307 |
+ |
21308 |
+ |
21309 |
+# |
21310 |
+# Desc: Combine all config files in a dir and place output in a file |
21311 |
+# Usage: generate_config <output config file> <config dir> <reference config dir> <silent> |
21312 |
+# Ex: generate_config /etc/modules.conf /etc/modules.d |
21313 |
+# |
21314 |
+generate_config() { |
21315 |
+ local config=$1 |
21316 |
+ local moddir=$2 |
21317 |
+ local refdir=$3 |
21318 |
+ local silent=$4 |
21319 |
+ local tmpfile="${config}.$$" |
21320 |
+ |
21321 |
+ [[ -z ${silent} ]] && ebegin "Updating ${config}" |
21322 |
+ |
21323 |
+ echo "${FULLHEADER//@MODDIR@/${refdir:-${moddir}}}" > "${tmpfile}" |
21324 |
+ |
21325 |
+ for cfg in "${moddir}"/* ; do |
21326 |
+ [[ -d ${cfg} ]] && continue |
21327 |
+ [[ ! -r ${cfg} ]] && continue |
21328 |
+ |
21329 |
+ # Skip backup and RCS files; fixes bug 20597 (07 May 2004 agriffis) |
21330 |
+ [[ ${cfg} == *~ || ${cfg} == *.bak || ${cfg} == *,v ]] && continue |
21331 |
+ |
21332 |
+ # If config file is found in the reference dir, then skip it |
21333 |
+ [[ -n ${refdir} ]] && [[ -e ${refdir}/${cfg##*/} ]] && continue |
21334 |
+ |
21335 |
+ echo "### modules-update: start processing ${cfg}" >> "${tmpfile}" |
21336 |
+ |
21337 |
+ if [[ -x ${cfg} ]] ; then |
21338 |
+ # $cfg can be executable; nice touch, Wichert! :) |
21339 |
+ "${cfg}" >> "${tmpfile}" |
21340 |
+ else |
21341 |
+ cat "${cfg}" >> "${tmpfile}" |
21342 |
+ fi |
21343 |
+ |
21344 |
+ echo >> "${tmpfile}" |
21345 |
+ echo "### modules-update: end processing ${cfg}" >> "${tmpfile}" |
21346 |
+ echo >> "${tmpfile}" |
21347 |
+ done |
21348 |
+ |
21349 |
+ backup "${config}" "${tmpfile}" |
21350 |
+ |
21351 |
+ [[ -z ${silent} ]] && eend 0 |
21352 |
+ |
21353 |
+ return 0 |
21354 |
+} |
21355 |
+ |
21356 |
+ |
21357 |
+# |
21358 |
+# Generate the old modules.conf file based upon all the snippets in |
21359 |
+# modules.d. Since modprobe doesnt handle modules.d, we need to gather |
21360 |
+# the files together in modules.conf for it. |
21361 |
+# |
21362 |
+ |
21363 |
+if [[ ! -d ${CFG_OLD_DIR} ]] ; then |
21364 |
+ vewarn "Skipping ${CFG_OLD_FILE} generation (${CFG_OLD_DIR} doesn't exist)" |
21365 |
+ |
21366 |
+elif ! ${GENERATE_OLD} ; then |
21367 |
+ vewarn "Skipping ${CFG_OLD_FILE} generation (prerequisites not satisfied)" |
21368 |
+ |
21369 |
+elif ! ( ${FORCE} || \ |
21370 |
+ [[ ! -e ${CFG_OLD_FILE} ]] || \ |
21371 |
+ is_older_than ${CFG_OLD_FILE} ${CFG_OLD_DIR} ) |
21372 |
+then |
21373 |
+ vewarn "Skipping ${CFG_OLD_FILE} generation (file is newer than dependencies)" |
21374 |
+ |
21375 |
+else |
21376 |
+ generate_config ${CFG_OLD_FILE} ${CFG_OLD_DIR} |
21377 |
+fi |
21378 |
+ |
21379 |
+ |
21380 |
+# |
21381 |
+# Generate the new modprobe.conf file if possible. What this entails is |
21382 |
+# grabbing details from the old modprobe via the -c option and sticking |
21383 |
+# it in the newer config file. This is useful for backwards compat support |
21384 |
+# and for packages that provide older style /etc/modules.d/ files but not |
21385 |
+# newer style /etc/modprobe.d/ files. |
21386 |
+# |
21387 |
+# First we try to use the script `generate-modprobe.conf` from the |
21388 |
+# module-init-tools and if that fails us, we try and generate modprobe.conf |
21389 |
+# ourselves from the /etc/modules.d/ files. |
21390 |
+# |
21391 |
+ |
21392 |
+if ! ${KERNEL_2_6} ; then |
21393 |
+ vewarn "Skipping ${CFG_NEW_FILE} generation (not needed for 2.4 kernels)" |
21394 |
+ |
21395 |
+elif ! type -p generate-modprobe.conf > /dev/null ; then |
21396 |
+ vewarn "Skipping ${CFG_NEW_FILE} generation (generate-modprobe.conf doesn't exist)" |
21397 |
+ |
21398 |
+elif ! ( ${FORCE} || \ |
21399 |
+ [[ ! -e ${CFG_NEW_FILE} ]] || \ |
21400 |
+ is_older_than ${CFG_NEW_FILE} ${CFG_OLD_DIR} ${CFG_NEW_DIR} ) |
21401 |
+then |
21402 |
+ vewarn "Skipping ${CFG_NEW_FILE} generation (file is newer than dependencies)" |
21403 |
+ |
21404 |
+else |
21405 |
+ |
21406 |
+ generated_ok=0 |
21407 |
+ tmpfile="${CFG_NEW_FILE}.$$" |
21408 |
+ |
21409 |
+ # |
21410 |
+ # First we try to use regular generate-modprobe.conf |
21411 |
+ # |
21412 |
+ if ${GENERATE_OLD} ; then |
21413 |
+ # Make sure that generate-modprobe.conf can handle --assume-kernel |
21414 |
+ # if we were called with it. |
21415 |
+ if [[ -n ${ASSUME_KV} ]] && \ |
21416 |
+ ! grep -qe --assume-kernel /sbin/generate-modprobe.conf ; then |
21417 |
+ eerror "Error: modules-update called with --assume-kernel flag, but" |
21418 |
+ eerror "generate-modprobe.conf doesn't understand it. You need to" |
21419 |
+ eerror "install >=module-init-tools-3.0-r2" |
21420 |
+ exit 3 |
21421 |
+ fi |
21422 |
+ |
21423 |
+ ebegin "Updating ${CFG_NEW_FILE}" |
21424 |
+ echo "${FULLHEADER//@MODDIR@/${CFG_NEW_DIR}}" > "${tmpfile}" |
21425 |
+ if generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ |
21426 |
+ >> "${tmpfile}" 2> "${tmpfile}.err" |
21427 |
+ then |
21428 |
+ backup "${CFG_NEW_FILE}" "${tmpfile}" |
21429 |
+ eend 0 |
21430 |
+ generated_ok=1 |
21431 |
+ else |
21432 |
+ [[ ${VERBOSE} -gt 0 ]] && cat "${tmpfile}.err" |
21433 |
+ eend 1 "Warning: could not generate ${CFG_NEW_FILE}!" |
21434 |
+ fi |
21435 |
+ fi |
21436 |
+ |
21437 |
+ # |
21438 |
+ # If the helper script failed, we fall back to doing it by hand |
21439 |
+ # |
21440 |
+ if [[ ${generated_ok} -eq 0 ]] ; then |
21441 |
+ ebegin "Updating ${CFG_NEW_FILE} by hand" |
21442 |
+ |
21443 |
+ generate_config "${CFG_NEW_FILE}" "${CFG_OLD_DIR}" "${CFG_NEW_DIR}" 0 |
21444 |
+ echo "${FULLHEADER//@MODDIR@/${CFG_NEW_DIR}}" > "${tmpfile}" |
21445 |
+ |
21446 |
+ # Just use generate-modprobe.conf to filter compatible syntax |
21447 |
+ if TESTING_MODPROBE_CONF=${CFG_NEW_FILE} \ |
21448 |
+ generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ |
21449 |
+ >> "${tmpfile}" 2> "${tmpfile}.err" |
21450 |
+ then |
21451 |
+ # we use mv here instead of backup_config() as the call to |
21452 |
+ # generate_config() above already took care of the backup |
21453 |
+ mv -f "${tmpfile}" "${CFG_NEW_FILE}" |
21454 |
+ eend $? |
21455 |
+ else |
21456 |
+ [[ ${VERBOSE} -gt 0 ]] && cat "${tmpfile}.err" |
21457 |
+ eend 1 "Warning: could not generate ${CFG_NEW_FILE}!" |
21458 |
+ fi |
21459 |
+ fi |
21460 |
+ |
21461 |
+ rm -f "${tmpfile}" "${tmpfile}.err" |
21462 |
+ |
21463 |
+ # |
21464 |
+ # Take care of generating /etc/modprobe.devfs if need be. |
21465 |
+ # |
21466 |
+ if ${GENERATE_DEVFS} && [[ -f ${CFG_OLD_DEVFS} ]] && \ |
21467 |
+ ( [[ ! -e ${CFG_NEW_DEVFS} ]] || [[ ${CFG_OLD_DEVFS} -nt ${CFG_NEW_DEVFS} ]] || ${FORCE} ) |
21468 |
+ then |
21469 |
+ ebegin "Updating ${CFG_NEW_DEVFS}" |
21470 |
+ |
21471 |
+ tmpfile="${CFG_NEW_DEVFS}.$$" |
21472 |
+ tmpfile_old="${CFG_OLD_DEVFS}.$$" |
21473 |
+ |
21474 |
+ echo "${FULLHEADER/@MODDIR@/${CFG_NEW_DIR}}" > "${tmpfile_old}" |
21475 |
+ cp -f "${tmpfile_old}" "${tmpfile}" |
21476 |
+ gawk '$0 !~ /^[[:space:]]*include/ { print $0 }' \ |
21477 |
+ "${CFG_OLD_DEVFS}" >> "${tmpfile_old}" |
21478 |
+ |
21479 |
+ if TESTING_MODPROBE_CONF=${tmpfile_old} \ |
21480 |
+ generate-modprobe.conf ${ASSUME_KV:+--assume-kernel=${KV}} \ |
21481 |
+ >> "${tmpfile}" 2> "${tmpfile}.err" |
21482 |
+ then |
21483 |
+ echo >> "${tmpfile}" |
21484 |
+ echo "include /etc/modprobe.conf" >> "${tmpfile}" |
21485 |
+ backup "${CFG_NEW_DEVFS}" "${tmpfile}" |
21486 |
+ eend 0 |
21487 |
+ else |
21488 |
+ [[ ${VERBOSE} -gt 0 ]] && cat "${tmpfile}.err" |
21489 |
+ eend 1 "Warning: could not generate ${CFG_NEW_DEVFS}!" |
21490 |
+ rm -f "${tmpfile}" |
21491 |
+ fi |
21492 |
+ |
21493 |
+ backup "${CFG_OLD_DEVFS}" "${tmpfile_old}" |
21494 |
+ |
21495 |
+ rm -f "${tmpfile_old}" "${tmpfile}" "${tmpfile}.err" |
21496 |
+ fi |
21497 |
+fi |
21498 |
+ |
21499 |
+ |
21500 |
+# |
21501 |
+# Call depmod to keep insmod from complaining that modules.conf is more |
21502 |
+# recent then the modules.dep file. |
21503 |
+# |
21504 |
+ |
21505 |
+grab_depfile() { |
21506 |
+ # the modules.conf file has optional syntax: |
21507 |
+ # depfile=/path/to/modules.dep |
21508 |
+ local ret="" |
21509 |
+ if [[ -e ${CFG_OLD_FILE} ]] ; then |
21510 |
+ ret=$(sed -n -e '/^[[:space:]]*depfile=/s:.*=::p' ${CFG_OLD_FILE}) |
21511 |
+ fi |
21512 |
+ [[ -z ${ret} ]] && ret="/lib/modules/${KV}/modules.dep" |
21513 |
+ eval echo "${ret}" |
21514 |
+} |
21515 |
+depfile=$(grab_depfile) |
21516 |
+ |
21517 |
+if [[ -d ${depfile%/*} ]] ; then |
21518 |
+ if [[ ${CFG_NEW_FILE} -nt ${depfile} ]] ; then |
21519 |
+ ebegin "Updating modules.dep" |
21520 |
+ for cfg in /lib/modules/${KV}/build /usr/src/linux-${KV} \ |
21521 |
+ /boot /usr/src/linux "" |
21522 |
+ do |
21523 |
+ cfg="${cfg}/System.map" |
21524 |
+ [[ -f ${cfg} ]] && break |
21525 |
+ done |
21526 |
+ [[ -n ${cfg} ]] && cfg="-F ${cfg}" |
21527 |
+ depmod -a ${cfg} ${KV} |
21528 |
+ eend $? |
21529 |
+ fi |
21530 |
+else |
21531 |
+ vewarn "The dir '${depfile}' does not exist, skipping call to depmod" |
21532 |
+fi |
21533 |
+ |
21534 |
+exit 0 |
21535 |
|
21536 |
|
21537 |
Property changes on: trunk/baselayout-prefix/sbin/modules-update |
21538 |
___________________________________________________________________ |
21539 |
Added: svn:executable |
21540 |
+ * |
21541 |
|
21542 |
Added: trunk/baselayout-prefix/sbin/rc |
21543 |
=================================================================== |
21544 |
--- trunk/baselayout-prefix/sbin/rc (rev 0) |
21545 |
+++ trunk/baselayout-prefix/sbin/rc 2011-03-31 14:11:17 UTC (rev 1682) |
21546 |
@@ -0,0 +1,910 @@ |
21547 |
+#!/sbin/runscript |
21548 |
+# Copyright 1999-2006 Gentoo Foundation |
21549 |
+# Distributed under the terms of the GNU General Public License v2 |
21550 |
+ |
21551 |
+trap ":" INT QUIT TSTP |
21552 |
+source /sbin/functions.sh |
21553 |
+# Only source this when this is a livecd booting ... |
21554 |
+[ -f /sbin/livecd-functions.sh ] && source /sbin/livecd-functions.sh |
21555 |
+# Silly users |
21556 |
+[[ -f /etc/conf.d/rc-extra ]] && source /etc/conf.d/rc-extra |
21557 |
+umask 022 |
21558 |
+ |
21559 |
+# Quick test to see if we can be interactive or not |
21560 |
+if [[ ${RC_INTERACTIVE:-yes} == "yes" ]] ; then |
21561 |
+ if tty -s && stty -a | grep -q " icanon" ; then |
21562 |
+ RC_INTERACTIVE="yes" |
21563 |
+ else |
21564 |
+ RC_INTERACTIVE="no" |
21565 |
+ fi |
21566 |
+fi |
21567 |
+ |
21568 |
+try() { |
21569 |
+ local errstr |
21570 |
+ local retval=0 |
21571 |
+ |
21572 |
+ if [ -c /dev/null ]; then |
21573 |
+ errstr="$((eval $*) 2>&1 >/dev/null)" |
21574 |
+ else |
21575 |
+ errstr="$((eval $*) 2>&1)" |
21576 |
+ fi |
21577 |
+ retval=$? |
21578 |
+ if [ "${retval}" -ne 0 ] |
21579 |
+ then |
21580 |
+ splash "critical" & |
21581 |
+ |
21582 |
+ echo -e "${ENDCOL}${NORMAL}[${BAD} oops ${NORMAL}]" |
21583 |
+ echo |
21584 |
+ eerror "The \"${1}\" command failed with error:" |
21585 |
+ echo |
21586 |
+ echo "${errstr#*: }" |
21587 |
+ echo |
21588 |
+ eerror "Since this is a critical task, startup cannot continue." |
21589 |
+ echo |
21590 |
+ /sbin/sulogin ${CONSOLE} |
21591 |
+ einfo "Unmounting filesystems" |
21592 |
+ if [ -c /dev/null ]; then |
21593 |
+ /bin/mount -a -o remount,ro &>/dev/null |
21594 |
+ else |
21595 |
+ /bin/mount -a -o remount,ro |
21596 |
+ fi |
21597 |
+ einfo "Rebooting" |
21598 |
+ /sbin/reboot -f |
21599 |
+ fi |
21600 |
+ |
21601 |
+ return ${retval} |
21602 |
+} |
21603 |
+ |
21604 |
+# Check that $1 exists ... |
21605 |
+check_statedir() { |
21606 |
+ [ -z "$1" ] && return 0 |
21607 |
+ |
21608 |
+ if [ ! -d "$1" ] ; then |
21609 |
+ if ! mkdir -p "$1" &>/dev/null ; then |
21610 |
+ splash "critical" & |
21611 |
+ echo |
21612 |
+ eerror "For Gentoo to function properly, \"$1\" needs to exist." |
21613 |
+ if [[ ${RC_FORCE_AUTO} == "yes" ]] ; then |
21614 |
+ eerror "Attempting to create \"$1\" for you ..." |
21615 |
+ mount -o remount,rw / |
21616 |
+ mkdir -p "$1" |
21617 |
+ else |
21618 |
+ eerror "Please mount your root partition read/write, and execute:" |
21619 |
+ echo |
21620 |
+ eerror " # mkdir -p $1" |
21621 |
+ echo; echo |
21622 |
+ /sbin/sulogin ${CONSOLE} |
21623 |
+ fi |
21624 |
+ einfo "Unmounting filesystems" |
21625 |
+ /bin/mount -a -o remount,ro &>/dev/null |
21626 |
+ einfo "Rebooting" |
21627 |
+ /sbin/reboot -f |
21628 |
+ fi |
21629 |
+ fi |
21630 |
+ |
21631 |
+ return 0 |
21632 |
+} |
21633 |
+ |
21634 |
+# void noblock_read(var) |
21635 |
+# |
21636 |
+# reads a line of input into var like regular read |
21637 |
+# but it does not block waiting for input |
21638 |
+# |
21639 |
+noblock_read() { |
21640 |
+ local old_tty_settings="$(stty -g)" |
21641 |
+ stty -icanon min 0 time 0 |
21642 |
+ read "$@" |
21643 |
+ stty "${old_tty_settings}" |
21644 |
+} |
21645 |
+ |
21646 |
+# bool user_want_interactive(void) |
21647 |
+# |
21648 |
+# return 0 if user wants interactive mode |
21649 |
+# |
21650 |
+user_want_interactive() { |
21651 |
+ [[ ${RC_INTERACTIVE} != "yes" ]] && return 1 |
21652 |
+ |
21653 |
+ local user_input |
21654 |
+ noblock_read user_input |
21655 |
+ [[ ${user_input} == *"I"* || ${user_input} == *"i"* ]] |
21656 |
+} |
21657 |
+ |
21658 |
+# void do_interactive |
21659 |
+# |
21660 |
+# starts, skips, continues or drops to the shell |
21661 |
+# depending on user selection |
21662 |
+# |
21663 |
+do_interactive() { |
21664 |
+ local service="$2" |
21665 |
+ |
21666 |
+ user_want_interactive && svcinteractive="yes" |
21667 |
+ if [[ ${svcinteractive} != "yes" || ! -e "/etc/init.d/${service}" ]] ; then |
21668 |
+ "$@" |
21669 |
+ return $? |
21670 |
+ fi |
21671 |
+ |
21672 |
+ local start_text="Start service" |
21673 |
+ local skip_text="Skip service" |
21674 |
+ local continue_text="Continue boot process" |
21675 |
+ local shell_text="Exit to shell" |
21676 |
+ |
21677 |
+ echo |
21678 |
+ echo "About to start the service ${service}" |
21679 |
+ PS3="Enter your selection: " |
21680 |
+ select action in "${start_text}" "${skip_text}" "${continue_text}" \ |
21681 |
+ "${shell_text}" |
21682 |
+ do |
21683 |
+ case ${action} in |
21684 |
+ "${start_text}") |
21685 |
+ "$@" |
21686 |
+ break |
21687 |
+ ;; |
21688 |
+ "${skip_text}") |
21689 |
+ break |
21690 |
+ ;; |
21691 |
+ "${continue_text}") |
21692 |
+ svcinteractive="no" |
21693 |
+ "$@" |
21694 |
+ break |
21695 |
+ ;; |
21696 |
+ "${shell_text}") |
21697 |
+ echo |
21698 |
+ sulogin "${CONSOLE}" |
21699 |
+ ;; |
21700 |
+ esac |
21701 |
+ done |
21702 |
+} |
21703 |
+ |
21704 |
+get_critical_services() { |
21705 |
+ local x= |
21706 |
+ CRITICAL_SERVICES= |
21707 |
+ |
21708 |
+ if [ -f "/etc/runlevels/${BOOTLEVEL}/.critical" ] |
21709 |
+ then |
21710 |
+ for x in $(< /etc/runlevels/${BOOTLEVEL}/.critical) |
21711 |
+ do |
21712 |
+ CRITICAL_SERVICES="${CRITICAL_SERVICES} ${x##*/}" |
21713 |
+ done |
21714 |
+ else |
21715 |
+ CRITICAL_SERVICES="checkroot modules checkfs localmount clock bootmisc" |
21716 |
+ fi |
21717 |
+ |
21718 |
+ export CRITICAL_SERVICES |
21719 |
+ |
21720 |
+ return 0 |
21721 |
+} |
21722 |
+ |
21723 |
+check_critical_services() { |
21724 |
+ local x |
21725 |
+ |
21726 |
+ # Ensure that critical services are in the boot runlevel |
21727 |
+ for x in ${CRITICAL_SERVICES} ; do |
21728 |
+ if [[ ! -L "/etc/runlevels/${BOOTLEVEL}/${x}" ]] ; then |
21729 |
+ ewarn "WARNING: Adding critical service ${x} to the ${BOOTLEVEL} runlevel" |
21730 |
+ ln -snf "/etc/init.d/${x}" "/etc/runlevels/${BOOTLEVEL}/${x}" |
21731 |
+ fi |
21732 |
+ done |
21733 |
+} |
21734 |
+ |
21735 |
+# Save $1 |
21736 |
+argv1="$1" |
21737 |
+ |
21738 |
+# First time boot stuff goes here. Note that 'sysinit' is an internal runlevel |
21739 |
+# used to bring up local filesystems, and should not be started with /sbin/rc |
21740 |
+# directly ... |
21741 |
+if [[ ( ${RUNLEVEL} == "S" || ${RUNLEVEL} == "1" ) && ${argv1} = "sysinit" ]] |
21742 |
+then |
21743 |
+ # Setup initial $PATH just in case |
21744 |
+ PATH="/bin:/sbin:/usr/bin:/usr/sbin:${PATH}" |
21745 |
+ |
21746 |
+ # Help users recover their systems incase these go missing |
21747 |
+ [ -c /dev/null ] && dev_null=1 || dev_null=0 |
21748 |
+ [ -c /dev/console ] && dev_console=1 || dev_console=0 |
21749 |
+ |
21750 |
+ # Set the console loglevel to 1 for a cleaner boot |
21751 |
+ # the logger should anyhow dump the ring-0 buffer at start to the |
21752 |
+ # logs, and that with dmesg can be used to check for problems |
21753 |
+ ${RC_DMESG_LEVEL+/bin/dmesg -n ${RC_DMESG_LEVEL}} |
21754 |
+ |
21755 |
+ echo |
21756 |
+ echo -e "${GOOD}Gentoo Linux${GENTOO_VERS}; ${BRACKET}http://www.gentoo.org/${NORMAL}" |
21757 |
+ echo -e " Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2" |
21758 |
+ echo |
21759 |
+ if [[ ${RC_INTERACTIVE} == "yes" ]] ; then |
21760 |
+ echo -e "Press ${GOOD}I${NORMAL} to enter interactive boot mode" |
21761 |
+ echo |
21762 |
+ fi |
21763 |
+ check_statedir /proc |
21764 |
+ |
21765 |
+ ebegin "Mounting proc at /proc" |
21766 |
+ if [[ ${RC_USE_FSTAB} = "yes" ]] ; then |
21767 |
+ mntcmd=$(get_mount_fstab /proc) |
21768 |
+ else |
21769 |
+ unset mntcmd |
21770 |
+ fi |
21771 |
+ try mount -n ${mntcmd:--t proc proc /proc -o noexec,nosuid,nodev} |
21772 |
+ eend $? |
21773 |
+ |
21774 |
+ # Start profiling init now we have /proc |
21775 |
+ profiling start |
21776 |
+ |
21777 |
+ # Read off the kernel commandline to see if there's any special settings |
21778 |
+ # especially check to see if we need to set the CDBOOT environment variable |
21779 |
+ # Note: /proc MUST be mounted |
21780 |
+ [ -f /sbin/livecd-functions.sh ] && livecd_read_commandline |
21781 |
+ |
21782 |
+ if [ "$(get_KV)" -ge "$(KV_to_int '2.6.0')" ] ; then |
21783 |
+ if [[ -d /sys ]] ; then |
21784 |
+ ebegin "Mounting sysfs at /sys" |
21785 |
+ if [[ ${RC_USE_FSTAB} = "yes" ]] ; then |
21786 |
+ mntcmd=$(get_mount_fstab /sys) |
21787 |
+ else |
21788 |
+ unset mntcmd |
21789 |
+ fi |
21790 |
+ try mount -n ${mntcmd:--t sysfs sysfs /sys -o noexec,nosuid,nodev} |
21791 |
+ eend $? |
21792 |
+ else |
21793 |
+ ewarn "No /sys to mount sysfs needed in 2.6 and later kernels!" |
21794 |
+ fi |
21795 |
+ fi |
21796 |
+ |
21797 |
+ check_statedir /dev |
21798 |
+ |
21799 |
+ # Fix weird bug where there is a /dev/.devfsd in a unmounted /dev |
21800 |
+ devfs_automounted="no" |
21801 |
+ if [ -e "/dev/.devfsd" ] |
21802 |
+ then |
21803 |
+ mymounts="$(awk '($3 == "devfs") { print "yes"; exit 0 }' /proc/mounts)" |
21804 |
+ if [ "${mymounts}" != "yes" ] |
21805 |
+ then |
21806 |
+ rm -f /dev/.devfsd |
21807 |
+ else |
21808 |
+ devfs_automounted="yes" |
21809 |
+ fi |
21810 |
+ fi |
21811 |
+ |
21812 |
+ # Try to figure out how the user wants /dev handled |
21813 |
+ # - check $RC_DEVICES from /etc/conf.d/rc |
21814 |
+ # - check boot parameters |
21815 |
+ # - make sure the required binaries exist |
21816 |
+ # - make sure the kernel has support |
21817 |
+ if [ "${RC_DEVICES}" = "static" ] |
21818 |
+ then |
21819 |
+ ebegin "Using existing device nodes in /dev" |
21820 |
+ eend 0 |
21821 |
+ else |
21822 |
+ fellback_to_devfs="no" |
21823 |
+ case "${RC_DEVICES}" in |
21824 |
+ devfs) devfs="yes" |
21825 |
+ udev="no" |
21826 |
+ ;; |
21827 |
+ udev) devfs="yes" |
21828 |
+ udev="yes" |
21829 |
+ fellback_to_devfs="yes" |
21830 |
+ ;; |
21831 |
+ auto|*) devfs="yes" |
21832 |
+ udev="yes" |
21833 |
+ ;; |
21834 |
+ esac |
21835 |
+ |
21836 |
+ # Check udev prerequisites and kernel params |
21837 |
+ if [ "${udev}" = "yes" ] && has_addon udev |
21838 |
+ then |
21839 |
+ if get_bootparam "noudev" || \ |
21840 |
+ [ ${devfs_automounted} = "yes" ] || \ |
21841 |
+ [ "$(get_KV)" -lt "$(KV_to_int '2.6.0')" ] |
21842 |
+ then |
21843 |
+ udev="no" |
21844 |
+ fi |
21845 |
+ fi |
21846 |
+ |
21847 |
+ # Check devfs prerequisites and kernel params |
21848 |
+ if [ "${devfs}" = "yes" ] && has_addon devfs |
21849 |
+ then |
21850 |
+ if get_bootparam "nodevfs" || [ "${udev}" = "yes" ] |
21851 |
+ then |
21852 |
+ devfs="no" |
21853 |
+ fi |
21854 |
+ fi |
21855 |
+ |
21856 |
+ # Actually start setting up /dev now |
21857 |
+ if [[ ${udev} == "yes" ]] ; then |
21858 |
+ start_addon udev |
21859 |
+ |
21860 |
+ # With devfs, /dev can be mounted by the kernel ... |
21861 |
+ elif [[ ${devfs} == "yes" ]] ; then |
21862 |
+ start_addon devfs |
21863 |
+ |
21864 |
+ # Did the user want udev in the config file but for |
21865 |
+ # some reason, udev support didnt work out ? |
21866 |
+ if [[ ${fellback_to_devfs} == "yes" ]] ; then |
21867 |
+ ewarn "You wanted udev but support for it was not available!" |
21868 |
+ ewarn "Please review your system after it's booted!" |
21869 |
+ fi |
21870 |
+ fi |
21871 |
+ |
21872 |
+ # OK, if we got here, things are probably not right :) |
21873 |
+ if [[ ${devfs} == "no" && ${udev} == "no" ]] ; then |
21874 |
+ clear |
21875 |
+ echo |
21876 |
+ einfo "The Gentoo Linux system initialization scripts have detected that" |
21877 |
+ einfo "your system does not support UDEV. Since Gentoo Linux has been" |
21878 |
+ einfo "designed with dynamic /dev in mind, it is highly suggested that you" |
21879 |
+ einfo "emerge sys-fs/udev and configure your system to use it." |
21880 |
+ einfo "Please read the Gentoo Handbook for more information!" |
21881 |
+ echo |
21882 |
+ einfo " http://www.gentoo.org/doc/en/handbook/" |
21883 |
+ echo |
21884 |
+ einfo "Thanks for using Gentoo! :)" |
21885 |
+ echo |
21886 |
+ read -t 15 -p "(hit Enter to continue or wait 15 seconds ...)" |
21887 |
+ fi |
21888 |
+ fi |
21889 |
+ |
21890 |
+ # From linux-2.5.68 we need to mount /dev/pts again ... |
21891 |
+ if [ "$(get_KV)" -ge "$(KV_to_int '2.5.68')" ] |
21892 |
+ then |
21893 |
+ have_devpts="$(awk '($2 == "devpts") { print "yes"; exit 0 }' /proc/filesystems)" |
21894 |
+ |
21895 |
+ if [ "${have_devpts}" = "yes" ] |
21896 |
+ then |
21897 |
+ # Only try to create /dev/pts if we have /dev mounted dynamically, |
21898 |
+ # else it might fail as / might be still mounted readonly. |
21899 |
+ if [ ! -d /dev/pts ] && \ |
21900 |
+ [ "${devfs}" = "yes" -o "${udev}" = "yes" ] |
21901 |
+ then |
21902 |
+ # Make sure we have /dev/pts |
21903 |
+ mkdir -p /dev/pts &>/dev/null || \ |
21904 |
+ ewarn "Could not create /dev/pts!" |
21905 |
+ fi |
21906 |
+ |
21907 |
+ if [[ -d /dev/pts ]] ; then |
21908 |
+ ebegin "Mounting devpts at /dev/pts" |
21909 |
+ if [[ ${RC_USE_FSTAB} = "yes" ]] ; then |
21910 |
+ mntcmd=$(get_mount_fstab /dev/pts) |
21911 |
+ else |
21912 |
+ unset mntcmd |
21913 |
+ fi |
21914 |
+ try mount -n ${mntcmd:--t devpts devpts /dev/pts -o gid=5,mode=0620,noexec,nosuid} |
21915 |
+ eend $? |
21916 |
+ fi |
21917 |
+ fi |
21918 |
+ fi |
21919 |
+ |
21920 |
+ # Start logging console output since we have all /dev stuff setup |
21921 |
+ bootlog start |
21922 |
+ |
21923 |
+ start_critical_service() { |
21924 |
+ local service="$1" |
21925 |
+ ( |
21926 |
+ local retval= |
21927 |
+ # Needed for some addons like dm-crypt that starts in critical services |
21928 |
+ local myservice="${service}" |
21929 |
+ |
21930 |
+ profiling name "/etc/init.d/${service} start" |
21931 |
+ splash "svc_start" "${service}" |
21932 |
+ |
21933 |
+ source "/etc/init.d/${service}" |
21934 |
+ retval=$? |
21935 |
+ if [[ ${retval} -ne 0 ]] ; then |
21936 |
+ eerror "Failed to source /etc/init.d/${service}" |
21937 |
+ return "${retval}" |
21938 |
+ fi |
21939 |
+ |
21940 |
+ local conf="$(add_suffix /etc/conf.d/${service})" |
21941 |
+ [[ -e ${conf} ]] && source "${conf}" |
21942 |
+ conf="$(add_suffix /etc/rc.conf)" |
21943 |
+ [[ -e ${conf} ]] && source "${conf}" |
21944 |
+ |
21945 |
+ start |
21946 |
+ ) |
21947 |
+ |
21948 |
+ if [[ $? == "0" ]] ; then |
21949 |
+ splash "svc_started" "${service}" "0" |
21950 |
+ return 0 |
21951 |
+ fi |
21952 |
+ |
21953 |
+ eerror "Failed to start /etc/init.d/${service}" |
21954 |
+ splash "critical" &>/dev/null & |
21955 |
+ echo |
21956 |
+ eerror "One or more critical startup scripts failed to start!" |
21957 |
+ eerror "Please correct this, and reboot ..." |
21958 |
+ echo; echo |
21959 |
+ /sbin/sulogin ${CONSOLE} |
21960 |
+ einfo "Unmounting filesystems" |
21961 |
+ /bin/mount -a -o remount,ro &>/dev/null |
21962 |
+ einfo "Rebooting" |
21963 |
+ /sbin/reboot -f |
21964 |
+ } |
21965 |
+ |
21966 |
+ # $BOOT can be used by rc-scripts to test if it is the first time |
21967 |
+ # the 'boot' runlevel is executed. Now also needed by some stuff in |
21968 |
+ # the 'sysinit' runlevel ... |
21969 |
+ export BOOT="yes" |
21970 |
+ |
21971 |
+ # We set the forced softlevel from the kernel command line |
21972 |
+ # It needs to be run right after proc is mounted for the |
21973 |
+ # boot runlevel |
21974 |
+ setup_defaultlevels |
21975 |
+ |
21976 |
+ # We first try to find a locally defined list of critical services |
21977 |
+ # for a particular runlevel. If we cannot find it, we use the |
21978 |
+ # defaults. |
21979 |
+ get_critical_services |
21980 |
+ |
21981 |
+ splash "rc_init" "${argv1}" |
21982 |
+ |
21983 |
+ # Start checkroot and modules before we load volumes |
21984 |
+ export START_CRITICAL="yes" |
21985 |
+ for x in checkroot modules ; do |
21986 |
+ [[ " ${CRITICAL_SERVICES} " != *" ${x} "* ]] && continue |
21987 |
+ start_critical_service "${x}" |
21988 |
+ done |
21989 |
+ |
21990 |
+ # Start RAID/LVM/EVMS/DM volumes for /usr, /var, etc. |
21991 |
+ for x in ${RC_VOLUME_ORDER} ; do |
21992 |
+ start_addon "${x}" |
21993 |
+ done |
21994 |
+ |
21995 |
+ # We do not want to break compatibility, so we do not fully integrate |
21996 |
+ # these into /sbin/rc, but rather start them by hand ... |
21997 |
+ for x in ${CRITICAL_SERVICES} ; do |
21998 |
+ [[ ${x} == "checkroot" || ${x} == "modules" ]] && continue |
21999 |
+ start_critical_service "${x}" |
22000 |
+ done |
22001 |
+ |
22002 |
+ unset START_CRITICAL |
22003 |
+ |
22004 |
+ # /var/log should be writable now, so starting saving the boot output |
22005 |
+ bootlog sync |
22006 |
+ |
22007 |
+ # Check that $svcdir exists ... |
22008 |
+ check_statedir "${svcdir}" |
22009 |
+ |
22010 |
+ # Should we use tmpfs/ramfs/ramdisk for caching dependency and |
22011 |
+ # general initscript data? Note that the 'gentoo=<fs>' kernel |
22012 |
+ # option should override any other setting ... |
22013 |
+ for fs in tmpfs ramfs ramdisk |
22014 |
+ do |
22015 |
+ if get_bootparam "${fs}" |
22016 |
+ then |
22017 |
+ svcmount="yes" |
22018 |
+ svcfstype="${fs}" |
22019 |
+ break |
22020 |
+ fi |
22021 |
+ done |
22022 |
+ if [ "${svcmount}" = "yes" ] |
22023 |
+ then |
22024 |
+ ebegin "Mounting ${svcfstype} at ${svcdir}" |
22025 |
+ case "${svcfstype}" in |
22026 |
+ ramfs) |
22027 |
+ try mount -t ramfs svcdir "${svcdir}" \ |
22028 |
+ -o rw,mode=0755,size="${svcsize}"k |
22029 |
+ ;; |
22030 |
+ ramdisk) |
22031 |
+ try dd if=/dev/zero of=/dev/ram0 bs=1k count="${svcsize}" |
22032 |
+ try /sbin/mke2fs -i 1024 -vm0 /dev/ram0 "${svcsize}" |
22033 |
+ try mount -t ext2 /dev/ram0 "${svcdir}" -o rw |
22034 |
+ ;; |
22035 |
+ tmpfs|*) |
22036 |
+ try mount -t tmpfs svcdir "${svcdir}" \ |
22037 |
+ -o rw,mode=0755,size="${svcsize}"k |
22038 |
+ ;; |
22039 |
+ esac |
22040 |
+ eend 0 |
22041 |
+ fi |
22042 |
+ |
22043 |
+ # If booting off CD, we want to update inittab before setting the runlevel |
22044 |
+ if [ -f "/sbin/livecd-functions.sh" -a -n "${CDBOOT}" ] |
22045 |
+ then |
22046 |
+ ebegin "Updating inittab" |
22047 |
+ livecd_fix_inittab |
22048 |
+ eend $? |
22049 |
+ /sbin/telinit q &>/dev/null |
22050 |
+ fi |
22051 |
+ |
22052 |
+ # Clear $svcdir from stale entries, but leave the caches around, as it |
22053 |
+ # should help speed things up a bit |
22054 |
+ rm -rf $(ls -d1 "${svcdir}/"* 2>/dev/null | \ |
22055 |
+ grep -ve '\(depcache\|deptree\|envcache\)') |
22056 |
+ |
22057 |
+ echo "sysinit" > "${svcdir}/softlevel" |
22058 |
+ |
22059 |
+ # Ensure all critical services have are in the boot runlevel |
22060 |
+ check_critical_services |
22061 |
+ |
22062 |
+ # Update the dependency cache |
22063 |
+ /sbin/depscan.sh |
22064 |
+ |
22065 |
+ # Now that the dependency cache are up to date, make sure these |
22066 |
+ # are marked as started ... |
22067 |
+ ( |
22068 |
+ profiling name "mark started" |
22069 |
+ |
22070 |
+ # Needed for mark_service_started() |
22071 |
+ source "${svclib}/sh/rc-services.sh" |
22072 |
+ |
22073 |
+ for x in ${CRITICAL_SERVICES} |
22074 |
+ do |
22075 |
+ mark_service_started "${x}" |
22076 |
+ done |
22077 |
+ ) |
22078 |
+ |
22079 |
+ # If the user's /dev/null or /dev/console are missing, we |
22080 |
+ # should help them out and explain how to rectify the situation |
22081 |
+ if [ ${dev_null} -eq 0 -o ${dev_console} -eq 0 ] \ |
22082 |
+ && [ -e /usr/share/baselayout/issue.devfix ] |
22083 |
+ then |
22084 |
+ # Backup current /etc/issue |
22085 |
+ if [ -e /etc/issue -a ! -e /etc/issue.devfix ] |
22086 |
+ then |
22087 |
+ mv /etc/issue /etc/issue.devfix |
22088 |
+ fi |
22089 |
+ |
22090 |
+ cp /usr/share/baselayout/issue.devfix /etc/issue |
22091 |
+ fi |
22092 |
+ |
22093 |
+ # Setup login records ... this has to be done here because when |
22094 |
+ # we exit this runlevel, init will write a boot record to utmp |
22095 |
+ # If /var/run is readonly, then print a warning, not errors |
22096 |
+ if touch /var/run/utmp 2>/dev/null |
22097 |
+ then |
22098 |
+ > /var/run/utmp |
22099 |
+ touch /var/log/wtmp |
22100 |
+ chgrp utmp /var/run/utmp /var/log/wtmp |
22101 |
+ chmod 0664 /var/run/utmp /var/log/wtmp |
22102 |
+ # Remove /var/run/utmpx (bug from the past) |
22103 |
+ rm -f /var/run/utmpx |
22104 |
+ else |
22105 |
+ ewarn "Skipping /var/run/utmp initialization (ro root?)" |
22106 |
+ fi |
22107 |
+ |
22108 |
+ # Check and save if the user wants interactive |
22109 |
+ user_want_interactive && svcinteractive="yes" |
22110 |
+ echo "${svcinteractive:-no}" > "${svcdir}/interactive" |
22111 |
+ |
22112 |
+ # sysinit is now done, so allow init scripts to run normally |
22113 |
+ [[ -e /dev/.rcsysinit ]] && rm -f /dev/.rcsysinit |
22114 |
+ |
22115 |
+ # All done logging |
22116 |
+ bootlog quit |
22117 |
+ |
22118 |
+ exit 0 |
22119 |
+fi # Sysinit ends here |
22120 |
+ |
22121 |
+if [[ ( ${RUNLEVEL} == "S" || ${RUNLEVEL} == "1" ) && ${argv1} == "boot" ]] |
22122 |
+then |
22123 |
+ setup_defaultlevels |
22124 |
+ |
22125 |
+ if [ -n "${DEFAULTLEVEL}" -a "${DEFAULTLEVEL}" != "default" ] |
22126 |
+ then |
22127 |
+ # Setup our default runlevel runlevel that will be run |
22128 |
+ # the first time /sbin/rc is called with argv1 != sysinit|boot |
22129 |
+ echo "${DEFAULTLEVEL}" > "${svcdir}/ksoftlevel" |
22130 |
+ fi |
22131 |
+ |
22132 |
+ # $BOOT can be used by rc-scripts to test if it is the first time |
22133 |
+ # the 'boot' runlevel is executed |
22134 |
+ export BOOT="yes" |
22135 |
+ |
22136 |
+ # We reset argv1 to the bootlevel given on the kernel command line |
22137 |
+ # if there is one |
22138 |
+ argv1="${BOOTLEVEL}" |
22139 |
+ |
22140 |
+elif [[ ${RUNLEVEL} != "S" && ${RUNLEVEL} != "1" && -e ${svcdir}/ksoftlevel ]] |
22141 |
+then |
22142 |
+ argv1="$(< ${svcdir}/ksoftlevel)" |
22143 |
+ rm -f "${svcdir}/ksoftlevel" |
22144 |
+elif [[ ${RUNLEVEL} != "S" && ${RUNLEVEL} != "1" && ${argv1} == "single" ]] |
22145 |
+then |
22146 |
+ /sbin/telinit S |
22147 |
+ exit 0 |
22148 |
+elif [[ ( ${RUNLEVEL} == "S" || ${RUNLEVEL} == "1" ) && ${argv1} != "single" ]] |
22149 |
+then |
22150 |
+ level=$(awk -v level="${argv1}" ' |
22151 |
+ $2 == level { |
22152 |
+ split($0, fields, ":") |
22153 |
+ print fields[2] |
22154 |
+ exit |
22155 |
+ }' /etc/inittab 2>/dev/null) |
22156 |
+ [[ -z ${level} ]] && level=3 |
22157 |
+ /sbin/telinit "${level}" |
22158 |
+ exit 0 |
22159 |
+fi |
22160 |
+ |
22161 |
+# Ensure that critical services are in the boot runlevel |
22162 |
+get_critical_services |
22163 |
+check_critical_services |
22164 |
+ |
22165 |
+source "${svclib}/sh/rc-services.sh" |
22166 |
+[[ -e "${svcdir}/interactive" ]] \ |
22167 |
+ && svcinteractive="$(<${svcdir}/interactive)" |
22168 |
+ |
22169 |
+if [ -f "${svcdir}/softlevel" ] |
22170 |
+then |
22171 |
+ # Set OLDSOFTLEVEL if we had a valid SOFTLEVEL |
22172 |
+ export OLDSOFTLEVEL="$(< ${svcdir}/softlevel)" |
22173 |
+else |
22174 |
+ export OLDSOFTLEVEL= |
22175 |
+fi |
22176 |
+ |
22177 |
+if [ -z "${argv1}" ] |
22178 |
+then |
22179 |
+ if [ -f "${svcdir}/softlevel" ] |
22180 |
+ then |
22181 |
+ export SOFTLEVEL="$(< ${svcdir}/softlevel)" |
22182 |
+ else |
22183 |
+ export SOFTLEVEL="${BOOTLEVEL}" |
22184 |
+ fi |
22185 |
+else |
22186 |
+ export SOFTLEVEL="${argv1}" |
22187 |
+fi |
22188 |
+ |
22189 |
+if [ ! -f "${svcdir}/softlevel" ] |
22190 |
+then |
22191 |
+ echo "${SOFTLEVEL}" > "${svcdir}/softlevel" |
22192 |
+fi |
22193 |
+ |
22194 |
+# For keeping a list of services that fails during boot/halt |
22195 |
+if [ ! -d "${svcdir}/failed" ] |
22196 |
+then |
22197 |
+ mkdir -p -m 0755 "${svcdir}/failed" |
22198 |
+else |
22199 |
+ rm -rf "${svcdir}"/failed/* |
22200 |
+fi |
22201 |
+ |
22202 |
+splash "rc_init" "${argv1}" |
22203 |
+ |
22204 |
+ |
22205 |
+if [ "${SOFTLEVEL}" = "reboot" -o "${SOFTLEVEL}" = "shutdown" ] |
22206 |
+then |
22207 |
+ myscripts= |
22208 |
+ |
22209 |
+elif [ "${SOFTLEVEL}" = "single" ] |
22210 |
+then |
22211 |
+ |
22212 |
+ myscripts="${CRITICAL_SERVICES}" |
22213 |
+ |
22214 |
+elif [ ! -d "/etc/runlevels/${SOFTLEVEL}" ] |
22215 |
+then |
22216 |
+ eerror "ERROR: runlevel ${SOFTLEVEL} does not exist; exiting ..." |
22217 |
+ exit 1 |
22218 |
+else |
22219 |
+ myscripts= |
22220 |
+ if [ "${SOFTLEVEL}" != "${BOOTLEVEL}" ] |
22221 |
+ then |
22222 |
+ # Normal runlevels *include* boot scripts |
22223 |
+ mylevels="$(dolisting "/etc/runlevels/${SOFTLEVEL}/")" |
22224 |
+ mylevels="${mylevels} $(dolisting /etc/runlevels/${BOOTLEVEL}/)" |
22225 |
+ else |
22226 |
+ # Non-normal runlevels don't include boot scripts as default |
22227 |
+ mylevels="$(dolisting "/etc/runlevels/${SOFTLEVEL}/")" |
22228 |
+ |
22229 |
+ # As we're in the bootlevel, add any services that failed due |
22230 |
+ # to /dev/.rcsysinit existing to the list |
22231 |
+ if [[ -d /dev/.rcboot ]] ; then |
22232 |
+ COLDPLUG_SERVICES= |
22233 |
+ for x in $(dolisting /dev/.rcboot/) ; do |
22234 |
+ [[ -L ${x} ]] && COLDPLUG_SERVICES="${COLDPLUG_SERVICES} ${x##*/}" |
22235 |
+ done |
22236 |
+ for x in ${COLDPLUG_SERVICES} ; do |
22237 |
+ if [[ ! -e /etc/runlevels/"${BOOTLEVEL}"/"${x}" \ |
22238 |
+ && ! -e /etc/runlevels/"${DEFAULTLEVEL}"/"${x}" ]] ; then |
22239 |
+ myscripts="${myscripts} ${x}" |
22240 |
+ mark_service_coldplugged "${x}" |
22241 |
+ fi |
22242 |
+ done |
22243 |
+ if [[ -n ${myscripts} ]] ; then |
22244 |
+ einfo "Device initiated services:${HILITE}${myscripts}${NORMAL}" |
22245 |
+ fi |
22246 |
+ rm -rf /dev/.rcboot |
22247 |
+ fi |
22248 |
+ fi |
22249 |
+ |
22250 |
+ for x in ${mylevels} |
22251 |
+ do |
22252 |
+ [ -L "${x}" ] && myscripts="${myscripts} ${x##*/}" |
22253 |
+ done |
22254 |
+fi |
22255 |
+ |
22256 |
+# The softscripts dir contains all scripts that belong to the |
22257 |
+# runlevel specified in ${svcdir}/softlevel |
22258 |
+# It needs to be a new directory, else when stopping the services |
22259 |
+# and the old directory is not intact, things get broken |
22260 |
+ |
22261 |
+mkdir -p -m 0755 "${svcdir}/softscripts.new" |
22262 |
+ |
22263 |
+for x in ${myscripts} ; do |
22264 |
+ if [[ ! -e /etc/init.d/${x} ]] ; then |
22265 |
+ ewarn "WARNING: /etc/init.d/${x} missing; skipping ..." |
22266 |
+ continue |
22267 |
+ fi |
22268 |
+ # The -f eliminates a warning if the symlink already exists, |
22269 |
+ # which can happen if a service is in both the boot level and |
22270 |
+ # the current "normal" runlevel |
22271 |
+ ln -snf "/etc/init.d/${x}" "${svcdir}/softscripts.new/${x}" |
22272 |
+done |
22273 |
+ |
22274 |
+get_stop_services() { |
22275 |
+ local x list |
22276 |
+ |
22277 |
+ for x in $(dolisting "${svcdir}/inactive/") \ |
22278 |
+ $(dolisting "${svcdir}/started/") ; do |
22279 |
+ list="${list} ${x##*/}" |
22280 |
+ done |
22281 |
+ |
22282 |
+ reverse_list $(trace_dependencies ${list}) |
22283 |
+} |
22284 |
+ |
22285 |
+dep_stop() { |
22286 |
+ local dep needsme service="${1##*/}" |
22287 |
+ |
22288 |
+ service_stopped "${service}" && return 0 |
22289 |
+ |
22290 |
+ # Candidate for zapping ? |
22291 |
+ [[ -L "${svcdir}/softscripts.new/${service}" ]] \ |
22292 |
+ && return 0 |
22293 |
+ |
22294 |
+ if [[ ${SOFTLEVEL} != "reboot" \ |
22295 |
+ && ${SOFTLEVEL} != "shutdown" \ |
22296 |
+ && ${SOFTLEVEL} != "single" ]] ; then |
22297 |
+ service_coldplugged "${service}" && return 0 |
22298 |
+ if net_service "${service}" ; then |
22299 |
+ [[ -z ${OLDSOFTLEVEL} ]] \ |
22300 |
+ || ! in_runlevel "${service}" "${OLDSOFTLEVEL}" \ |
22301 |
+ && return 0 |
22302 |
+ fi |
22303 |
+ fi |
22304 |
+ |
22305 |
+ # Something may depend on me |
22306 |
+ needsme=0 |
22307 |
+ for dep in $(needsme "${service}") ; do |
22308 |
+ if [[ -L "${svcdir}/softscripts.new/${dep}" ]] \ |
22309 |
+ || service_coldplugged "${dep}" ; then |
22310 |
+ # This dep is valid |
22311 |
+ needsme=1 |
22312 |
+ break |
22313 |
+ fi |
22314 |
+ done |
22315 |
+ [[ ${needsme} -eq 0 ]] && stop_service "${service}" |
22316 |
+} |
22317 |
+ |
22318 |
+# Stop services |
22319 |
+if [[ ${SOFTLEVEL} != "single" && \ |
22320 |
+ ${SOFTLEVEL} != "reboot" && \ |
22321 |
+ ${SOFTLEVEL} != "shutdown" ]] |
22322 |
+then |
22323 |
+ for i in $(get_stop_services) ; do |
22324 |
+ dep_stop "${i}" |
22325 |
+ done |
22326 |
+ |
22327 |
+ # Wait for any services that may still be stopping ... |
22328 |
+ [ "${RC_PARALLEL_STARTUP}" = "yes" ] && wait |
22329 |
+else |
22330 |
+ get_critical_services |
22331 |
+ |
22332 |
+ is_critical_service() { |
22333 |
+ local x |
22334 |
+ local service=${1##*/} |
22335 |
+ |
22336 |
+ for x in ${CRITICAL_SERVICES} ${LOGGER_SERVICE} ; do |
22337 |
+ [[ ${service} == "${x}" ]] && return 0 |
22338 |
+ done |
22339 |
+ |
22340 |
+ return 1 |
22341 |
+ } |
22342 |
+ |
22343 |
+ # First stop non critical services |
22344 |
+ for i in $(get_stop_services) ; do |
22345 |
+ is_critical_service "${i}" || dep_stop "${i}" |
22346 |
+ done |
22347 |
+ |
22348 |
+ # Wait for any services that may still be stopping ... |
22349 |
+ [ "${RC_PARALLEL_STARTUP}" = "yes" ] && wait |
22350 |
+ |
22351 |
+ export STOP_CRITICAL="yes" |
22352 |
+ # Now stop the rest |
22353 |
+ for i in $(get_stop_services) ; do |
22354 |
+ dep_stop "${i}" |
22355 |
+ done |
22356 |
+ unset STOP_CRITICAL |
22357 |
+fi |
22358 |
+ |
22359 |
+# Only change softlevel AFTER all the services have been stopped, |
22360 |
+# else they will not get the depend's right (wrong SOFTLEVEL) |
22361 |
+ |
22362 |
+echo "${SOFTLEVEL}" > "${svcdir}/softlevel" |
22363 |
+ |
22364 |
+if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then |
22365 |
+ # Clear $svcdir from stale entries, but leave the caches around, as it |
22366 |
+ # should help speed things up a bit |
22367 |
+ rm -rf $(ls -d1 "${svcdir}/"* 2>/dev/null | \ |
22368 |
+ grep -ve '\(depcache\|deptree\|envcache\)') |
22369 |
+ |
22370 |
+ # Call halt.sh with LC_ALL=C so that bash doesn't load any locales |
22371 |
+ # which could interfere with unmounting /usr |
22372 |
+ LC_ALL=C exec /etc/init.d/halt.sh "${SOFTLEVEL}" |
22373 |
+ |
22374 |
+ # Should never get here |
22375 |
+ exit 0 |
22376 |
+fi |
22377 |
+ |
22378 |
+if [[ ${SOFTLEVEL} == "single" ]] ; then |
22379 |
+ rm -rf "${svcdir}/softscripts.new" |
22380 |
+ /sbin/sulogin ${CONSOLE} |
22381 |
+ exit 0 |
22382 |
+fi |
22383 |
+ |
22384 |
+# Move the old softscritps directory to a different one |
22385 |
+# and make the new softscripts directory the current |
22386 |
+ |
22387 |
+mv -f "${svcdir}/softscripts" "${svcdir}/softscripts.old" |
22388 |
+mv -f "${svcdir}/softscripts.new" "${svcdir}/softscripts" |
22389 |
+ |
22390 |
+get_start_services() { |
22391 |
+ local x list |
22392 |
+ |
22393 |
+ get_critical_services |
22394 |
+ list=${CRITICAL_SERVICES} |
22395 |
+ |
22396 |
+ [[ -n ${LOGGER_SERVICE} && \ |
22397 |
+ -L ${svcdir}/softscripts/${LOGGER_SERVICE} ]] && \ |
22398 |
+ list="${list} ${LOGGER_SERVICE}" |
22399 |
+ |
22400 |
+ for x in $(dolisting "${svcdir}/softscripts/") ; do |
22401 |
+ list="${list} ${x##*/}" |
22402 |
+ done |
22403 |
+ |
22404 |
+ trace_dependencies ${list} |
22405 |
+} |
22406 |
+ |
22407 |
+# Start scripts |
22408 |
+for i in $(get_start_services) ; do |
22409 |
+ if service_stopped "${i}" ; then |
22410 |
+ do_interactive start_service "${i}" |
22411 |
+ fi |
22412 |
+done |
22413 |
+ |
22414 |
+# Wait for any services that may still be running ... |
22415 |
+[[ ${RC_PARALLEL_STARTUP} == "yes" ]] && wait |
22416 |
+ |
22417 |
+# Clean the old runlevel |
22418 |
+rm -rf "${svcdir}/softscripts.old" &>/dev/null |
22419 |
+ |
22420 |
+# Depends gets nuked, so update them |
22421 |
+# (this problem should be solved now, but i think it will be a good idea |
22422 |
+# to recreate the deps after a change in runlevel) |
22423 |
+ |
22424 |
+#/sbin/depscan.sh &>/dev/null |
22425 |
+ |
22426 |
+# We want devfsd running after a change of runlevel (this is mostly if we return |
22427 |
+# from runlevel 'single') |
22428 |
+if [ -z "`ps --no-heading -C 'devfsd'`" -a \ |
22429 |
+ -n "`gawk '/\/dev devfs/ { print }' /proc/mounts 2>/dev/null`" ] |
22430 |
+then |
22431 |
+ if [ "${RC_DEVFSD_STARTUP}" != "no" ] |
22432 |
+ then |
22433 |
+ /sbin/devfsd /dev &>/dev/null |
22434 |
+ fi |
22435 |
+fi |
22436 |
+ |
22437 |
+# Runlevel end, so clear stale fail list |
22438 |
+rm -rf "${svcdir}/failed" &>/dev/null |
22439 |
+ |
22440 |
+# If we were in the boot runlevel, it is done now ... |
22441 |
+if [[ -n ${BOOT} ]]; then |
22442 |
+ unset BOOT |
22443 |
+ # Save our interactive mode into the default runlevel |
22444 |
+ user_want_interactive && svcinteractive="yes" |
22445 |
+ echo "${svcinteractive}" > "${svcdir}/interactive" |
22446 |
+else |
22447 |
+ # As we're not boot, we remove the interactive file |
22448 |
+ [[ -e "${svcdir}/interactive" ]] && rm -f "${svcdir}/interactive" |
22449 |
+fi |
22450 |
+ |
22451 |
+# Remove the cached CONSOLETYPE |
22452 |
+unset CONSOLETYPE |
22453 |
+ |
22454 |
+splash "rc_exit" |
22455 |
+ |
22456 |
+# vim:ts=4 |
22457 |
|
22458 |
|
22459 |
Property changes on: trunk/baselayout-prefix/sbin/rc |
22460 |
___________________________________________________________________ |
22461 |
Added: svn:executable |
22462 |
+ * |
22463 |
|
22464 |
Added: trunk/baselayout-prefix/sbin/rc-daemon.sh |
22465 |
=================================================================== |
22466 |
--- trunk/baselayout-prefix/sbin/rc-daemon.sh (rev 0) |
22467 |
+++ trunk/baselayout-prefix/sbin/rc-daemon.sh 2011-03-31 14:11:17 UTC (rev 1682) |
22468 |
@@ -0,0 +1,427 @@ |
22469 |
+# Copyright 1999-2006 Gentoo Foundation |
22470 |
+# Distributed under the terms of the GNU General Public License v2 |
22471 |
+ |
22472 |
+# RC functions to work with daemons |
22473 |
+# Basically we're a fancy wrapper for start-stop-daemon |
22474 |
+# and should be called as such. This means that our init scripts |
22475 |
+# should work as is with zero modification :) |
22476 |
+ |
22477 |
+# Actually, the above is a small as lie we have some init scripts which try to |
22478 |
+# get start-stop-daemon to launch a shell script. While this does work with |
22479 |
+# the start-stop-daemon program in /sbin, it does cause a problem for us |
22480 |
+# when we're testing for the daemon to be running. I (Roy Marples) view this |
22481 |
+# as behaviour by design as start-stop-daemon should not be used to run shell |
22482 |
+# scripts! |
22483 |
+ |
22484 |
+RC_GOT_DAEMON="yes" |
22485 |
+ |
22486 |
+[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh |
22487 |
+[[ ${RC_GOT_SERVICES} != "yes" ]] && source "${svclib}/sh/rc-services.sh" |
22488 |
+ |
22489 |
+RC_RETRY_KILL="no" |
22490 |
+RC_RETRY_TIMEOUT=1 |
22491 |
+RC_RETRY_COUNT=5 |
22492 |
+RC_FAIL_ON_ZOMBIE="no" |
22493 |
+RC_KILL_CHILDREN="no" |
22494 |
+RC_WAIT_ON_START="0.1" |
22495 |
+ |
22496 |
+# void rc_shift_args(void) |
22497 |
+# |
22498 |
+# Proccess vars - makes things easier by using the shift command |
22499 |
+# and indirect variables |
22500 |
+rc_shift_args() { |
22501 |
+ local addvar |
22502 |
+ |
22503 |
+ while [[ $# != "0" ]]; do |
22504 |
+ if [[ $1 != "-"* && -n ${addvar} ]]; then |
22505 |
+ if [[ -z ${!addvar} ]]; then |
22506 |
+ eval "${addvar}=\"$1\"" |
22507 |
+ else |
22508 |
+ eval "${addvar}=\"${!addvar} $1\"" |
22509 |
+ fi |
22510 |
+ shift |
22511 |
+ continue |
22512 |
+ fi |
22513 |
+ unset addvar |
22514 |
+ case "$1" in |
22515 |
+ -S|--start) |
22516 |
+ stopping=false |
22517 |
+ ;; |
22518 |
+ -K|--stop) |
22519 |
+ stopping=true |
22520 |
+ ;; |
22521 |
+ -n|--name) |
22522 |
+ addvar="name" |
22523 |
+ ;; |
22524 |
+ -x|--exec|-a|--startas) |
22525 |
+ addvar="cmd" |
22526 |
+ ;; |
22527 |
+ -p|--pidfile) |
22528 |
+ addvar="pidfile" |
22529 |
+ ;; |
22530 |
+ --pidfile=*) |
22531 |
+ pidfile="${1##--pidfile=}" |
22532 |
+ ;; |
22533 |
+ --pid=*) |
22534 |
+ pidfile="${1##--pid=}" |
22535 |
+ ;; |
22536 |
+ -R|--retry) |
22537 |
+ unset RC_RETRY_COUNT |
22538 |
+ addvar="RC_RETRY_COUNT" |
22539 |
+ ;; |
22540 |
+ -s|--signal) |
22541 |
+ addvar="signal" |
22542 |
+ ;; |
22543 |
+ -t|--test|-o|--oknodo) |
22544 |
+ nothing=true |
22545 |
+ ;; |
22546 |
+ esac |
22547 |
+ shift |
22548 |
+ done |
22549 |
+ |
22550 |
+ [[ -z ${RC_RETRY_COUNT} ]] && RC_RETRY_COUNT=5 |
22551 |
+} |
22552 |
+ |
22553 |
+# void rc_setup_daemon_vars(void) |
22554 |
+# |
22555 |
+# Setup our vars based on the start-stop-daemon command |
22556 |
+rc_setup_daemon_vars() { |
22557 |
+ local -a sargs=( "${args%% \'--\' *}" ) eargs=() |
22558 |
+ local x="${args// \'--\' /}" i= |
22559 |
+ [[ ${x} != "${args}" ]] && eargs=( "${args##* \'--\' }" ) |
22560 |
+ |
22561 |
+ eval rc_shift_args "${sargs[@]}" |
22562 |
+ |
22563 |
+ [[ -n ${name} ]] && cmd="${name}" |
22564 |
+ |
22565 |
+ # We may want to launch the daemon with a custom command |
22566 |
+ # This is mainly useful for debugging with apps like valgrind, strace |
22567 |
+ local bash_service="$( bash_variable "${SVCNAME}" )" |
22568 |
+ if [[ -n ${RC_DAEMON} ]]; then |
22569 |
+ local -a d=( ${RC_DAEMON} ) |
22570 |
+ if ${stopping}; then |
22571 |
+ args="--stop" |
22572 |
+ else |
22573 |
+ args="--start" |
22574 |
+ fi |
22575 |
+ |
22576 |
+ # Add -- or - arguments as s-s-d options |
22577 |
+ j=${#d[@]} |
22578 |
+ for (( i=0; i<j; i++ )); do |
22579 |
+ [[ ${d[i]:0:1} != "-" ]] && break |
22580 |
+ args="${args} ${d[i]}" |
22581 |
+ unset d[i] |
22582 |
+ done |
22583 |
+ d=( "${d[@]}" ) |
22584 |
+ |
22585 |
+ eval args=\"${args} --exec '${d[0]}' -- ${d[@]:1} '${cmd}' ${eargs[@]}\" |
22586 |
+ ! ${stopping} && cmd="${d[0]}" |
22587 |
+ fi |
22588 |
+ |
22589 |
+ return 0 |
22590 |
+} |
22591 |
+ |
22592 |
+# bool rc_try_kill_pid(int pid, char* signal, bool session) |
22593 |
+# |
22594 |
+# Repeatedly kill the pid with the given signal until it dies |
22595 |
+# If session is true then we use tread pid as session and send it |
22596 |
+# via pkill |
22597 |
+# Returns 0 if successfuly otherwise 1 |
22598 |
+rc_try_kill_pid() { |
22599 |
+ local pid="$1" signal="${2:-TERM}" session="${3:-false}" i s p e |
22600 |
+ |
22601 |
+ # We split RC_RETRY_TIMEOUT into tenths of seconds |
22602 |
+ # So we return as fast as possible |
22603 |
+ s=$(( ${RC_RETRY_TIMEOUT}/10 )).$(( ${RC_RETRY_TIMEOUT}%10 )) |
22604 |
+ |
22605 |
+ for (( i=0; i<RC_RETRY_COUNT*10; i++ )); do |
22606 |
+ if ${session} ; then |
22607 |
+ if [[ -x /usr/bin/pkill ]]; then |
22608 |
+ pkill "-${signal}" -s "${pid}" |
22609 |
+ pgrep -s "${pid}" >/dev/null || return 0 |
22610 |
+ else |
22611 |
+ local pids="$(ps eo pid,sid | sed -n "s/ ${pid}\$//p")" |
22612 |
+ [[ -z ${pids} ]] && return 0 |
22613 |
+ kill -s "${signal}" ${pids} 2>/dev/null |
22614 |
+ e=false |
22615 |
+ for p in ${pids}; do |
22616 |
+ if [[ -d "/proc/${p}" ]]; then |
22617 |
+ e=true |
22618 |
+ break |
22619 |
+ fi |
22620 |
+ done |
22621 |
+ ${e} || return 0 |
22622 |
+ fi |
22623 |
+ else |
22624 |
+ [[ ${i} == "0" ]] && kill -s "${signal}" "${pid}" 2>/dev/null |
22625 |
+ [[ ! -d "/proc/${pid}" ]] && return 0 |
22626 |
+ fi |
22627 |
+ LC_ALL=C /bin/sleep "${s}" |
22628 |
+ done |
22629 |
+ |
22630 |
+ return 1 |
22631 |
+} |
22632 |
+ |
22633 |
+# bool rc_kill_pid(int pid, bool session) |
22634 |
+# |
22635 |
+# Kills the given pid/session |
22636 |
+# Returns 1 if we fail to kill the pid (if it's valid) otherwise 0 |
22637 |
+rc_kill_pid() { |
22638 |
+ local pid="$1" session="${2:-false}" |
22639 |
+ |
22640 |
+ rc_try_kill_pid "${pid}" "${signal}" "${session}" && return 0 |
22641 |
+ |
22642 |
+ [[ ${RC_RETRY_KILL} == "yes" ]] \ |
22643 |
+ && rc_try_kill_pid "${pid}" KILL "${session}" && return 0 |
22644 |
+ |
22645 |
+ return 1 |
22646 |
+} |
22647 |
+ |
22648 |
+# char* pidof(char* cmd, ...) |
22649 |
+# |
22650 |
+# Returns a space seperated list of pids associated with the command |
22651 |
+# This is to handle the rpc.nfsd program which acts weird |
22652 |
+pidof() { |
22653 |
+ local arg args |
22654 |
+ |
22655 |
+ for arg in "$@"; do |
22656 |
+ [[ ${arg##*/} == "rpc.nfsd" ]] && arg="${arg%/*}/nfsd" |
22657 |
+ args="${args} '"${arg}"'" |
22658 |
+ done |
22659 |
+ |
22660 |
+ eval /bin/pidof -x ${args} |
22661 |
+} |
22662 |
+ |
22663 |
+# bool is_daemon_running(char* cmd, char* pidfile) |
22664 |
+# |
22665 |
+# Returns 0 if the given daemon is running, otherwise 1 |
22666 |
+# If a pidfile is supplied, the pid inside it must match |
22667 |
+# a pid in the list of pidof ${cmd} |
22668 |
+is_daemon_running() { |
22669 |
+ local cmd pidfile pids pid |
22670 |
+ |
22671 |
+ if [[ $# == "1" ]]; then |
22672 |
+ cmd="$1" |
22673 |
+ else |
22674 |
+ local i j="$#" |
22675 |
+ for (( i=0; i<j-1; i++ )); do |
22676 |
+ cmd="${cmd} $1" |
22677 |
+ shift |
22678 |
+ done |
22679 |
+ pidfile="$1" |
22680 |
+ fi |
22681 |
+ |
22682 |
+ pids="$( pidof ${cmd} )" |
22683 |
+ [[ -z ${pids} ]] && return 1 |
22684 |
+ |
22685 |
+ [[ -s ${pidfile} ]] || return 0 |
22686 |
+ |
22687 |
+ read pid < "${pidfile}" |
22688 |
+ pids=" ${pids} " |
22689 |
+ [[ ${pids// ${pid} /} != "${pids}" ]] |
22690 |
+} |
22691 |
+ |
22692 |
+# int rc_start_daemon(void) |
22693 |
+# |
22694 |
+# We don't do anyting fancy - just pass the given options |
22695 |
+# to start-stop-daemon and return the value |
22696 |
+rc_start_daemon() { |
22697 |
+ eval /sbin/start-stop-daemon "${args}" |
22698 |
+ local retval="$?" |
22699 |
+ |
22700 |
+ [[ ${retval} != "0" ]] && return "${retval}" |
22701 |
+ [[ ${RC_WAIT_ON_START} == "0" ]] && return "${retval}" |
22702 |
+ |
22703 |
+ # Give the daemon upto 1 second to fork after s-s-d returns |
22704 |
+ # Some daemons like acpid and vsftpd need this when system is under load |
22705 |
+ # Seems to be only daemons that do not create pid files though ... |
22706 |
+ local i=0 |
22707 |
+ for ((i=0; i<10; i++)); do |
22708 |
+ is_daemon_running ${cmd} "${pidfile}" && break |
22709 |
+ LC_ALL=C /bin/sleep "0.1" |
22710 |
+ done |
22711 |
+ |
22712 |
+ # We pause for RC_WAIT_ON_START seconds and then |
22713 |
+ # check if the daemon is still running - this is mainly |
22714 |
+ # to handle daemons who launch and then fail due to invalid |
22715 |
+ # configuration files |
22716 |
+ LC_ALL=C /bin/sleep "${RC_WAIT_ON_START}" |
22717 |
+ is_daemon_running ${cmd} "${pidfile}" |
22718 |
+ retval="$?" |
22719 |
+ [[ ${retval} == "0" ]] && return 0 |
22720 |
+ |
22721 |
+ # Stop if we can to clean things up |
22722 |
+ [[ -n ${pidfile} ]] && rc_stop_daemon |
22723 |
+ |
22724 |
+ return "${retval}" |
22725 |
+} |
22726 |
+ |
22727 |
+# bool rc_stop_daemon(void) |
22728 |
+# |
22729 |
+# Instead of calling start-stop-daemon we instead try and |
22730 |
+# kill the process ourselves and any children left over |
22731 |
+# Returns 0 if everything was successful otherwise 1 |
22732 |
+rc_stop_daemon() { |
22733 |
+ local pid pids retval="0" |
22734 |
+ |
22735 |
+ if [[ -n ${cmd} ]]; then |
22736 |
+ if ! is_daemon_running ${cmd} "${pidfile}" ; then |
22737 |
+ [[ ${RC_FAIL_ON_ZOMBIE} == "yes" ]] && return 1 |
22738 |
+ fi |
22739 |
+ pids="$( pidof ${cmd} )" |
22740 |
+ fi |
22741 |
+ |
22742 |
+ if [[ -s ${pidfile} ]]; then |
22743 |
+ read pid < "${pidfile}" |
22744 |
+ # Check that the given program is actually running the pid |
22745 |
+ if [[ -n ${pids} ]]; then |
22746 |
+ pids=" ${pids} " |
22747 |
+ [[ ${pids// ${pid} /} == "${pids}" ]] && return 1 |
22748 |
+ fi |
22749 |
+ pids="${pid}" |
22750 |
+ fi |
22751 |
+ |
22752 |
+ # If there's nothing to kill then return without error |
22753 |
+ [[ -z ${pids} ]] && return 0 |
22754 |
+ |
22755 |
+ # We may not have pgrep to find our children, so we provide |
22756 |
+ # two methods |
22757 |
+ if [[ ${RC_KILL_CHILDREN} == "yes" ]]; then |
22758 |
+ if [[ -x /usr/bin/pgrep ]]; then |
22759 |
+ pids="${pids} $(pgrep -P "${pids// /,}")" |
22760 |
+ else |
22761 |
+ local npids |
22762 |
+ for pid in ${pids} ; do |
22763 |
+ npids="${npids} $(ps eo pid,ppid | sed -n "s/ ${pid}\$//p")" |
22764 |
+ done |
22765 |
+ pids="${pids} ${npids}" |
22766 |
+ fi |
22767 |
+ fi |
22768 |
+ |
22769 |
+ for pid in ${pids}; do |
22770 |
+ if [[ ${RC_FAIL_ON_ZOMBIE} == "yes" ]]; then |
22771 |
+ ps p "${pid}" &>/dev/null || return 1 |
22772 |
+ fi |
22773 |
+ |
22774 |
+ if rc_kill_pid "${pid}" false ; then |
22775 |
+ # Remove the pidfile if the process didn't |
22776 |
+ [[ -f ${pidfile} ]] && rm -f "${pidfile}" |
22777 |
+ else |
22778 |
+ retval=1 |
22779 |
+ fi |
22780 |
+ |
22781 |
+ if [[ ${RC_KILL_CHILDREN} == "yes" ]]; then |
22782 |
+ rc_kill_pid "${pid}" true || retval=1 |
22783 |
+ fi |
22784 |
+ done |
22785 |
+ |
22786 |
+ return "${retval}" |
22787 |
+} |
22788 |
+ |
22789 |
+# void update_service_status(char *service) |
22790 |
+# |
22791 |
+# Loads the service state file and ensures that all listed daemons are still |
22792 |
+# running - hopefully on their correct pids too |
22793 |
+# If not, we stop the service |
22794 |
+update_service_status() { |
22795 |
+ local service="$1" daemonfile="${svcdir}/daemons/$1" i |
22796 |
+ local -a RC_DAEMONS=() RC_PIDFILES=() |
22797 |
+ |
22798 |
+ # We only care about marking started services as stopped if the daemon(s) |
22799 |
+ # for it are no longer running |
22800 |
+ ! service_started "${service}" && return |
22801 |
+ [[ ! -f ${daemonfile} ]] && return |
22802 |
+ |
22803 |
+ # OK, now check that every daemon launched is active |
22804 |
+ # If the --start command was any good a pidfile was specified too |
22805 |
+ source "${daemonfile}" |
22806 |
+ for (( i=0; i<${#RC_DAEMONS[@]}; i++ )); do |
22807 |
+ if ! is_daemon_running ${RC_DAEMONS[i]} "${RC_PIDFILES[i]}" ; then |
22808 |
+ if [[ -e "/etc/init.d/${service}" ]]; then |
22809 |
+ ( /etc/init.d/"${service}" stop &>/dev/null ) |
22810 |
+ break |
22811 |
+ fi |
22812 |
+ fi |
22813 |
+ done |
22814 |
+} |
22815 |
+ |
22816 |
+# int start-stop-daemon(...) |
22817 |
+# |
22818 |
+# Provide a wrapper to start-stop-daemon |
22819 |
+# Return the result of start_daemon or stop_daemon depending on |
22820 |
+# how we are called |
22821 |
+start-stop-daemon() { |
22822 |
+ local args="$( requote "$@" )" result i |
22823 |
+ local cmd name pidfile pid stopping signal nothing=false |
22824 |
+ local daemonfile= |
22825 |
+ local -a RC_DAEMONS=() RC_PIDFILES=() |
22826 |
+ |
22827 |
+ if [[ -n ${SVCNAME} ]] ; then |
22828 |
+ daemonfile="${svcdir}/daemons/${SVCNAME}" |
22829 |
+ [[ -e ${daemonfile} ]] && source "${daemonfile}" |
22830 |
+ fi |
22831 |
+ |
22832 |
+ rc_setup_daemon_vars |
22833 |
+ |
22834 |
+ # We pass --oknodo and --test directly to start-stop-daemon and return |
22835 |
+ if ${nothing}; then |
22836 |
+ eval /sbin/start-stop-daemon "${args}" |
22837 |
+ return "$?" |
22838 |
+ fi |
22839 |
+ |
22840 |
+ if ${stopping}; then |
22841 |
+ rc_stop_daemon |
22842 |
+ result="$?" |
22843 |
+ if [[ ${result} == "0" && -n ${daemonfile} ]]; then |
22844 |
+ # We stopped the daemon successfully |
22845 |
+ # so we remove it from our state |
22846 |
+ for (( i=0; i<${#RC_DAEMONS[@]}; i++ )); do |
22847 |
+ # We should really check for valid cmd AND pidfile |
22848 |
+ # But most called to --stop only set the pidfile |
22849 |
+ if [[ ${RC_DAEMONS[i]} == "{cmd}" \ |
22850 |
+ || ${RC_PIDFILES[i]} == "${pidfile}" ]]; then |
22851 |
+ unset RC_DAEMONS[i] RC_PIDFILES[i] |
22852 |
+ RC_DAEMONS=( "${RC_DAEMONS[@]}" ) |
22853 |
+ RC_PIDFILES=( "${RC_PIDFILES[@]}" ) |
22854 |
+ break |
22855 |
+ fi |
22856 |
+ done |
22857 |
+ fi |
22858 |
+ else |
22859 |
+ rc_start_daemon |
22860 |
+ result="$?" |
22861 |
+ if [[ ${result} == "0" && -n ${daemonfile} ]]; then |
22862 |
+ # We started the daemon sucessfully |
22863 |
+ # so we add it to our state |
22864 |
+ local max="${#RC_DAEMONS[@]}" |
22865 |
+ for (( i=0; i<${max}; i++ )); do |
22866 |
+ if [[ ${RC_DAEMONS[i]} == "{cmd}" \ |
22867 |
+ && ${RC_PIDFILES[i]}="${pidfile}" ]]; then |
22868 |
+ break |
22869 |
+ fi |
22870 |
+ done |
22871 |
+ |
22872 |
+ if [[ ${i} == "${max}" ]]; then |
22873 |
+ RC_DAEMONS[max]="${cmd}" |
22874 |
+ RC_PIDFILES[max]="${pidfile}" |
22875 |
+ fi |
22876 |
+ fi |
22877 |
+ fi |
22878 |
+ |
22879 |
+ # Write the new list of daemon states for this service |
22880 |
+ if [[ ${#RC_DAEMONS[@]} == "0" ]]; then |
22881 |
+ [[ -f ${daemonfile} ]] && rm -f "${daemonfile}" |
22882 |
+ elif [[ -n ${daemonfile} ]] ; then |
22883 |
+ echo "RC_DAEMONS[0]=\"${RC_DAEMONS[0]}\"" > "${daemonfile}" |
22884 |
+ echo "RC_PIDFILES[0]=\"${RC_PIDFILES[0]}\"" >> "${daemonfile}" |
22885 |
+ |
22886 |
+ for (( i=1; i<${#RC_DAEMONS[@]}; i++ )); do |
22887 |
+ echo "RC_DAEMONS[${i}]=\"${RC_DAEMONS[i]}\"" >> "${daemonfile}" |
22888 |
+ echo "RC_PIDFILES[${i}]=\"${RC_PIDFILES[i]}\"" >> "${daemonfile}" |
22889 |
+ done |
22890 |
+ fi |
22891 |
+ |
22892 |
+ return "${result}" |
22893 |
+} |
22894 |
+ |
22895 |
+# vim:ts=4 |
22896 |
|
22897 |
|
22898 |
Property changes on: trunk/baselayout-prefix/sbin/rc-daemon.sh |
22899 |
___________________________________________________________________ |
22900 |
Added: svn:executable |
22901 |
+ * |
22902 |
|
22903 |
Added: trunk/baselayout-prefix/sbin/rc-help.sh |
22904 |
=================================================================== |
22905 |
--- trunk/baselayout-prefix/sbin/rc-help.sh (rev 0) |
22906 |
+++ trunk/baselayout-prefix/sbin/rc-help.sh 2011-03-31 14:11:17 UTC (rev 1682) |
22907 |
@@ -0,0 +1,252 @@ |
22908 |
+#!/bin/bash |
22909 |
+# Copyright 1999-2006 Gentoo Foundation |
22910 |
+# Distributed under the terms of the GNU General Public License v2 |
22911 |
+ |
22912 |
+source /sbin/functions.sh |
22913 |
+ |
22914 |
+if [[ ${RC_NOCOLOR} == "yes" ]] ; then |
22915 |
+ unset BLUE GREEN OFF CYAN |
22916 |
+else |
22917 |
+ BLUE="\033[34;01m" |
22918 |
+ GREEN="\033[32;01m" |
22919 |
+ OFF="\033[0m" |
22920 |
+ CYAN="\033[36;01m" |
22921 |
+fi |
22922 |
+ |
22923 |
+myscript=$1 |
22924 |
+if [[ -z ${myscript} ]] ; then |
22925 |
+ echo "Please execute an init.d script" |
22926 |
+ exit 1 |
22927 |
+fi |
22928 |
+ |
22929 |
+if [[ -L ${myscript} ]] ; then |
22930 |
+ SERVICE=$(readlink "${myscript}") |
22931 |
+else |
22932 |
+ SERVICE=${myscript} |
22933 |
+fi |
22934 |
+SERVICE=${SERVICE##*/} |
22935 |
+ |
22936 |
+if [[ $2 == "help" ]] ; then |
22937 |
+ BE_VERBOSE="yes" |
22938 |
+ NL=$'\n' |
22939 |
+else |
22940 |
+ BE_VERBOSE="no" |
22941 |
+ NL="" |
22942 |
+fi |
22943 |
+ |
22944 |
+default_opts="start stop restart pause zap" |
22945 |
+extra_opts=$(source "${myscript}" 2>/dev/null ; echo ${opts}) |
22946 |
+ |
22947 |
+if [[ ${BE_VERBOSE} == "yes" ]] ; then |
22948 |
+echo -e " |
22949 |
+${GREEN}Gentoo RC-Scripts; ${BLUE}http://www.gentoo.org/${OFF} |
22950 |
+ Copyright 1999-2006 Gentoo Foundation; Distributed under the GPL |
22951 |
+" |
22952 |
+fi |
22953 |
+ |
22954 |
+echo -e "Usage: ${CYAN}${SERVICE}${OFF} [ ${GREEN}flags${OFF} ] < ${GREEN}options${OFF} > |
22955 |
+ |
22956 |
+${CYAN}Normal Options:${OFF}" |
22957 |
+ |
22958 |
+if [[ ${BE_VERBOSE} == "yes" ]] ; then |
22959 |
+echo -e " |
22960 |
+ ${GREEN}start${OFF} |
22961 |
+ Start service, as well as the services it depends on (if not already |
22962 |
+ started). |
22963 |
+ |
22964 |
+ ${GREEN}stop${OFF} |
22965 |
+ Stop service, as well as the services that depend on it (if not already |
22966 |
+ stopped). |
22967 |
+ |
22968 |
+ ${GREEN}restart${OFF} |
22969 |
+ Restart service, as well as the services that depend on it. |
22970 |
+ |
22971 |
+ Note to developers: If this function is replaced with a custom one, |
22972 |
+ 'svc_start' and 'svc_stop' should be used instead of 'start' and |
22973 |
+ 'stop' to restart the service. This is so that the dependencies |
22974 |
+ can be handled correctly. Refer to the portmap rc-script for an |
22975 |
+ example. |
22976 |
+ |
22977 |
+ ${GREEN}pause${OFF} |
22978 |
+ Same as 'stop', but the services that depends on it, will not be |
22979 |
+ stopped. This is useful for stopping a network interface without |
22980 |
+ stopping all the network services that depend on 'net'. |
22981 |
+ |
22982 |
+ ${GREEN}zap${OFF} |
22983 |
+ Reset a service that is currently stopped, but still marked as started, |
22984 |
+ to the stopped state. Basically for killing zombie services. |
22985 |
+ |
22986 |
+ ${GREEN}status${OFF} |
22987 |
+ Prints \"status: started\" if the service is running, else it |
22988 |
+ prints \"status: stopped\". |
22989 |
+ |
22990 |
+ Note that if the '--quiet' flag is given, it will return true if the |
22991 |
+ service is running, else false. |
22992 |
+ |
22993 |
+ ${GREEN}ineed|iuse${OFF} |
22994 |
+ List the services this one depends on. Consult the section about |
22995 |
+ dependencies for more info on the different types of dependencies. |
22996 |
+ |
22997 |
+ ${GREEN}needsme|usesme${OFF} |
22998 |
+ List the services that depend on this one. Consult the section about |
22999 |
+ dependencies for more info on the different types of dependencies. |
23000 |
+ |
23001 |
+ ${GREEN}broken${OFF} |
23002 |
+ List the missing or broken dependencies of type 'need' this service |
23003 |
+ depends on. |
23004 |
+" |
23005 |
+ |
23006 |
+else |
23007 |
+ |
23008 |
+echo -e " ${GREEN}${default_opts}${OFF} |
23009 |
+ Default init.d options." |
23010 |
+ |
23011 |
+fi |
23012 |
+ |
23013 |
+if [[ -n ${extra_opts} ]] ; then |
23014 |
+echo -e " |
23015 |
+${CYAN}Additional Options:${OFF}${NL} |
23016 |
+ ${GREEN}${extra_opts}${OFF} |
23017 |
+ Extra options supported by this init.d script." |
23018 |
+fi |
23019 |
+ |
23020 |
+echo -e " |
23021 |
+${CYAN}Flags:${OFF}${NL} |
23022 |
+ ${GREEN}--quiet${OFF} |
23023 |
+ Suppress output to stdout, except if:${NL} |
23024 |
+ 1) It is a warning, then output to stdout |
23025 |
+ 2) It is an error, then output to stderr${NL} |
23026 |
+ ${GREEN}--nocolor${OFF} |
23027 |
+ Suppress the use of colors." |
23028 |
+ |
23029 |
+if [[ ${BE_VERBOSE} == "yes" ]] ; then |
23030 |
+echo -e " |
23031 |
+${CYAN}Dependencies:${OFF} |
23032 |
+ |
23033 |
+ This is the heart of the Gentoo RC-Scripts, as it determines the order |
23034 |
+ in which services gets started, and also to some extend what services |
23035 |
+ get started in the first place. |
23036 |
+ |
23037 |
+ The following example demonstrates how to use dependencies in |
23038 |
+ rc-scripts: |
23039 |
+ |
23040 |
+ depend() { |
23041 |
+ need foo bar |
23042 |
+ use ray |
23043 |
+ } |
23044 |
+ |
23045 |
+ Here we have foo and bar as dependencies of type 'need', and ray of |
23046 |
+ type 'use'. You can have as many dependencies of each type as needed, as |
23047 |
+ long as there is only one entry for each type, listing all its dependencies |
23048 |
+ on one line only. |
23049 |
+ |
23050 |
+ ${GREEN}need${OFF} |
23051 |
+ These are all the services needed for this service to start. If any |
23052 |
+ service in the 'need' line is not started, it will be started even if it |
23053 |
+ is not in the current, or 'boot' runlevel, and then this service will be |
23054 |
+ started. If any services in the 'need' line fails to start or is |
23055 |
+ missing, this service will never be started. |
23056 |
+ |
23057 |
+ ${GREEN}use${OFF} |
23058 |
+ This can be seen as representing optional services this service depends on |
23059 |
+ that are not critical for it to start. For any service in the 'use' line, |
23060 |
+ it must be added to the 'boot' or current runlevel to be considered a |
23061 |
+ valid 'use' dependency. It can also be used to determine startup order. |
23062 |
+ |
23063 |
+ ${GREEN}before${OFF} |
23064 |
+ This, together with the 'after' dependency type, can be used to control |
23065 |
+ startup order. In core, 'before' and 'after' do not denote a dependency, |
23066 |
+ but should be used for order changes that will only be honoured during |
23067 |
+ a change of runlevel. All services listed will get started *after* the |
23068 |
+ current service. In other words, this service will get started *before* |
23069 |
+ all listed services. |
23070 |
+ |
23071 |
+ ${GREEN}after${OFF} |
23072 |
+ All services listed will be started *before* the current service. Have a |
23073 |
+ look at 'before' for more info. |
23074 |
+ |
23075 |
+ ${GREEN}provide${OFF} |
23076 |
+ This is not really a dependency type, rather it will enable you to create |
23077 |
+ virtual services. This is useful if there is more than one version of |
23078 |
+ a specific service type, system loggers or crons for instance. Just |
23079 |
+ have each system logger provide 'logger', and make all services in need |
23080 |
+ of a system logger depend on 'logger'. This should make things much more |
23081 |
+ generic. |
23082 |
+ |
23083 |
+ Note that the 'need', 'use', 'before', and 'after' dependency types accept |
23084 |
+ an '*' as an argument. Having: |
23085 |
+ |
23086 |
+ depend() { |
23087 |
+ before * |
23088 |
+ } |
23089 |
+ |
23090 |
+ will make the service start first in the current runlevel, and: |
23091 |
+ |
23092 |
+ depend() { |
23093 |
+ after * |
23094 |
+ } |
23095 |
+ |
23096 |
+ will make the service the last to start. |
23097 |
+ |
23098 |
+ You should however be careful how you use this, as I really will not |
23099 |
+ recommend using it with the 'need' or 'use' dependency type ... you have |
23100 |
+ been warned! |
23101 |
+ |
23102 |
+${CYAN}'net' Dependency and 'net.*' Services:${OFF} |
23103 |
+ |
23104 |
+ Example: |
23105 |
+ |
23106 |
+ depend() { |
23107 |
+ need net |
23108 |
+ } |
23109 |
+ |
23110 |
+ This is a special dependency of type 'need'. It represents a state where |
23111 |
+ a network interface or interfaces besides lo is up and active. Any service |
23112 |
+ starting with 'net.' will be treated as a part of the 'net' dependency, |
23113 |
+ if: |
23114 |
+ |
23115 |
+ 1. It is part of the 'boot' runlevel |
23116 |
+ 2. It is part of the current runlevel |
23117 |
+ |
23118 |
+ A few examples are the /etc/init.d/net.eth0 and /etc/init.d/net.lo services." |
23119 |
+fi |
23120 |
+ |
23121 |
+echo -e " |
23122 |
+${CYAN}Configuration files:${OFF}" |
23123 |
+ |
23124 |
+if [[ ${BE_VERBOSE} == "yes" ]] ; then |
23125 |
+echo -e " |
23126 |
+ There are two files which will be sourced for possible configuration by |
23127 |
+ the rc-scripts. They are (sourced from top to bottom): |
23128 |
+" |
23129 |
+fi |
23130 |
+ |
23131 |
+echo -e " /etc/conf.d/${SERVICE}${NL} /etc/rc.conf" |
23132 |
+ |
23133 |
+if [[ ${BE_VERBOSE} == "yes" ]] ; then |
23134 |
+echo -e " |
23135 |
+ You can add extra dependencies to ${SERVICE} by adding some variables to |
23136 |
+ /etc/conf.d/${SERVICE} |
23137 |
+ RC_NEED=\"openvpn ntpd\" |
23138 |
+ RC_USE=\"dns\" |
23139 |
+ |
23140 |
+ This makes ${SERVICE} need openvpn and ntpd, while it just uses dns. |
23141 |
+ |
23142 |
+ A good example of this is nfsmount needing openvpn if the nfs mounts in |
23143 |
+ /etc/fstab are over the vpn link. |
23144 |
+" |
23145 |
+fi |
23146 |
+ |
23147 |
+if [[ ${BE_VERBOSE} == "yes" ]] ; then |
23148 |
+echo -e " |
23149 |
+${CYAN}Management:${OFF} |
23150 |
+ |
23151 |
+ Services are added and removed via the 'rc-update' tool. Running it without |
23152 |
+ arguments should give sufficient help. |
23153 |
+" |
23154 |
+else |
23155 |
+echo -e " |
23156 |
+For more info, please run '${myscript} help'." |
23157 |
+fi |
23158 |
+ |
23159 |
+exit 0 |
23160 |
|
23161 |
|
23162 |
Property changes on: trunk/baselayout-prefix/sbin/rc-help.sh |
23163 |
___________________________________________________________________ |
23164 |
Added: svn:executable |
23165 |
+ * |
23166 |
|
23167 |
Added: trunk/baselayout-prefix/sbin/rc-services.sh |
23168 |
=================================================================== |
23169 |
--- trunk/baselayout-prefix/sbin/rc-services.sh (rev 0) |
23170 |
+++ trunk/baselayout-prefix/sbin/rc-services.sh 2011-03-31 14:11:17 UTC (rev 1682) |
23171 |
@@ -0,0 +1,932 @@ |
23172 |
+# Copyright 1999-2004 Gentoo Foundation |
23173 |
+# Distributed under the terms of the GNU General Public License v2 |
23174 |
+ |
23175 |
+# RC Dependency and misc service functions |
23176 |
+RC_GOT_SERVICES="yes" |
23177 |
+ |
23178 |
+[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh |
23179 |
+ |
23180 |
+if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then |
23181 |
+ # Only try and update if we are root |
23182 |
+ if [[ ${EUID} == "0" ]] && ! /sbin/depscan.sh ; then |
23183 |
+ echo |
23184 |
+ eerror "Error running '/sbin/depscan.sh'!" |
23185 |
+ eerror "Please correct any problems above." |
23186 |
+ exit 1 |
23187 |
+ fi |
23188 |
+ |
23189 |
+ source "${svcdir}/deptree" |
23190 |
+ if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then |
23191 |
+ echo |
23192 |
+ eerror "Dependency info is missing! Please run" |
23193 |
+ eerror " # /sbin/depscan.sh" |
23194 |
+ eerror "to fix this." |
23195 |
+ exit 1 |
23196 |
+ fi |
23197 |
+fi |
23198 |
+ |
23199 |
+##################### |
23200 |
+# Internal variables |
23201 |
+##################### |
23202 |
+ |
23203 |
+# The name of the service whose dependency info we currently have |
23204 |
+rc_name= |
23205 |
+# The index of the service whose dependency info we currently have |
23206 |
+rc_index=0 |
23207 |
+# Our dependency types ... |
23208 |
+rc_ineed= |
23209 |
+rc_needsme= |
23210 |
+rc_iuse= |
23211 |
+rc_usesme= |
23212 |
+rc_ibefore= |
23213 |
+rc_iafter= |
23214 |
+rc_broken= |
23215 |
+rc_mtime= |
23216 |
+ |
23217 |
+############ |
23218 |
+# Functions |
23219 |
+############ |
23220 |
+ |
23221 |
+# bool get_service_index(service, index) |
23222 |
+# |
23223 |
+# Print the index of 'service'. 'index' is the current index. |
23224 |
+# |
23225 |
+get_service_index() { |
23226 |
+ if [[ -z $1 || -z $2 ]] ; then |
23227 |
+ echo "0" |
23228 |
+ return 1 |
23229 |
+ fi |
23230 |
+ |
23231 |
+ local x myservice="$1" index="$2" |
23232 |
+ |
23233 |
+ # Do we already have the index? |
23234 |
+ if [[ -n ${index} && ${index} -gt 0 \ |
23235 |
+ && ${myservice} == "${RC_DEPEND_TREE[${index}]}" ]] ; then |
23236 |
+ echo "${index}" |
23237 |
+ return 0 |
23238 |
+ fi |
23239 |
+ |
23240 |
+ for (( x=1; x<=${RC_DEPEND_TREE[0]}; x++ )); do |
23241 |
+ index="$(( ${x} * ${rc_index_scale} ))" |
23242 |
+ if [[ ${myservice} == "${RC_DEPEND_TREE[${index}]}" ]] ; then |
23243 |
+ echo "${index}" |
23244 |
+ return 0 |
23245 |
+ fi |
23246 |
+ done |
23247 |
+ |
23248 |
+ echo "0" |
23249 |
+ return 1 |
23250 |
+} |
23251 |
+ |
23252 |
+# bool get_dep_info(service) |
23253 |
+# |
23254 |
+# Set the Dependency variables to contain data for 'service' |
23255 |
+# |
23256 |
+get_dep_info() { |
23257 |
+ [[ -z $1 ]] && return 1 |
23258 |
+ |
23259 |
+ local myservice="$1" |
23260 |
+ |
23261 |
+ # We already have the right stuff ... |
23262 |
+ [[ ${myservice} == "${rc_name}" && -n ${rc_mtime} ]] && return 0 |
23263 |
+ |
23264 |
+ rc_index="$(get_service_index "${myservice}" "${rc_index}")" |
23265 |
+ rc_mtime="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_mtime}))]}" |
23266 |
+ |
23267 |
+ # Verify that we have the correct index (rc_index) ... |
23268 |
+ # [[ ${rc_index} == "0" ]] && return 1 |
23269 |
+ |
23270 |
+ rc_name="${RC_DEPEND_TREE[${rc_index}]}" |
23271 |
+ rc_ineed="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_ineed}))]}" |
23272 |
+ rc_needsme="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_needsme}))]}" |
23273 |
+ rc_iuse="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_iuse}))]}" |
23274 |
+ rc_usesme="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_usesme}))]}" |
23275 |
+ rc_ibefore="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_ibefore}))]}" |
23276 |
+ rc_iafter="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_iafter}))]}" |
23277 |
+ rc_broken="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_broken}))]}" |
23278 |
+ rc_mtime="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_mtime}))]}" |
23279 |
+ return 0 |
23280 |
+} |
23281 |
+ |
23282 |
+# string check_dependency(deptype, service1) |
23283 |
+# |
23284 |
+# List all the services that depend on 'service1' of dependency |
23285 |
+# type 'deptype' |
23286 |
+# |
23287 |
+# bool check_dependency(deptype, -t, service1, service2) |
23288 |
+# |
23289 |
+# Returns true if 'service2' is a dependency of type 'deptype' |
23290 |
+# of 'service1' |
23291 |
+# |
23292 |
+check_dependency() { |
23293 |
+ [[ -z $1 || -z $2 ]] && return 1 |
23294 |
+ |
23295 |
+ local x myservice deps |
23296 |
+ |
23297 |
+ # Set the dependency variables to relate to 'service1' |
23298 |
+ if [[ $2 == "-t" ]] ; then |
23299 |
+ [[ -z $3 || -z $4 ]] && return 1 |
23300 |
+ myservice="$3" |
23301 |
+ else |
23302 |
+ myservice="$2" |
23303 |
+ fi |
23304 |
+ |
23305 |
+ if ! get_dep_info "${myservice}" >/dev/null ; then |
23306 |
+ eerror "Could not get dependency info for ${myservice}!" > /dev/stderr |
23307 |
+ eerror "Please run:" > /dev/stderr |
23308 |
+ eerror " # /sbin/depscan.sh" > /dev/stderr |
23309 |
+ eerror "to try and fix this." > /dev/stderr |
23310 |
+ return 1 |
23311 |
+ fi |
23312 |
+ |
23313 |
+ # Do we have valid info for 'deptype' ? |
23314 |
+ deps="rc_$1" |
23315 |
+ [[ -z ${!deps} ]] && return 1 |
23316 |
+ |
23317 |
+ if [[ $2 == "-t" && -n $4 ]]; then |
23318 |
+ # Check if 'service1' have 'deptype' dependency on 'service2' |
23319 |
+ for x in ${!deps} ; do |
23320 |
+ [[ ${x} == "$4" ]] && return 0 |
23321 |
+ done |
23322 |
+ return 1 |
23323 |
+ else |
23324 |
+ # Just list all services that 'service1' have 'deptype' dependency on. |
23325 |
+ echo "${!deps}" |
23326 |
+ return 0 |
23327 |
+ fi |
23328 |
+} |
23329 |
+ |
23330 |
+# Same as for check_dependency, except 'deptype' is set to |
23331 |
+# 'ineed'. It will return all the services 'service1' NEED's. |
23332 |
+ineed() { |
23333 |
+ check_dependency ineed "$@" |
23334 |
+} |
23335 |
+ |
23336 |
+# Same as for check_dependency, except 'deptype' is set to |
23337 |
+# 'needsme'. It will return all the services that NEED 'service1'. |
23338 |
+needsme() { |
23339 |
+ check_dependency needsme "$@" |
23340 |
+} |
23341 |
+ |
23342 |
+# Same as for check_dependency, except 'deptype' is set to |
23343 |
+# 'iuse'. It will return all the services 'service1' USE's. |
23344 |
+iuse() { |
23345 |
+ check_dependency iuse "$@" |
23346 |
+} |
23347 |
+ |
23348 |
+# Same as for check_dependency, except 'deptype' is set to |
23349 |
+# 'usesme'. It will return all the services that USE 'service1'. |
23350 |
+usesme() { |
23351 |
+ check_dependency usesme "$@" |
23352 |
+} |
23353 |
+ |
23354 |
+# Same as for check_dependency, except 'deptype' is set to |
23355 |
+# 'ibefore'. It will return all the services that are started |
23356 |
+# *after* 'service1' (iow, it will start 'service1' before the |
23357 |
+# list of services returned). |
23358 |
+ibefore() { |
23359 |
+ check_dependency ibefore "$@" |
23360 |
+} |
23361 |
+ |
23362 |
+# Same as for check_dependency, except 'deptype' is set to |
23363 |
+# 'iafter'. It will return all the services that are started |
23364 |
+# *before* 'service1' (iow, it will start 'service1' after the |
23365 |
+# list of services returned). |
23366 |
+iafter() { |
23367 |
+ check_dependency iafter "$@" |
23368 |
+} |
23369 |
+ |
23370 |
+# Same as for check_dependency, except 'deptype' is set to |
23371 |
+# 'broken'. It will return all the services that 'service1' |
23372 |
+# NEED, but are not present. |
23373 |
+broken() { |
23374 |
+ check_dependency broken "$@" |
23375 |
+} |
23376 |
+ |
23377 |
+# bool is_fake_service(service, runlevel) |
23378 |
+# |
23379 |
+# Returns ture if 'service' is a fake service in 'runlevel'. |
23380 |
+# |
23381 |
+is_fake_service() { |
23382 |
+ local x fake_services |
23383 |
+ |
23384 |
+ [[ -z $1 || -z $2 ]] && return 1 |
23385 |
+ |
23386 |
+ [[ $2 != "${BOOTLEVEL}" && -e /etc/runlevels/"${BOOTLEVEL}"/.fake ]] && \ |
23387 |
+ fake_services="$( < /etc/runlevels/"${BOOTLEVEL}"/.fake )" |
23388 |
+ |
23389 |
+ [[ -e /etc/runlevels/"$2"/.fake ]] && \ |
23390 |
+ fake_services="${fake_services} $( < /etc/runlevels/"$2"/.fake )" |
23391 |
+ |
23392 |
+ for x in ${fake_services} ; do |
23393 |
+ [[ $1 == "${x##*/}" ]] && return 0 |
23394 |
+ done |
23395 |
+ |
23396 |
+ return 1 |
23397 |
+} |
23398 |
+ |
23399 |
+# bool in_runlevel(service, runlevel) |
23400 |
+# |
23401 |
+# Returns true if 'service' is in runlevel 'runlevel'. |
23402 |
+# |
23403 |
+in_runlevel() { |
23404 |
+ [[ -z $1 || -z $2 ]] && return 1 |
23405 |
+ |
23406 |
+ [[ -L "/etc/runlevels/$2/$1" ]] && return 0 |
23407 |
+ |
23408 |
+ return 1 |
23409 |
+} |
23410 |
+ |
23411 |
+# bool is_runlevel_start() |
23412 |
+# |
23413 |
+# Returns true if it is a runlevel change, and we are busy |
23414 |
+# starting services. |
23415 |
+# |
23416 |
+is_runlevel_start() { |
23417 |
+ [[ -d "${svcdir}/softscripts.old" ]] |
23418 |
+} |
23419 |
+ |
23420 |
+# bool is_runlevel_stop() |
23421 |
+# |
23422 |
+# Returns true if it is a runlevel change, and we are busy |
23423 |
+# stopping services. |
23424 |
+# |
23425 |
+is_runlevel_stop() { |
23426 |
+ [[ -d "${svcdir}/softscripts.new" ]] |
23427 |
+} |
23428 |
+ |
23429 |
+# void save_options(char *option, char *optstring) |
23430 |
+# |
23431 |
+# save the settings ("optstring") for "option" |
23432 |
+# |
23433 |
+save_options() { |
23434 |
+ local myopts="$1" |
23435 |
+ |
23436 |
+ shift |
23437 |
+ if [[ ! -d "${svcdir}/options/${SVCNAME}" ]] ; then |
23438 |
+ mkdir -p -m 0755 "${svcdir}/options/${SVCNAME}" |
23439 |
+ fi |
23440 |
+ |
23441 |
+ echo "$*" > "${svcdir}/options/${SVCNAME}/${myopts}" |
23442 |
+} |
23443 |
+ |
23444 |
+# char *get_options(char *option) |
23445 |
+# |
23446 |
+# get the "optstring" for "option" that was saved |
23447 |
+# by calling the save_options function |
23448 |
+# |
23449 |
+get_options() { |
23450 |
+ local svc="${SVCNAME}" |
23451 |
+ [[ -n $2 ]] && svc="$2" |
23452 |
+ |
23453 |
+ if [[ -f "${svcdir}/options/${svc}/$1" ]] ; then |
23454 |
+ echo "$(< ${svcdir}/options/${svc}/$1)" |
23455 |
+ fi |
23456 |
+} |
23457 |
+ |
23458 |
+# void sevice_message([char *type] char *message) |
23459 |
+# |
23460 |
+# Print out a service message if we are on parallel |
23461 |
+service_message() { |
23462 |
+ [[ ${RC_PARALLEL_STARTUP} != "yes" || ${RC_QUIET} == "yes" ]] && return |
23463 |
+ |
23464 |
+ local cmd="einfo" |
23465 |
+ case "$1" in |
23466 |
+ 1|error|eerror) |
23467 |
+ cmd="eerror" |
23468 |
+ shift |
23469 |
+ ;; |
23470 |
+ ewarn) |
23471 |
+ cmd="ewarn" |
23472 |
+ shift |
23473 |
+ ;; |
23474 |
+ esac |
23475 |
+ |
23476 |
+ local r="${RC_QUIET_STDOUT}" |
23477 |
+ RC_QUIET_STDOUT="no" |
23478 |
+ ${cmd} "$@" |
23479 |
+ RC_QUIET_STDOUT="${r}" |
23480 |
+} |
23481 |
+ |
23482 |
+# bool begin_service( service ) |
23483 |
+# |
23484 |
+# atomically marks the service as being executed |
23485 |
+# use like this: |
23486 |
+# |
23487 |
+# if begin_service service ; then |
23488 |
+# whatever is in here can only be executed by one process |
23489 |
+# end_service service |
23490 |
+# fi |
23491 |
+begin_service() { |
23492 |
+ local service="$1" |
23493 |
+ [[ -z ${service} ]] && return 1 |
23494 |
+ |
23495 |
+ [[ ${START_CRITICAL} == "yes" || ${STOP_CRITICAL} == "yes" ]] && return 0 |
23496 |
+ |
23497 |
+ mkfifo "${svcdir}/exclusive/${service}" 2> /dev/null |
23498 |
+} |
23499 |
+ |
23500 |
+# void end_service(service, exitcode) |
23501 |
+# |
23502 |
+# stops executing a exclusive region and |
23503 |
+# wakes up anybody who is waiting for the exclusive region |
23504 |
+# |
23505 |
+end_service() { |
23506 |
+ local service="$1" exitstatus="$2" |
23507 |
+ [[ -z ${service} ]] && return |
23508 |
+ |
23509 |
+ # if we are doing critical services, there is no fifo |
23510 |
+ [[ ${START_CRITICAL} == "yes" || ${STOP_CRITICAL} == "yes" ]] && return |
23511 |
+ |
23512 |
+ if [[ -n ${exitstatus} ]] ; then |
23513 |
+ echo "${exitstatus}" > "${svcdir}/exitcodes/${service}" |
23514 |
+ fi |
23515 |
+ |
23516 |
+ # move the fifo to a unique name so no-one is waiting for it |
23517 |
+ local fifo="${svcdir}/exclusive/${service}" |
23518 |
+ if [[ -e ${fifo} ]] ; then |
23519 |
+ local tempname="${fifo}.$$" |
23520 |
+ mv -f "${fifo}" "${tempname}" |
23521 |
+ |
23522 |
+ # wake up anybody that was waiting for the fifo |
23523 |
+ touch "${tempname}" |
23524 |
+ |
23525 |
+ # We dont need the fifo anymore |
23526 |
+ rm -f "${tempname}" |
23527 |
+ fi |
23528 |
+} |
23529 |
+ |
23530 |
+# int wait_service(service) |
23531 |
+# |
23532 |
+# If a service has started, or a fifo does not exist return 0 |
23533 |
+# Otherwise, wait until we get an exit code via the fifo and return |
23534 |
+# that instead. |
23535 |
+wait_service() { |
23536 |
+ local service="$1" |
23537 |
+ local fifo="${svcdir}/exclusive/${service}" |
23538 |
+ |
23539 |
+ [[ ${START_CRITICAL} == "yes" || ${STOP_CRITICAL} == "yes" ]] && return 0 |
23540 |
+ [[ ! -e ${fifo} ]] && return 0 |
23541 |
+ |
23542 |
+ # This will block until the service fifo is touched |
23543 |
+ # Otheriwse we don't block |
23544 |
+ # We need to use cat instead of the bash inbuilt < so we don't see errors |
23545 |
+ local tmp="$( cat "${fifo}" 2>/dev/null )" |
23546 |
+ local exitstatus="$( < "${svcdir}/exitcodes/${service}" )" |
23547 |
+ |
23548 |
+ return "${exitstatus}" |
23549 |
+} |
23550 |
+ |
23551 |
+# int start_service(service) |
23552 |
+# |
23553 |
+# Start 'service' if it is not already running. |
23554 |
+# |
23555 |
+start_service() { |
23556 |
+ local service="$1" |
23557 |
+ [[ -z ${service} ]] && return 1 |
23558 |
+ |
23559 |
+ if [[ ! -e "/etc/init.d/${service}" ]] ; then |
23560 |
+ mark_service_stopped "${service}" |
23561 |
+ return 1 |
23562 |
+ fi |
23563 |
+ |
23564 |
+ service_starting "${service}" && return 0 |
23565 |
+ service_started "${service}" && return 0 |
23566 |
+ service_inactive "${service}" && return 1 |
23567 |
+ |
23568 |
+ if is_fake_service "${service}" "${SOFTLEVEL}" ; then |
23569 |
+ mark_service_started "${service}" |
23570 |
+ splash "svc_start" "${service}" |
23571 |
+ splash "svc_started" "${service}" "0" |
23572 |
+ return 0 |
23573 |
+ fi |
23574 |
+ |
23575 |
+ begin_service "${service}" || return 0 |
23576 |
+ splash "svc_start" "${service}" |
23577 |
+ if [[ ${RC_PARALLEL_STARTUP} != "yes" || \ |
23578 |
+ ${START_CRITICAL} == "yes" ]] ; then |
23579 |
+ # if we can not start the services in parallel |
23580 |
+ # then just start it and return the exit status |
23581 |
+ ( |
23582 |
+ profiling name "/etc/init.d/${service} start" |
23583 |
+ "/etc/init.d/${service}" start |
23584 |
+ ) |
23585 |
+ |
23586 |
+ service_started "${service}" || service_inactive "${service}" \ |
23587 |
+ || service_scheduled "${service}" |
23588 |
+ retval=$? |
23589 |
+ |
23590 |
+ end_service "${service}" "${retval}" |
23591 |
+ splash "svc_started" "${service}" "${retval}" |
23592 |
+ |
23593 |
+ return "${retval}" |
23594 |
+ else |
23595 |
+ # if parallel startup is allowed, start it in background |
23596 |
+ ( |
23597 |
+ profiling name "/etc/init.d/${service} start" |
23598 |
+ "/etc/init.d/${service}" start |
23599 |
+ |
23600 |
+ service_started "${service}" || service_inactive "${service}" \ |
23601 |
+ || service_scheduled "${service}" |
23602 |
+ retval=$? |
23603 |
+ |
23604 |
+ end_service "${service}" "${retval}" |
23605 |
+ splash "svc_started" "${service}" "${retval}" |
23606 |
+ ) & |
23607 |
+ return 0 |
23608 |
+ fi |
23609 |
+} |
23610 |
+ |
23611 |
+# int stop_service(service) |
23612 |
+# |
23613 |
+# Stop 'service' if it is not already running. |
23614 |
+# |
23615 |
+stop_service() { |
23616 |
+ local service="$1" |
23617 |
+ [[ -z ${service} ]] && return 1 |
23618 |
+ |
23619 |
+ if [[ ! -e "/etc/init.d/${service}" ]] ; then |
23620 |
+ mark_service_stopped "${service}" |
23621 |
+ return 0 |
23622 |
+ fi |
23623 |
+ |
23624 |
+ service_stopping "${service}" && return 0 |
23625 |
+ service_stopped "${service}" && return 0 |
23626 |
+ |
23627 |
+ local level="${SOFTLEVEL}" |
23628 |
+ is_runlevel_stop && level="${OLDSOFTLEVEL}" |
23629 |
+ |
23630 |
+ if is_fake_service "${service}" "${level}" ; then |
23631 |
+ splash "svc_stop" "${service}" |
23632 |
+ mark_service_stopped "${service}" |
23633 |
+ splash "svc_stopped" "${service}" "0" |
23634 |
+ return 0 |
23635 |
+ fi |
23636 |
+ |
23637 |
+ begin_service "${service}" || return 0 |
23638 |
+ |
23639 |
+ splash "svc_stop" "${service}" |
23640 |
+ if [[ ${RC_PARALLEL_STARTUP} != "yes" || \ |
23641 |
+ ${STOP_CRITICAL} == "yes" ]] ; then |
23642 |
+ # if we can not start the services in parallel |
23643 |
+ # then just start it and return the exit status |
23644 |
+ ( "/etc/init.d/${service}" stop ) |
23645 |
+ service_stopped "${service}" |
23646 |
+ retval=$? |
23647 |
+ end_service "${service}" "${retval}" |
23648 |
+ splash "svc_stopped" "${service}" "${retval}" |
23649 |
+ return "${retval}" |
23650 |
+ else |
23651 |
+ # if parallel startup is allowed, start it in background |
23652 |
+ ( |
23653 |
+ ( "/etc/init.d/${service}" stop ) |
23654 |
+ service_stopped "${service}" |
23655 |
+ retval=$? |
23656 |
+ end_service "${service}" "${retval}" |
23657 |
+ splash "svc_stopped" "${service}" "${retval}" |
23658 |
+ ) & |
23659 |
+ return 0 |
23660 |
+ fi |
23661 |
+} |
23662 |
+ |
23663 |
+# bool mark_service_coldplugged(service) |
23664 |
+# |
23665 |
+# Mark 'service' as coldplugged. |
23666 |
+# |
23667 |
+mark_service_coldplugged() { |
23668 |
+ [[ -z $1 ]] && return 1 |
23669 |
+ |
23670 |
+ ln -snf "/etc/init.d/$1" "${svcdir}/coldplugged/$1" |
23671 |
+ return 0 |
23672 |
+} |
23673 |
+ |
23674 |
+# bool mark_service_starting(service) |
23675 |
+# |
23676 |
+# Mark 'service' as starting. |
23677 |
+# |
23678 |
+mark_service_starting() { |
23679 |
+ [[ -z $1 ]] && return 1 |
23680 |
+ |
23681 |
+ ln -sn "/etc/init.d/$1" "${svcdir}/starting/$1" 2>/dev/null || return 1 |
23682 |
+ |
23683 |
+ [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" |
23684 |
+ [[ -f "${svcdir}/inactive/$1" ]] \ |
23685 |
+ && mv "${svcdir}/inactive/$1" "${svcdir}/wasinactive/$1" |
23686 |
+ return 0 |
23687 |
+} |
23688 |
+ |
23689 |
+# bool mark_service_started(service) |
23690 |
+# |
23691 |
+# Mark 'service' as started. |
23692 |
+# |
23693 |
+mark_service_started() { |
23694 |
+ [[ -z $1 ]] && return 1 |
23695 |
+ |
23696 |
+ ln -snf "/etc/init.d/$1" "${svcdir}/started/$1" |
23697 |
+ |
23698 |
+ rm -f "${svcdir}/starting/$1" "${svcdir}/inactive/$1" \ |
23699 |
+ "${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \ |
23700 |
+ "${svcdir}"/scheduled/*/"$1" |
23701 |
+ |
23702 |
+ return 0 |
23703 |
+} |
23704 |
+ |
23705 |
+# bool mark_service_inactive(service) |
23706 |
+# |
23707 |
+# Mark service as inactive |
23708 |
+# |
23709 |
+mark_service_inactive() { |
23710 |
+ [[ -z $1 ]] && return 1 |
23711 |
+ |
23712 |
+ ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1" |
23713 |
+ |
23714 |
+ rm -f "${svcdir}/started/$1" "${svcdir}/wasinactive/$1" \ |
23715 |
+ "${svcdir}/starting/$1" "${svcdir}/stopping/$1" |
23716 |
+ |
23717 |
+ return 0 |
23718 |
+} |
23719 |
+ |
23720 |
+# bool mark_service_stopping(service) |
23721 |
+# |
23722 |
+# Mark 'service' as stopping. |
23723 |
+# |
23724 |
+mark_service_stopping() { |
23725 |
+ [[ -z $1 ]] && return 1 |
23726 |
+ |
23727 |
+ ln -sn "/etc/init.d/$1" "${svcdir}/stopping/$1" 2>/dev/null || return 1 |
23728 |
+ |
23729 |
+ rm -f "${svcdir}/started/$1" |
23730 |
+ [[ -f "${svcdir}/inactive/$1" ]] \ |
23731 |
+ && mv "${svcdir}/inactive/$1" "${svcdir}/wasinactive/$1" |
23732 |
+ |
23733 |
+ return 0 |
23734 |
+} |
23735 |
+ |
23736 |
+# bool mark_service_stopped(service) |
23737 |
+# |
23738 |
+# Mark 'service' as stopped. |
23739 |
+# |
23740 |
+mark_service_stopped() { |
23741 |
+ [[ -z $1 ]] && return 1 |
23742 |
+ |
23743 |
+ rm -Rf "${svcdir}/daemons/$1" "${svcdir}/starting/$1" \ |
23744 |
+ "${svcdir}/started/$1" "${svcdir}/inactive/$1" \ |
23745 |
+ "${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \ |
23746 |
+ "${svcdir}/scheduled/$1" "${svcdir}/options/$1" \ |
23747 |
+ "${svcdir}/coldplugged/$1" |
23748 |
+ |
23749 |
+ return 0 |
23750 |
+} |
23751 |
+ |
23752 |
+# bool test_service_state(char *service, char *state) |
23753 |
+# |
23754 |
+# Returns 0 if the service link exists and points to a file, otherwise 1 |
23755 |
+# If 1 then the link is erased if it exists |
23756 |
+test_service_state() { |
23757 |
+ [[ -z $1 || -z $2 ]] && return 1 |
23758 |
+ |
23759 |
+ local f="${svcdir}/$2/$1" |
23760 |
+ |
23761 |
+ # Service is in the state requested |
23762 |
+ [[ -L ${f} ]] && return 0 |
23763 |
+ |
23764 |
+ [[ ! -e ${f} ]] && rm -f "${f}" |
23765 |
+ return 1 |
23766 |
+} |
23767 |
+ |
23768 |
+# bool service_coldplugged(service) |
23769 |
+# |
23770 |
+# Returns true if 'service' is coldplugged |
23771 |
+# |
23772 |
+service_coldplugged() { |
23773 |
+ test_service_state "$1" "coldplugged" |
23774 |
+} |
23775 |
+ |
23776 |
+# bool service_starting(service) |
23777 |
+# |
23778 |
+# Returns true if 'service' is starting |
23779 |
+# |
23780 |
+service_starting() { |
23781 |
+ test_service_state "$1" "starting" |
23782 |
+} |
23783 |
+ |
23784 |
+# bool service_started(service) |
23785 |
+# |
23786 |
+# Returns true if 'service' is started |
23787 |
+# |
23788 |
+service_started() { |
23789 |
+ test_service_state "$1" "started" |
23790 |
+} |
23791 |
+ |
23792 |
+# bool service_inactive(service) |
23793 |
+# |
23794 |
+# Returns true if 'service' is inactive |
23795 |
+# |
23796 |
+service_inactive() { |
23797 |
+ test_service_state "$1" "inactive" |
23798 |
+} |
23799 |
+ |
23800 |
+# bool service_wasinactive(service) |
23801 |
+# |
23802 |
+# Returns true if 'service' is inactive |
23803 |
+# |
23804 |
+service_wasinactive() { |
23805 |
+ test_service_state "$1" "wasinactive" |
23806 |
+} |
23807 |
+ |
23808 |
+# bool service_stopping(service) |
23809 |
+# |
23810 |
+# Returns true if 'service' is stopping |
23811 |
+# |
23812 |
+service_stopping() { |
23813 |
+ test_service_state "$1" "stopping" |
23814 |
+} |
23815 |
+ |
23816 |
+# bool service_stopped(service) |
23817 |
+# |
23818 |
+# Returns true if 'service' is stopped |
23819 |
+# |
23820 |
+service_stopped() { |
23821 |
+ [[ -z $1 ]] && return 1 |
23822 |
+ |
23823 |
+ service_starting "$1" && return 1 |
23824 |
+ service_started "$1" && return 1 |
23825 |
+ service_stopping "$1" && return 1 |
23826 |
+ service_inactive "$1" && return 1 |
23827 |
+ |
23828 |
+ return 0 |
23829 |
+} |
23830 |
+ |
23831 |
+# char service_scheduled_by(service) |
23832 |
+# |
23833 |
+# Returns a list of services which will try and start 'service' when they |
23834 |
+# are started |
23835 |
+# |
23836 |
+service_scheduled_by() { |
23837 |
+ [[ -z $1 ]] && return 1 |
23838 |
+ |
23839 |
+ local x= s= r= |
23840 |
+ for x in $(dolisting "${svcdir}/scheduled/*/$1") ; do |
23841 |
+ s="${x%/*}" |
23842 |
+ r="${r} ${s##*/}" |
23843 |
+ done |
23844 |
+ |
23845 |
+ echo "${r:1}" |
23846 |
+} |
23847 |
+ |
23848 |
+# bool service_scheduled() |
23849 |
+# |
23850 |
+# Returns true if 'service' is scheduled to be started by another service |
23851 |
+# |
23852 |
+service_scheduled() { |
23853 |
+ [[ -n $(service_scheduled_by "$@") ]] |
23854 |
+} |
23855 |
+ |
23856 |
+# bool mark_service_failed(service) |
23857 |
+# |
23858 |
+# Mark service as failed for current runlevel. Note that |
23859 |
+# this is only valid on runlevel change ... |
23860 |
+# |
23861 |
+mark_service_failed() { |
23862 |
+ [[ -z $1 || ! -d "${svcdir}/failed" ]] && return 1 |
23863 |
+ |
23864 |
+ ln -snf "/etc/init.d/$1" "${svcdir}/failed/$1" |
23865 |
+} |
23866 |
+ |
23867 |
+# bool service_failed(service) |
23868 |
+# |
23869 |
+# Return true if 'service' have failed during this runlevel. |
23870 |
+# |
23871 |
+service_failed() { |
23872 |
+ [[ -n $1 && -L "${svcdir}/failed/$1" ]] |
23873 |
+} |
23874 |
+ |
23875 |
+# bool service_started_daemon(char *interface, char *daemon, int index) |
23876 |
+# Returns 0 if the service started the given daemon |
23877 |
+# via start-stop-daemon, otherwise 1. |
23878 |
+# If index is emtpy, then we don't care what the first daemon launched |
23879 |
+# was, otherwise the daemon must also be at that index |
23880 |
+service_started_daemon() { |
23881 |
+ local service="$1" daemon="$2" index="${3:-[0-9]*}" |
23882 |
+ local daemonfile="${svcdir}/daemons/${service}" |
23883 |
+ |
23884 |
+ [[ ! -e ${daemonfile} ]] && return 1 |
23885 |
+ grep -q '^RC_DAEMONS\['"${index}"'\]="'${daemon}'"$' "${daemonfile}" |
23886 |
+} |
23887 |
+ |
23888 |
+# bool net_service(service) |
23889 |
+# |
23890 |
+# Returns true if 'service' is a service controlling a network interface |
23891 |
+# |
23892 |
+net_service() { |
23893 |
+ [[ -n $1 && ${1%%.*} == "net" && ${1#*.} != "$1" ]] |
23894 |
+} |
23895 |
+ |
23896 |
+# bool is_net_up(char *exclude) |
23897 |
+# |
23898 |
+# Return true if service 'net' is considered up, else false. |
23899 |
+# |
23900 |
+# Notes for RC_NET_STRICT_CHECKING values: |
23901 |
+# none net is up without checking anything - usefull for vservers |
23902 |
+# lo Interface 'lo' is counted and if only it is up, net is up. |
23903 |
+# no Interface 'lo' is not counted, and net is down even with it up, |
23904 |
+# so there have to be at least one other interface up. |
23905 |
+# yes All interfaces must be up. |
23906 |
+is_net_up() { |
23907 |
+ local x= |
23908 |
+ |
23909 |
+ case "${RC_NET_STRICT_CHECKING}" in |
23910 |
+ none) |
23911 |
+ return 0 |
23912 |
+ ;; |
23913 |
+ lo) |
23914 |
+ service_started "net.lo" |
23915 |
+ return $? |
23916 |
+ ;; |
23917 |
+ yes) |
23918 |
+ for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ |
23919 |
+ $(dolisting "/etc/runlevels/${SOFTLEVEL}/net.*") ; do |
23920 |
+ local y="${x##*/}" |
23921 |
+ [[ ${y} == "$1" ]] && return 1 |
23922 |
+ service_started "${y}" || return 1 |
23923 |
+ done |
23924 |
+ return 0 |
23925 |
+ ;; |
23926 |
+ *) |
23927 |
+ for x in $(dolisting "${svcdir}/started/net.*") ; do |
23928 |
+ local y="${x##*/}" |
23929 |
+ [[ ${y} == "$1" ]] && continue |
23930 |
+ [[ ${y} != "net.lo" ]] && return 0 |
23931 |
+ done |
23932 |
+ return 1 |
23933 |
+ ;; |
23934 |
+ esac |
23935 |
+} |
23936 |
+ |
23937 |
+# bool dependon(service1, service2) |
23938 |
+# |
23939 |
+# Does service1 depend (NEED or USE) on service2 ? |
23940 |
+# |
23941 |
+dependon() { |
23942 |
+ ineed -t "$1" "$2" || iuse -t "$1" "$2" |
23943 |
+} |
23944 |
+ |
23945 |
+# string validi(use/after, service) |
23946 |
+# |
23947 |
+# This is the main code for valid_after and valid_iuse |
23948 |
+# No point in writing it twice! |
23949 |
+valid_i() { |
23950 |
+ # Just set to dummy for now (don't know if $svcdir/softlevel exists yet). |
23951 |
+ local mylevel="${BOOTLEVEL}" x= valid= |
23952 |
+ |
23953 |
+ [[ $1 != "after" && $1 != "use" ]] && return 1 |
23954 |
+ |
23955 |
+ # Cannot be SOFTLEVEL, as we need to know current runlevel |
23956 |
+ [[ -f "${svcdir}/softlevel" ]] && mylevel=$( < "${svcdir}/softlevel" ) |
23957 |
+ |
23958 |
+ for x in $( i$1 "$2" ) ; do |
23959 |
+ [[ -e "/etc/runlevels/${BOOTLEVEL}/${x}" || \ |
23960 |
+ -e "/etc/runlevels/${mylevel}/${x}" || \ |
23961 |
+ ${x} == "net" ]] \ |
23962 |
+ && valid="${valid} ${x}" |
23963 |
+ done |
23964 |
+ |
23965 |
+ echo "${valid:1}" |
23966 |
+ return 0 |
23967 |
+} |
23968 |
+ |
23969 |
+# string valid_iuse(service) |
23970 |
+# |
23971 |
+# This will only give the valid use's for the service |
23972 |
+# (they must be in the boot or current runlevel) |
23973 |
+# |
23974 |
+valid_iuse() { |
23975 |
+ valid_i "use" "$1" |
23976 |
+} |
23977 |
+ |
23978 |
+#string valid_iafter(service) |
23979 |
+# |
23980 |
+# Valid services for current or boot rc level that should start |
23981 |
+# before 'service' |
23982 |
+# |
23983 |
+valid_iafter() { |
23984 |
+ valid_i "after" "$1" |
23985 |
+} |
23986 |
+ |
23987 |
+# string trace_dependencies(service[s]) |
23988 |
+# |
23989 |
+# Get and sort the dependencies of given service[s]. |
23990 |
+# |
23991 |
+trace_dependencies() { |
23992 |
+ local -a services=( "$@" ) net_deps=() |
23993 |
+ local i= j= net_services= x= |
23994 |
+ |
23995 |
+ if [[ $1 == -* ]]; then |
23996 |
+ deptype="${1/-/}" |
23997 |
+ if net_service "${SVCNAME}" ; then |
23998 |
+ services=( "net" "${SVCNAME}" ) |
23999 |
+ else |
24000 |
+ services=( "${SVCNAME}" ) |
24001 |
+ fi |
24002 |
+ fi |
24003 |
+ |
24004 |
+ if is_net_up || is_runlevel_stop ; then |
24005 |
+ for x in $(dolisting "${svcdir}/started/net.*") \ |
24006 |
+ $(dolisting "${svcdir}/inactive/net.*") ; do |
24007 |
+ net_services="${net_services} ${x##*/}" |
24008 |
+ done |
24009 |
+ else |
24010 |
+ for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ |
24011 |
+ $(dolisting "/etc/runlevels/${SOFTLEVEL}/net.*") \ |
24012 |
+ $(dolisting "/etc/runlevels/coldplugged/net.*") ; do |
24013 |
+ net_services="${net_services} ${x##*/}" |
24014 |
+ done |
24015 |
+ fi |
24016 |
+ |
24017 |
+ # Cache the generic "net" depends |
24018 |
+ net_deps=( $( ineed net ) $( valid_iuse net ) ) |
24019 |
+ if is_runlevel_start || is_runlevel_stop ; then |
24020 |
+ net_deps=( "${net_deps[@]}" $( valid_iafter net ) ) |
24021 |
+ fi |
24022 |
+ |
24023 |
+ # OK, this is a topological sort |
24024 |
+ # The bonus about doing it in bash is that we can calculate our sort |
24025 |
+ # order as we calculate our dependencies |
24026 |
+ local -a visited sorted |
24027 |
+ visit_service() { |
24028 |
+ local service="$1" dep x |
24029 |
+ local -a deps |
24030 |
+ |
24031 |
+ [[ " ${visited[@]} " == *" ${service} "* ]] && return |
24032 |
+ visited=( "${visited[@]}" "${service}" ) |
24033 |
+ |
24034 |
+ if [[ -n ${deptype} ]] ; then |
24035 |
+ deps=( $( "${deptype}" "${service}" ) ) |
24036 |
+ else |
24037 |
+ deps=( $( ineed "${service}" ) $( valid_iuse "${service}" ) ) |
24038 |
+ if is_runlevel_start || is_runlevel_stop ; then |
24039 |
+ deps=( "${deps[@]}" $( valid_iafter "${service}" ) ) |
24040 |
+ fi |
24041 |
+ |
24042 |
+ # If we're a net service, we have to get deps for ourself |
24043 |
+ # and the net service as we're both |
24044 |
+ net_service "${service}" && deps=( "${deps[@]}" "${net_deps[@]}" ) |
24045 |
+ |
24046 |
+ x=" ${deps[@]} " |
24047 |
+ deps=( "${deps[@]}" ${x// net / ${net_services} } ) |
24048 |
+ fi |
24049 |
+ |
24050 |
+ services=( "${services[@]}" "${deps[@]}" ) |
24051 |
+ for dep in ${deps[@]}; do |
24052 |
+ visit_service "${dep}" |
24053 |
+ done |
24054 |
+ sorted=( "${sorted[@]}" "${service}" ) |
24055 |
+ } |
24056 |
+ |
24057 |
+ for (( i=0; i<${#services[@]}; i++)); do |
24058 |
+ visit_service "${services[i]}" |
24059 |
+ done |
24060 |
+ |
24061 |
+ services=( "${sorted[@]}" ) |
24062 |
+ |
24063 |
+ if [[ -n ${deptype} ]] ; then |
24064 |
+ # If deptype is set, we do not want the name of this service |
24065 |
+ x=" ${services[@]} " |
24066 |
+ services=( ${x// ${SVCNAME} / } ) |
24067 |
+ |
24068 |
+ # If its a net service, do not include "net" |
24069 |
+ if net_service "${SVCNAME}" ; then |
24070 |
+ x=" ${services[@]} " |
24071 |
+ sorted=( ${services// net / } ) |
24072 |
+ fi |
24073 |
+ fi |
24074 |
+ |
24075 |
+ echo "${services[@]}" |
24076 |
+} |
24077 |
+ |
24078 |
+# bool query_before(service1, service2) |
24079 |
+# |
24080 |
+# Return true if 'service2' should be started *before* |
24081 |
+# service1. |
24082 |
+# |
24083 |
+query_before() { |
24084 |
+ local x list |
24085 |
+ local netservice="no" |
24086 |
+ |
24087 |
+ [[ -z $1 || -z $2 ]] && return 1 |
24088 |
+ |
24089 |
+ list="$( trace_dependencies "$1" )" |
24090 |
+ |
24091 |
+ net_service "$2" && netservice="yes" |
24092 |
+ |
24093 |
+ for x in ${list} ; do |
24094 |
+ [[ ${x} == "$2" ]] && return 0 |
24095 |
+ |
24096 |
+ # Also match "net" if this is a network service ... |
24097 |
+ [[ ${netservice} == "yes" && ${x} == "net" ]] && return 0 |
24098 |
+ done |
24099 |
+ |
24100 |
+ return 1 |
24101 |
+} |
24102 |
+ |
24103 |
+# vim:ts=4 |
24104 |
|
24105 |
|
24106 |
Property changes on: trunk/baselayout-prefix/sbin/rc-services.sh |
24107 |
___________________________________________________________________ |
24108 |
Added: svn:executable |
24109 |
+ * |
24110 |
|
24111 |
Added: trunk/baselayout-prefix/sbin/rc-update |
24112 |
=================================================================== |
24113 |
--- trunk/baselayout-prefix/sbin/rc-update (rev 0) |
24114 |
+++ trunk/baselayout-prefix/sbin/rc-update 2011-03-31 14:11:17 UTC (rev 1682) |
24115 |
@@ -0,0 +1,238 @@ |
24116 |
+#!/bin/bash |
24117 |
+# Copyright 1999-2006 Gentoo Foundation |
24118 |
+# Distributed under the terms of the GNU General Public License v2 |
24119 |
+ |
24120 |
+source /sbin/functions.sh |
24121 |
+esyslog() { :; } |
24122 |
+ |
24123 |
+argv0=${0##*/} |
24124 |
+ |
24125 |
+usage() { |
24126 |
+cat << FOO |
24127 |
+usage: ${argv0} -a|add script runlevel1 [runlevel2 ...] |
24128 |
+ ${argv0} -d|del script [runlevel1 ...] |
24129 |
+ ${argv0} -s|show [-v|--verbose] [runlevel1 ...] |
24130 |
+ |
24131 |
+examples: |
24132 |
+ # ${argv0} add net.eth0 default |
24133 |
+ Adds the net.eth0 script (in /etc/init.d) to the "default" runlevel. |
24134 |
+ |
24135 |
+ # ${argv0} del sysklogd |
24136 |
+ Deletes the sysklogd script from all runlevels. The original script |
24137 |
+ is not deleted, just any symlinks to the script in /etc/runlevels/*. |
24138 |
+ |
24139 |
+ # ${argv0} del net.eth2 default wumpus |
24140 |
+ Delete the net.eth2 script from the default and wumpus runlevels. |
24141 |
+ All other runlevels are unaffected. Again, the net.eth2 script |
24142 |
+ residing in /etc/init.d is not deleted, just any symlinks in |
24143 |
+ /etc/runlevels/default and /etc/runlevels/wumpus. |
24144 |
+ |
24145 |
+ # ${argv0} show |
24146 |
+ Show all enabled scripts and list at which runlevels they will |
24147 |
+ execute. Run with --verbose to see all available scripts. |
24148 |
+FOO |
24149 |
+ exit ${1:-0} |
24150 |
+} |
24151 |
+ |
24152 |
+add() { |
24153 |
+ local ret=0 |
24154 |
+ local x= |
24155 |
+ local myscript= |
24156 |
+ |
24157 |
+ if [[ $# -lt 2 ]] ; then |
24158 |
+ eerror "Usage: ${argv0} add <script> runlevel1 [runlevel2 ...]" 1>&2 |
24159 |
+ exit 1 |
24160 |
+ fi |
24161 |
+ |
24162 |
+ [[ ${quiet} -gt 0 ]] && exec 2> /dev/null |
24163 |
+ |
24164 |
+ myscript=$1 |
24165 |
+ if [[ ! -e ${ROOT}/etc/init.d/${myscript} ]] ; then |
24166 |
+ eerror "${argv0}: '${ROOT}etc/init.d/${myscript}' not found; aborting" 1>&2 |
24167 |
+ exit 1 |
24168 |
+ fi |
24169 |
+ shift |
24170 |
+ for x in $* ; do |
24171 |
+ if [[ ! -e ${ROOT}etc/runlevels/${x} ]] ; then |
24172 |
+ ewarn "runlevel '${x}' not found; skipping" 1>&2 |
24173 |
+ ((++ret)) |
24174 |
+ continue |
24175 |
+ fi |
24176 |
+ if [[ -L ${ROOT}etc/runlevels/${x}/${myscript} ]] ; then |
24177 |
+ ewarn "${myscript} already installed in runlevel '${x}'; skipping" 1>&2 |
24178 |
+ continue |
24179 |
+ fi |
24180 |
+ if [[ ! -x ${ROOT}etc/init.d/${myscript} ]] ; then |
24181 |
+ ewarn "${myscript} not executable; skipping" 1>&2 |
24182 |
+ ((++ret)) |
24183 |
+ continue |
24184 |
+ fi |
24185 |
+ ln -snf "/etc/init.d/${myscript}" "${ROOT}etc/runlevels/${x}/${myscript}" |
24186 |
+ if [[ $? -ne 0 ]] ; then |
24187 |
+ eerror "${argv0}: failed to add '${myscript}' to '${x}'" 1>&2 |
24188 |
+ ((++ret)) |
24189 |
+ continue |
24190 |
+ fi |
24191 |
+ einfo "${myscript} added to runlevel ${x}" |
24192 |
+ done |
24193 |
+ |
24194 |
+ return ${ret} |
24195 |
+} |
24196 |
+ |
24197 |
+del() { |
24198 |
+ local x= |
24199 |
+ local mylevels= |
24200 |
+ local myscript= |
24201 |
+ local remlevels= |
24202 |
+ |
24203 |
+ if [[ $# -lt 1 ]] ; then |
24204 |
+ eerror "Usage: ${argv0} del <script> [runlevel1 ...]" 1>&2 |
24205 |
+ exit 1 |
24206 |
+ fi |
24207 |
+ |
24208 |
+ [[ ${quiet} -gt 0 ]] && exec 2> /dev/null |
24209 |
+ |
24210 |
+ myscript=$1 |
24211 |
+ shift |
24212 |
+ if [[ $# -eq 0 ]] ; then |
24213 |
+ mylevels=$(cd "${ROOT}"etc/runlevels/; ls) |
24214 |
+ else |
24215 |
+ mylevels="$*" |
24216 |
+ fi |
24217 |
+ remlevels="" |
24218 |
+ for x in ${mylevels} ; do |
24219 |
+ # -e will return false for broken symlinks so we need the extra -L |
24220 |
+ [[ ! -L ${ROOT}etc/runlevels/${x}/${myscript} ]] && \ |
24221 |
+ [[ ! -e ${ROOT}etc/runlevels/${x}/${myscript} ]] && continue |
24222 |
+ |
24223 |
+ remlevels="${remlevels} ${x}" |
24224 |
+ if [[ ! -L ${ROOT}etc/runlevels/${x}/${myscript} ]] ; then |
24225 |
+ ewarn "Removing invalid init.d script: '${ROOT}etc/runlevels/${x}/${myscript}'" 1>&2 |
24226 |
+ fi |
24227 |
+ rm -f "${ROOT}etc/runlevels/${x}/${myscript}" |
24228 |
+ ((ret+=$?)) |
24229 |
+ done |
24230 |
+ if [[ -z ${remlevels} ]] ; then |
24231 |
+ ewarn "'${myscript}' not found in any of the specified runlevels" 1>&2 |
24232 |
+ elif [[ ${quiet} -eq 0 ]] ; then |
24233 |
+ einfo "'${myscript}' removed from the following runlevels:${remlevels}" |
24234 |
+ fi |
24235 |
+ return ${ret} |
24236 |
+} |
24237 |
+ |
24238 |
+show() { |
24239 |
+ local x= |
24240 |
+ local y= |
24241 |
+ local mylevels= |
24242 |
+ local myscripts= |
24243 |
+ |
24244 |
+ shopt -s nullglob |
24245 |
+ if [[ $# -eq 0 ]] ; then |
24246 |
+ mylevels=$(cd "${ROOT}"etc/runlevels/; ls) |
24247 |
+ else |
24248 |
+ mylevels="$*" |
24249 |
+ # verify runlevels provided by user |
24250 |
+ for y in ${mylevels} ; do |
24251 |
+ [[ ! -d ${ROOT}etc/runlevels/${y} ]] && ewarn "Runlevel doesn't exist: ${y}" |
24252 |
+ done |
24253 |
+ fi |
24254 |
+ myscripts=$(cd "${ROOT}"etc/init.d; ls) |
24255 |
+ |
24256 |
+ # Sanity check to make sure everything is kosher ... |
24257 |
+ for x in $(find "${ROOT}"etc/runlevels -xtype l) ; do |
24258 |
+ ewarn "Broken runlevel entry: ${x}" |
24259 |
+ done |
24260 |
+ for x in $(find "${ROOT}"etc/runlevels ! -type l -a ! -type d) ; do |
24261 |
+ ewarn "Invalid runlevel entry: ${x}" |
24262 |
+ done |
24263 |
+ |
24264 |
+ for x in ${myscripts} ; do |
24265 |
+ # skip *.sh scripts as they are helpers, not init.d scripts |
24266 |
+ [[ ${x} == *.sh ]] && continue |
24267 |
+ |
24268 |
+ # unless we are running in verbose mode, don't display scripts |
24269 |
+ # that aren't in any runlevels that we are examining |
24270 |
+ if [[ ${verbose} -eq 0 ]] ; then |
24271 |
+ local found_it=0 |
24272 |
+ for y in ${mylevels} ; do |
24273 |
+ if [[ -L ${ROOT}etc/runlevels/${y}/${x} ]] ; then |
24274 |
+ found_it=1 |
24275 |
+ break |
24276 |
+ fi |
24277 |
+ done |
24278 |
+ [[ ${found_it} -eq 0 ]] && continue |
24279 |
+ fi |
24280 |
+ |
24281 |
+ # ok, let's show this script already ! |
24282 |
+ printf "%20s | " ${x:0:19} |
24283 |
+ for y in ${mylevels} ; do |
24284 |
+ if [[ -L ${ROOT}etc/runlevels/${y}/${x} ]] ; then |
24285 |
+ echo -n "${y} " |
24286 |
+ else |
24287 |
+ printf "%${#y}s " " " |
24288 |
+ fi |
24289 |
+ done |
24290 |
+ echo "" |
24291 |
+ done |
24292 |
+} |
24293 |
+ |
24294 |
+check_is_root() { |
24295 |
+ if [[ ${EUID} -ne 0 ]] ; then |
24296 |
+ eerror "${argv0}: must be root to complete this operation" 1>&2 |
24297 |
+ exit 1 |
24298 |
+ fi |
24299 |
+} |
24300 |
+ |
24301 |
+export ROOT=${ROOT%/}/ |
24302 |
+[[ ${ROOT} != "/" ]] && einfo "Working with files in root ${ROOT} ..." |
24303 |
+ |
24304 |
+verbose=0 |
24305 |
+quiet=0 |
24306 |
+action="" |
24307 |
+opts="" |
24308 |
+check_root=0 |
24309 |
+ |
24310 |
+[[ ${RC_VERBOSE} == "yes" ]] && ((++verbose)) |
24311 |
+ |
24312 |
+while [[ -n $* ]] ; do |
24313 |
+ case "$1" in |
24314 |
+ add|-a) |
24315 |
+ check_root=1 |
24316 |
+ action="add" |
24317 |
+ ;; |
24318 |
+ del|delete|-d) |
24319 |
+ check_root=1 |
24320 |
+ action="del" |
24321 |
+ ;; |
24322 |
+ show|-s) |
24323 |
+ action="show" |
24324 |
+ ;; |
24325 |
+ help|-h|--help) |
24326 |
+ usage 0 |
24327 |
+ ;; |
24328 |
+ verbose|-v|--verbose) |
24329 |
+ ((++verbose)) |
24330 |
+ ;; |
24331 |
+ quiet|-q|--quiet) |
24332 |
+ ((++quiet)) |
24333 |
+ ;; |
24334 |
+ -*) |
24335 |
+ echo -e "${argv0}: Unknown option $1\n" 1>&2 |
24336 |
+ usage 1 |
24337 |
+ ;; |
24338 |
+ *) |
24339 |
+ opts="${opts} $1" |
24340 |
+ ;; |
24341 |
+ esac |
24342 |
+ shift |
24343 |
+done |
24344 |
+ |
24345 |
+if [[ -z ${action} ]] ; then |
24346 |
+ eerror "${argv0}: gimme something to do!" 1>&2 |
24347 |
+ usage 1 |
24348 |
+fi |
24349 |
+ |
24350 |
+[[ ${check_root} -eq 1 ]] && check_is_root |
24351 |
+${action} ${opts} |
24352 |
+ |
24353 |
+# vim:ts=4 |
24354 |
|
24355 |
|
24356 |
Property changes on: trunk/baselayout-prefix/sbin/rc-update |
24357 |
___________________________________________________________________ |
24358 |
Added: svn:executable |
24359 |
+ * |
24360 |
|
24361 |
Added: trunk/baselayout-prefix/sbin/runscript.sh |
24362 |
=================================================================== |
24363 |
--- trunk/baselayout-prefix/sbin/runscript.sh (rev 0) |
24364 |
+++ trunk/baselayout-prefix/sbin/runscript.sh 2011-03-31 14:11:17 UTC (rev 1682) |
24365 |
@@ -0,0 +1,696 @@ |
24366 |
+#!/bin/bash |
24367 |
+# Copyright 1999-2006 Gentoo Foundation |
24368 |
+# Distributed under the terms of the GNU General Public License v2 |
24369 |
+ |
24370 |
+# Common functions |
24371 |
+[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh |
24372 |
+ |
24373 |
+# User must be root to run most script stuff (except status) |
24374 |
+if [[ ${EUID} != "0" ]] && ! [[ $2 == "status" && $# -eq 2 ]] ; then |
24375 |
+ eerror "$0: must be root to run init scripts" |
24376 |
+ exit 1 |
24377 |
+fi |
24378 |
+ |
24379 |
+myscript="$1" |
24380 |
+if [[ -L $1 && ! -L "/etc/init.d/${1##*/}" ]] ; then |
24381 |
+ SVCNAME="$(readlink "$1")" |
24382 |
+else |
24383 |
+ SVCNAME="$1" |
24384 |
+fi |
24385 |
+ |
24386 |
+declare -r SVCNAME="${SVCNAME##*/}" |
24387 |
+export SVCNAME |
24388 |
+# Support deprecated myservice variable |
24389 |
+myservice="${SVCNAME}" |
24390 |
+ |
24391 |
+svc_trap() { |
24392 |
+ trap 'eerror "ERROR: ${SVCNAME} caught an interrupt"; exit 1' \ |
24393 |
+ INT QUIT TSTP |
24394 |
+} |
24395 |
+ |
24396 |
+# Setup a default trap |
24397 |
+svc_trap |
24398 |
+ |
24399 |
+# coldplug events can trigger init scripts, but we don't want to run them |
24400 |
+# until after rc sysinit has completed so we punt them to the boot runlevel |
24401 |
+if [[ -e /dev/.rcsysinit ]] ; then |
24402 |
+ eerror "ERROR: cannot run ${SVCNAME} until sysinit completes" |
24403 |
+ [[ ${RC_COLDPLUG:-yes} != "yes" ]] && exit 1 |
24404 |
+ set -f |
24405 |
+ for x in ${RC_PLUG_SERVICES} ; do |
24406 |
+ [[ ${SVCNAME} == ${x} ]] && break |
24407 |
+ [[ "!${SVCNAME}" == ${x} ]] && exit 1 |
24408 |
+ done |
24409 |
+ eerror "${SVCNAME} will be started in the ${BOOTLEVEL} runlevel" |
24410 |
+ if [[ ! -L /dev/.rcboot/"${SVCNAME}" ]] ; then |
24411 |
+ [[ ! -d /dev/.rcboot ]] && mkdir /dev/.rcboot |
24412 |
+ ln -snf "$1" /dev/.rcboot/"${SVCNAME}" |
24413 |
+ fi |
24414 |
+ exit 1 |
24415 |
+fi |
24416 |
+ |
24417 |
+# Only hotplug if we're allowed to |
24418 |
+if [[ ${IN_HOTPLUG} == "1" ]] ; then |
24419 |
+ if [[ ${RC_HOTPLUG:-yes} != "yes" ]] ; then |
24420 |
+ eerror "${SVCNAME} is not allowed to be hotplugged" |
24421 |
+ exit 1 |
24422 |
+ fi |
24423 |
+ |
24424 |
+ set -f |
24425 |
+ for x in ${RC_PLUG_SERVICES} ; do |
24426 |
+ [[ ${SVCNAME} == ${x} ]] && break |
24427 |
+ if [[ "!${SVCNAME}" == ${x} ]] ; then |
24428 |
+ eerror "${SVCNAME} is not allowed to be hotplugged" |
24429 |
+ exit 1 |
24430 |
+ fi |
24431 |
+ done |
24432 |
+ set +f |
24433 |
+fi |
24434 |
+ |
24435 |
+# State variables |
24436 |
+svcpause="no" |
24437 |
+svcrestart="no" |
24438 |
+ |
24439 |
+# Functions to handle dependencies and services |
24440 |
+[[ ${RC_GOT_SERVICES} != "yes" ]] && source "${svclib}/sh/rc-services.sh" |
24441 |
+# Functions to control daemons |
24442 |
+[[ ${RC_GOT_DAEMON} != "yes" ]] && source "${svclib}/sh/rc-daemon.sh" |
24443 |
+ |
24444 |
+# Source configuration files. |
24445 |
+# (1) Source /etc/conf.d/net if it is a net.* service |
24446 |
+# (2) Source /etc/conf.d/${SVCNAME} to get initscript-specific |
24447 |
+# configuration (if it exists). |
24448 |
+# (3) Source /etc/rc.conf to pick up potentially overriding |
24449 |
+# configuration, if the system administrator chose to put it |
24450 |
+# there (if it exists). |
24451 |
+if net_service "${SVCNAME}" ; then |
24452 |
+ conf="$(add_suffix /etc/conf.d/net)" |
24453 |
+ [[ -e ${conf} ]] && source "${conf}" |
24454 |
+fi |
24455 |
+conf="$(add_suffix "/etc/conf.d/${SVCNAME}")" |
24456 |
+[[ -e ${conf} ]] && source "${conf}" |
24457 |
+conf="$(add_suffix /etc/rc.conf)" |
24458 |
+[[ -e ${conf} ]] && source "${conf}" |
24459 |
+ |
24460 |
+mylevel="${SOFTLEVEL}" |
24461 |
+[[ ${SOFTLEVEL} == "${BOOTLEVEL}" \ |
24462 |
+ || ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] \ |
24463 |
+ && mylevel="${DEFAULTLEVEL}" |
24464 |
+ |
24465 |
+# Call svc_quit if we abort AND we have obtained a lock |
24466 |
+service_started "${SVCNAME}" |
24467 |
+svcstarted="$?" |
24468 |
+service_inactive "${SVCNAME}" |
24469 |
+svcinactive="$?" |
24470 |
+svc_quit() { |
24471 |
+ eerror "ERROR: ${SVCNAME} caught an interrupt" |
24472 |
+ if service_inactive "${SVCNAME}" || [[ ${svcinactive} == "0" ]] ; then |
24473 |
+ mark_service_inactive "${SVCNAME}" |
24474 |
+ elif [[ ${svcstarted} == "0" ]] ; then |
24475 |
+ mark_service_started "${SVCNAME}" |
24476 |
+ else |
24477 |
+ mark_service_stopped "${SVCNAME}" |
24478 |
+ fi |
24479 |
+ exit 1 |
24480 |
+} |
24481 |
+ |
24482 |
+usage() { |
24483 |
+ local IFS="|" |
24484 |
+ myline="Usage: ${SVCNAME} { $* " |
24485 |
+ echo |
24486 |
+ eerror "${myline}}" |
24487 |
+ eerror " ${SVCNAME} without arguments for full help" |
24488 |
+} |
24489 |
+ |
24490 |
+stop() { |
24491 |
+ # Return success so the symlink gets removed |
24492 |
+ return 0 |
24493 |
+} |
24494 |
+ |
24495 |
+start() { |
24496 |
+ eerror "ERROR: ${SVCNAME} does not have a start function." |
24497 |
+ # Return failure so the symlink doesn't get created |
24498 |
+ return 1 |
24499 |
+} |
24500 |
+ |
24501 |
+restart() { |
24502 |
+ svc_restart |
24503 |
+} |
24504 |
+ |
24505 |
+status() { |
24506 |
+ # Dummy function |
24507 |
+ return 0 |
24508 |
+} |
24509 |
+ |
24510 |
+svc_schedule_start() { |
24511 |
+ local service="$1" start="$2" |
24512 |
+ [[ ! -d "${svcdir}/scheduled/${service}" ]] \ |
24513 |
+ && mkdir -p "${svcdir}/scheduled/${service}" |
24514 |
+ ln -snf "/etc/init.d/${service}" \ |
24515 |
+ "${svcdir}/scheduled/${service}/${start}" |
24516 |
+} |
24517 |
+ |
24518 |
+svc_start_scheduled() { |
24519 |
+ [[ ! -d "${svcdir}/scheduled/${SVCNAME}" ]] && return |
24520 |
+ local x= services= |
24521 |
+ |
24522 |
+ for x in $(dolisting "${svcdir}/scheduled/${SVCNAME}/") ; do |
24523 |
+ services="${services} ${x##*/}" |
24524 |
+ done |
24525 |
+ |
24526 |
+ for x in ${services} ; do |
24527 |
+ service_stopped "${x}" && start_service "${x}" |
24528 |
+ rm -f "${svcdir}/scheduled/${SVCNAME}/${x}" |
24529 |
+ done |
24530 |
+ |
24531 |
+ rmdir "${svcdir}/scheduled/${SVCNAME}" |
24532 |
+} |
24533 |
+ |
24534 |
+svc_stop() { |
24535 |
+ local x= mydep= mydeps= retval=0 |
24536 |
+ local -a servicelist=() |
24537 |
+ |
24538 |
+ # Do not try to stop if it had already failed to do so |
24539 |
+ if is_runlevel_stop && service_failed "${SVCNAME}" ; then |
24540 |
+ return 1 |
24541 |
+ elif service_stopped "${SVCNAME}" ; then |
24542 |
+ ewarn "WARNING: ${SVCNAME} has not yet been started." |
24543 |
+ return 0 |
24544 |
+ fi |
24545 |
+ if ! mark_service_stopping "${SVCNAME}" ; then |
24546 |
+ eerror "ERROR: ${SVCNAME} is already stopping." |
24547 |
+ return 1 |
24548 |
+ fi |
24549 |
+ |
24550 |
+ # Ensure that we clean up if we abort for any reason |
24551 |
+ trap "svc_quit" INT QUIT TSTP |
24552 |
+ |
24553 |
+ mark_service_starting "${SVCNAME}" |
24554 |
+ service_message "Service ${SVCNAME} stopping" |
24555 |
+ |
24556 |
+ if in_runlevel "${SVCNAME}" "${BOOTLEVEL}" && \ |
24557 |
+ [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" && \ |
24558 |
+ ${SOFTLEVEL} != "single" ]] ; then |
24559 |
+ ewarn "WARNING: you are stopping a boot service." |
24560 |
+ fi |
24561 |
+ |
24562 |
+ if [[ ${svcpause} != "yes" && ${RC_NO_DEPS} != "yes" ]] \ |
24563 |
+ && ! service_wasinactive "${SVCNAME}" ; then |
24564 |
+ if net_service "${SVCNAME}" ; then |
24565 |
+ if is_runlevel_stop || ! is_net_up "${SVCNAME}" ; then |
24566 |
+ mydeps="net" |
24567 |
+ fi |
24568 |
+ fi |
24569 |
+ mydeps="${mydeps} ${SVCNAME}" |
24570 |
+ fi |
24571 |
+ |
24572 |
+ # Save the IN_BACKGROUND var as we need to clear it for stopping depends |
24573 |
+ local ib_save="${IN_BACKGROUND}" |
24574 |
+ unset IN_BACKGROUND |
24575 |
+ |
24576 |
+ for mydep in ${mydeps} ; do |
24577 |
+ for x in $(needsme "${mydep}") ; do |
24578 |
+ if service_started "${x}" || service_inactive "${x}" ; then |
24579 |
+ stop_service "${x}" |
24580 |
+ fi |
24581 |
+ service_list=( "${service_list[@]}" "${x}" ) |
24582 |
+ done |
24583 |
+ done |
24584 |
+ |
24585 |
+ for x in "${service_list[@]}" ; do |
24586 |
+ service_stopped "${x}" && continue |
24587 |
+ wait_service "${x}" |
24588 |
+ if ! service_stopped "${x}" ; then |
24589 |
+ eerror "ERROR: cannot stop ${SVCNAME} as ${x} is still up." |
24590 |
+ retval=1 |
24591 |
+ break |
24592 |
+ fi |
24593 |
+ done |
24594 |
+ |
24595 |
+ IN_BACKGROUND="${ib_save}" |
24596 |
+ |
24597 |
+ if [[ ${retval} == "0" ]] ; then |
24598 |
+ # Now that deps are stopped, stop our service |
24599 |
+ ( |
24600 |
+ exit() { |
24601 |
+ RC_QUIET_STDOUT="no" |
24602 |
+ eerror "DO NOT USE EXIT IN INIT.D SCRIPTS" |
24603 |
+ eerror "This IS a bug, please fix your broken init.d" |
24604 |
+ unset -f exit |
24605 |
+ exit "$@" |
24606 |
+ } |
24607 |
+ # Stop einfo/ebegin/eend from working as parallel messes us up |
24608 |
+ if [[ ${RC_PARALLEL_STARTUP} == "yes" ]] ; then |
24609 |
+ [[ ${RC_VERBOSE} != "yes" \ |
24610 |
+ || -e ${svcdir}/exclusive/${SVCNAME} ]] \ |
24611 |
+ && RC_QUIET_STDOUT="yes" |
24612 |
+ fi |
24613 |
+ stop |
24614 |
+ ) |
24615 |
+ retval="$?" |
24616 |
+ |
24617 |
+ # If a service has been marked inactive, exit now as something |
24618 |
+ # may attempt to start it again later |
24619 |
+ if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then |
24620 |
+ svcinactive=0 |
24621 |
+ return 0 |
24622 |
+ fi |
24623 |
+ fi |
24624 |
+ |
24625 |
+ if [[ ${retval} != 0 ]] ; then |
24626 |
+ # Did we fail to stop? create symlink to stop multible attempts at |
24627 |
+ # runlevel change. Note this is only used at runlevel change ... |
24628 |
+ is_runlevel_stop && mark_service_failed "${SVCNAME}" |
24629 |
+ |
24630 |
+ # If we are halting the system, do it as cleanly as possible |
24631 |
+ if [[ ${SOFTLEVEL} == "reboot" || ${SOFTLEVEL} == "shutdown" ]] ; then |
24632 |
+ mark_service_stopped "${SVCNAME}" |
24633 |
+ else |
24634 |
+ if [[ ${svcinactive} == "0" ]] ; then |
24635 |
+ mark_service_inactive "${SVCNAME}" |
24636 |
+ else |
24637 |
+ mark_service_started "${SVCNAME}" |
24638 |
+ fi |
24639 |
+ fi |
24640 |
+ |
24641 |
+ service_message "eerror" "ERROR: ${SVCNAME} failed to stop" |
24642 |
+ else |
24643 |
+ svcstarted=1 |
24644 |
+ if service_inactive "${SVCNAME}" ; then |
24645 |
+ svcinactive=0 |
24646 |
+ else |
24647 |
+ mark_service_stopped "${SVCNAME}" |
24648 |
+ fi |
24649 |
+ service_message "Service ${SVCNAME} stopped" |
24650 |
+ fi |
24651 |
+ |
24652 |
+ # Reset the trap |
24653 |
+ svc_trap |
24654 |
+ |
24655 |
+ return "${retval}" |
24656 |
+} |
24657 |
+ |
24658 |
+svc_start() { |
24659 |
+ local x= y= retval=0 startinactive= |
24660 |
+ |
24661 |
+ # Do not try to start if i have done so already on runlevel change |
24662 |
+ if is_runlevel_start && service_failed "${SVCNAME}" ; then |
24663 |
+ return 1 |
24664 |
+ elif service_started "${SVCNAME}" ; then |
24665 |
+ ewarn "WARNING: ${SVCNAME} has already been started." |
24666 |
+ return 0 |
24667 |
+ elif service_inactive "${SVCNAME}" ; then |
24668 |
+ if [[ ${IN_BACKGROUND} != "true" ]] ; then |
24669 |
+ ewarn "WARNING: ${SVCNAME} has already been started." |
24670 |
+ return 0 |
24671 |
+ fi |
24672 |
+ fi |
24673 |
+ |
24674 |
+ if ! mark_service_starting "${SVCNAME}" ; then |
24675 |
+ if service_stopping "${SVCNAME}" ; then |
24676 |
+ eerror "ERROR: ${SVCNAME} is already stopping." |
24677 |
+ else |
24678 |
+ eerror "ERROR: ${SVCNAME} is already starting." |
24679 |
+ fi |
24680 |
+ return 1 |
24681 |
+ fi |
24682 |
+ |
24683 |
+ # Ensure that we clean up if we abort for any reason |
24684 |
+ trap "svc_quit" INT QUIT TSTP |
24685 |
+ |
24686 |
+ service_message "Service ${SVCNAME} starting" |
24687 |
+ |
24688 |
+ if broken "${SVCNAME}" ; then |
24689 |
+ eerror "ERROR: Some services needed are missing. Run" |
24690 |
+ eerror " './${SVCNAME} broken' for a list of those" |
24691 |
+ eerror " services. ${SVCNAME} was not started." |
24692 |
+ retval=1 |
24693 |
+ fi |
24694 |
+ |
24695 |
+ # Save the IN_BACKGROUND var as we need to clear it for starting depends |
24696 |
+ local ib_save="${IN_BACKGROUND}" |
24697 |
+ unset IN_BACKGROUND |
24698 |
+ |
24699 |
+ if [[ ${retval} == "0" && ${RC_NO_DEPS} != "yes" ]] ; then |
24700 |
+ local startupservices="$(ineed "${SVCNAME}") $(valid_iuse "${SVCNAME}")" |
24701 |
+ local netservices= |
24702 |
+ for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ |
24703 |
+ $(dolisting "/etc/runlevels/${mylevel}/net.*") \ |
24704 |
+ $(dolisting "/var/lib/init.d/coldplugged/net.*") ; do |
24705 |
+ netservices="${netservices} ${x##*/}" |
24706 |
+ done |
24707 |
+ |
24708 |
+ # Start dependencies, if any. |
24709 |
+ if ! is_runlevel_start ; then |
24710 |
+ for x in ${startupservices} ; do |
24711 |
+ if [[ ${x} == "net" ]] && ! net_service "${SVCNAME}" \ |
24712 |
+ && ! is_net_up ; then |
24713 |
+ for y in ${netservices} ; do |
24714 |
+ service_stopped "${y}" && start_service "${y}" |
24715 |
+ done |
24716 |
+ elif [[ ${x} != "net" ]] ; then |
24717 |
+ service_stopped "${x}" && start_service "${x}" |
24718 |
+ fi |
24719 |
+ done |
24720 |
+ fi |
24721 |
+ |
24722 |
+ # We also wait for any services we're after to finish incase they |
24723 |
+ # have a "before" dep but we don't dep on them. |
24724 |
+ if is_runlevel_start ; then |
24725 |
+ startupservices="${startupservices} $(valid_iafter "${SVCNAME}")" |
24726 |
+ if net_service "${SVCNAME}" ; then |
24727 |
+ startupservices="${startupservices} $(valid_iafter "net")" |
24728 |
+ fi |
24729 |
+ fi |
24730 |
+ |
24731 |
+ if [[ " ${startupservices} " == *" net "* ]] ; then |
24732 |
+ startupservices=" ${startupservices} " |
24733 |
+ startupservices="${startupservices/ net / ${netservices} }" |
24734 |
+ startupservices="${startupservices// net /}" |
24735 |
+ fi |
24736 |
+ |
24737 |
+ # Wait for dependencies to finish. |
24738 |
+ for x in ${startupservices} ; do |
24739 |
+ service_started "${x}" && continue |
24740 |
+ wait_service "${x}" |
24741 |
+ if ! service_started "${x}" ; then |
24742 |
+ # A 'need' dependency is critical for startup |
24743 |
+ if ineed -t "${SVCNAME}" "${x}" >/dev/null \ |
24744 |
+ || ( net_service "${x}" && ineed -t "${SVCNAME}" net \ |
24745 |
+ && ! is_net_up ) ; then |
24746 |
+ if service_inactive "${x}" || service_wasinactive "${x}" || \ |
24747 |
+ [[ -n $(dolisting "${svcdir}"/scheduled/*/"${x}") ]] ; then |
24748 |
+ svc_schedule_start "${x}" "${SVCNAME}" |
24749 |
+ [[ -n ${startinactive} ]] && startinactive="${startinactive}, " |
24750 |
+ startinactive="${startinactive}${x}" |
24751 |
+ else |
24752 |
+ eerror "ERROR: cannot start ${SVCNAME} as ${x} could not start" |
24753 |
+ retval=1 |
24754 |
+ break |
24755 |
+ fi |
24756 |
+ fi |
24757 |
+ fi |
24758 |
+ done |
24759 |
+ |
24760 |
+ if [[ -n ${startinactive} && ${retval} == "0" ]] ; then |
24761 |
+ # Change the last , to or for correct grammar. |
24762 |
+ x="${startinactive##*, }" |
24763 |
+ startinactive="${startinactive/%, ${x}/ or ${x}}" |
24764 |
+ ewarn "WARNING: ${SVCNAME} is scheduled to start when ${startinactive} has started." |
24765 |
+ retval=1 |
24766 |
+ fi |
24767 |
+ fi |
24768 |
+ |
24769 |
+ if [[ ${retval} == "0" ]] ; then |
24770 |
+ IN_BACKGROUND="${ib_save}" |
24771 |
+ ( |
24772 |
+ exit() { |
24773 |
+ RC_QUIET_STDOUT="no" |
24774 |
+ eerror "DO NOT USE EXIT IN INIT.D SCRIPTS" |
24775 |
+ eerror "This IS a bug, please fix your broken init.d" |
24776 |
+ unset -f exit |
24777 |
+ exit "$@" |
24778 |
+ } |
24779 |
+ |
24780 |
+ # Apply any ulimits if defined |
24781 |
+ [[ -n ${RC_ULIMIT} ]] && ulimit ${RC_ULIMIT} |
24782 |
+ |
24783 |
+ # Stop einfo/ebegin/eend from working as parallel messes us up |
24784 |
+ if [[ ${RC_PARALLEL_STARTUP} == "yes" ]] ; then |
24785 |
+ [[ ${RC_VERBOSE} != "yes" \ |
24786 |
+ || -e ${svcdir}/exclusive/${SVCNAME} ]] \ |
24787 |
+ && RC_QUIET_STDOUT="yes" |
24788 |
+ fi |
24789 |
+ |
24790 |
+ start |
24791 |
+ ) |
24792 |
+ retval="$?" |
24793 |
+ |
24794 |
+ # If a service has been marked inactive, exit now as something |
24795 |
+ # may attempt to start it again later |
24796 |
+ if [[ ${retval} == "0" ]] && service_inactive "${SVCNAME}" ; then |
24797 |
+ svcinactive=0 |
24798 |
+ service_message "ewarn" "WARNING: ${SVCNAME} has started but is inactive" |
24799 |
+ return 1 |
24800 |
+ fi |
24801 |
+ fi |
24802 |
+ |
24803 |
+ if [[ ${retval} != "0" ]] ; then |
24804 |
+ if [[ ${svcinactive} == "0" ]] ; then |
24805 |
+ mark_service_inactive "${SVCNAME}" |
24806 |
+ else |
24807 |
+ mark_service_stopped "${SVCNAME}" |
24808 |
+ fi |
24809 |
+ |
24810 |
+ if [[ -z ${startinactive} ]] ; then |
24811 |
+ is_runlevel_start && mark_service_failed "${SVCNAME}" |
24812 |
+ service_message "eerror" "ERROR: ${SVCNAME} failed to start" |
24813 |
+ fi |
24814 |
+ else |
24815 |
+ svcstarted=0 |
24816 |
+ mark_service_started "${SVCNAME}" |
24817 |
+ service_message "Service ${SVCNAME} started" |
24818 |
+ fi |
24819 |
+ |
24820 |
+ # Reset the trap |
24821 |
+ svc_trap |
24822 |
+ |
24823 |
+ return "${retval}" |
24824 |
+} |
24825 |
+ |
24826 |
+svc_restart() { |
24827 |
+ if ! service_stopped "${SVCNAME}" ; then |
24828 |
+ svc_stop || return "$?" |
24829 |
+ fi |
24830 |
+ svc_start |
24831 |
+} |
24832 |
+ |
24833 |
+svc_status() { |
24834 |
+ # The basic idea here is to have some sort of consistent |
24835 |
+ # output in the status() function which scripts can use |
24836 |
+ # as an generic means to detect status. Any other output |
24837 |
+ # should thus be formatted in the custom status() function |
24838 |
+ # to work with the printed " * status: foo". |
24839 |
+ local efunc="" state="" |
24840 |
+ |
24841 |
+ # If we are effectively root, check to see if required daemons are running |
24842 |
+ # and update our status accordingly |
24843 |
+ [[ ${EUID} == 0 ]] && update_service_status "${SVCNAME}" |
24844 |
+ |
24845 |
+ if service_stopping "${SVCNAME}" ; then |
24846 |
+ efunc="eerror" |
24847 |
+ state="stopping" |
24848 |
+ elif service_starting "${SVCNAME}" ; then |
24849 |
+ efunc="einfo" |
24850 |
+ state="starting" |
24851 |
+ elif service_inactive "${SVCNAME}" ; then |
24852 |
+ efunc="ewarn" |
24853 |
+ state="inactive" |
24854 |
+ elif service_started "${SVCNAME}" ; then |
24855 |
+ efunc="einfo" |
24856 |
+ state="started" |
24857 |
+ else |
24858 |
+ efunc="eerror" |
24859 |
+ state="stopped" |
24860 |
+ fi |
24861 |
+ [[ ${RC_QUIET_STDOUT} != "yes" ]] \ |
24862 |
+ && ${efunc} "status: ${state}" |
24863 |
+ |
24864 |
+ status |
24865 |
+ # Return 0 if started, otherwise 1 |
24866 |
+ [[ ${state} == "started" ]] |
24867 |
+} |
24868 |
+ |
24869 |
+rcscript_errors="$(bash -n "${myscript}" 2>&1)" || { |
24870 |
+ [[ -n ${rcscript_errors} ]] && echo "${rcscript_errors}" >&2 |
24871 |
+ eerror "ERROR: ${myscript} has syntax errors in it; aborting ..." |
24872 |
+ exit 1 |
24873 |
+} |
24874 |
+ |
24875 |
+# set *after* wrap_rcscript, else we get duplicates. |
24876 |
+opts="start stop restart" |
24877 |
+ |
24878 |
+source "${myscript}" |
24879 |
+ |
24880 |
+# make sure whe have valid $opts |
24881 |
+if [[ -z ${opts} ]] ; then |
24882 |
+ opts="start stop restart" |
24883 |
+fi |
24884 |
+ |
24885 |
+svc_homegrown() { |
24886 |
+ local x arg="$1" |
24887 |
+ shift |
24888 |
+ |
24889 |
+ # Walk through the list of available options, looking for the |
24890 |
+ # requested one. |
24891 |
+ for x in ${opts} ; do |
24892 |
+ if [[ ${x} == "${arg}" ]] ; then |
24893 |
+ if typeset -F "${x}" &>/dev/null ; then |
24894 |
+ # Run the homegrown function |
24895 |
+ "${x}" |
24896 |
+ |
24897 |
+ return $? |
24898 |
+ fi |
24899 |
+ fi |
24900 |
+ done |
24901 |
+ x="" |
24902 |
+ |
24903 |
+ # If we're here, then the function wasn't in $opts. |
24904 |
+ [[ -n $* ]] && x="/ $* " |
24905 |
+ eerror "ERROR: wrong args ( "${arg}" ${x})" |
24906 |
+ # Do not quote this either ... |
24907 |
+ usage ${opts} |
24908 |
+ exit 1 |
24909 |
+} |
24910 |
+ |
24911 |
+shift |
24912 |
+if [[ $# -lt 1 ]] ; then |
24913 |
+ eerror "ERROR: not enough args." |
24914 |
+ usage ${opts} |
24915 |
+ exit 1 |
24916 |
+fi |
24917 |
+for arg in $* ; do |
24918 |
+ case "${arg}" in |
24919 |
+ --quiet) |
24920 |
+ RC_QUIET="yes" |
24921 |
+ RC_QUIET_STDOUT="yes" |
24922 |
+ ;; |
24923 |
+# We check this in functions.sh ... |
24924 |
+# --nocolor) |
24925 |
+# RC_NOCOLOR="yes" |
24926 |
+# ;; |
24927 |
+ --nodeps) |
24928 |
+ RC_NO_DEPS="yes" |
24929 |
+ ;; |
24930 |
+ --verbose) |
24931 |
+ RC_VERBOSE="yes" |
24932 |
+ ;; |
24933 |
+ esac |
24934 |
+done |
24935 |
+ |
24936 |
+retval=0 |
24937 |
+for arg in $* ; do |
24938 |
+ case "${arg}" in |
24939 |
+ stop) |
24940 |
+ if [[ -e "${svcdir}/scheduled/${SVCNAME}" ]] ; then |
24941 |
+ rm -Rf "${svcdir}/scheduled/${SVCNAME}" |
24942 |
+ fi |
24943 |
+ |
24944 |
+ # Stoped from the background - treat this as a restart so that |
24945 |
+ # stopped services come back up again when started. |
24946 |
+ if [[ ${IN_BACKGROUND} == "true" ]] ; then |
24947 |
+ rm -rf "${svcdir}/snapshot/$$" |
24948 |
+ mkdir -p "${svcdir}/snapshot/$$" |
24949 |
+ cp -pP "${svcdir}"/started/* "${svcdir}/snapshot/$$/" |
24950 |
+ rm -f "${svcdir}/snapshot/$$/${SVCNAME}" |
24951 |
+ fi |
24952 |
+ |
24953 |
+ svc_stop |
24954 |
+ retval="$?" |
24955 |
+ |
24956 |
+ if [[ ${IN_BACKGROUND} == "true" ]] ; then |
24957 |
+ for x in $(dolisting "${svcdir}/snapshot/$$/") ; do |
24958 |
+ if [[ -x ${x} ]] && service_stopped "${x##*/}" ; then |
24959 |
+ svc_schedule_start "${SVCNAME}" "${x##*/}" |
24960 |
+ fi |
24961 |
+ done |
24962 |
+ rm -rf "${svcdir}/snapshot/$$" |
24963 |
+ else |
24964 |
+ rm -f "${svcdir}"/scheduled/*/"${SVCNAME}" |
24965 |
+ fi |
24966 |
+ |
24967 |
+ ;; |
24968 |
+ start) |
24969 |
+ svc_start |
24970 |
+ retval="$?" |
24971 |
+ service_started "${SVCNAME}" && svc_start_scheduled |
24972 |
+ ;; |
24973 |
+ needsme|ineed|usesme|iuse|broken) |
24974 |
+ trace_dependencies "-${arg}" |
24975 |
+ ;; |
24976 |
+ status) |
24977 |
+ svc_status |
24978 |
+ retval="$?" |
24979 |
+ ;; |
24980 |
+ zap) |
24981 |
+ einfo "Manually resetting ${SVCNAME} to stopped state." |
24982 |
+ mark_service_stopped "${SVCNAME}" |
24983 |
+ ;; |
24984 |
+ restart) |
24985 |
+ svcrestart="yes" |
24986 |
+ |
24987 |
+ # We don't kill child processes if we're restarting |
24988 |
+ # This is especically important for sshd .... |
24989 |
+ RC_KILL_CHILDREN="no" |
24990 |
+ |
24991 |
+ # Create a snapshot of started services |
24992 |
+ rm -rf "${svcdir}/snapshot/$$" |
24993 |
+ mkdir -p "${svcdir}/snapshot/$$" |
24994 |
+ cp -pP "${svcdir}"/started/* "${svcdir}/snapshot/$$/" |
24995 |
+ rm -f "${svcdir}/snapshot/$$/${SVCNAME}" |
24996 |
+ |
24997 |
+ # Simple way to try and detect if the service use svc_{start,stop} |
24998 |
+ # to restart if it have a custom restart() funtion. |
24999 |
+ if [[ -n $(egrep '^[[:space:]]*restart[[:space:]]*()' "/etc/init.d/${SVCNAME}") ]] ; then |
25000 |
+ if [[ -z $(egrep 'svc_stop' "/etc/init.d/${SVCNAME}") || \ |
25001 |
+ -z $(egrep 'svc_start' "/etc/init.d/${SVCNAME}") ]] ; then |
25002 |
+ echo |
25003 |
+ ewarn "Please use 'svc_stop; svc_start' and not 'stop; start' to" |
25004 |
+ ewarn "restart the service in its custom 'restart()' function." |
25005 |
+ ewarn "Run ${SVCNAME} without arguments for more info." |
25006 |
+ echo |
25007 |
+ svc_restart |
25008 |
+ else |
25009 |
+ restart |
25010 |
+ fi |
25011 |
+ else |
25012 |
+ restart |
25013 |
+ fi |
25014 |
+ retval="$?" |
25015 |
+ |
25016 |
+ [[ -e "${svcdir}/scheduled/${SVCNAME}" ]] \ |
25017 |
+ && rm -Rf "${svcdir}/scheduled/${SVCNAME}" |
25018 |
+ |
25019 |
+ # Restart dependencies as well |
25020 |
+ for x in $(dolisting "${svcdir}/snapshot/$$/") ; do |
25021 |
+ if [[ -x ${x} ]] && service_stopped "${x##*/}" ; then |
25022 |
+ if service_inactive "${SVCNAME}" \ |
25023 |
+ || service_wasinactive "${SVCNAME}" ; then |
25024 |
+ svc_schedule_start "${SVCNAME}" "${x##*/}" |
25025 |
+ ewarn "WARNING: ${x##*/} is scheduled to start when ${SVCNAME} has started." |
25026 |
+ elif service_started "${SVCNAME}" ; then |
25027 |
+ start_service "${x##*/}" |
25028 |
+ fi |
25029 |
+ fi |
25030 |
+ done |
25031 |
+ rm -rf "${svcdir}/snapshot/$$" |
25032 |
+ |
25033 |
+ service_started "${SVCNAME}" && svc_start_scheduled |
25034 |
+ |
25035 |
+ # Wait for services to come up |
25036 |
+ [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && wait |
25037 |
+ |
25038 |
+ svcrestart="no" |
25039 |
+ ;; |
25040 |
+ pause) |
25041 |
+ svcpause="yes" |
25042 |
+ svc_stop |
25043 |
+ retval="$?" |
25044 |
+ svcpause="no" |
25045 |
+ ;; |
25046 |
+ --quiet|--nocolor|--nodeps|--verbose) |
25047 |
+ ;; |
25048 |
+ help) |
25049 |
+ exec "${svclib}"/sh/rc-help.sh "${myscript}" help |
25050 |
+ ;; |
25051 |
+ *) |
25052 |
+ # Allow for homegrown functions |
25053 |
+ svc_homegrown ${arg} |
25054 |
+ retval="$?" |
25055 |
+ ;; |
25056 |
+ esac |
25057 |
+done |
25058 |
+ |
25059 |
+exit "${retval}" |
25060 |
+ |
25061 |
+# vim:ts=4 |
25062 |
|
25063 |
|
25064 |
Property changes on: trunk/baselayout-prefix/sbin/runscript.sh |
25065 |
___________________________________________________________________ |
25066 |
Added: svn:executable |
25067 |
+ * |
25068 |
|
25069 |
Added: trunk/baselayout-prefix/src/Makefile |
25070 |
=================================================================== |
25071 |
--- trunk/baselayout-prefix/src/Makefile (rev 0) |
25072 |
+++ trunk/baselayout-prefix/src/Makefile 2011-03-31 14:11:17 UTC (rev 1682) |
25073 |
@@ -0,0 +1,48 @@ |
25074 |
+# Copyright 1999-2006 Gentoo Foundation |
25075 |
+# Distributed under the terms of the GNU General Public License v2 |
25076 |
+ |
25077 |
+CC = gcc |
25078 |
+LD = gcc |
25079 |
+ |
25080 |
+CFLAGS ?= -Wall -O2 |
25081 |
+DESTDIR = |
25082 |
+LIBDIR = lib |
25083 |
+ |
25084 |
+BIN_TARGETS = |
25085 |
+SBIN_TARGETS = consoletype runscript start-stop-daemon |
25086 |
+SYS_WHITELIST = env_whitelist |
25087 |
+ |
25088 |
+TARGET = $(BIN_TARGETS) $(SBIN_TARGETS) |
25089 |
+ |
25090 |
+OS = Linux |
25091 |
+ifeq ($(OS),Linux) |
25092 |
+LDFLAGS_RS = -ldl |
25093 |
+endif |
25094 |
+ifeq ($(OS),BSD) |
25095 |
+LDFLAGS_SSD = -lkvm |
25096 |
+endif |
25097 |
+ |
25098 |
+override CFLAGS += -DLIBDIR=\"$(LIBDIR)\" |
25099 |
+ |
25100 |
+all: $(TARGET) |
25101 |
+ |
25102 |
+rs-misc.o: core/misc.c |
25103 |
+ $(CC) $(CFLAGS) -c -o $@ $^ |
25104 |
+ |
25105 |
+runscript: runscript.o rs-misc.o |
25106 |
+ $(LD) $(LDFLAGS) -o $@ $^ $(LDFLAGS_RS) |
25107 |
+ |
25108 |
+start-stop-daemon: start-stop-daemon.c |
25109 |
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDFLAGS_SSD) |
25110 |
+ |
25111 |
+install: $(TARGET) |
25112 |
+ install -m 0755 -d $(DESTDIR)/bin |
25113 |
+ install -m 0755 -d $(DESTDIR)/sbin |
25114 |
+# install -m 0755 $(BIN_TARGETS) $(DESTDIR)/bin |
25115 |
+ install -m 0755 $(SBIN_TARGETS) $(DESTDIR)/sbin |
25116 |
+ install -m 0755 -d $(DESTDIR)/$(LIBDIR)/rcscripts/conf.d |
25117 |
+ install -m 0644 $(SYS_WHITELIST) $(DESTDIR)/$(LIBDIR)/rcscripts/conf.d |
25118 |
+ |
25119 |
+clean: |
25120 |
+ rm -f $(TARGET) |
25121 |
+ rm -f *.o *~ |
25122 |
|
25123 |
Added: trunk/baselayout-prefix/src/awk/cachedepends.awk |
25124 |
=================================================================== |
25125 |
--- trunk/baselayout-prefix/src/awk/cachedepends.awk (rev 0) |
25126 |
+++ trunk/baselayout-prefix/src/awk/cachedepends.awk 2011-03-31 14:11:17 UTC (rev 1682) |
25127 |
@@ -0,0 +1,223 @@ |
25128 |
+# Copyright 1999-2006 Gentoo Foundation |
25129 |
+# Distributed under the terms of the GNU General Public License v2 |
25130 |
+ |
25131 |
+function print_start() { |
25132 |
+ print "source /sbin/functions.sh" >> TMPCACHE |
25133 |
+ print "" >> TMPCACHE |
25134 |
+ print "need() {" >> TMPCACHE |
25135 |
+ print " echo \"NEED $*\"; return 0" >> TMPCACHE |
25136 |
+ print "}" >> TMPCACHE |
25137 |
+ print "" >> TMPCACHE |
25138 |
+ print "use() {" >> TMPCACHE |
25139 |
+ print " echo \"USE $*\"; return 0" >> TMPCACHE |
25140 |
+ print "}" >> TMPCACHE |
25141 |
+ print "" >> TMPCACHE |
25142 |
+ print "before() {" >> TMPCACHE |
25143 |
+ print " echo \"BEFORE $*\"; return 0" >> TMPCACHE |
25144 |
+ print "}" >> TMPCACHE |
25145 |
+ print "" >> TMPCACHE |
25146 |
+ print "after() {" >> TMPCACHE |
25147 |
+ print " echo \"AFTER $*\"; return 0" >> TMPCACHE |
25148 |
+ print "}" >> TMPCACHE |
25149 |
+ print "" >> TMPCACHE |
25150 |
+ print "provide() {" >> TMPCACHE |
25151 |
+ print " echo \"PROVIDE $*\"; return 0" >> TMPCACHE |
25152 |
+ print "}" >> TMPCACHE |
25153 |
+ print "" >> TMPCACHE |
25154 |
+} |
25155 |
+ |
25156 |
+function print_header1(mtime) { |
25157 |
+ print "#*** " MYFILENAME " ***" >> TMPCACHE |
25158 |
+ print "" >> TMPCACHE |
25159 |
+ print "SVCNAME=\"" MYFILENAME "\"" >> TMPCACHE |
25160 |
+ print "SVCNAME=\"${SVCNAME##*/}\"" >> TMPCACHE |
25161 |
+ |
25162 |
+ # Support deprected myservice variable |
25163 |
+ print "myservice=\"${SVCNAME}\"" >> TMPCACHE |
25164 |
+ |
25165 |
+ print "echo \"RCSCRIPT ${SVCNAME}\"" >> TMPCACHE |
25166 |
+ print "" >> TMPCACHE |
25167 |
+ print "echo \"MTIME " mtime "\"" >> TMPCACHE |
25168 |
+ print "" >> TMPCACHE |
25169 |
+} |
25170 |
+ |
25171 |
+function print_header2(mtime) { |
25172 |
+ print "(" >> TMPCACHE |
25173 |
+ print " # Get settings for rc-script ..." >> TMPCACHE |
25174 |
+ print "" >> TMPCACHE |
25175 |
+ print " [ -e /etc/conf.d/net ] && \\" >> TMPCACHE |
25176 |
+ print " [ \"${SVCNAME%%.*}\" = \"net\" ] && \\" >> TMPCACHE |
25177 |
+ print " [ \"${SVCNAME#*.}\" != \"${SVCNAME}\" ] && source /etc/conf.d/net" >> TMPCACHE |
25178 |
+ print "" >> TMPCACHE |
25179 |
+ print " [ -e \"/etc/conf.d/${SVCNAME}\" ] && source \"/etc/conf.d/${SVCNAME}\"" >> TMPCACHE |
25180 |
+ print "" >> TMPCACHE |
25181 |
+ print " [ -e /etc/rc.conf ] && source /etc/rc.conf" >> TMPCACHE |
25182 |
+ print "" >> TMPCACHE |
25183 |
+ print " depend() {" >> TMPCACHE |
25184 |
+ print " return 0" >> TMPCACHE |
25185 |
+ print " }" >> TMPCACHE |
25186 |
+ print "" >> TMPCACHE |
25187 |
+} |
25188 |
+ |
25189 |
+function print_end() { |
25190 |
+ print "" >> TMPCACHE |
25191 |
+ print " depend" >> TMPCACHE |
25192 |
+ |
25193 |
+ # Support user defined RC_NEED and RC_USE |
25194 |
+ print "" >> TMPCACHE |
25195 |
+ print " for x in ${RC_NEED} ; do" >> TMPCACHE |
25196 |
+ print " need \"${x}\"" >> TMPCACHE |
25197 |
+ print " done" >> TMPCACHE |
25198 |
+ print "" >> TMPCACHE |
25199 |
+ print " for x in ${RC_USE} ; do" >> TMPCACHE |
25200 |
+ print " use \"${x}\"" >> TMPCACHE |
25201 |
+ print " done" >> TMPCACHE |
25202 |
+ print ")" >> TMPCACHE |
25203 |
+ print "" >> TMPCACHE |
25204 |
+} |
25205 |
+ |
25206 |
+BEGIN { |
25207 |
+ |
25208 |
+ extension("/lib/rcscripts/filefuncs.so", "dlload") |
25209 |
+ |
25210 |
+ # Get our environment variables |
25211 |
+ SVCDIR = ENVIRON["SVCDIR"] |
25212 |
+ if (SVCDIR == "") { |
25213 |
+ eerror("Could not get SVCDIR!") |
25214 |
+ exit 1 |
25215 |
+ } |
25216 |
+ |
25217 |
+ # Since this could be called more than once simultaneously, use a |
25218 |
+ # temporary cache and rename when finished. See bug 47111 |
25219 |
+ ("/bin/mktemp "SVCDIR"/depcache.XXXXXXX") | getline TMPCACHE |
25220 |
+ if (TMPCACHE == "") { |
25221 |
+ eerror("Failed to create temporary cache!") |
25222 |
+ exit 1 |
25223 |
+ } |
25224 |
+ |
25225 |
+ pipe = "ls /etc/init.d/*" |
25226 |
+ while ((pipe | getline tmpstring) > 0) |
25227 |
+ scripts = scripts " " tmpstring |
25228 |
+ close(pipe) |
25229 |
+ |
25230 |
+ split(scripts, TMPRCSCRIPTS) |
25231 |
+ |
25232 |
+ # Make sure that its a file we are working with, |
25233 |
+ # and do not process scripts, source or backup files. |
25234 |
+ for (x in TMPRCSCRIPTS) |
25235 |
+ if (((isfile(TMPRCSCRIPTS[x])) || (islink(TMPRCSCRIPTS[x]))) && |
25236 |
+ (TMPRCSCRIPTS[x] !~ /((\.(c|bak))|\~)$/)) { |
25237 |
+ |
25238 |
+ RCCOUNT++ |
25239 |
+ |
25240 |
+ RCSCRIPTS[RCCOUNT] = TMPRCSCRIPTS[x] |
25241 |
+ } |
25242 |
+ |
25243 |
+ if (RCCOUNT == 0) { |
25244 |
+ eerror("No scripts to process!") |
25245 |
+ dosystem("rm -f "TMPCACHE) |
25246 |
+ exit 1 |
25247 |
+ } |
25248 |
+ |
25249 |
+ print_start() |
25250 |
+ |
25251 |
+ for (count = 1;count <= RCCOUNT;count++) { |
25252 |
+ |
25253 |
+ MYFNR = 1 |
25254 |
+ MYFILENAME = RCSCRIPTS[count] |
25255 |
+ STAT_DATA[1] = 1 |
25256 |
+ |
25257 |
+ while (((getline < (RCSCRIPTS[count])) > 0) && (!NEXTFILE)) { |
25258 |
+ |
25259 |
+ # If line start with a '#' and is the first line |
25260 |
+ if (($0 ~ /^[[:space:]]*#/) && (MYFNR == 1)) { |
25261 |
+ |
25262 |
+ # Remove any spaces and tabs |
25263 |
+ gsub(/[[:space:]]+/, "") |
25264 |
+ |
25265 |
+ if ($0 == "#!/sbin/runscript") { |
25266 |
+ |
25267 |
+ if (RCSCRIPTS[count] ~ /\.sh$/) { |
25268 |
+ |
25269 |
+ ewarn(RCSCRIPTS[count] " is invalid (should not end with '.sh')") |
25270 |
+ NEXTFILE = 1 |
25271 |
+ continue |
25272 |
+ } |
25273 |
+ |
25274 |
+ if (stat(MYFILENAME, STAT_DATA) != 0) |
25275 |
+ ewarn("Could not stat \"" MYFILENAME "\"") |
25276 |
+ |
25277 |
+ ISRCSCRIPT = 1 |
25278 |
+ print_header1(STAT_DATA["mtime"]) |
25279 |
+ } else { |
25280 |
+ |
25281 |
+ NEXTFILE = 1 |
25282 |
+ continue |
25283 |
+ } |
25284 |
+ } |
25285 |
+ |
25286 |
+ # Filter out comments and only process if its a rcscript |
25287 |
+ if (($0 !~ /^[[:space:]]*#/) && (ISRCSCRIPT)) { |
25288 |
+ |
25289 |
+ # If line contain 'depend()', set GOTDEPEND to 1 |
25290 |
+ if ($0 ~ /depend[[:space:]]*\(\)/) { |
25291 |
+ |
25292 |
+ GOTDEPEND = 1 |
25293 |
+ |
25294 |
+ print_header2() |
25295 |
+ print " # Actual depend() function ..." >> TMPCACHE |
25296 |
+ } |
25297 |
+ |
25298 |
+ # We have the depend function... |
25299 |
+ if (GOTDEPEND) { |
25300 |
+ |
25301 |
+ # Basic theory is that COUNT will be 0 when we |
25302 |
+ # have matching '{' and '}' |
25303 |
+ COUNT += gsub(/{/, "{") |
25304 |
+ COUNT -= gsub(/}/, "}") |
25305 |
+ |
25306 |
+ # This is just to verify that we have started with |
25307 |
+ # the body of depend() |
25308 |
+ SBCOUNT += gsub(/{/, "{") |
25309 |
+ |
25310 |
+ # Make sure depend() contain something, else bash |
25311 |
+ # errors out (empty function). |
25312 |
+ if ((SBCOUNT > 0) && (COUNT == 0)) |
25313 |
+ print " \treturn 0" >> TMPCACHE |
25314 |
+ |
25315 |
+ # Print the depend() function |
25316 |
+ print " " $0 >> TMPCACHE |
25317 |
+ |
25318 |
+ # If COUNT=0, and SBCOUNT>0, it means we have read |
25319 |
+ # all matching '{' and '}' for depend(), so stop. |
25320 |
+ if ((SBCOUNT > 0) && (COUNT == 0)) { |
25321 |
+ |
25322 |
+ GOTDEPEND = 0 |
25323 |
+ COUNT = 0 |
25324 |
+ SBCOUNT = 0 |
25325 |
+ ISRCSCRIPT = 0 |
25326 |
+ |
25327 |
+ print_end() |
25328 |
+ |
25329 |
+ NEXTFILE = 1 |
25330 |
+ continue |
25331 |
+ } |
25332 |
+ } |
25333 |
+ } |
25334 |
+ |
25335 |
+ MYFNR++ |
25336 |
+ } |
25337 |
+ |
25338 |
+ close(RCSCRIPTS[count]) |
25339 |
+ |
25340 |
+ NEXTFILE = 0 |
25341 |
+ |
25342 |
+ } |
25343 |
+ |
25344 |
+ |
25345 |
+ assert(dosystem("rm -f "SVCDIR"/depcache"), "system(rm -f "SVCDIR"/depcache)") |
25346 |
+ assert(dosystem("mv "TMPCACHE" "SVCDIR"/depcache"), "system(mv "TMPCACHE" "SVCDIR"/depcache)") |
25347 |
+} |
25348 |
+ |
25349 |
+ |
25350 |
+# vim:ts=4 |
25351 |
|
25352 |
Added: trunk/baselayout-prefix/src/awk/functions.awk |
25353 |
=================================================================== |
25354 |
--- trunk/baselayout-prefix/src/awk/functions.awk (rev 0) |
25355 |
+++ trunk/baselayout-prefix/src/awk/functions.awk 2011-03-31 14:11:17 UTC (rev 1682) |
25356 |
@@ -0,0 +1,156 @@ |
25357 |
+# Copyright 1999-2004 Gentoo Foundation |
25358 |
+# Distributed under the terms of the GNU General Public License v2 |
25359 |
+# $Header$ |
25360 |
+ |
25361 |
+function einfo(string) |
25362 |
+{ |
25363 |
+ printf(" %s %s%s", "\033[32;01m*\033[0m", string, "\n") |
25364 |
+} |
25365 |
+ |
25366 |
+function ewarn(string) |
25367 |
+{ |
25368 |
+ printf(" %s %s%s" , "\033[33;01m*\033[0m", string, "\n") |
25369 |
+} |
25370 |
+ |
25371 |
+function eerror(string) |
25372 |
+{ |
25373 |
+ printf(" %s %s%s" , "\033[31;01m*\033[0m", string, "\n") |
25374 |
+} |
25375 |
+ |
25376 |
+function isfile(pathname, x, ret, data) |
25377 |
+{ |
25378 |
+ ret = 0 |
25379 |
+ data[1] = 1 |
25380 |
+ |
25381 |
+ if (pathname == "") |
25382 |
+ return 0 |
25383 |
+ |
25384 |
+ ret = stat(pathname, data) |
25385 |
+ if (ret < 0) |
25386 |
+ return 0 |
25387 |
+ |
25388 |
+ for (i in data) { |
25389 |
+ if (i == "type") |
25390 |
+ if (data[i] == "file") |
25391 |
+ ret = 1 |
25392 |
+ } |
25393 |
+ |
25394 |
+ return ret |
25395 |
+} |
25396 |
+ |
25397 |
+function islink(pathname, x, ret, data) |
25398 |
+{ |
25399 |
+ ret = 0 |
25400 |
+ data[1] = 1 |
25401 |
+ |
25402 |
+ if (pathname == "") |
25403 |
+ return 0 |
25404 |
+ |
25405 |
+ ret = stat(pathname, data) |
25406 |
+ if (ret < 0) |
25407 |
+ return 0 |
25408 |
+ |
25409 |
+ for (i in data) { |
25410 |
+ if (i == "type") |
25411 |
+ if (data[i] == "symlink") |
25412 |
+ ret = 1 |
25413 |
+ } |
25414 |
+ |
25415 |
+ return ret |
25416 |
+} |
25417 |
+ |
25418 |
+function isdir(pathname, x, ret, data) |
25419 |
+{ |
25420 |
+ ret = 0 |
25421 |
+ data[1] = 1 |
25422 |
+ |
25423 |
+ if (pathname == "") |
25424 |
+ return 0 |
25425 |
+ |
25426 |
+ ret = stat(pathname, data) |
25427 |
+ if (ret < 0) |
25428 |
+ return 0 |
25429 |
+ |
25430 |
+ for (i in data) { |
25431 |
+ if (i == "type") |
25432 |
+ if (data[i] == "directory") |
25433 |
+ ret = 1 |
25434 |
+ } |
25435 |
+ |
25436 |
+ return ret |
25437 |
+} |
25438 |
+ |
25439 |
+function mktree(pathname, mode, x, max, ret, data, pathnodes, tmppath) |
25440 |
+{ |
25441 |
+ ret = 0 |
25442 |
+ data[1] = 1 |
25443 |
+ pathnodes[1] = 1 |
25444 |
+ |
25445 |
+ if (pathname == "") |
25446 |
+ return 0 |
25447 |
+ |
25448 |
+ if (pathname ~ /^\//) |
25449 |
+ tmppath = "" |
25450 |
+ else |
25451 |
+ tmppath = "." |
25452 |
+ |
25453 |
+ split(pathname, pathnodes, "/") |
25454 |
+ |
25455 |
+ for (x in pathnodes) |
25456 |
+ max++ |
25457 |
+ |
25458 |
+ # We cannot use 'for (x in pathnodes)', as gawk likes to |
25459 |
+ # sort the order indexes are processed ... |
25460 |
+ for (x = 1;x <= max;x++) { |
25461 |
+ if (pathnodes[x] == "") |
25462 |
+ continue |
25463 |
+ |
25464 |
+ tmppath = tmppath "/" pathnodes[x] |
25465 |
+ |
25466 |
+ ret = stat(tmppath, data) |
25467 |
+ if (ret < 0) |
25468 |
+ if (mkdir(tmppath, mode) < 0) |
25469 |
+ return 0 |
25470 |
+ } |
25471 |
+ |
25472 |
+ return 1 |
25473 |
+} |
25474 |
+ |
25475 |
+# symlink() wrapper that normalize return codes ... |
25476 |
+function dosymlink(oldpath, newpath, ret) |
25477 |
+{ |
25478 |
+ ret = 0 |
25479 |
+ |
25480 |
+ ret = symlink(oldpath, newpath) |
25481 |
+ if (ret < 0) |
25482 |
+ return 0 |
25483 |
+ else |
25484 |
+ return 1 |
25485 |
+} |
25486 |
+ |
25487 |
+# system() wrapper that normalize return codes ... |
25488 |
+function dosystem(command, ret) |
25489 |
+{ |
25490 |
+ ret = 0 |
25491 |
+ |
25492 |
+ ret = system(command) |
25493 |
+ if (ret == 0) |
25494 |
+ return 1 |
25495 |
+ else |
25496 |
+ return 0 |
25497 |
+} |
25498 |
+ |
25499 |
+# assert --- assert that a condition is true. Otherwise exit. |
25500 |
+# This is from the gawk info manual. |
25501 |
+function assert(condition, string) |
25502 |
+{ |
25503 |
+ if (! condition) { |
25504 |
+ printf("%s:%d: assertion failed: %s\n", |
25505 |
+ FILENAME, FNR, string) > "/dev/stderr" |
25506 |
+ _assert_exit = 1 |
25507 |
+ exit 1 |
25508 |
+ } |
25509 |
+} |
25510 |
+ |
25511 |
+ |
25512 |
+# vim:ts=4 |
25513 |
|
25514 |
Added: trunk/baselayout-prefix/src/awk/gendepends.awk |
25515 |
=================================================================== |
25516 |
--- trunk/baselayout-prefix/src/awk/gendepends.awk (rev 0) |
25517 |
+++ trunk/baselayout-prefix/src/awk/gendepends.awk 2011-03-31 14:11:17 UTC (rev 1682) |
25518 |
@@ -0,0 +1,563 @@ |
25519 |
+# Copyright 1999-2006 Gentoo Foundation |
25520 |
+# Distributed under the terms of the GNU General Public License v2 |
25521 |
+ |
25522 |
+# bool check_service(name) |
25523 |
+# |
25524 |
+# Returns true if the service exists |
25525 |
+# |
25526 |
+function check_service(name, x) |
25527 |
+{ |
25528 |
+ for (x = 1; x <= RC_NUMBER; x++) { |
25529 |
+ if (DEPTREE[x,NAME] == name) |
25530 |
+ return 1 |
25531 |
+ } |
25532 |
+ |
25533 |
+ return 0 |
25534 |
+} |
25535 |
+ |
25536 |
+# int get_service_index(name) |
25537 |
+# |
25538 |
+# Return the index position in DEPTREE |
25539 |
+# |
25540 |
+function get_service_index(name, x) |
25541 |
+{ |
25542 |
+ for (x = 1; x <= RC_NUMBER; x++) { |
25543 |
+ if (DEPTREE[x,NAME] == name) |
25544 |
+ return x |
25545 |
+ } |
25546 |
+ |
25547 |
+ return 0 |
25548 |
+} |
25549 |
+ |
25550 |
+# bool check_depend(service1, type, service2) |
25551 |
+# |
25552 |
+# Returns true if 'service1' need/use/is_before/is_after 'service2' |
25553 |
+# |
25554 |
+function check_depend(service1, type, service2, tmpsplit, x) |
25555 |
+{ |
25556 |
+ if (check_service(service1)) { |
25557 |
+ x = get_service_index(service1) |
25558 |
+ |
25559 |
+ if ((x,type) in DEPTREE) { |
25560 |
+ split(DEPTREE[x,type], tmpsplit) |
25561 |
+ |
25562 |
+ for (x in tmpsplit) { |
25563 |
+ if (tmpsplit[x] == service2) |
25564 |
+ return 1 |
25565 |
+ } |
25566 |
+ } |
25567 |
+ } |
25568 |
+ |
25569 |
+ return 0 |
25570 |
+} |
25571 |
+ |
25572 |
+# bool check_resolved_depend(service1, type, service2) |
25573 |
+# |
25574 |
+# Returns true if 'service1' need/use/is_before/is_after 'service2' |
25575 |
+# It should only be trusted if we do the BEFORE/AFTER loop |
25576 |
+# |
25577 |
+function check_resolved_depend(service1, type, service2, tmpsplit, x) |
25578 |
+{ |
25579 |
+ if (check_service(service1)) { |
25580 |
+ x = get_service_index(service1) |
25581 |
+ |
25582 |
+ if ((x,type) in RESOLVED_DEPTREE) { |
25583 |
+ split(RESOLVED_DEPTREE[x,type], tmpsplit) |
25584 |
+ |
25585 |
+ for (x in tmpsplit) { |
25586 |
+ if (tmpsplit[x] == service2) |
25587 |
+ return 1 |
25588 |
+ } |
25589 |
+ } |
25590 |
+ } |
25591 |
+ |
25592 |
+ return 0 |
25593 |
+} |
25594 |
+ |
25595 |
+# string get_resolved_depends(service, type) |
25596 |
+# |
25597 |
+# Return the services that depend of type on service |
25598 |
+# It should only be trusted if we do the BEFORE/AFTER loop |
25599 |
+# |
25600 |
+function get_resolved_depends(service, type, x) |
25601 |
+{ |
25602 |
+ if (check_service(service)) { |
25603 |
+ x = get_service_index(service) |
25604 |
+ |
25605 |
+ if ((x,type) in RESOLVED_DEPTREE) |
25606 |
+ return RESOLVED_DEPTREE[x,type] |
25607 |
+ } |
25608 |
+ |
25609 |
+ return "" |
25610 |
+} |
25611 |
+ |
25612 |
+# bool check_recursive_depend(service1, service2, bool checkuse) |
25613 |
+# |
25614 |
+# Return true if service1 USE/NEED a service that NEEDS/USES |
25615 |
+# service2 |
25616 |
+# It should only be trusted if we do the BEFORE/AFTER loop |
25617 |
+# |
25618 |
+function check_recursive_depend(service1, service2, checkuse, x, deps, deplist) |
25619 |
+{ |
25620 |
+ deps = get_resolved_depends(service2, NEEDME) |
25621 |
+ if (deps != "") { |
25622 |
+ split(deps, deplist) |
25623 |
+ for (x in deplist) |
25624 |
+ if (check_resolved_depend(service1, NEED, deplist[x])) |
25625 |
+ return 1 |
25626 |
+ if (checkuse && check_resolved_depend(service1, USE, deplist[x])) |
25627 |
+ return 1 |
25628 |
+ } |
25629 |
+ |
25630 |
+ if (!checkuse) |
25631 |
+ return 0 |
25632 |
+ |
25633 |
+ deps = get_resolved_depends(service2, USEME) |
25634 |
+ if (deps != "") { |
25635 |
+ split(deps, deplist) |
25636 |
+ for (x in deplist) |
25637 |
+ if (check_resolved_depend(service1, NEED, deplist[x]) || |
25638 |
+ check_resolved_depend(service1, USE, deplist[x])) { |
25639 |
+ return 1 |
25640 |
+ } |
25641 |
+ } |
25642 |
+ |
25643 |
+ return 0 |
25644 |
+} |
25645 |
+ |
25646 |
+# bool add_deptree_item(rcnumber, type, item) |
25647 |
+# |
25648 |
+# Add an item(s) 'item' to the DEPTREE array at index [rcnumber,type] |
25649 |
+# |
25650 |
+function add_deptree_item(rcnumber, type, item) |
25651 |
+{ |
25652 |
+ if (DEPTREE[rcnumber,type] != "") |
25653 |
+ DEPTREE[rcnumber,type] = DEPTREE[rcnumber,type] " " item |
25654 |
+ else |
25655 |
+ DEPTREE[rcnumber,type] = item |
25656 |
+ |
25657 |
+ return 1 |
25658 |
+} |
25659 |
+ |
25660 |
+# bool add_provide(service, provide) |
25661 |
+# |
25662 |
+# Add a name of a virtual service ('provide') that 'service' Provides |
25663 |
+# |
25664 |
+function add_provide(service, provide) |
25665 |
+{ |
25666 |
+ # We cannot have a service Provide a virtual service with the same name as |
25667 |
+ # an existing service ... |
25668 |
+ if (check_service(provide)) { |
25669 |
+ eerror(" Cannot add provide '" provide "', as a service with the same name exists!") |
25670 |
+ return 0 |
25671 |
+ } |
25672 |
+ |
25673 |
+ if (check_provide(provide)) { |
25674 |
+ # We cannot have more than one service Providing a virtual ... |
25675 |
+ ewarn(" Service '" get_provide(provide) "' already provided by '" provide "'!;") |
25676 |
+ ewarn(" Not adding service '" service "'...") |
25677 |
+ # Do not fail here as we do have a service that resolves the virtual |
25678 |
+ } else { |
25679 |
+ # Sanity check |
25680 |
+ if (check_service(service)) { |
25681 |
+ PROVIDE_LIST[provide] = service |
25682 |
+ } else { |
25683 |
+ eerror(" Cannot add provide '" provide "', as service '" service "' does not exist!") |
25684 |
+ return 0 |
25685 |
+ } |
25686 |
+ } |
25687 |
+ |
25688 |
+ return 1 |
25689 |
+} |
25690 |
+ |
25691 |
+# string get_provide(provide) |
25692 |
+# |
25693 |
+# Return the name of the service that Provides 'provide' |
25694 |
+# |
25695 |
+function get_provide(provide) |
25696 |
+{ |
25697 |
+ if (provide in PROVIDE_LIST) |
25698 |
+ if (check_service(PROVIDE_LIST[provide])) |
25699 |
+ return PROVIDE_LIST[provide] |
25700 |
+ |
25701 |
+ return "" |
25702 |
+} |
25703 |
+ |
25704 |
+# bool check_provide(provide) |
25705 |
+# |
25706 |
+# Return true if any service Provides the virtual service with name 'provide' |
25707 |
+# |
25708 |
+function check_provide(provide) |
25709 |
+{ |
25710 |
+ if (provide in PROVIDE_LIST) |
25711 |
+ return 1 |
25712 |
+ |
25713 |
+ return 0 |
25714 |
+} |
25715 |
+ |
25716 |
+# bool add_db_entry(service, type, item) |
25717 |
+# |
25718 |
+# Add a entry to RESOLVED_DEPTREE |
25719 |
+# |
25720 |
+function add_db_entry(service, type, item, x, sindex, tmpsplit) |
25721 |
+{ |
25722 |
+ if (!check_service(service)) { |
25723 |
+ eerror(" Service '" service "' do not exist!") |
25724 |
+ return 0 |
25725 |
+ } |
25726 |
+ |
25727 |
+ sindex = get_service_index(service) |
25728 |
+ |
25729 |
+ if ((sindex,type) in RESOLVED_DEPTREE) { |
25730 |
+ split(RESOLVED_DEPTREE[sindex,type], tmpsplit) |
25731 |
+ |
25732 |
+ for (x in tmpsplit) { |
25733 |
+ if (tmpsplit[x] == item) |
25734 |
+ return 1 |
25735 |
+ } |
25736 |
+ |
25737 |
+ RESOLVED_DEPTREE[sindex,type] = RESOLVED_DEPTREE[sindex,type] " " item |
25738 |
+ } else { |
25739 |
+ RESOLVED_DEPTREE[sindex,type] = item |
25740 |
+ } |
25741 |
+ |
25742 |
+ return 1 |
25743 |
+} |
25744 |
+ |
25745 |
+# void resolve_depend(type, service, deplist) |
25746 |
+# |
25747 |
+# Verify a depend entry(s) 'deplist' for service 'service' of type 'type', |
25748 |
+# and then add it to the DB. |
25749 |
+# |
25750 |
+function resolve_depend(type, service, deplist, x, deparray) |
25751 |
+{ |
25752 |
+ if ((type == "") || (service == "") || (deplist == "")) |
25753 |
+ return |
25754 |
+ |
25755 |
+ # If there are no existing service 'service', resolve possible |
25756 |
+ # provided services |
25757 |
+ if (!check_service(service)) { |
25758 |
+ if (check_provide(service)) |
25759 |
+ service = get_provide(service) |
25760 |
+ else |
25761 |
+ return |
25762 |
+ } |
25763 |
+ |
25764 |
+ split(deplist, deparray) |
25765 |
+ |
25766 |
+ for (x in deparray) { |
25767 |
+ |
25768 |
+ # If there are no existing service 'deparray[x]', resolve possible |
25769 |
+ # provided services |
25770 |
+ if (!check_service(deparray[x])) { |
25771 |
+ if (check_provide(deparray[x])) |
25772 |
+ deparray[x] = get_provide(deparray[x]) |
25773 |
+ } |
25774 |
+ |
25775 |
+ # Handle 'need', as it is the only dependency type that |
25776 |
+ # should handle invalid database entries currently. |
25777 |
+ if (!check_service(deparray[x])) { |
25778 |
+ |
25779 |
+ if (((type == NEED) || (type == NEEDME)) && (deparray[x] != "net")) { |
25780 |
+ |
25781 |
+ ewarn(" Can't find service '" deparray[x] "' needed by '" service "'; continuing...") |
25782 |
+ |
25783 |
+ # service is broken due to missing 'need' dependencies |
25784 |
+ add_db_entry(service, BROKEN, deparray[x]) |
25785 |
+ |
25786 |
+ continue |
25787 |
+ } |
25788 |
+ else if (deparray[x] != "net") |
25789 |
+ continue |
25790 |
+ } |
25791 |
+ |
25792 |
+ # Ugly bug ... if a service depends on itself, it creates |
25793 |
+ # a 'mini fork bomb' effect, and breaks things... |
25794 |
+ if (deparray[x] == service) { |
25795 |
+ |
25796 |
+ # Dont work too well with the '*' use and need |
25797 |
+ if ((type != BEFORE) && (type != AFTER)) |
25798 |
+ ewarn(" Service '" deparray[x] "' can't depend on itself; continuing...") |
25799 |
+ |
25800 |
+ continue |
25801 |
+ } |
25802 |
+ |
25803 |
+ # Currently only these depend/order types are supported |
25804 |
+ if ((type == NEED) || (type == USE) || (type == BEFORE) || (type == AFTER)) { |
25805 |
+ |
25806 |
+ if (type == BEFORE) { |
25807 |
+ # NEED and USE override BEFORE (service BEFORE deparray[x]) |
25808 |
+ if (check_resolved_depend(service, NEED, deparray[x]) || |
25809 |
+ check_resolved_depend(service, USE, deparray[x])) |
25810 |
+ continue |
25811 |
+ |
25812 |
+ if (check_recursive_depend(service, deparray[x], 1)) { |
25813 |
+ ewarn(" Service '" service "' should be BEFORE service '" deparray[x] "', but one of") |
25814 |
+ ewarn(" the services '" service "' depends on, depends on '" deparray[x] "'!") |
25815 |
+ continue |
25816 |
+ } |
25817 |
+ } |
25818 |
+ |
25819 |
+ if (type == AFTER) { |
25820 |
+ # NEED and USE override AFTER (service AFTER deparray[x]) |
25821 |
+ if (check_resolved_depend(deparray[x], NEED, service) || |
25822 |
+ check_resolved_depend(deparray[x], USE, service)) |
25823 |
+ continue |
25824 |
+ |
25825 |
+ if (check_recursive_depend(deparray[x], service, 1)) { |
25826 |
+ ewarn(" Service '" service "' should be AFTER service '" deparray[x] "', but one of") |
25827 |
+ ewarn(" the services '" deparray[x] "' depends on, depends on '" service "'!") |
25828 |
+ continue |
25829 |
+ } |
25830 |
+ } |
25831 |
+ |
25832 |
+ # NEED override USE (service USE deparray[x]) |
25833 |
+ if (type == USE && (check_resolved_depend(deparray[x], NEED, service) || |
25834 |
+ check_recursive_depend(deparray[x], service, 0))) { |
25835 |
+ ewarn(" Service '" deparray[x] "' NEED service '" service "', but service '" service "' wants") |
25836 |
+ ewarn(" to USE service '" deparray[x] "'!") |
25837 |
+ continue |
25838 |
+ } |
25839 |
+ |
25840 |
+ # We do not want to add circular depends ... |
25841 |
+ if (check_depend(deparray[x], type, service) || |
25842 |
+ check_resolved_depend(deparray[x], type, service)) { |
25843 |
+ |
25844 |
+ if ((service,deparray[x],type) in CIRCULAR_DEPEND) |
25845 |
+ continue |
25846 |
+ |
25847 |
+ if ((deparray[x],service,type) in CIRCULAR_DEPEND) |
25848 |
+ continue |
25849 |
+ |
25850 |
+ ewarn(" Services '" service "' and '" deparray[x] "' have circular") |
25851 |
+ ewarn(" dependency of type '" TYPE_NAMES[type] "'; continuing...") |
25852 |
+ |
25853 |
+ CIRCULAR_DEPEND[service,deparray[x],type] = "yes" |
25854 |
+ |
25855 |
+ continue |
25856 |
+ } |
25857 |
+ |
25858 |
+ add_db_entry(service, type, deparray[x]) |
25859 |
+ |
25860 |
+ # Reverse mapping |
25861 |
+ if (type == NEED) |
25862 |
+ add_db_entry(deparray[x], NEEDME, service) |
25863 |
+ |
25864 |
+ # Reverse mapping |
25865 |
+ if (type == USE) |
25866 |
+ add_db_entry(deparray[x], USEME, service) |
25867 |
+ |
25868 |
+ # Reverse mapping |
25869 |
+ if (type == BEFORE) |
25870 |
+ add_db_entry(deparray[x], AFTER, service) |
25871 |
+ |
25872 |
+ # Reverse mapping |
25873 |
+ if (type == AFTER) |
25874 |
+ add_db_entry(deparray[x], BEFORE, service) |
25875 |
+ } |
25876 |
+ } |
25877 |
+} |
25878 |
+ |
25879 |
+BEGIN { |
25880 |
+ NAME = 1 |
25881 |
+ RC_NUMBER = 0 |
25882 |
+ |
25883 |
+ # Types ... |
25884 |
+ NEED = 2 |
25885 |
+ NEEDME = 3 |
25886 |
+ USE = 4 |
25887 |
+ USEME = 5 |
25888 |
+ BEFORE = 6 |
25889 |
+ AFTER = 7 |
25890 |
+ BROKEN = 8 |
25891 |
+ MTIME = 9 |
25892 |
+ PROVIDE = 10 # Not part of Types as when finally printed ... |
25893 |
+ TYPES_MIN = 2 |
25894 |
+ TYPES_MAX = 9 |
25895 |
+ |
25896 |
+ TYPE_NAMES[NEED] = "ineed" |
25897 |
+ TYPE_NAMES[NEEDME] = "needsme" |
25898 |
+ TYPE_NAMES[USE] = "iuse" |
25899 |
+ TYPE_NAMES[USEME] = "usesme" |
25900 |
+ TYPE_NAMES[BEFORE] = "ibefore" |
25901 |
+ TYPE_NAMES[AFTER] = "iafter" |
25902 |
+ TYPE_NAMES[BROKEN] = "broken" |
25903 |
+ TYPE_NAMES[PROVIDE] = "provide" |
25904 |
+ TYPE_NAMES[MTIME] = "mtime" |
25905 |
+ |
25906 |
+ # Get our environment variables |
25907 |
+ SVCDIR = ENVIRON["SVCDIR"] |
25908 |
+ if (SVCDIR == "") { |
25909 |
+ eerror("Could not get SVCDIR!") |
25910 |
+ exit 1 |
25911 |
+ } |
25912 |
+ |
25913 |
+ # There we do not really use yet |
25914 |
+ DEPTYPES = ENVIRON["DEPTYPES"] |
25915 |
+ ORDTYPES = ENVIRON["ORDTYPES"] |
25916 |
+ |
25917 |
+ #CACHEDTREE = SVCDIR "/deptree" |
25918 |
+ ORIGCACHEDTREE = SVCDIR "/deptree" |
25919 |
+ |
25920 |
+ # Since this could be called more than once simultaneously, use a |
25921 |
+ # temporary cache and rename when finished. See bug 48303 |
25922 |
+ ("/bin/mktemp "SVCDIR"/treecache.XXXXXXX") | getline CACHEDTREE |
25923 |
+ if (CACHEDTREE == "") { |
25924 |
+ eerror("Failed to create temporary cache!") |
25925 |
+ exit 1 |
25926 |
+ } |
25927 |
+ |
25928 |
+ # We remove it below now only before moving the temp one over. |
25929 |
+ #assert(dosystem("rm -f " CACHEDTREE ), "system(rm -f " CACHEDTREE ")") |
25930 |
+} |
25931 |
+ |
25932 |
+{ |
25933 |
+ # |
25934 |
+ # Build our DEPTREE array |
25935 |
+ # |
25936 |
+ |
25937 |
+ if ($1 == "RCSCRIPT") { |
25938 |
+ RC_NUMBER++ |
25939 |
+ |
25940 |
+ DEPTREE[RC_NUMBER,NAME] = $2 |
25941 |
+ } |
25942 |
+ |
25943 |
+ if ($1 == "NEED") { |
25944 |
+ sub(/NEED[[:space:]]*/, "") |
25945 |
+ |
25946 |
+ if ($0 != "") |
25947 |
+ add_deptree_item(RC_NUMBER, NEED, $0) |
25948 |
+ } |
25949 |
+ |
25950 |
+ if ($1 == "USE") { |
25951 |
+ sub(/USE[[:space:]]*/, "") |
25952 |
+ |
25953 |
+ if ($0 != "") |
25954 |
+ add_deptree_item(RC_NUMBER, USE, $0) |
25955 |
+ } |
25956 |
+ |
25957 |
+ if ($1 == "BEFORE") { |
25958 |
+ sub(/BEFORE[[:space:]]*/, "") |
25959 |
+ |
25960 |
+ if ($0 != "") |
25961 |
+ add_deptree_item(RC_NUMBER, BEFORE, $0) |
25962 |
+ } |
25963 |
+ |
25964 |
+ if ($1 == "AFTER") { |
25965 |
+ sub(/AFTER[[:space:]]*/, "") |
25966 |
+ |
25967 |
+ if ($0 != "") |
25968 |
+ add_deptree_item(RC_NUMBER, AFTER, $0) |
25969 |
+ } |
25970 |
+ |
25971 |
+ if ($1 == "PROVIDE") { |
25972 |
+ sub(/PROVIDE[[:space:]]*/, "") |
25973 |
+ |
25974 |
+ if ($0 != "") |
25975 |
+ add_deptree_item(RC_NUMBER, PROVIDE, $0) |
25976 |
+ } |
25977 |
+ |
25978 |
+ if ($1 == "MTIME") { |
25979 |
+ sub(/MTIME[[:space:]]*/, "") |
25980 |
+ |
25981 |
+ if ($0 != "") { |
25982 |
+ # We add this directly to RESOLVED_DEPTREE |
25983 |
+ add_db_entry(DEPTREE[RC_NUMBER,NAME], MTIME, $0) |
25984 |
+ } |
25985 |
+ } |
25986 |
+} |
25987 |
+ |
25988 |
+END { |
25989 |
+ # Add the 'net' service if it do not exist ... |
25990 |
+ if (!check_service("net")) { |
25991 |
+ RC_NUMBER++ |
25992 |
+ DEPTREE[RC_NUMBER,NAME] = "net" |
25993 |
+ } |
25994 |
+ |
25995 |
+ # Calculate all the provides ... |
25996 |
+ for (x = 1;x <= RC_NUMBER;x++) { |
25997 |
+ if ((x,PROVIDE) in DEPTREE) |
25998 |
+ add_provide(DEPTREE[x,NAME], DEPTREE[x,PROVIDE]) |
25999 |
+ } |
26000 |
+ |
26001 |
+ # Now do NEED |
26002 |
+ for (x = 1;x <= RC_NUMBER;x++) { |
26003 |
+ if ((x,NEED) in DEPTREE) |
26004 |
+ resolve_depend(NEED, DEPTREE[x,NAME], DEPTREE[x,NEED]) |
26005 |
+ } |
26006 |
+ |
26007 |
+ # Now do USE |
26008 |
+ for (x = 1;x <= RC_NUMBER;x++) { |
26009 |
+ if ((x,USE) in DEPTREE) |
26010 |
+ resolve_depend(USE, DEPTREE[x,NAME], DEPTREE[x,USE]) |
26011 |
+ } |
26012 |
+ |
26013 |
+ # Now do BEFORE and AFTER |
26014 |
+ for (x = 1;x <= RC_NUMBER;x++) { |
26015 |
+ |
26016 |
+ if ((x,BEFORE) in DEPTREE) |
26017 |
+ resolve_depend(BEFORE, DEPTREE[x,NAME], DEPTREE[x,BEFORE]) |
26018 |
+ |
26019 |
+ if ((x,AFTER) in DEPTREE) |
26020 |
+ resolve_depend(AFTER, DEPTREE[x,NAME], DEPTREE[x,AFTER]) |
26021 |
+ } |
26022 |
+ |
26023 |
+ for (x = TYPES_MIN; x <= TYPES_MAX; x++) |
26024 |
+ print "declare -r rc_type_" TYPE_NAMES[x] "=" x >> (CACHEDTREE) |
26025 |
+ print "declare -r rc_index_scale=" (TYPES_MAX + 1) >> (CACHEDTREE) |
26026 |
+ print "" >> (CACHEDTREE) |
26027 |
+ print "declare -a RC_DEPEND_TREE" >> (CACHEDTREE) |
26028 |
+ print "" >> (CACHEDTREE) |
26029 |
+ print "RC_DEPEND_TREE[0]=" RC_NUMBER >> (CACHEDTREE) |
26030 |
+ print "" >> (CACHEDTREE) |
26031 |
+ |
26032 |
+ # Generate the resolved CACHEDTREE |
26033 |
+ # |
26034 |
+ # NOTE: We used to use depinfo_<scriptname>() function to resolve our |
26035 |
+ # rc_<type> variables, but that do not scale when the names of |
26036 |
+ # the scripts include invalid bash variable characters (+,.,etc). |
26037 |
+ # |
26038 |
+ for (x = 1;x <= RC_NUMBER;x++) { |
26039 |
+ |
26040 |
+ print "RC_DEPEND_TREE[" (x * (TYPES_MAX + 1)) "]=\"" DEPTREE[x,NAME] "\"" >> (CACHEDTREE) |
26041 |
+ |
26042 |
+ for (y = TYPES_MIN; y <= TYPES_MAX; y++) { |
26043 |
+ |
26044 |
+ tmpname = "RC_DEPEND_TREE[" (x * (TYPES_MAX + 1)) "+" y "]" |
26045 |
+ |
26046 |
+ if ((x,y) in RESOLVED_DEPTREE) { |
26047 |
+ |
26048 |
+ split(RESOLVED_DEPTREE[x,y], tmparray1) |
26049 |
+ count = asort(tmparray1, tmparray2) |
26050 |
+ tmpstr = tmparray2[1] |
26051 |
+ |
26052 |
+ for (i = 2;i <= count;i++) |
26053 |
+ tmpstr = tmpstr " " tmparray2[i] |
26054 |
+ |
26055 |
+ print tmpname "=\"" tmpstr "\"" >> (CACHEDTREE) |
26056 |
+ } else |
26057 |
+ print tmpname "=" >> (CACHEDTREE) |
26058 |
+ } |
26059 |
+ |
26060 |
+ print "" >> (CACHEDTREE) |
26061 |
+ } |
26062 |
+ # Ensure that no-one changes our tree |
26063 |
+ print "declare -r RC_DEPEND_TREE" >> (CACHEDTREE) |
26064 |
+ |
26065 |
+ # Do not export these, as we want them local |
26066 |
+ print "declare -r RC_GOT_DEPTREE_INFO=\"yes\"" >> (CACHEDTREE) |
26067 |
+ print "" >> (CACHEDTREE) |
26068 |
+ |
26069 |
+ if (check_provide("logger")) |
26070 |
+ print "declare -r LOGGER_SERVICE=\"" get_provide("logger") "\"" >> (CACHEDTREE) |
26071 |
+ else |
26072 |
+ print "declare -r LOGGER_SERVICE=" >> (CACHEDTREE) |
26073 |
+ |
26074 |
+ close(CACHEDTREE) |
26075 |
+ |
26076 |
+ assert(dosystem("rm -f "ORIGCACHEDTREE), "system(rm -f "ORIGCACHEDTREE")") |
26077 |
+ assert(dosystem("mv "CACHEDTREE" "ORIGCACHEDTREE), "system(mv "CACHEDTREE" "ORIGCACHEDTREE")") |
26078 |
+} |
26079 |
+ |
26080 |
+ |
26081 |
+# vim:ts=4 |
26082 |
|
26083 |
Added: trunk/baselayout-prefix/src/awk/genenviron.awk |
26084 |
=================================================================== |
26085 |
--- trunk/baselayout-prefix/src/awk/genenviron.awk (rev 0) |
26086 |
+++ trunk/baselayout-prefix/src/awk/genenviron.awk 2011-03-31 14:11:17 UTC (rev 1682) |
26087 |
@@ -0,0 +1,182 @@ |
26088 |
+# Copyright 1999-2006 Gentoo Foundation |
26089 |
+# Distributed under the terms of the GNU General Public License v2 |
26090 |
+ |
26091 |
+BEGIN { |
26092 |
+ |
26093 |
+ extension("/lib/rcscripts/filefuncs.so", "dlload") |
26094 |
+ |
26095 |
+ # Get our environment variables |
26096 |
+ SVCDIR = ENVIRON["SVCDIR"] |
26097 |
+ if (SVCDIR == "") { |
26098 |
+ eerror("Could not get SVCDIR!") |
26099 |
+ exit 1 |
26100 |
+ } |
26101 |
+ |
26102 |
+ pipe = "ls -1 /etc/env.d/." |
26103 |
+ while ((pipe | getline tmpstring) > 0) |
26104 |
+ scripts = scripts " /etc/env.d/" tmpstring |
26105 |
+ close(pipe) |
26106 |
+ |
26107 |
+ split(scripts, TMPENVFILES) |
26108 |
+ |
26109 |
+ # Make sure that its a file we are working with, |
26110 |
+ # and do not process scripts, source or backup files. |
26111 |
+ # NOTE: do not use 'for (x in TMPENVFILES)', as gawk |
26112 |
+ # have this notion that it should mess with the |
26113 |
+ # order it list things then .... |
26114 |
+ for (x = 1;;x++) { |
26115 |
+ |
26116 |
+ if (x in TMPENVFILES) { |
26117 |
+ |
26118 |
+ if ((isfile(TMPENVFILES[x])) && |
26119 |
+ (TMPENVFILES[x] !~ /((\.(sh|c|bak))|\~)$/)) { |
26120 |
+ |
26121 |
+ ENVCOUNT++ |
26122 |
+ |
26123 |
+ ENVFILES[ENVCOUNT] = TMPENVFILES[x] |
26124 |
+ } |
26125 |
+ } else |
26126 |
+ break |
26127 |
+ } |
26128 |
+ |
26129 |
+ if (ENVCOUNT == 0) { |
26130 |
+ |
26131 |
+ eerror("No files to process!") |
26132 |
+ exit 1 |
26133 |
+ } |
26134 |
+ |
26135 |
+ ENVCACHE = SVCDIR "/envcache" |
26136 |
+ SHPROFILE = "/etc/profile.env" |
26137 |
+ CSHPROFILE = "/etc/csh.env" |
26138 |
+ |
26139 |
+ # SPECIALS are treated differently. For each env.d file, the variables are |
26140 |
+ # appended seperated with a ':'. If not in specials, for each env.d file, |
26141 |
+ # the variable are just set to the new value. |
26142 |
+ tmpspecials = \ |
26143 |
+ "ADA_INCLUDE_PATH:ADA_OBJECTS_PATH:CLASSPATH:" \ |
26144 |
+ "CONFIG_PROTECT:CONFIG_PROTECT_MASK:INFOPATH:" \ |
26145 |
+ "KDEDIRS:LDPATH:MANPATH:PATH:PKG_CONFIG_PATH:" \ |
26146 |
+ "PRELINK_PATH:PRELINK_PATH_MASK:PYTHONPATH:ROOTPATH" |
26147 |
+ split(tmpspecials, SPECIALS, ":") |
26148 |
+ |
26149 |
+ unlink(ENVCACHE) |
26150 |
+ |
26151 |
+ for (count = 1;count <= ENVCOUNT;count++) { |
26152 |
+ |
26153 |
+ while ((getline < (ENVFILES[count])) > 0) { |
26154 |
+ |
26155 |
+ # Filter out comments |
26156 |
+ if ($0 !~ /^[[:space:]]*#/) { |
26157 |
+ |
26158 |
+ split($0, envnode, "=") |
26159 |
+ |
26160 |
+ if (envnode[2] == "") |
26161 |
+ continue |
26162 |
+ |
26163 |
+ if ($0 == "") |
26164 |
+ continue |
26165 |
+ |
26166 |
+ # LDPATH should not be in environment |
26167 |
+ if (envnode[1] == "LDPATH") |
26168 |
+ continue |
26169 |
+ |
26170 |
+ # In bash there should be no space between the variable name and |
26171 |
+ # the '=' ... |
26172 |
+ if (envnode[1] ~ /[^[:space:]]*[[:space:]]+$/) |
26173 |
+ continue |
26174 |
+ |
26175 |
+ # strip variable name and '=' from data |
26176 |
+ sub("^[[:space:]]*" envnode[1] "[[:space:]]*=", "") |
26177 |
+ # strip all '"' and '\'' |
26178 |
+ gsub(/\"/, "") |
26179 |
+ gsub(/\'/, "") |
26180 |
+ # strip leading and trailing spaces |
26181 |
+ gsub(/^[[:space:]]*/, "") |
26182 |
+ gsub(/[[:space:]]*$/, "") |
26183 |
+ |
26184 |
+ if (envnode[1] in ENVTREE) { |
26185 |
+ |
26186 |
+ DOSPECIAL = 0 |
26187 |
+ |
26188 |
+ for (x in SPECIALS) { |
26189 |
+ |
26190 |
+ # Is this a special variable ? |
26191 |
+ if (envnode[1] == SPECIALS[x]) |
26192 |
+ DOSPECIAL = 1 |
26193 |
+ } |
26194 |
+ |
26195 |
+ if (DOSPECIAL) { |
26196 |
+ split(ENVTREE[envnode[1]], tmpstr, ":") |
26197 |
+ |
26198 |
+ # Check that we do not add dups ... |
26199 |
+ NODUPS = 1 |
26200 |
+ for (x in tmpstr) |
26201 |
+ if (tmpstr[x] == $0) |
26202 |
+ NODUPS = 0 |
26203 |
+ |
26204 |
+ if (NODUPS) |
26205 |
+ # Once again, "CONFIG_PROTECT" and "CONFIG_PROTECT_MASK" |
26206 |
+ # are handled differently ... |
26207 |
+ if ((envnode[1] == "CONFIG_PROTECT") || (envnode[1] == "CONFIG_PROTECT_MASK")) |
26208 |
+ ENVTREE[envnode[1]] = ENVTREE[envnode[1]] " " $0 |
26209 |
+ else |
26210 |
+ ENVTREE[envnode[1]] = ENVTREE[envnode[1]] ":" $0 |
26211 |
+ } else |
26212 |
+ ENVTREE[envnode[1]] = $0 |
26213 |
+ } else |
26214 |
+ ENVTREE[envnode[1]] = $0 |
26215 |
+ } |
26216 |
+ } |
26217 |
+ |
26218 |
+ close(ENVFILES[count]) |
26219 |
+ } |
26220 |
+ |
26221 |
+ for (x in ENVTREE) |
26222 |
+ print "export " x "=\"" ENVTREE[x] "\"" >> (ENVCACHE) |
26223 |
+ |
26224 |
+ for (x in ENVTREE) { |
26225 |
+ |
26226 |
+ # Print this a second time to make sure all variables |
26227 |
+ # are expanded .. |
26228 |
+ print "export " x "=\"" ENVTREE[x] "\"" >> (ENVCACHE) |
26229 |
+ print "echo \"" x "=${" x "}\"" >> (ENVCACHE) |
26230 |
+ } |
26231 |
+ |
26232 |
+ close (ENVCACHE) |
26233 |
+ |
26234 |
+ unlink(SHPROFILE) |
26235 |
+ unlink(CSHPROFILE) |
26236 |
+ |
26237 |
+ # Add warning header for SHPROFILE |
26238 |
+ print "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update." > (SHPROFILE) |
26239 |
+ print "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES" >> (SHPROFILE) |
26240 |
+ print "# GO INTO /etc/profile NOT /etc/profile.env" >> (SHPROFILE) |
26241 |
+ print "" >> (SHPROFILE) |
26242 |
+ |
26243 |
+ # Add warning header for CSHPROFILE |
26244 |
+ print "# THIS FILE IS AUTOMATICALLY GENERATED BY env-update." > (CSHPROFILE) |
26245 |
+ print "# DO NOT EDIT THIS FILE. CHANGES TO STARTUP PROFILES" >> (CSHPROFILE) |
26246 |
+ print "# GO INTO /etc/csh.cshrc NOT /etc/csh.env" >> (CSHPROFILE) |
26247 |
+ print "" >> (CSHPROFILE) |
26248 |
+ |
26249 |
+ |
26250 |
+ pipe = "bash " ENVCACHE |
26251 |
+ while ((pipe | getline) > 0) { |
26252 |
+ |
26253 |
+ sub(/=/, "='") |
26254 |
+ sub(/$/, "'") |
26255 |
+ |
26256 |
+ print "export " $0 >> (SHPROFILE) |
26257 |
+ |
26258 |
+ sub(/=/, " ") |
26259 |
+ |
26260 |
+ print "setenv " $0 >> (CSHPROFILE) |
26261 |
+ } |
26262 |
+ |
26263 |
+ close(pipe) |
26264 |
+ close(SHPROFILE) |
26265 |
+ close(CSHPROFILE) |
26266 |
+} |
26267 |
+ |
26268 |
+ |
26269 |
+# vim:ts=4 |
26270 |
|
26271 |
Added: trunk/baselayout-prefix/src/consoletype.c |
26272 |
=================================================================== |
26273 |
--- trunk/baselayout-prefix/src/consoletype.c (rev 0) |
26274 |
+++ trunk/baselayout-prefix/src/consoletype.c 2011-03-31 14:11:17 UTC (rev 1682) |
26275 |
@@ -0,0 +1,38 @@ |
26276 |
+/* |
26277 |
+ * consoletype.c |
26278 |
+ * simple app to figure out whether the current terminal |
26279 |
+ * is serial, console (vt), or remote (pty). |
26280 |
+ * |
26281 |
+ * Copyright 1999-2004 Gentoo Foundation |
26282 |
+ * Distributed under the terms of the GNU General Public License v2 |
26283 |
+ * $Header$ |
26284 |
+ */ |
26285 |
+ |
26286 |
+#include <stdio.h> |
26287 |
+#include <string.h> |
26288 |
+#include <sys/ioctl.h> |
26289 |
+#include <sys/stat.h> |
26290 |
+#include "headers.h" |
26291 |
+ |
26292 |
+int main(int argc, char *argv[]) |
26293 |
+{ |
26294 |
+ unsigned char twelve = 12; |
26295 |
+ int maj; |
26296 |
+ struct stat sb; |
26297 |
+ |
26298 |
+ fstat(0, &sb); |
26299 |
+ maj = major(sb.st_rdev); |
26300 |
+ if (maj != 3 && (maj < 136 || maj > 143)) { |
26301 |
+#if defined(__linux__) |
26302 |
+ if (ioctl (0, TIOCLINUX, &twelve) < 0) { |
26303 |
+ printf("serial\n"); |
26304 |
+ return 1; |
26305 |
+ } |
26306 |
+#endif |
26307 |
+ printf("vt\n"); |
26308 |
+ return 0; |
26309 |
+ } else { |
26310 |
+ printf("pty\n"); |
26311 |
+ return 2; |
26312 |
+ } |
26313 |
+} |
26314 |
|
26315 |
Added: trunk/baselayout-prefix/src/core/ChangeLog |
26316 |
=================================================================== |
26317 |
--- trunk/baselayout-prefix/src/core/ChangeLog (rev 0) |
26318 |
+++ trunk/baselayout-prefix/src/core/ChangeLog 2011-03-31 14:11:17 UTC (rev 1682) |
26319 |
@@ -0,0 +1,163 @@ |
26320 |
+# ChangeLog for Gentoo System Intialization core utilities. |
26321 |
+# Copyright 1999-2006 Gentoo Foundation; Distributed under the GPLv2 |
26322 |
+# $Header$ |
26323 |
+ |
26324 |
+26 Jul 2005 Martin Schlemmer <azarah@g.o> |
26325 |
+ |
26326 |
+ * depend.c |
26327 |
+ * depend.h |
26328 |
+ * parse.c |
26329 |
+ * parse.h: Remove the "parallel" stuff, as we do not use it anymore. |
26330 |
+ |
26331 |
+15 Apr 2005 Martin Schlemmer <azarah@g.o> |
26332 |
+ |
26333 |
+ * parse.c: Do not source rc.conf for every script - once is enough. |
26334 |
+ |
26335 |
+14 Apr 2005 Martin Schlemmer <azarah@g.o> |
26336 |
+ |
26337 |
+ * depscan.c: Update error comments for stage name changes some time |
26338 |
+ back. |
26339 |
+ |
26340 |
+ * parse.c, |
26341 |
+ * parse.h: Do not try to extract the depend() function from the |
26342 |
+ scripts, but rather source the whole file. This way we can detect |
26343 |
+ syntax errors, etc. Little bit slower, but not much. |
26344 |
+ |
26345 |
+07 Apr 2005 Martin Schlemmer <azarah@g.o> |
26346 |
+ |
26347 |
+ * test-regex.c: Add two more tests. |
26348 |
+ |
26349 |
+ * depscan.c |
26350 |
+ * misc.c |
26351 |
+ * misc.h: Add basic klibc support. I need to add a mkstemp |
26352 |
+ implementation to get it done properly. |
26353 |
+ |
26354 |
+12 Mar 2005 Martin Schlemmer <azarah@g.o> |
26355 |
+ |
26356 |
+ * Makefile: Also remove the tests in the clean target. |
26357 |
+ |
26358 |
+11 Mar 2005 Martin Schlemmer <azarah@g.o> |
26359 |
+ |
26360 |
+ * test-regex.c: Add a few strings and patterns. Enable tests to |
26361 |
+ specify if they should fail or pass. |
26362 |
+ |
26363 |
+10 Mar 2005 Martin Schlemmer <azarah@g.o> |
26364 |
+ |
26365 |
+ * test-regex.c: New file |
26366 |
+ * Makefile: Add check target to compile and run tests |
26367 |
+ * simple-regex.c (__match_wildcard): Get recursion right so that we |
26368 |
+ do not match a wildcard _and_ inc data_p if there are still other |
26369 |
+ wildcards (?, *) that could match. |
26370 |
+ |
26371 |
+ * Makefile |
26372 |
+ * depend.c |
26373 |
+ * simple-regex.c: Override the debug/warning CFLAGS. Kill a few |
26374 |
+ warnings. |
26375 |
+ |
26376 |
+23 Feb 2005 Martin Schlemmer <azarah@g.o> |
26377 |
+ |
26378 |
+ * misc.c: Fix memory leak in mktree(). |
26379 |
+ |
26380 |
+18 Feb 2005 Martin Schlemmer <azarah@g.o> |
26381 |
+ |
26382 |
+ * Makefile: Add -fbounds-checking support when DEBUG=1. |
26383 |
+ |
26384 |
+ * misc.h: Scrap STRING_LIST_FOR_EACH_SAFE() and recode from scratch |
26385 |
+ fixing invalid pointer operations. |
26386 |
+ |
26387 |
+ * misc.c: Remove the last strlen() from strndup() that caused an |
26388 |
+ overrun. |
26389 |
+ |
26390 |
+17 Feb 2005 Martin Schlemmer <azarah@g.o>: |
26391 |
+ |
26392 |
+ * misc.c: Fix overrun in strndup(), thanks to report from |
26393 |
+ Ned Ludd <solar@g.o>. |
26394 |
+ |
26395 |
+ * debug.h |
26396 |
+ * misc.h |
26397 |
+ * simple-regex.c: Print debug/errors to stderr, patch from |
26398 |
+ Ned Ludd <solar@g.o>. |
26399 |
+ |
26400 |
+ * debug.h: Replace invalid EXIT_FAILSTATUS with EXIT_FAILURE. |
26401 |
+ |
26402 |
+ * parse.c: Modify parse_print_body() to be more ash friendly. |
26403 |
+ Suggestions from Ned Ludd <solar@g.o>. |
26404 |
+ |
26405 |
+ * debug.h: Remove the 'errno = ESPIPE' in DBG_MSG() for now, as it |
26406 |
+ seems to be fixed by the select() changes. |
26407 |
+ |
26408 |
+ * parse.c: Disable write select() for now, as it is not needed. |
26409 |
+ |
26410 |
+ * depscan.c: Only print EINFO msg if we actually update the cache. |
26411 |
+ |
26412 |
+ * parse.c: Rename write_output() macro to PRINT_TO_BUFFER(). |
26413 |
+ |
26414 |
+ * parse.c |
26415 |
+ * parse.h: Rewrote large parts of generate_stage[12]() and their |
26416 |
+ machanics to use select() when writing to the pipes. This fixes a |
26417 |
+ buffering issue where too much data would cause the write to be |
26418 |
+ truncated, and the read pipe would then wait forever. |
26419 |
+ |
26420 |
+ * misc.c: Fix gbasename() to compile under gcc-2.95.3. |
26421 |
+ |
26422 |
+ * parse.c: Switch to stdio based io for reading pipes in |
26423 |
+ generate_stage2(). |
26424 |
+ |
26425 |
+ * misc.c |
26426 |
+ * misc.h: Add gbasename() that is similar to GNU's basename(). |
26427 |
+ |
26428 |
+ * parse.c: Use gbasename() instead of POSIX version. |
26429 |
+ |
26430 |
+ * parse.c: Fix write_legacy_stage3() to quote the mtime in its output. |
26431 |
+ |
26432 |
+ * misc.c |
26433 |
+ * parse.c: Change type of length from int to size_t to avoid warnings |
26434 |
+ when compiled for darwin. |
26435 |
+ |
26436 |
+ * misc.c |
26437 |
+ misc.h: Add strndup() instead of relying on glibc's implementation |
26438 |
+ (should fix some issues on bsd and darwin). |
26439 |
+ |
26440 |
+ * depend.c |
26441 |
+ * simple-regex.c: Do not define _GNU_SOURCE, but rather use our |
26442 |
+ strndup() from misc.h. |
26443 |
+ |
26444 |
+ * parse.c: Do not define _GNU_SOURCE, but rather use our strndup() from |
26445 |
+ misc.h. Also change all usage of basename() to conform to POSIX, and |
26446 |
+ do not use the GNU variants. |
26447 |
+ |
26448 |
+16 Feb 2005; Martin Schlemmer <azarah@g.o>: |
26449 |
+ |
26450 |
+ * depscan.c: Add uid check and quit if user is not root. |
26451 |
+ |
26452 |
+ * depend.c |
26453 |
+ * depend.h: Change service_type_names declaration in depend.h to extern |
26454 |
+ and move the definition to depend.c to avoid warnings. |
26455 |
+ |
26456 |
+ * README: New file. |
26457 |
+ |
26458 |
+ * depscan.c: Add delete_var_dirs() to delete volatile directories in |
26459 |
+ svcdir. Change 'char *' declarations for create_directory() and |
26460 |
+ create_var_dirs() to 'const char*'. |
26461 |
+ |
26462 |
+ * misc.h |
26463 |
+ * misc.c: Add rmtree() function. Fix ls_dir() not to include '.' and |
26464 |
+ '..' in its listing. Fix segfault in ls_dir() if the file list is |
26465 |
+ empty. |
26466 |
+ |
26467 |
+ Add Header tags to all source files and Makefile. |
26468 |
+ |
26469 |
+ * debug.h: perror() set errno to ESPIPE for some reason - restore errno |
26470 |
+ after calling perror(). |
26471 |
+ |
26472 |
+ * depscan.c: Add code to create svcdir and co if missing. |
26473 |
+ |
26474 |
+ * misc.c: Add missing '\n' to DBG_MSG in mktree(). |
26475 |
+ |
26476 |
+ * misc.h: Add a comment about strcatpaths() allocating the memory needed. |
26477 |
+ |
26478 |
+ Initial checkin. Still rough in some parts, but should be 100% similar |
26479 |
+ in output to depscan.sh and co. |
26480 |
+ |
26481 |
+ |
26482 |
+# vim:expandtab |
26483 |
|
26484 |
Added: trunk/baselayout-prefix/src/core/Makefile |
26485 |
=================================================================== |
26486 |
--- trunk/baselayout-prefix/src/core/Makefile (rev 0) |
26487 |
+++ trunk/baselayout-prefix/src/core/Makefile 2011-03-31 14:11:17 UTC (rev 1682) |
26488 |
@@ -0,0 +1,81 @@ |
26489 |
+# Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
26490 |
+# |
26491 |
+# |
26492 |
+# This program is free software; you can redistribute it and/or modify it |
26493 |
+# under the terms of the GNU General Public License as published by the |
26494 |
+# Free Software Foundation version 2 of the License. |
26495 |
+# |
26496 |
+# This program is distributed in the hope that it will be useful, but |
26497 |
+# WITHOUT ANY WARRANTY; without even the implied warranty of |
26498 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
26499 |
+# General Public License for more details. |
26500 |
+# |
26501 |
+# You should have received a copy of the GNU General Public License along |
26502 |
+# with this program; if not, write to the Free Software Foundation, Inc., |
26503 |
+# 675 Mass Ave, Cambridge, MA 02139, USA. |
26504 |
+# |
26505 |
+# $Header$ |
26506 |
+ |
26507 |
+CC = gcc |
26508 |
+override CFLAGS += -Wall |
26509 |
+EXTRA_CFLAGS = -DLEGACY_DEPSCAN |
26510 |
+STRIP = strip |
26511 |
+ |
26512 |
+DEPSCAN = depscan |
26513 |
+TEST_REGEX = test-regex |
26514 |
+ |
26515 |
+TARGETS = $(DEPSCAN) |
26516 |
+CHECK_TARGETS = $(TEST_REGEX) |
26517 |
+ |
26518 |
+all: $(TARGETS) |
26519 |
+ |
26520 |
+.ALL: all |
26521 |
+ |
26522 |
+OBJS = \ |
26523 |
+ parse.o \ |
26524 |
+ depend.o \ |
26525 |
+ simple-regex.o \ |
26526 |
+ misc.o |
26527 |
+ |
26528 |
+HEADERS = \ |
26529 |
+ parse.h \ |
26530 |
+ depend.h \ |
26531 |
+ simple-regex.h \ |
26532 |
+ misc.h \ |
26533 |
+ debug.h |
26534 |
+ |
26535 |
+ |
26536 |
+# cc-option (from linux kernel sources) |
26537 |
+# Usage: cflags-y += $(call gcc-option, -march=winchip-c6, -march=i586) |
26538 |
+ |
26539 |
+cc-option = $(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null \ |
26540 |
+ > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) |
26541 |
+ |
26542 |
+ |
26543 |
+ifeq ($(DEBUG),1) |
26544 |
+ override CFLAGS += -ggdb3 |
26545 |
+ override CFLAGS += $(call cc-option, -fbounds-checking, -pipe) |
26546 |
+ EXTRA_CFLAGS += -DRC_DEBUG |
26547 |
+endif |
26548 |
+ |
26549 |
+$(DEPSCAN): $(OBJS) $(DEPSCAN).o |
26550 |
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $^ |
26551 |
+ |
26552 |
+$(TEST_REGEX): $(TEST_REGEX).o simple-regex.o |
26553 |
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $^ |
26554 |
+ |
26555 |
+$(OBJS): $(HEADERS) |
26556 |
+ |
26557 |
+.c.o: |
26558 |
+ $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< |
26559 |
+ |
26560 |
+check: $(CHECK_TARGETS) |
26561 |
+ @for x in $^; do \ |
26562 |
+ ./$${x} || exit 1; \ |
26563 |
+ done |
26564 |
+ |
26565 |
+strip: $(TARGETS) |
26566 |
+ $(STRIP) -s --remove-section=.note --remove-section=.comment $(TARGETS) |
26567 |
+ |
26568 |
+clean: |
26569 |
+ rm -f *.o $(TARGETS) $(CHECK_TARGETS) |
26570 |
|
26571 |
Added: trunk/baselayout-prefix/src/core/README |
26572 |
=================================================================== |
26573 |
--- trunk/baselayout-prefix/src/core/README (rev 0) |
26574 |
+++ trunk/baselayout-prefix/src/core/README 2011-03-31 14:11:17 UTC (rev 1682) |
26575 |
@@ -0,0 +1,15 @@ |
26576 |
+* Introduction |
26577 |
+============== |
26578 |
+ |
26579 |
+This is still fairly alpha code, although I have tried to regression test it |
26580 |
+fairly extensively. After many requests, I have added it to CVS, so please |
26581 |
+do understand that it still is work in progress, although it should duplicate |
26582 |
+depscan.sh in functionality. |
26583 |
+ |
26584 |
+To all those that might dabble with this, please send comments or fixes my |
26585 |
+way, and if I can ask very nicely, please do not commit before checking with |
26586 |
+me first, as I do have some large changes and additions still in the pipeline. |
26587 |
+ |
26588 |
+ |
26589 |
+Martin Schlemmer |
26590 |
+<azarah@g.o> |
26591 |
|
26592 |
Added: trunk/baselayout-prefix/src/core/debug.h |
26593 |
=================================================================== |
26594 |
--- trunk/baselayout-prefix/src/core/debug.h (rev 0) |
26595 |
+++ trunk/baselayout-prefix/src/core/debug.h 2011-03-31 14:11:17 UTC (rev 1682) |
26596 |
@@ -0,0 +1,85 @@ |
26597 |
+/* |
26598 |
+ * debug.h |
26599 |
+ * |
26600 |
+ * Simle debugging/logging macro's and functions. |
26601 |
+ * |
26602 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
26603 |
+ * |
26604 |
+ * |
26605 |
+ * This program is free software; you can redistribute it and/or modify it |
26606 |
+ * under the terms of the GNU General Public License as published by the |
26607 |
+ * Free Software Foundation version 2 of the License. |
26608 |
+ * |
26609 |
+ * This program is distributed in the hope that it will be useful, but |
26610 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
26611 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
26612 |
+ * General Public License for more details. |
26613 |
+ * |
26614 |
+ * You should have received a copy of the GNU General Public License along |
26615 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
26616 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
26617 |
+ * |
26618 |
+ * $Header$ |
26619 |
+ */ |
26620 |
+ |
26621 |
+#ifndef _DEBUG_H |
26622 |
+#define _DEBUG_H |
26623 |
+ |
26624 |
+#if defined(RC_DEBUG) |
26625 |
+# define DBG_MSG(_format, _arg...) \ |
26626 |
+ do { \ |
26627 |
+ int old_errno = errno; \ |
26628 |
+ fprintf(stderr, "DEBUG(1): in %s, function %s(), line %i:\n", __FILE__, \ |
26629 |
+ __FUNCTION__, __LINE__); \ |
26630 |
+ fprintf(stderr, "DEBUG(2): " _format, ## _arg); \ |
26631 |
+ errno = old_errno; \ |
26632 |
+ if (0 != errno) { \ |
26633 |
+ perror("DEBUG(3)"); \ |
26634 |
+ /* perror() for some reason sets errno to ESPIPE */ \ |
26635 |
+ errno = old_errno; \ |
26636 |
+ } \ |
26637 |
+ } while (0) |
26638 |
+#else |
26639 |
+# define DBG_MSG(_format, _arg...) \ |
26640 |
+ do { \ |
26641 |
+ int old_errno = errno; \ |
26642 |
+ /* Bit of a hack, as how we do things tend to cause seek |
26643 |
+ * errors when reading the parent/child pipes */ \ |
26644 |
+ /* if ((0 != errno) && (ESPIPE != errno)) { */ \ |
26645 |
+ if (0 != errno) { \ |
26646 |
+ fprintf(stderr, "DEBUG(1): in %s, function %s(), line %i:\n", \ |
26647 |
+ __FILE__, __FUNCTION__, __LINE__); \ |
26648 |
+ fprintf(stderr, "DEBUG(2): " _format, ## _arg); \ |
26649 |
+ errno = old_errno; \ |
26650 |
+ perror("DEBUG(3)"); \ |
26651 |
+ /* perror() for some reason sets errno to ESPIPE */ \ |
26652 |
+ errno = old_errno; \ |
26653 |
+ } \ |
26654 |
+ } while (0) |
26655 |
+#endif |
26656 |
+ |
26657 |
+#define FATAL_ERROR() \ |
26658 |
+ do { \ |
26659 |
+ int old_errno = errno; \ |
26660 |
+ fprintf(stderr, "ERROR: file '%s', function '%s', line %i.\n", \ |
26661 |
+ __FILE__, __FUNCTION__, __LINE__); \ |
26662 |
+ errno = old_errno; \ |
26663 |
+ if (0 != errno) \ |
26664 |
+ perror("ERROR"); \ |
26665 |
+ exit(EXIT_FAILURE); \ |
26666 |
+ } while (0) |
26667 |
+ |
26668 |
+#define NEG_FATAL_ERROR(_x) \ |
26669 |
+ do { \ |
26670 |
+ if (-1 == _x) \ |
26671 |
+ FATAL_ERROR(); \ |
26672 |
+ } while (0) |
26673 |
+ |
26674 |
+#define NULL_FATAL_ERROR(_x) \ |
26675 |
+ do { \ |
26676 |
+ if (NULL == _x) \ |
26677 |
+ FATAL_ERROR(); \ |
26678 |
+ } while (0) |
26679 |
+ |
26680 |
+#endif /* _DEBUG_H */ |
26681 |
+ |
26682 |
|
26683 |
Added: trunk/baselayout-prefix/src/core/depend.c |
26684 |
=================================================================== |
26685 |
--- trunk/baselayout-prefix/src/core/depend.c (rev 0) |
26686 |
+++ trunk/baselayout-prefix/src/core/depend.c 2011-03-31 14:11:17 UTC (rev 1682) |
26687 |
@@ -0,0 +1,532 @@ |
26688 |
+/* |
26689 |
+ * depend.c |
26690 |
+ * |
26691 |
+ * Dependancy engine for Gentoo style rc-scripts. |
26692 |
+ * |
26693 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
26694 |
+ * |
26695 |
+ * |
26696 |
+ * This program is free software; you can redistribute it and/or modify it |
26697 |
+ * under the terms of the GNU General Public License as published by the |
26698 |
+ * Free Software Foundation version 2 of the License. |
26699 |
+ * |
26700 |
+ * This program is distributed in the hope that it will be useful, but |
26701 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
26702 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
26703 |
+ * General Public License for more details. |
26704 |
+ * |
26705 |
+ * You should have received a copy of the GNU General Public License along |
26706 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
26707 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
26708 |
+ * |
26709 |
+ * $Header$ |
26710 |
+ */ |
26711 |
+ |
26712 |
+#include <errno.h> |
26713 |
+#include <string.h> |
26714 |
+#include <stddef.h> |
26715 |
+#include <stdio.h> |
26716 |
+#include <stdlib.h> |
26717 |
+ |
26718 |
+#include "debug.h" |
26719 |
+#include "depend.h" |
26720 |
+#include "list.h" |
26721 |
+#include "misc.h" |
26722 |
+ |
26723 |
+LIST_HEAD(service_info_list); |
26724 |
+ |
26725 |
+/* Names for service types (service_type_t) in depend.h. |
26726 |
+ * Note that this should sync with service_type_t */ |
26727 |
+char *service_type_names[] = { |
26728 |
+ "NEED", |
26729 |
+ "NEED_ME", |
26730 |
+ "USE", |
26731 |
+ "USE_ME", |
26732 |
+ "BEFORE", |
26733 |
+ "AFTER", |
26734 |
+ "BROKEN", |
26735 |
+ "PROVIDE", |
26736 |
+ NULL |
26737 |
+}; |
26738 |
+ |
26739 |
+int __service_resolve_dependency(char *servicename, char *dependency, service_type_t type); |
26740 |
+ |
26741 |
+service_info_t *service_get_info(char *servicename) { |
26742 |
+ service_info_t *info; |
26743 |
+ |
26744 |
+ if ((NULL == servicename) || (0 == strlen(servicename))) { |
26745 |
+ DBG_MSG("Invalid argument passed!\n"); |
26746 |
+ return NULL; |
26747 |
+ } |
26748 |
+ |
26749 |
+ list_for_each_entry(info, &service_info_list, node) { |
26750 |
+ if (NULL != info->name) |
26751 |
+ if (0 == strcmp(info->name, servicename)) |
26752 |
+ return info; |
26753 |
+ } |
26754 |
+ |
26755 |
+ /* We use this to check if a service exists, so rather do not |
26756 |
+ * add debugging, otherwise it is very noisy! */ |
26757 |
+ /* DBG_MSG("Invalid service name '%s'!\n", servicename); */ |
26758 |
+ |
26759 |
+ return NULL; |
26760 |
+} |
26761 |
+ |
26762 |
+int service_add(char *servicename) { |
26763 |
+ service_info_t *info; |
26764 |
+ service_info_t *sorted; |
26765 |
+ int count; |
26766 |
+ |
26767 |
+ if ((NULL == servicename) || (0 == strlen(servicename))) { |
26768 |
+ DBG_MSG("Invalid argument passed!\n"); |
26769 |
+ return -1; |
26770 |
+ } |
26771 |
+ |
26772 |
+ info = service_get_info(servicename); |
26773 |
+ if (NULL == info) { |
26774 |
+ DBG_MSG("Adding service '%s'.\n", servicename); |
26775 |
+ |
26776 |
+ info = malloc(sizeof(service_info_t)); |
26777 |
+ if (NULL == info) { |
26778 |
+ DBG_MSG("Failed to allocate service_info_t!\n"); |
26779 |
+ return -1; |
26780 |
+ } |
26781 |
+ |
26782 |
+ info->name = strndup(servicename, strlen(servicename)); |
26783 |
+ if (NULL == info->name) { |
26784 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
26785 |
+ free(info); |
26786 |
+ return -1; |
26787 |
+ } |
26788 |
+ |
26789 |
+ for (count = 0; count < ALL_SERVICE_TYPE_T; count++) |
26790 |
+ info->depend_info[count] = NULL; |
26791 |
+ info->provide = NULL; |
26792 |
+ |
26793 |
+ /* We want to keep the list sorted */ |
26794 |
+ list_for_each_entry(sorted, &service_info_list, node) { |
26795 |
+ if (strcmp(sorted->name, servicename) > 0) { |
26796 |
+ break; |
26797 |
+ } |
26798 |
+ } |
26799 |
+ |
26800 |
+ list_add_tail(&info->node, &sorted->node); |
26801 |
+ |
26802 |
+ return 0; |
26803 |
+ } else { |
26804 |
+ DBG_MSG("Tried to add duplicate service '%s'!\n", servicename); |
26805 |
+ } |
26806 |
+ |
26807 |
+ return -1; |
26808 |
+} |
26809 |
+ |
26810 |
+int service_is_dependency(char *servicename, char *dependency, service_type_t type) { |
26811 |
+ service_info_t *info; |
26812 |
+ char *service; |
26813 |
+ int count = 0; |
26814 |
+ |
26815 |
+ if ((NULL == servicename) || (0 == strlen(servicename)) || |
26816 |
+ (NULL == dependency) || (0 == strlen(dependency))) { |
26817 |
+ DBG_MSG("Invalid argument passed!\n"); |
26818 |
+ return -1; |
26819 |
+ } |
26820 |
+ |
26821 |
+ info = service_get_info(servicename); |
26822 |
+ if (NULL != info) { |
26823 |
+ STRING_LIST_FOR_EACH(info->depend_info[type], service, count) { |
26824 |
+ if (0 == strcmp(dependency, service)) |
26825 |
+ return 0; |
26826 |
+ } |
26827 |
+ } else { |
26828 |
+ DBG_MSG("Invalid service name '%s'!\n", servicename); |
26829 |
+ } |
26830 |
+ |
26831 |
+ return -1; |
26832 |
+} |
26833 |
+ |
26834 |
+int service_add_dependency(char *servicename, char *dependency, service_type_t type) { |
26835 |
+ service_info_t *info; |
26836 |
+ char *tmp_buf; |
26837 |
+ |
26838 |
+ if ((NULL == servicename) || (0 == strlen(servicename)) || |
26839 |
+ (NULL == dependency) || (0 == strlen(dependency))) { |
26840 |
+ DBG_MSG("Invalid argument passed!\n"); |
26841 |
+ return -1; |
26842 |
+ } |
26843 |
+ |
26844 |
+ info = service_get_info(servicename); |
26845 |
+ if (NULL != info) { |
26846 |
+ /* Do not add duplicates */ |
26847 |
+ if (-1 == service_is_dependency(servicename, dependency, type)) { |
26848 |
+ DBG_MSG("Adding dependency '%s' of service '%s', type '%s'.\n", |
26849 |
+ dependency, servicename, service_type_names[type]); |
26850 |
+ |
26851 |
+ tmp_buf = strndup(dependency, strlen(dependency)); |
26852 |
+ if (NULL == tmp_buf) { |
26853 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
26854 |
+ return -1; |
26855 |
+ } |
26856 |
+ |
26857 |
+ STRING_LIST_ADD_SORT(info->depend_info[type], tmp_buf, error); |
26858 |
+ } else { |
26859 |
+ DBG_MSG("Duplicate dependency '%s' for service '%s', type '%s'!\n", |
26860 |
+ dependency, servicename, |
26861 |
+ service_type_names[type]); |
26862 |
+ /* Rather do not fail here, as we add a lot of doubles |
26863 |
+ * during resolving of dependencies */ |
26864 |
+ } |
26865 |
+ |
26866 |
+ return 0; |
26867 |
+ } else { |
26868 |
+ DBG_MSG("Invalid service name '%s'!\n", servicename); |
26869 |
+ } |
26870 |
+ |
26871 |
+error: |
26872 |
+ return -1; |
26873 |
+} |
26874 |
+ |
26875 |
+int service_del_dependency(char *servicename, char *dependency, service_type_t type) { |
26876 |
+ service_info_t *info; |
26877 |
+ |
26878 |
+ if ((NULL == servicename) || (0 == strlen(servicename)) || |
26879 |
+ (NULL == dependency) || (0 == strlen(dependency))) { |
26880 |
+ DBG_MSG("Invalid argument passed!\n"); |
26881 |
+ return -1; |
26882 |
+ } |
26883 |
+ |
26884 |
+ if (-1 == service_is_dependency(servicename, dependency, type)) { |
26885 |
+ DBG_MSG("Tried to remove invalid dependency '%s'!\n", dependency); |
26886 |
+ return -1; |
26887 |
+ } |
26888 |
+ |
26889 |
+ info = service_get_info(servicename); |
26890 |
+ if (NULL != info) { |
26891 |
+ DBG_MSG("Removing dependency '%s' of service '%s', type '%s'.\n", |
26892 |
+ dependency , servicename, service_type_names[type]); |
26893 |
+ |
26894 |
+ STRING_LIST_DEL(info->depend_info[type], dependency, error); |
26895 |
+ return 0; |
26896 |
+ } else { |
26897 |
+ DBG_MSG("Invalid service name '%s'!\n", servicename); |
26898 |
+ } |
26899 |
+ |
26900 |
+error: |
26901 |
+ return -1; |
26902 |
+} |
26903 |
+ |
26904 |
+service_info_t *service_get_virtual(char *virtual) { |
26905 |
+ service_info_t *info; |
26906 |
+ |
26907 |
+ if ((NULL == virtual) || (0 == strlen(virtual))) { |
26908 |
+ DBG_MSG("Invalid argument passed!\n"); |
26909 |
+ return NULL; |
26910 |
+ } |
26911 |
+ |
26912 |
+ list_for_each_entry(info, &service_info_list, node) { |
26913 |
+ if (NULL != info->provide) |
26914 |
+ if (0 == strcmp(info->provide, virtual)) |
26915 |
+ return info; |
26916 |
+ } |
26917 |
+ |
26918 |
+ /* We use this to check if a virtual exists, so rather do not |
26919 |
+ * add debugging, otherwise it is very noisy! */ |
26920 |
+ /* DBG_MSG("Invalid service name '%s'!\n", virtual); */ |
26921 |
+ |
26922 |
+ return NULL; |
26923 |
+} |
26924 |
+ |
26925 |
+int service_add_virtual(char *servicename, char* virtual) { |
26926 |
+ service_info_t *info; |
26927 |
+ |
26928 |
+ if ((NULL == servicename) || (0 == strlen(servicename)) || |
26929 |
+ (NULL == virtual ) || (0 == strlen(virtual))) { |
26930 |
+ DBG_MSG("Invalid argument passed!\n"); |
26931 |
+ return -1; |
26932 |
+ } |
26933 |
+ |
26934 |
+ if (NULL != service_get_info(virtual)) { |
26935 |
+ EERROR(" Cannot add provide '%s', as a service with the same name exists!\n", |
26936 |
+ virtual); |
26937 |
+ /* Do not fail here as we do have a service that resolves |
26938 |
+ * the virtual */ |
26939 |
+ } |
26940 |
+ |
26941 |
+ info = service_get_virtual(virtual); |
26942 |
+ if (NULL != info) { |
26943 |
+ /* We cannot have more than one service Providing a virtual */ |
26944 |
+ EWARN(" Service '%s' already provides '%s'!;\n", |
26945 |
+ info->name, virtual); |
26946 |
+ EWARN(" Not adding service '%s'...\n", servicename); |
26947 |
+ /* Do not fail here as we do have a service that resolves |
26948 |
+ * the virtual */ |
26949 |
+ } else { |
26950 |
+ info = service_get_info(servicename); |
26951 |
+ if (NULL != info) { |
26952 |
+ DBG_MSG("Adding virtual '%s' of service '%s'.\n", |
26953 |
+ virtual, servicename); |
26954 |
+ |
26955 |
+ info->provide = strndup(virtual, strlen(virtual)); |
26956 |
+ if (NULL == info->provide) { |
26957 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
26958 |
+ return -1; |
26959 |
+ } |
26960 |
+ } else { |
26961 |
+ DBG_MSG("Invalid service name '%s'!\n", servicename); |
26962 |
+ return -1; |
26963 |
+ } |
26964 |
+ } |
26965 |
+ |
26966 |
+ return 0; |
26967 |
+} |
26968 |
+ |
26969 |
+int service_set_mtime(char *servicename, time_t mtime) { |
26970 |
+ service_info_t *info; |
26971 |
+ |
26972 |
+ if ((NULL == servicename) || (0 == strlen(servicename))) { |
26973 |
+ DBG_MSG("Invalid argument passed!\n"); |
26974 |
+ return -1; |
26975 |
+ } |
26976 |
+ |
26977 |
+ info = service_get_info(servicename); |
26978 |
+ if (NULL != info) { |
26979 |
+ DBG_MSG("Setting mtime '%li' of service '%s'.\n", |
26980 |
+ mtime, servicename); |
26981 |
+ |
26982 |
+ info->mtime = mtime; |
26983 |
+ |
26984 |
+ return 0; |
26985 |
+ } else { |
26986 |
+ DBG_MSG("Invalid service name '%s'!\n", servicename); |
26987 |
+ } |
26988 |
+ |
26989 |
+ return -1; |
26990 |
+} |
26991 |
+ |
26992 |
+int __service_resolve_dependency(char *servicename, char *dependency, service_type_t type) { |
26993 |
+ service_info_t *info; |
26994 |
+ int retval; |
26995 |
+ |
26996 |
+ if ((NULL == servicename) || (0 == strlen(servicename)) || |
26997 |
+ (NULL == dependency) || (0 == strlen(dependency))) { |
26998 |
+ DBG_MSG("Invalid argument passed!\n"); |
26999 |
+ return -1; |
27000 |
+ } |
27001 |
+ |
27002 |
+ info = service_get_info(servicename); |
27003 |
+ if (NULL == info) { |
27004 |
+ DBG_MSG("Invalid service name passed!\n"); |
27005 |
+ return -1; |
27006 |
+ } |
27007 |
+ |
27008 |
+ DBG_MSG("Checking dependency '%s' of service '%s', type '%s'.\n", |
27009 |
+ dependency, servicename, service_type_names[type]); |
27010 |
+ |
27011 |
+ /* If there are no existing service 'dependency', try to resolve |
27012 |
+ * possible virtual services */ |
27013 |
+ info = service_get_info(dependency); |
27014 |
+ if (NULL == info) { |
27015 |
+ info = service_get_virtual(dependency); |
27016 |
+ if (NULL != info) { |
27017 |
+ DBG_MSG("Virtual '%s' -> '%s' for service '%s', type '%s'.\n", |
27018 |
+ dependency, info->name, servicename, |
27019 |
+ service_type_names[type]); |
27020 |
+ |
27021 |
+ retval = service_del_dependency(servicename, dependency, type); |
27022 |
+ if (-1 == retval) { |
27023 |
+ DBG_MSG("Failed to delete dependency!\n"); |
27024 |
+ return -1; |
27025 |
+ } |
27026 |
+ |
27027 |
+ /* Add the actual service name for the virtual */ |
27028 |
+ dependency = info->name; |
27029 |
+ retval = service_add_dependency(servicename, dependency, type); |
27030 |
+ if (-1 == retval) { |
27031 |
+ DBG_MSG("Failed to add dependency!\n"); |
27032 |
+ return -1; |
27033 |
+ } |
27034 |
+ } |
27035 |
+ } |
27036 |
+ |
27037 |
+ /* Handle 'need', as it is the only dependency type that should |
27038 |
+ * handle invalid database entries currently. */ |
27039 |
+ if (NULL == info) { |
27040 |
+ if ((type == NEED) || (type == NEED_ME)) { |
27041 |
+ EWARN(" Can't find service '%s' needed by '%s'; continuing...\n", |
27042 |
+ dependency, servicename); |
27043 |
+ |
27044 |
+ retval = service_add_dependency(servicename, dependency, BROKEN); |
27045 |
+ if (-1 == retval) { |
27046 |
+ DBG_MSG("Failed to add dependency!\n"); |
27047 |
+ return -1; |
27048 |
+ } |
27049 |
+ |
27050 |
+ /* Delete invalid entry */ |
27051 |
+ goto remove; |
27052 |
+ } |
27053 |
+ |
27054 |
+ /* For the rest, if the dependency is not 'net', just silently |
27055 |
+ * die without error. Should not be needed as we add a 'net' |
27056 |
+ * service manually before we start, but you never know ... */ |
27057 |
+ if (0 != strcmp(dependency, "net")) { |
27058 |
+ /* Delete invalid entry */ |
27059 |
+ goto remove; |
27060 |
+ } |
27061 |
+ } |
27062 |
+ |
27063 |
+ /* Ugly bug ... if a service depends on itself, it creates a |
27064 |
+ * 'mini fork bomb' effect, and breaks things horribly ... */ |
27065 |
+ if (0 == strcmp(servicename, dependency)) { |
27066 |
+ /* Dont work too well with the '*' before and after */ |
27067 |
+ if ((type != BEFORE) && (type != AFTER)) |
27068 |
+ EWARN(" Service '%s' can't depend on itself; continuing...\n", |
27069 |
+ servicename); |
27070 |
+ |
27071 |
+ /* Delete invalid entry */ |
27072 |
+ goto remove; |
27073 |
+ } |
27074 |
+ |
27075 |
+ /* Currently only these depend/order types are supported */ |
27076 |
+ if ((type == NEED) || (type == USE) || (type == BEFORE) || (type == AFTER)) { |
27077 |
+ if (type == BEFORE) { |
27078 |
+ /* NEED and USE override BEFORE |
27079 |
+ * ('servicename' BEFORE 'dependency') */ |
27080 |
+ if ((0 == service_is_dependency(servicename, dependency, NEED)) || |
27081 |
+ (0 == service_is_dependency(servicename, dependency, USE))) { |
27082 |
+ /* Delete invalid entry */ |
27083 |
+ goto remove; |
27084 |
+ } |
27085 |
+ } |
27086 |
+ |
27087 |
+ if (type == AFTER) { |
27088 |
+ /* NEED and USE override AFTER |
27089 |
+ * ('servicename' AFTER 'dependency') */ |
27090 |
+ if ((0 == service_is_dependency(dependency, servicename, NEED)) || |
27091 |
+ (0 == service_is_dependency(dependency, servicename, USE))) { |
27092 |
+ /* Delete invalid entry */ |
27093 |
+ goto remove; |
27094 |
+ } |
27095 |
+ } |
27096 |
+ |
27097 |
+ /* We do not want to add circular dependencies ... */ |
27098 |
+ if (0 == service_is_dependency(dependency, servicename, type)) { |
27099 |
+ EWARN(" Services '%s' and '%s' have circular\n", |
27100 |
+ servicename, dependency); |
27101 |
+ EWARN(" dependency of type '%s'; continuing...\n", |
27102 |
+ service_type_names[type]); |
27103 |
+ |
27104 |
+ /* For now remove this dependency */ |
27105 |
+ goto remove; |
27106 |
+ } |
27107 |
+ |
27108 |
+ /* Reverse mapping */ |
27109 |
+ if (type == NEED) { |
27110 |
+ retval = service_add_dependency(dependency, servicename, NEED_ME); |
27111 |
+ if (-1 == retval) { |
27112 |
+ DBG_MSG("Failed to add dependency!\n"); |
27113 |
+ return -1; |
27114 |
+ } |
27115 |
+ } |
27116 |
+ |
27117 |
+ /* Reverse mapping */ |
27118 |
+ if (type == USE) { |
27119 |
+ retval = service_add_dependency(dependency, servicename, USE_ME); |
27120 |
+ if (-1 == retval) { |
27121 |
+ DBG_MSG("Failed to add dependency!\n"); |
27122 |
+ return -1; |
27123 |
+ } |
27124 |
+ } |
27125 |
+ |
27126 |
+ /* Reverse mapping */ |
27127 |
+ if (type == BEFORE) { |
27128 |
+ retval = service_add_dependency(dependency, servicename, AFTER); |
27129 |
+ if (-1 == retval) { |
27130 |
+ DBG_MSG("Failed to add dependency!\n"); |
27131 |
+ return -1; |
27132 |
+ } |
27133 |
+ } |
27134 |
+ |
27135 |
+ /* Reverse mapping */ |
27136 |
+ if (type == AFTER) { |
27137 |
+ retval = service_add_dependency(dependency, servicename, BEFORE); |
27138 |
+ if (-1 == retval) { |
27139 |
+ DBG_MSG("Failed to add dependency!\n"); |
27140 |
+ return -1; |
27141 |
+ } |
27142 |
+ } |
27143 |
+ } |
27144 |
+ |
27145 |
+ return 0; |
27146 |
+ |
27147 |
+remove: |
27148 |
+ /* Delete invalid entry */ |
27149 |
+ DBG_MSG("Removing invalid dependency '%s' of service '%s', type '%s'.\n", |
27150 |
+ dependency, servicename, service_type_names[type]); |
27151 |
+ |
27152 |
+ retval = service_del_dependency(servicename, dependency, type); |
27153 |
+ if (-1 == retval) { |
27154 |
+ DBG_MSG("Failed to delete dependency!\n"); |
27155 |
+ return -1; |
27156 |
+ } |
27157 |
+ |
27158 |
+ /* Here we should not die with error */ |
27159 |
+ return 0; |
27160 |
+} |
27161 |
+ |
27162 |
+int service_resolve_dependencies(void) { |
27163 |
+ service_info_t *info; |
27164 |
+ char *service; |
27165 |
+ char *next = NULL; |
27166 |
+ int count; |
27167 |
+ |
27168 |
+ /* Add our 'net' service */ |
27169 |
+ if (NULL == service_get_info("net")) { |
27170 |
+ if (-1 == service_add("net")) |
27171 |
+ return -1; |
27172 |
+ } |
27173 |
+ |
27174 |
+ /* Calculate all virtuals */ |
27175 |
+ list_for_each_entry(info, &service_info_list, node) { |
27176 |
+ STRING_LIST_FOR_EACH_SAFE(info->depend_info[PROVIDE], service, next, count) |
27177 |
+ if (-1 == service_add_virtual(info->name, service)) { |
27178 |
+ DBG_MSG("Failed to add virtual!\n"); |
27179 |
+ return -1; |
27180 |
+ } |
27181 |
+ } |
27182 |
+ |
27183 |
+ /* Now do NEED, USE, BEFORE and AFTER */ |
27184 |
+ list_for_each_entry(info, &service_info_list, node) { |
27185 |
+ STRING_LIST_FOR_EACH_SAFE(info->depend_info[NEED], service, next, count) { |
27186 |
+ if (-1 == __service_resolve_dependency(info->name, service, NEED)) { |
27187 |
+ DBG_MSG("Failed to resolve dependency!\n"); |
27188 |
+ return -1; |
27189 |
+ } |
27190 |
+ } |
27191 |
+ } |
27192 |
+ list_for_each_entry(info, &service_info_list, node) { |
27193 |
+ STRING_LIST_FOR_EACH_SAFE(info->depend_info[USE], service, next, count) { |
27194 |
+ if (-1 == __service_resolve_dependency(info->name, service, USE)) { |
27195 |
+ DBG_MSG("Failed to resolve dependency!\n"); |
27196 |
+ return -1; |
27197 |
+ } |
27198 |
+ } |
27199 |
+ } |
27200 |
+ list_for_each_entry(info, &service_info_list, node) { |
27201 |
+ STRING_LIST_FOR_EACH_SAFE(info->depend_info[BEFORE], service, next, count) { |
27202 |
+ if (-1 == __service_resolve_dependency(info->name, service, BEFORE)) { |
27203 |
+ DBG_MSG("Failed to resolve dependency!\n"); |
27204 |
+ return -1; |
27205 |
+ } |
27206 |
+ } |
27207 |
+ } |
27208 |
+ list_for_each_entry(info, &service_info_list, node) { |
27209 |
+ STRING_LIST_FOR_EACH_SAFE(info->depend_info[AFTER], service, next, count) { |
27210 |
+ if (-1 == __service_resolve_dependency(info->name, service, AFTER)) { |
27211 |
+ DBG_MSG("Failed to resolve dependency!\n"); |
27212 |
+ return -1; |
27213 |
+ } |
27214 |
+ } |
27215 |
+ } |
27216 |
+ |
27217 |
+ return 0; |
27218 |
+} |
27219 |
+ |
27220 |
|
27221 |
Added: trunk/baselayout-prefix/src/core/depend.h |
27222 |
=================================================================== |
27223 |
--- trunk/baselayout-prefix/src/core/depend.h (rev 0) |
27224 |
+++ trunk/baselayout-prefix/src/core/depend.h 2011-03-31 14:11:17 UTC (rev 1682) |
27225 |
@@ -0,0 +1,75 @@ |
27226 |
+/* |
27227 |
+ * depend.h |
27228 |
+ * |
27229 |
+ * Dependancy engine for Gentoo style rc-scripts. |
27230 |
+ * |
27231 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
27232 |
+ * |
27233 |
+ * |
27234 |
+ * This program is free software; you can redistribute it and/or modify it |
27235 |
+ * under the terms of the GNU General Public License as published by the |
27236 |
+ * Free Software Foundation version 2 of the License. |
27237 |
+ * |
27238 |
+ * This program is distributed in the hope that it will be useful, but |
27239 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
27240 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27241 |
+ * General Public License for more details. |
27242 |
+ * |
27243 |
+ * You should have received a copy of the GNU General Public License along |
27244 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
27245 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
27246 |
+ * |
27247 |
+ * $Header$ |
27248 |
+ */ |
27249 |
+ |
27250 |
+#ifndef _DEPEND_H |
27251 |
+#define _DEPEND_H |
27252 |
+ |
27253 |
+#include <sys/types.h> |
27254 |
+#include "list.h" |
27255 |
+ |
27256 |
+/* Dependency types supported or still to be implemented */ |
27257 |
+typedef enum { |
27258 |
+ NEED, /* All dependencies needed by specified service */ |
27259 |
+ NEED_ME, /* All dependencies that need specified service */ |
27260 |
+ USE, /* All dependencies used by specified service */ |
27261 |
+ USE_ME, /* All dependencies that use specified service */ |
27262 |
+ BEFORE, /* All services started before specified service */ |
27263 |
+ AFTER, /* All services started after specified service */ |
27264 |
+ BROKEN, /* All dependencies of type NEED missing for |
27265 |
+ specified service */ |
27266 |
+ PROVIDE, /* All virtual services provided by specified service */ |
27267 |
+ ALL_SERVICE_TYPE_T |
27268 |
+} service_type_t; |
27269 |
+ |
27270 |
+/* Names for above service types (service_type_t). |
27271 |
+ * Note that this should sync with above service_type_t */ |
27272 |
+extern char *service_type_names[]; |
27273 |
+ |
27274 |
+typedef struct { |
27275 |
+ struct list_head node; |
27276 |
+ |
27277 |
+ char *name; /* Name of service */ |
27278 |
+ char **depend_info[ALL_SERVICE_TYPE_T]; /* String lists for each service |
27279 |
+ type */ |
27280 |
+ char *provide; /* Name of virtual service it |
27281 |
+ provides. This is only valid |
27282 |
+ after we resolving - thus after |
27283 |
+ service_resolve_dependencies() */ |
27284 |
+ time_t mtime; /* Modification time of script */ |
27285 |
+} service_info_t; |
27286 |
+ |
27287 |
+struct list_head service_info_list; |
27288 |
+ |
27289 |
+service_info_t *service_get_info(char *servicename); |
27290 |
+int service_add(char *servicename); |
27291 |
+int service_is_dependency(char *servicename, char *dependency, service_type_t type); |
27292 |
+int service_add_dependency(char *servicename, char *dependency, service_type_t type); |
27293 |
+int service_del_dependency(char *servicename, char *dependency, service_type_t type); |
27294 |
+service_info_t *service_get_virtual(char *virtual); |
27295 |
+int service_add_virtual(char *servicename, char* virtual); |
27296 |
+int service_set_mtime(char *servicename, time_t mtime); |
27297 |
+int service_resolve_dependencies(void); |
27298 |
+ |
27299 |
+#endif /* _DEPEND_H */ |
27300 |
+ |
27301 |
|
27302 |
Added: trunk/baselayout-prefix/src/core/depscan.c |
27303 |
=================================================================== |
27304 |
--- trunk/baselayout-prefix/src/core/depscan.c (rev 0) |
27305 |
+++ trunk/baselayout-prefix/src/core/depscan.c 2011-03-31 14:11:17 UTC (rev 1682) |
27306 |
@@ -0,0 +1,297 @@ |
27307 |
+/* |
27308 |
+ * depscan.c |
27309 |
+ * |
27310 |
+ * Basic frontend for updating the dependency cache. |
27311 |
+ * |
27312 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
27313 |
+ * |
27314 |
+ * |
27315 |
+ * This program is free software; you can redistribute it and/or modify it |
27316 |
+ * under the terms of the GNU General Public License as published by the |
27317 |
+ * Free Software Foundation version 2 of the License. |
27318 |
+ * |
27319 |
+ * This program is distributed in the hope that it will be useful, but |
27320 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
27321 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
27322 |
+ * General Public License for more details. |
27323 |
+ * |
27324 |
+ * You should have received a copy of the GNU General Public License along |
27325 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
27326 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
27327 |
+ * |
27328 |
+ * $Header$ |
27329 |
+ */ |
27330 |
+ |
27331 |
+#include <errno.h> |
27332 |
+#ifndef __KLIBC__ |
27333 |
+# include <locale.h> |
27334 |
+#endif |
27335 |
+#include <stdio.h> |
27336 |
+#include <stdlib.h> |
27337 |
+#include <string.h> |
27338 |
+#include <sys/types.h> |
27339 |
+#include <sys/stat.h> |
27340 |
+#include <fcntl.h> |
27341 |
+#include <unistd.h> |
27342 |
+ |
27343 |
+#include "debug.h" |
27344 |
+#include "depend.h" |
27345 |
+#include "misc.h" |
27346 |
+#include "parse.h" |
27347 |
+ |
27348 |
+char* svcdir_subdirs[] = { |
27349 |
+ "softscripts", |
27350 |
+ "snapshot", |
27351 |
+ "options", |
27352 |
+ "started", |
27353 |
+ "starting", |
27354 |
+ "inactive", |
27355 |
+ "stopping", |
27356 |
+ NULL |
27357 |
+}; |
27358 |
+ |
27359 |
+char *svcdir_volatile_subdirs[] = { |
27360 |
+ "snapshot", |
27361 |
+ "broken", |
27362 |
+ NULL |
27363 |
+}; |
27364 |
+ |
27365 |
+int create_directory(const char *name); |
27366 |
+int create_var_dirs(const char *svcdir); |
27367 |
+int delete_var_dirs(const char *svcdir); |
27368 |
+ |
27369 |
+int create_directory(const char *name) { |
27370 |
+ if ((NULL == name) || (0 == strlen(name))) { |
27371 |
+ DBG_MSG("Invalid argument passed!\n"); |
27372 |
+ errno = EINVAL; |
27373 |
+ return -1; |
27374 |
+ } |
27375 |
+ |
27376 |
+ /* Check if directory exist, and is not a symlink */ |
27377 |
+ if (!is_dir(name, 0)) { |
27378 |
+ if (exists(name)) { |
27379 |
+ /* Remove it if not a directory */ |
27380 |
+ if (-1 == unlink(name)) { |
27381 |
+ DBG_MSG("Failed to remove '%s'!\n", name); |
27382 |
+ return -1; |
27383 |
+ } |
27384 |
+ } |
27385 |
+ /* Now try to create the directory */ |
27386 |
+ if (-1 == mktree(name, 0755)) { |
27387 |
+ DBG_MSG("Failed to create '%s'!\n", name); |
27388 |
+ return -1; |
27389 |
+ } |
27390 |
+ } |
27391 |
+ |
27392 |
+ return 0; |
27393 |
+} |
27394 |
+ |
27395 |
+int create_var_dirs(const char *svcdir) { |
27396 |
+ char *tmp_path = NULL; |
27397 |
+ int i = 0; |
27398 |
+ |
27399 |
+ if ((NULL == svcdir) || (0 == strlen(svcdir))) { |
27400 |
+ DBG_MSG("Invalid argument passed!\n"); |
27401 |
+ errno = EINVAL; |
27402 |
+ return -1; |
27403 |
+ } |
27404 |
+ |
27405 |
+ /* Check and create svcdir if needed */ |
27406 |
+ if (-1 == create_directory(svcdir)) { |
27407 |
+ DBG_MSG("Failed to create '%s'!\n", svcdir); |
27408 |
+ return -1; |
27409 |
+ } |
27410 |
+ |
27411 |
+ while (NULL != svcdir_subdirs[i]) { |
27412 |
+ tmp_path = strcatpaths(svcdir, svcdir_subdirs[i]); |
27413 |
+ if (NULL == tmp_path) { |
27414 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
27415 |
+ return -1; |
27416 |
+ } |
27417 |
+ |
27418 |
+ /* Check and create all the subdirs if needed */ |
27419 |
+ if (-1 == create_directory(tmp_path)) { |
27420 |
+ DBG_MSG("Failed to create '%s'!\n", tmp_path); |
27421 |
+ free(tmp_path); |
27422 |
+ return -1; |
27423 |
+ } |
27424 |
+ |
27425 |
+ free(tmp_path); |
27426 |
+ i++; |
27427 |
+ } |
27428 |
+ |
27429 |
+ return 0; |
27430 |
+} |
27431 |
+ |
27432 |
+int delete_var_dirs(const char *svcdir) { |
27433 |
+ char *tmp_path = NULL; |
27434 |
+ int i = 0; |
27435 |
+ |
27436 |
+ if ((NULL == svcdir) || (0 == strlen(svcdir))) { |
27437 |
+ DBG_MSG("Invalid argument passed!\n"); |
27438 |
+ errno = EINVAL; |
27439 |
+ return -1; |
27440 |
+ } |
27441 |
+ |
27442 |
+ /* Just quit if svcdir do not exist */ |
27443 |
+ if (!exists(svcdir)) { |
27444 |
+ DBG_MSG("'%s' does not exist!\n", svcdir); |
27445 |
+ return 0; |
27446 |
+ } |
27447 |
+ |
27448 |
+ while (NULL != svcdir_volatile_subdirs[i]) { |
27449 |
+ tmp_path = strcatpaths(svcdir, svcdir_volatile_subdirs[i]); |
27450 |
+ if (NULL == tmp_path) { |
27451 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
27452 |
+ return -1; |
27453 |
+ } |
27454 |
+ |
27455 |
+ /* Skip the directory if it does not exist */ |
27456 |
+ if (!exists(tmp_path)) |
27457 |
+ goto _continue; |
27458 |
+ |
27459 |
+ /* Check and delete all files and sub directories if needed */ |
27460 |
+ if (-1 == rmtree(tmp_path)) { |
27461 |
+ DBG_MSG("Failed to delete '%s'!\n", tmp_path); |
27462 |
+ free(tmp_path); |
27463 |
+ return -1; |
27464 |
+ } |
27465 |
+ |
27466 |
+_continue: |
27467 |
+ free(tmp_path); |
27468 |
+ i++; |
27469 |
+ } |
27470 |
+ |
27471 |
+ return 0; |
27472 |
+} |
27473 |
+ |
27474 |
+#if defined(LEGACY_DEPSCAN) |
27475 |
+ |
27476 |
+int main() { |
27477 |
+ FILE *cachefile_fd = NULL; |
27478 |
+ char *data = NULL; |
27479 |
+ char *svcdir = NULL; |
27480 |
+ char *cachefile = NULL; |
27481 |
+ char *tmp_cachefile = NULL; |
27482 |
+ int tmp_cachefile_fd = 0; |
27483 |
+ int datasize = 0; |
27484 |
+ |
27485 |
+ /* Make sure we do not run into locale issues */ |
27486 |
+#ifndef __KLIBC__ |
27487 |
+ setlocale (LC_ALL, "C"); |
27488 |
+#endif |
27489 |
+ |
27490 |
+ if (0 != getuid()) { |
27491 |
+ EERROR("Must be root!\n"); |
27492 |
+ exit(EXIT_FAILURE); |
27493 |
+ } |
27494 |
+ |
27495 |
+ svcdir = get_cnf_entry(RC_CONFD_FILE_NAME, SVCDIR_CONFIG_ENTRY); |
27496 |
+ if (NULL == svcdir) { |
27497 |
+ EERROR("Failed to get config entry '%s'!\n", |
27498 |
+ SVCDIR_CONFIG_ENTRY); |
27499 |
+ exit(EXIT_FAILURE); |
27500 |
+ } |
27501 |
+ |
27502 |
+ /* Delete (if needed) volatile directories in svcdir */ |
27503 |
+ if (-1 == delete_var_dirs(svcdir)) { |
27504 |
+ /* XXX: Not 100% accurate below message ... */ |
27505 |
+ EERROR("Failed to delete '%s', %s", svcdir, |
27506 |
+ "or one of its sub directories!\n"); |
27507 |
+ exit(EXIT_FAILURE); |
27508 |
+ } |
27509 |
+ |
27510 |
+ /* Create all needed directories in svcdir */ |
27511 |
+ if (-1 == create_var_dirs(svcdir)) { |
27512 |
+ EERROR("Failed to create '%s', %s", svcdir, |
27513 |
+ "or one of its sub directories!\n"); |
27514 |
+ exit(EXIT_FAILURE); |
27515 |
+ } |
27516 |
+ |
27517 |
+ cachefile = strcatpaths(svcdir, LEGACY_CACHE_FILE_NAME); |
27518 |
+ if (NULL == cachefile) { |
27519 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
27520 |
+ exit(EXIT_FAILURE); |
27521 |
+ } |
27522 |
+ |
27523 |
+ tmp_cachefile = strcatpaths(cachefile, "XXXXXX"); |
27524 |
+ if (NULL == tmp_cachefile) { |
27525 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
27526 |
+ exit(EXIT_FAILURE); |
27527 |
+ } |
27528 |
+ /* Replace the "/XXXXXX" with ".XXXXXX" |
27529 |
+ * Yes, I am lazy. */ |
27530 |
+ tmp_cachefile[strlen(tmp_cachefile) - strlen(".XXXXXX")] = '.'; |
27531 |
+ |
27532 |
+ if (-1 == get_rcscripts()) { |
27533 |
+ EERROR("Failed to get rc-scripts list!\n"); |
27534 |
+ exit(EXIT_FAILURE); |
27535 |
+ } |
27536 |
+ |
27537 |
+ if (-1 == check_rcscripts_mtime(cachefile)) { |
27538 |
+ EINFO("Caching service dependencies ...\n"); |
27539 |
+ DBG_MSG("Regenerating cache file '%s'.\n", cachefile); |
27540 |
+ |
27541 |
+ datasize = generate_stage2(&data); |
27542 |
+ if (-1 == datasize) { |
27543 |
+ EERROR("Failed to generate stage2!\n"); |
27544 |
+ exit(EXIT_FAILURE); |
27545 |
+ } |
27546 |
+ |
27547 |
+ if (-1 == parse_cache(data, datasize)) { |
27548 |
+ EERROR("Failed to parse stage2 output!\n"); |
27549 |
+ free(data); |
27550 |
+ exit(EXIT_FAILURE); |
27551 |
+ } |
27552 |
+ |
27553 |
+#if 0 |
27554 |
+ tmp_cachefile_fd = open("foo", O_CREAT | O_TRUNC | O_RDWR, 0600); |
27555 |
+ write(tmp_cachefile_fd, data, datasize); |
27556 |
+ close(tmp_cachefile_fd); |
27557 |
+#endif |
27558 |
+ |
27559 |
+ free(data); |
27560 |
+ |
27561 |
+ if (-1 == service_resolve_dependencies()) { |
27562 |
+ EERROR("Failed to resolve dependencies!\n"); |
27563 |
+ exit(EXIT_FAILURE); |
27564 |
+ } |
27565 |
+ |
27566 |
+#ifndef __KLIBC__ |
27567 |
+ tmp_cachefile_fd = mkstemp(tmp_cachefile); |
27568 |
+#else |
27569 |
+ /* FIXME: Need to add a mkstemp implementation for klibc */ |
27570 |
+ tmp_cachefile_fd = open(tmp_cachefile, O_CREAT | O_TRUNC | O_RDWR, 0600); |
27571 |
+#endif |
27572 |
+ if (-1 == tmp_cachefile_fd) { |
27573 |
+ EERROR("Could not open temporary file for writing!\n"); |
27574 |
+ exit(EXIT_FAILURE); |
27575 |
+ } |
27576 |
+ cachefile_fd = fdopen(tmp_cachefile_fd, "w"); |
27577 |
+ if (NULL == cachefile_fd) { |
27578 |
+ EERROR("Could not open temporary file for writing!\n"); |
27579 |
+ exit(EXIT_FAILURE); |
27580 |
+ } |
27581 |
+ |
27582 |
+ write_legacy_stage3(cachefile_fd); |
27583 |
+ fclose(cachefile_fd); |
27584 |
+ |
27585 |
+ if ((-1 == unlink(cachefile)) && (exists(cachefile))) { |
27586 |
+ EERROR("Could not remove '%s'!\n", cachefile); |
27587 |
+ unlink(tmp_cachefile); |
27588 |
+ exit(EXIT_FAILURE); |
27589 |
+ } |
27590 |
+ |
27591 |
+ if (-1 == rename(tmp_cachefile, cachefile)) { |
27592 |
+ EERROR("Could not move temporary file to '%s'!\n", |
27593 |
+ cachefile); |
27594 |
+ unlink(tmp_cachefile); |
27595 |
+ exit(EXIT_FAILURE); |
27596 |
+ } |
27597 |
+ } |
27598 |
+ |
27599 |
+ exit(EXIT_SUCCESS); |
27600 |
+} |
27601 |
+ |
27602 |
+#endif |
27603 |
+ |
27604 |
|
27605 |
Added: trunk/baselayout-prefix/src/core/list.h |
27606 |
=================================================================== |
27607 |
--- trunk/baselayout-prefix/src/core/list.h (rev 0) |
27608 |
+++ trunk/baselayout-prefix/src/core/list.h 2011-03-31 14:11:17 UTC (rev 1682) |
27609 |
@@ -0,0 +1,446 @@ |
27610 |
+/* |
27611 |
+ * Copied from the Linux kernel source tree, version 2.6.0-test1. |
27612 |
+ * |
27613 |
+ * Licensed under the GPL v2 as per the whole kernel source tree. |
27614 |
+ * |
27615 |
+ * Ripped out the rcu stuff, as it's not needed. |
27616 |
+ * |
27617 |
+ * $Header$ |
27618 |
+ */ |
27619 |
+ |
27620 |
+#ifndef _LINUX_LIST_H |
27621 |
+#define _LINUX_LIST_H |
27622 |
+ |
27623 |
+//#include <linux/stddef.h> |
27624 |
+/** |
27625 |
+ * container_of - cast a member of a structure out to the containing structure |
27626 |
+ * |
27627 |
+ * @ptr: the pointer to the member. |
27628 |
+ * @type: the type of the container struct this is embedded in. |
27629 |
+ * @member: the name of the member within the struct. |
27630 |
+ * |
27631 |
+ */ |
27632 |
+#define container_of(ptr, type, member) ({ \ |
27633 |
+ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
27634 |
+ (type *)( (char *)__mptr - offsetof(type,member) );}) |
27635 |
+ |
27636 |
+//#include <linux/prefetch.h> |
27637 |
+static inline void prefetch(const void *x) {;} |
27638 |
+ |
27639 |
+//#include <asm/system.h> |
27640 |
+ |
27641 |
+/* |
27642 |
+ * These are non-NULL pointers that will result in page faults |
27643 |
+ * under normal circumstances, used to verify that nobody uses |
27644 |
+ * non-initialized list entries. |
27645 |
+ */ |
27646 |
+#define LIST_POISON1 ((void *) 0x00100100) |
27647 |
+#define LIST_POISON2 ((void *) 0x00200200) |
27648 |
+ |
27649 |
+/* |
27650 |
+ * Simple doubly linked list implementation. |
27651 |
+ * |
27652 |
+ * Some of the internal functions ("__xxx") are useful when |
27653 |
+ * manipulating whole lists rather than single entries, as |
27654 |
+ * sometimes we already know the next/prev entries and we can |
27655 |
+ * generate better code by using them directly rather than |
27656 |
+ * using the generic single-entry routines. |
27657 |
+ */ |
27658 |
+ |
27659 |
+struct list_head { |
27660 |
+ struct list_head *next, *prev; |
27661 |
+}; |
27662 |
+ |
27663 |
+#define LIST_HEAD_INIT(name) { &(name), &(name) } |
27664 |
+ |
27665 |
+#define LIST_HEAD(name) \ |
27666 |
+ struct list_head name = LIST_HEAD_INIT(name) |
27667 |
+ |
27668 |
+#define INIT_LIST_HEAD(ptr) do { \ |
27669 |
+ (ptr)->next = (ptr); (ptr)->prev = (ptr); \ |
27670 |
+} while (0) |
27671 |
+ |
27672 |
+/* |
27673 |
+ * Insert a new entry between two known consecutive entries. |
27674 |
+ * |
27675 |
+ * This is only for internal list manipulation where we know |
27676 |
+ * the prev/next entries already! |
27677 |
+ */ |
27678 |
+static inline void __list_add(struct list_head *new, |
27679 |
+ struct list_head *prev, |
27680 |
+ struct list_head *next) |
27681 |
+{ |
27682 |
+ next->prev = new; |
27683 |
+ new->next = next; |
27684 |
+ new->prev = prev; |
27685 |
+ prev->next = new; |
27686 |
+} |
27687 |
+ |
27688 |
+/** |
27689 |
+ * list_add - add a new entry |
27690 |
+ * @new: new entry to be added |
27691 |
+ * @head: list head to add it after |
27692 |
+ * |
27693 |
+ * Insert a new entry after the specified head. |
27694 |
+ * This is good for implementing stacks. |
27695 |
+ */ |
27696 |
+static inline void list_add(struct list_head *new, struct list_head *head) |
27697 |
+{ |
27698 |
+ __list_add(new, head, head->next); |
27699 |
+} |
27700 |
+ |
27701 |
+/** |
27702 |
+ * list_add_tail - add a new entry |
27703 |
+ * @new: new entry to be added |
27704 |
+ * @head: list head to add it before |
27705 |
+ * |
27706 |
+ * Insert a new entry before the specified head. |
27707 |
+ * This is useful for implementing queues. |
27708 |
+ */ |
27709 |
+static inline void list_add_tail(struct list_head *new, struct list_head *head) |
27710 |
+{ |
27711 |
+ __list_add(new, head->prev, head); |
27712 |
+} |
27713 |
+ |
27714 |
+/* |
27715 |
+ * Delete a list entry by making the prev/next entries |
27716 |
+ * point to each other. |
27717 |
+ * |
27718 |
+ * This is only for internal list manipulation where we know |
27719 |
+ * the prev/next entries already! |
27720 |
+ */ |
27721 |
+static inline void __list_del(struct list_head * prev, struct list_head * next) |
27722 |
+{ |
27723 |
+ next->prev = prev; |
27724 |
+ prev->next = next; |
27725 |
+} |
27726 |
+ |
27727 |
+/** |
27728 |
+ * list_del - deletes entry from list. |
27729 |
+ * @entry: the element to delete from the list. |
27730 |
+ * Note: list_empty on entry does not return true after this, the entry is |
27731 |
+ * in an undefined state. |
27732 |
+ */ |
27733 |
+static inline void list_del(struct list_head *entry) |
27734 |
+{ |
27735 |
+ __list_del(entry->prev, entry->next); |
27736 |
+ entry->next = LIST_POISON1; |
27737 |
+ entry->prev = LIST_POISON2; |
27738 |
+} |
27739 |
+ |
27740 |
+/** |
27741 |
+ * list_del_init - deletes entry from list and reinitialize it. |
27742 |
+ * @entry: the element to delete from the list. |
27743 |
+ */ |
27744 |
+static inline void list_del_init(struct list_head *entry) |
27745 |
+{ |
27746 |
+ __list_del(entry->prev, entry->next); |
27747 |
+ INIT_LIST_HEAD(entry); |
27748 |
+} |
27749 |
+ |
27750 |
+/** |
27751 |
+ * list_move - delete from one list and add as another's head |
27752 |
+ * @list: the entry to move |
27753 |
+ * @head: the head that will precede our entry |
27754 |
+ */ |
27755 |
+static inline void list_move(struct list_head *list, struct list_head *head) |
27756 |
+{ |
27757 |
+ __list_del(list->prev, list->next); |
27758 |
+ list_add(list, head); |
27759 |
+} |
27760 |
+ |
27761 |
+/** |
27762 |
+ * list_move_tail - delete from one list and add as another's tail |
27763 |
+ * @list: the entry to move |
27764 |
+ * @head: the head that will follow our entry |
27765 |
+ */ |
27766 |
+static inline void list_move_tail(struct list_head *list, |
27767 |
+ struct list_head *head) |
27768 |
+{ |
27769 |
+ __list_del(list->prev, list->next); |
27770 |
+ list_add_tail(list, head); |
27771 |
+} |
27772 |
+ |
27773 |
+/** |
27774 |
+ * list_empty - tests whether a list is empty |
27775 |
+ * @head: the list to test. |
27776 |
+ */ |
27777 |
+static inline int list_empty(struct list_head *head) |
27778 |
+{ |
27779 |
+ return head->next == head; |
27780 |
+} |
27781 |
+ |
27782 |
+static inline void __list_splice(struct list_head *list, |
27783 |
+ struct list_head *head) |
27784 |
+{ |
27785 |
+ struct list_head *first = list->next; |
27786 |
+ struct list_head *last = list->prev; |
27787 |
+ struct list_head *at = head->next; |
27788 |
+ |
27789 |
+ first->prev = head; |
27790 |
+ head->next = first; |
27791 |
+ |
27792 |
+ last->next = at; |
27793 |
+ at->prev = last; |
27794 |
+} |
27795 |
+ |
27796 |
+/** |
27797 |
+ * list_splice - join two lists |
27798 |
+ * @list: the new list to add. |
27799 |
+ * @head: the place to add it in the first list. |
27800 |
+ */ |
27801 |
+static inline void list_splice(struct list_head *list, struct list_head *head) |
27802 |
+{ |
27803 |
+ if (!list_empty(list)) |
27804 |
+ __list_splice(list, head); |
27805 |
+} |
27806 |
+ |
27807 |
+/** |
27808 |
+ * list_splice_init - join two lists and reinitialise the emptied list. |
27809 |
+ * @list: the new list to add. |
27810 |
+ * @head: the place to add it in the first list. |
27811 |
+ * |
27812 |
+ * The list at @list is reinitialised |
27813 |
+ */ |
27814 |
+static inline void list_splice_init(struct list_head *list, |
27815 |
+ struct list_head *head) |
27816 |
+{ |
27817 |
+ if (!list_empty(list)) { |
27818 |
+ __list_splice(list, head); |
27819 |
+ INIT_LIST_HEAD(list); |
27820 |
+ } |
27821 |
+} |
27822 |
+ |
27823 |
+/** |
27824 |
+ * list_entry - get the struct for this entry |
27825 |
+ * @ptr: the &struct list_head pointer. |
27826 |
+ * @type: the type of the struct this is embedded in. |
27827 |
+ * @member: the name of the list_struct within the struct. |
27828 |
+ */ |
27829 |
+#define list_entry(ptr, type, member) \ |
27830 |
+ container_of(ptr, type, member) |
27831 |
+ |
27832 |
+/** |
27833 |
+ * list_for_each - iterate over a list |
27834 |
+ * @pos: the &struct list_head to use as a loop counter. |
27835 |
+ * @head: the head for your list. |
27836 |
+ */ |
27837 |
+#define list_for_each(pos, head) \ |
27838 |
+ for (pos = (head)->next, prefetch(pos->next); pos != (head); \ |
27839 |
+ pos = pos->next, prefetch(pos->next)) |
27840 |
+ |
27841 |
+/** |
27842 |
+ * __list_for_each - iterate over a list |
27843 |
+ * @pos: the &struct list_head to use as a loop counter. |
27844 |
+ * @head: the head for your list. |
27845 |
+ * |
27846 |
+ * This variant differs from list_for_each() in that it's the |
27847 |
+ * simplest possible list iteration code, no prefetching is done. |
27848 |
+ * Use this for code that knows the list to be very short (empty |
27849 |
+ * or 1 entry) most of the time. |
27850 |
+ */ |
27851 |
+#define __list_for_each(pos, head) \ |
27852 |
+ for (pos = (head)->next; pos != (head); pos = pos->next) |
27853 |
+ |
27854 |
+/** |
27855 |
+ * list_for_each_prev - iterate over a list backwards |
27856 |
+ * @pos: the &struct list_head to use as a loop counter. |
27857 |
+ * @head: the head for your list. |
27858 |
+ */ |
27859 |
+#define list_for_each_prev(pos, head) \ |
27860 |
+ for (pos = (head)->prev, prefetch(pos->prev); pos != (head); \ |
27861 |
+ pos = pos->prev, prefetch(pos->prev)) |
27862 |
+ |
27863 |
+/** |
27864 |
+ * list_for_each_safe - iterate over a list safe against removal of list entry |
27865 |
+ * @pos: the &struct list_head to use as a loop counter. |
27866 |
+ * @n: another &struct list_head to use as temporary storage |
27867 |
+ * @head: the head for your list. |
27868 |
+ */ |
27869 |
+#define list_for_each_safe(pos, n, head) \ |
27870 |
+ for (pos = (head)->next, n = pos->next; pos != (head); \ |
27871 |
+ pos = n, n = pos->next) |
27872 |
+ |
27873 |
+/** |
27874 |
+ * list_for_each_entry - iterate over list of given type |
27875 |
+ * @pos: the type * to use as a loop counter. |
27876 |
+ * @head: the head for your list. |
27877 |
+ * @member: the name of the list_struct within the struct. |
27878 |
+ */ |
27879 |
+#define list_for_each_entry(pos, head, member) \ |
27880 |
+ for (pos = list_entry((head)->next, typeof(*pos), member), \ |
27881 |
+ prefetch(pos->member.next); \ |
27882 |
+ &pos->member != (head); \ |
27883 |
+ pos = list_entry(pos->member.next, typeof(*pos), member), \ |
27884 |
+ prefetch(pos->member.next)) |
27885 |
+ |
27886 |
+/** |
27887 |
+ * list_for_each_entry_reverse - iterate backwards over list of given type. |
27888 |
+ * @pos: the type * to use as a loop counter. |
27889 |
+ * @head: the head for your list. |
27890 |
+ * @member: the name of the list_struct within the struct. |
27891 |
+ */ |
27892 |
+#define list_for_each_entry_reverse(pos, head, member) \ |
27893 |
+ for (pos = list_entry((head)->prev, typeof(*pos), member), \ |
27894 |
+ prefetch(pos->member.prev); \ |
27895 |
+ &pos->member != (head); \ |
27896 |
+ pos = list_entry(pos->member.prev, typeof(*pos), member), \ |
27897 |
+ prefetch(pos->member.prev)) |
27898 |
+ |
27899 |
+ |
27900 |
+/** |
27901 |
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry |
27902 |
+ * @pos: the type * to use as a loop counter. |
27903 |
+ * @n: another type * to use as temporary storage |
27904 |
+ * @head: the head for your list. |
27905 |
+ * @member: the name of the list_struct within the struct. |
27906 |
+ */ |
27907 |
+#define list_for_each_entry_safe(pos, n, head, member) \ |
27908 |
+ for (pos = list_entry((head)->next, typeof(*pos), member), \ |
27909 |
+ n = list_entry(pos->member.next, typeof(*pos), member); \ |
27910 |
+ &pos->member != (head); \ |
27911 |
+ pos = n, n = list_entry(n->member.next, typeof(*n), member)) |
27912 |
+ |
27913 |
+/* |
27914 |
+ * Double linked lists with a single pointer list head. |
27915 |
+ * Mostly useful for hash tables where the two pointer list head is |
27916 |
+ * too wasteful. |
27917 |
+ * You lose the ability to access the tail in O(1). |
27918 |
+ */ |
27919 |
+ |
27920 |
+struct hlist_head { |
27921 |
+ struct hlist_node *first; |
27922 |
+}; |
27923 |
+ |
27924 |
+struct hlist_node { |
27925 |
+ struct hlist_node *next, **pprev; |
27926 |
+}; |
27927 |
+ |
27928 |
+#define HLIST_HEAD_INIT { .first = NULL } |
27929 |
+#define HLIST_HEAD(name) struct hlist_head name = { .first = NULL } |
27930 |
+#define INIT_HLIST_HEAD(ptr) ((ptr)->first = NULL) |
27931 |
+#define INIT_HLIST_NODE(ptr) ((ptr)->next = NULL, (ptr)->pprev = NULL) |
27932 |
+ |
27933 |
+static __inline__ int hlist_unhashed(struct hlist_node *h) |
27934 |
+{ |
27935 |
+ return !h->pprev; |
27936 |
+} |
27937 |
+ |
27938 |
+static __inline__ int hlist_empty(struct hlist_head *h) |
27939 |
+{ |
27940 |
+ return !h->first; |
27941 |
+} |
27942 |
+ |
27943 |
+static __inline__ void __hlist_del(struct hlist_node *n) |
27944 |
+{ |
27945 |
+ struct hlist_node *next = n->next; |
27946 |
+ struct hlist_node **pprev = n->pprev; |
27947 |
+ *pprev = next; |
27948 |
+ if (next) |
27949 |
+ next->pprev = pprev; |
27950 |
+} |
27951 |
+ |
27952 |
+static __inline__ void hlist_del(struct hlist_node *n) |
27953 |
+{ |
27954 |
+ __hlist_del(n); |
27955 |
+ n->next = LIST_POISON1; |
27956 |
+ n->pprev = LIST_POISON2; |
27957 |
+} |
27958 |
+ |
27959 |
+static __inline__ void hlist_del_init(struct hlist_node *n) |
27960 |
+{ |
27961 |
+ if (n->pprev) { |
27962 |
+ __hlist_del(n); |
27963 |
+ INIT_HLIST_NODE(n); |
27964 |
+ } |
27965 |
+} |
27966 |
+ |
27967 |
+static __inline__ void hlist_add_head(struct hlist_node *n, struct hlist_head *h) |
27968 |
+{ |
27969 |
+ struct hlist_node *first = h->first; |
27970 |
+ n->next = first; |
27971 |
+ if (first) |
27972 |
+ first->pprev = &n->next; |
27973 |
+ h->first = n; |
27974 |
+ n->pprev = &h->first; |
27975 |
+} |
27976 |
+ |
27977 |
+/* next must be != NULL */ |
27978 |
+static __inline__ void hlist_add_before(struct hlist_node *n, struct hlist_node *next) |
27979 |
+{ |
27980 |
+ n->pprev = next->pprev; |
27981 |
+ n->next = next; |
27982 |
+ next->pprev = &n->next; |
27983 |
+ *(n->pprev) = n; |
27984 |
+} |
27985 |
+ |
27986 |
+static __inline__ void hlist_add_after(struct hlist_node *n, |
27987 |
+ struct hlist_node *next) |
27988 |
+{ |
27989 |
+ next->next = n->next; |
27990 |
+ *(next->pprev) = n; |
27991 |
+ n->next = next; |
27992 |
+} |
27993 |
+ |
27994 |
+#define hlist_entry(ptr, type, member) container_of(ptr,type,member) |
27995 |
+ |
27996 |
+/* Cannot easily do prefetch unfortunately */ |
27997 |
+#define hlist_for_each(pos, head) \ |
27998 |
+ for (pos = (head)->first; pos && ({ prefetch(pos->next); 1; }); \ |
27999 |
+ pos = pos->next) |
28000 |
+ |
28001 |
+#define hlist_for_each_safe(pos, n, head) \ |
28002 |
+ for (pos = (head)->first; n = pos ? pos->next : 0, pos; \ |
28003 |
+ pos = n) |
28004 |
+ |
28005 |
+/** |
28006 |
+ * hlist_for_each_entry - iterate over list of given type |
28007 |
+ * @tpos: the type * to use as a loop counter. |
28008 |
+ * @pos: the &struct hlist_node to use as a loop counter. |
28009 |
+ * @head: the head for your list. |
28010 |
+ * @member: the name of the hlist_node within the struct. |
28011 |
+ */ |
28012 |
+#define hlist_for_each_entry(tpos, pos, head, member) \ |
28013 |
+ for (pos = (head)->first; \ |
28014 |
+ pos && ({ prefetch(pos->next); 1;}) && \ |
28015 |
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
28016 |
+ pos = pos->next) |
28017 |
+ |
28018 |
+/** |
28019 |
+ * hlist_for_each_entry_continue - iterate over a hlist continuing after existing point |
28020 |
+ * @tpos: the type * to use as a loop counter. |
28021 |
+ * @pos: the &struct hlist_node to use as a loop counter. |
28022 |
+ * @member: the name of the hlist_node within the struct. |
28023 |
+ */ |
28024 |
+#define hlist_for_each_entry_continue(tpos, pos, member) \ |
28025 |
+ for (pos = (pos)->next; \ |
28026 |
+ pos && ({ prefetch(pos->next); 1;}) && \ |
28027 |
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
28028 |
+ pos = pos->next) |
28029 |
+ |
28030 |
+/** |
28031 |
+ * hlist_for_each_entry_from - iterate over a hlist continuing from existing point |
28032 |
+ * @tpos: the type * to use as a loop counter. |
28033 |
+ * @pos: the &struct hlist_node to use as a loop counter. |
28034 |
+ * @member: the name of the hlist_node within the struct. |
28035 |
+ */ |
28036 |
+#define hlist_for_each_entry_from(tpos, pos, member) \ |
28037 |
+ for (; pos && ({ prefetch(pos->next); 1;}) && \ |
28038 |
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
28039 |
+ pos = pos->next) |
28040 |
+ |
28041 |
+/** |
28042 |
+ * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry |
28043 |
+ * @tpos: the type * to use as a loop counter. |
28044 |
+ * @pos: the &struct hlist_node to use as a loop counter. |
28045 |
+ * @n: another &struct hlist_node to use as temporary storage |
28046 |
+ * @head: the head for your list. |
28047 |
+ * @member: the name of the hlist_node within the struct. |
28048 |
+ */ |
28049 |
+#define hlist_for_each_entry_safe(tpos, pos, n, head, member) \ |
28050 |
+ for (pos = (head)->first; \ |
28051 |
+ pos && ({ n = pos->next; 1; }) && \ |
28052 |
+ ({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;}); \ |
28053 |
+ pos = n) |
28054 |
+ |
28055 |
+#endif |
28056 |
|
28057 |
Added: trunk/baselayout-prefix/src/core/misc.c |
28058 |
=================================================================== |
28059 |
--- trunk/baselayout-prefix/src/core/misc.c (rev 0) |
28060 |
+++ trunk/baselayout-prefix/src/core/misc.c 2011-03-31 14:11:17 UTC (rev 1682) |
28061 |
@@ -0,0 +1,649 @@ |
28062 |
+/* |
28063 |
+ * misc.c |
28064 |
+ * |
28065 |
+ * Miscellaneous macro's and functions. |
28066 |
+ * |
28067 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
28068 |
+ * |
28069 |
+ * |
28070 |
+ * This program is free software; you can redistribute it and/or modify it |
28071 |
+ * under the terms of the GNU General Public License as published by the |
28072 |
+ * Free Software Foundation version 2 of the License. |
28073 |
+ * |
28074 |
+ * This program is distributed in the hope that it will be useful, but |
28075 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
28076 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
28077 |
+ * General Public License for more details. |
28078 |
+ * |
28079 |
+ * You should have received a copy of the GNU General Public License along |
28080 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
28081 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
28082 |
+ * |
28083 |
+ * $Header$ |
28084 |
+ */ |
28085 |
+ |
28086 |
+#include <errno.h> |
28087 |
+#include <string.h> |
28088 |
+#include <stdio.h> |
28089 |
+#include <stdlib.h> |
28090 |
+#include <sys/mman.h> |
28091 |
+#include <sys/types.h> |
28092 |
+#include <sys/stat.h> |
28093 |
+#include <sys/param.h> |
28094 |
+#include <dirent.h> |
28095 |
+#include <unistd.h> |
28096 |
+#include <fcntl.h> |
28097 |
+ |
28098 |
+#include "debug.h" |
28099 |
+#include "misc.h" |
28100 |
+ |
28101 |
+char *memrepchr(char **str, char old, char new, size_t size) { |
28102 |
+ char *str_p; |
28103 |
+ |
28104 |
+ if ((NULL == str) || (NULL == *str) || (0 == strlen(*str))) { |
28105 |
+ DBG_MSG("Invalid argument passed!\n"); |
28106 |
+ errno = EINVAL; |
28107 |
+ return NULL; |
28108 |
+ } |
28109 |
+ |
28110 |
+ str_p = memchr(*str, old, size); |
28111 |
+ |
28112 |
+ while (NULL != str_p) { |
28113 |
+ str_p[0] = new; |
28114 |
+ str_p = memchr(&str_p[1], old, size - (str_p - *str) - 1); |
28115 |
+ } |
28116 |
+ |
28117 |
+ return *str; |
28118 |
+} |
28119 |
+ |
28120 |
+char *strcatpaths(const char *pathname1, const char *pathname2) { |
28121 |
+ char *new_path = NULL; |
28122 |
+ int lenght; |
28123 |
+ |
28124 |
+ if ((NULL == pathname1) || (0 == strlen(pathname1)) || |
28125 |
+ (NULL == pathname2) || (0 == strlen(pathname2))) { |
28126 |
+ DBG_MSG("Invalid argument passed!\n"); |
28127 |
+ errno = EINVAL; |
28128 |
+ return NULL; |
28129 |
+ } |
28130 |
+ |
28131 |
+ /* Lenght of pathname1 + lenght of pathname2 + '/' if needed */ |
28132 |
+ lenght = strlen(pathname1) + strlen(pathname2) + 1; |
28133 |
+ /* lenght + '\0' */ |
28134 |
+ new_path = malloc(lenght + 1); |
28135 |
+ if (NULL == new_path) { |
28136 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
28137 |
+ return NULL; |
28138 |
+ } |
28139 |
+ |
28140 |
+ strncpy(new_path, pathname1, lenght); |
28141 |
+ /* Should we add a '/' ? */ |
28142 |
+ if (new_path[strlen(new_path)-1] != '/') |
28143 |
+ strncat(new_path, "/", lenght - strlen(new_path)); |
28144 |
+ strncat(new_path, pathname2, lenght - strlen(new_path)); |
28145 |
+ |
28146 |
+ return new_path; |
28147 |
+} |
28148 |
+ |
28149 |
+char *strndup(const char *str, size_t size) { |
28150 |
+ char *new_str = NULL; |
28151 |
+ size_t len; |
28152 |
+ |
28153 |
+ if (NULL == str) { |
28154 |
+ DBG_MSG("Invalid argument passed!\n"); |
28155 |
+ errno = EINVAL; |
28156 |
+ return NULL; |
28157 |
+ } |
28158 |
+ |
28159 |
+ /* Check lenght of str without breaching the size limit */ |
28160 |
+ for (len = 0;(len < size) && ('\0' != str[len]);len++); |
28161 |
+ |
28162 |
+ new_str = malloc(len + 1); |
28163 |
+ if (NULL == new_str) { |
28164 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
28165 |
+ return NULL; |
28166 |
+ } |
28167 |
+ |
28168 |
+ /* Make sure our string is NULL terminated */ |
28169 |
+ new_str[len] = '\0'; |
28170 |
+ |
28171 |
+ return (char *)memcpy(new_str, str, len); |
28172 |
+} |
28173 |
+ |
28174 |
+char *gbasename(const char *path) { |
28175 |
+ char *new_path = NULL; |
28176 |
+ |
28177 |
+ if ((NULL == path) || (0 == strlen(path))) { |
28178 |
+ DBG_MSG("Invalid argument passed!\n"); |
28179 |
+ errno = EINVAL; |
28180 |
+ return NULL; |
28181 |
+ } |
28182 |
+ |
28183 |
+ /* Copied from glibc */ |
28184 |
+ new_path = strrchr (path, '/'); |
28185 |
+ return new_path ? new_path + 1 : (char *)path; |
28186 |
+} |
28187 |
+ |
28188 |
+ |
28189 |
+int exists(const char *pathname) { |
28190 |
+ struct stat buf; |
28191 |
+ int retval; |
28192 |
+ |
28193 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28194 |
+ DBG_MSG("Invalid argument passed!\n"); |
28195 |
+ return 0; |
28196 |
+ } |
28197 |
+ |
28198 |
+ retval = lstat(pathname, &buf); |
28199 |
+ if (-1 != retval) |
28200 |
+ return 1; |
28201 |
+ |
28202 |
+ /* Clear errno, as we do not want debugging to trigger */ |
28203 |
+ errno = 0; |
28204 |
+ |
28205 |
+ return 0; |
28206 |
+} |
28207 |
+ |
28208 |
+int is_file(const char *pathname, int follow_link) { |
28209 |
+ struct stat buf; |
28210 |
+ int retval; |
28211 |
+ |
28212 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28213 |
+ DBG_MSG("Invalid argument passed!\n"); |
28214 |
+ return 0; |
28215 |
+ } |
28216 |
+ |
28217 |
+ retval = follow_link ? stat(pathname, &buf) : lstat(pathname, &buf); |
28218 |
+ if ((-1 != retval) && (S_ISREG(buf.st_mode))) |
28219 |
+ return 1; |
28220 |
+ |
28221 |
+ /* Clear errno, as we do not want debugging to trigger */ |
28222 |
+ errno = 0; |
28223 |
+ |
28224 |
+ return 0; |
28225 |
+} |
28226 |
+ |
28227 |
+int is_link(const char *pathname) { |
28228 |
+ struct stat buf; |
28229 |
+ int retval; |
28230 |
+ |
28231 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28232 |
+ DBG_MSG("Invalid argument passed!\n"); |
28233 |
+ return 0; |
28234 |
+ } |
28235 |
+ |
28236 |
+ retval = lstat(pathname, &buf); |
28237 |
+ if ((-1 != retval) && (S_ISLNK(buf.st_mode))) |
28238 |
+ return 1; |
28239 |
+ |
28240 |
+ /* Clear errno, as we do not want debugging to trigger */ |
28241 |
+ errno = 0; |
28242 |
+ |
28243 |
+ return 0; |
28244 |
+} |
28245 |
+ |
28246 |
+int is_dir(const char *pathname, int follow_link) { |
28247 |
+ struct stat buf; |
28248 |
+ int retval; |
28249 |
+ |
28250 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28251 |
+ DBG_MSG("Invalid argument passed!\n"); |
28252 |
+ return 0; |
28253 |
+ } |
28254 |
+ |
28255 |
+ retval = follow_link ? stat(pathname, &buf) : lstat(pathname, &buf); |
28256 |
+ if ((-1 != retval) && (S_ISDIR(buf.st_mode))) |
28257 |
+ return 1; |
28258 |
+ |
28259 |
+ /* Clear errno, as we do not want debugging to trigger */ |
28260 |
+ errno = 0; |
28261 |
+ |
28262 |
+ return 0; |
28263 |
+} |
28264 |
+ |
28265 |
+time_t get_mtime(const char *pathname, int follow_link) { |
28266 |
+ struct stat buf; |
28267 |
+ int retval; |
28268 |
+ |
28269 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28270 |
+ DBG_MSG("Invalid argument passed!\n"); |
28271 |
+ return 0; |
28272 |
+ } |
28273 |
+ |
28274 |
+ retval = follow_link ? stat(pathname, &buf) : lstat(pathname, &buf); |
28275 |
+ if (-1 != retval) |
28276 |
+ return buf.st_mtime; |
28277 |
+ |
28278 |
+ /* Clear errno, as we do not want debugging to trigger */ |
28279 |
+ errno = 0; |
28280 |
+ |
28281 |
+ return 0; |
28282 |
+} |
28283 |
+ |
28284 |
+#ifdef __KLIBC__ |
28285 |
+int remove(const char *pathname) { |
28286 |
+ int retval; |
28287 |
+ |
28288 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28289 |
+ DBG_MSG("Invalid argument passed!\n"); |
28290 |
+ errno = EINVAL; |
28291 |
+ return -1; |
28292 |
+ } |
28293 |
+ |
28294 |
+ if (is_dir(pathname, 0)) |
28295 |
+ retval = rmdir(pathname); |
28296 |
+ else |
28297 |
+ retval = unlink(pathname); |
28298 |
+ |
28299 |
+ return retval; |
28300 |
+} |
28301 |
+#endif |
28302 |
+ |
28303 |
+int mktree(const char *pathname, mode_t mode) { |
28304 |
+ char *temp_name = NULL; |
28305 |
+ char *temp_token = NULL; |
28306 |
+ char *token_p; |
28307 |
+ char *token; |
28308 |
+ int retval; |
28309 |
+ int lenght; |
28310 |
+ |
28311 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28312 |
+ DBG_MSG("Invalid argument passed!\n"); |
28313 |
+ errno = EINVAL; |
28314 |
+ return -1; |
28315 |
+ } |
28316 |
+ |
28317 |
+ /* Lenght of 'pathname' + extra for "./" if needed */ |
28318 |
+ lenght = strlen(pathname) + 2; |
28319 |
+ /* lenght + '\0' */ |
28320 |
+ temp_name = malloc(lenght + 1); |
28321 |
+ if (NULL == temp_name) { |
28322 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
28323 |
+ return -1; |
28324 |
+ } |
28325 |
+ |
28326 |
+ temp_token = strndup(pathname, strlen(pathname)); |
28327 |
+ if (NULL == temp_token) { |
28328 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
28329 |
+ goto error; |
28330 |
+ } |
28331 |
+ token_p = temp_token; |
28332 |
+ |
28333 |
+ if (pathname[0] == '/') |
28334 |
+ temp_name[0] = '\0'; |
28335 |
+ else |
28336 |
+ /* If not an absolute path, make it local */ |
28337 |
+ strncpy(temp_name, ".", lenght); |
28338 |
+ |
28339 |
+ token = strsep(&token_p, "/"); |
28340 |
+ /* First token might be "", but that is OK as it will be when the |
28341 |
+ * pathname starts with '/' */ |
28342 |
+ while (NULL != token) { |
28343 |
+ strncat(temp_name, "/", lenght - strlen(temp_name)); |
28344 |
+ strncat(temp_name, token, lenght - strlen(temp_name)); |
28345 |
+ |
28346 |
+ /* If it does not exist, create the dir. If it does exit, |
28347 |
+ * but is not a directory, we will catch it below. */ |
28348 |
+ if (!exists(temp_name)) { |
28349 |
+ retval = mkdir(temp_name, mode); |
28350 |
+ if (-1 == retval) { |
28351 |
+ DBG_MSG("Failed to create directory!\n"); |
28352 |
+ goto error; |
28353 |
+ } |
28354 |
+ /* Not a directory or symlink pointing to a directory */ |
28355 |
+ } else if (!is_dir(temp_name, 1)) { |
28356 |
+ DBG_MSG("Component in pathname is not a directory!\n"); |
28357 |
+ errno = ENOTDIR; |
28358 |
+ goto error; |
28359 |
+ } |
28360 |
+ |
28361 |
+ do { |
28362 |
+ token = strsep(&token_p, "/"); |
28363 |
+ /* The first "" was Ok, but rather skip double '/' after that */ |
28364 |
+ } while ((NULL != token) && (0 == strlen(token))); |
28365 |
+ } |
28366 |
+ |
28367 |
+ free(temp_name); |
28368 |
+ free(temp_token); |
28369 |
+ |
28370 |
+ return 0; |
28371 |
+ |
28372 |
+error: |
28373 |
+ free(temp_name); |
28374 |
+ free(temp_token); |
28375 |
+ |
28376 |
+ return -1; |
28377 |
+} |
28378 |
+ |
28379 |
+int rmtree(const char *pathname) { |
28380 |
+ char **dirlist = NULL; |
28381 |
+ int i = 0; |
28382 |
+ |
28383 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28384 |
+ DBG_MSG("Invalid argument passed!\n"); |
28385 |
+ errno = EINVAL; |
28386 |
+ return -1; |
28387 |
+ } |
28388 |
+ |
28389 |
+ if (!exists(pathname)) { |
28390 |
+ DBG_MSG("'%s' does not exists!\n", pathname); |
28391 |
+ errno = ENOENT; |
28392 |
+ return -1; |
28393 |
+ } |
28394 |
+ |
28395 |
+ dirlist = ls_dir(pathname, 1); |
28396 |
+ if ((NULL == dirlist) && (0 != errno)) { |
28397 |
+ /* If errno = ENOENT and the directory exists, then it means |
28398 |
+ * it is empty, so we should not error out */ |
28399 |
+ if (ENOENT != errno) { |
28400 |
+ DBG_MSG("Could not get listing for '%s'!\n", pathname); |
28401 |
+ return -1; |
28402 |
+ } |
28403 |
+ } |
28404 |
+ |
28405 |
+ while ((NULL != dirlist) && (NULL != dirlist[i])) { |
28406 |
+ /* If it is a directory, call rmtree() again with |
28407 |
+ * it as argument */ |
28408 |
+ if (is_dir(dirlist[i], 0)) { |
28409 |
+ if (-1 == rmtree(dirlist[i])) { |
28410 |
+ DBG_MSG("Failed to delete sub directory!\n"); |
28411 |
+ goto error; |
28412 |
+ } |
28413 |
+ } |
28414 |
+ |
28415 |
+ /* Now actually remove it. Note that if it was a directory, |
28416 |
+ * it should already be removed by above rmtree() call */ |
28417 |
+ if ((exists(dirlist[i]) && (-1 == remove(dirlist[i])))) { |
28418 |
+ DBG_MSG("Failed to remove '%s'!\n", dirlist[i]); |
28419 |
+ goto error; |
28420 |
+ } |
28421 |
+ i++; |
28422 |
+ } |
28423 |
+ |
28424 |
+ STRING_LIST_FREE(dirlist); |
28425 |
+ |
28426 |
+ /* Now remove the parent */ |
28427 |
+ if (-1 == remove(pathname)) { |
28428 |
+ DBG_MSG("Failed to remove '%s'!\n", pathname); |
28429 |
+ goto error; |
28430 |
+ } |
28431 |
+ |
28432 |
+ return 0; |
28433 |
+error: |
28434 |
+ STRING_LIST_FREE(dirlist); |
28435 |
+ |
28436 |
+ return -1; |
28437 |
+} |
28438 |
+ |
28439 |
+char **ls_dir(const char *pathname, int hidden) { |
28440 |
+ DIR *dirfd; |
28441 |
+ struct dirent *dir_entry; |
28442 |
+ char **dirlist = NULL; |
28443 |
+ |
28444 |
+ if ((NULL == pathname) || (0 == strlen(pathname))) { |
28445 |
+ DBG_MSG("Invalid argument passed!\n"); |
28446 |
+ errno = EINVAL; |
28447 |
+ return NULL; |
28448 |
+ } |
28449 |
+ |
28450 |
+ dirfd = opendir(pathname); |
28451 |
+ if (NULL == dirfd) { |
28452 |
+ DBG_MSG("Failed to call opendir()!\n"); |
28453 |
+ /* errno will be set by opendir() */ |
28454 |
+ goto error; |
28455 |
+ } |
28456 |
+ |
28457 |
+ do { |
28458 |
+ /* Clear errno to distinguish between EOF and error */ |
28459 |
+ errno = 0; |
28460 |
+ dir_entry = readdir(dirfd); |
28461 |
+ /* Only an error if 'errno' != 0, else EOF */ |
28462 |
+ if ((NULL == dir_entry) && (0 != errno)) { |
28463 |
+ DBG_MSG("Failed to call readdir()!\n"); |
28464 |
+ goto error; |
28465 |
+ } |
28466 |
+ if ((NULL != dir_entry) && |
28467 |
+ /* Should we display hidden files? */ |
28468 |
+ (hidden ? 1 : dir_entry->d_name[0] != '.')) |
28469 |
+ { |
28470 |
+ char *d_name = dir_entry->d_name; |
28471 |
+ char *tmp_p; |
28472 |
+ |
28473 |
+ /* Do not list current or parent entries */ |
28474 |
+ if ((0 == strcmp(d_name, ".")) || |
28475 |
+ (0 == strcmp(d_name, ".."))) |
28476 |
+ continue; |
28477 |
+ |
28478 |
+ tmp_p = strcatpaths(pathname, d_name); |
28479 |
+ if (NULL == tmp_p) { |
28480 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
28481 |
+ /* errno = ENOMEM */ |
28482 |
+ goto error; |
28483 |
+ } |
28484 |
+ |
28485 |
+ STRING_LIST_ADD(dirlist, tmp_p, error); |
28486 |
+ } |
28487 |
+ } while (NULL != dir_entry); |
28488 |
+ |
28489 |
+ if ((NULL == dirlist) || (NULL == dirlist[0])) { |
28490 |
+ DBG_MSG("Directory is empty.\n"); |
28491 |
+ errno = ENOENT; |
28492 |
+ goto error; |
28493 |
+ } |
28494 |
+ |
28495 |
+ closedir(dirfd); |
28496 |
+ |
28497 |
+ return dirlist; |
28498 |
+ |
28499 |
+error: |
28500 |
+ /* Free dirlist on error */ |
28501 |
+ STRING_LIST_FREE(dirlist); |
28502 |
+ |
28503 |
+ if (NULL != dirfd) { |
28504 |
+ int old_errno = errno; |
28505 |
+ closedir(dirfd); |
28506 |
+ /* closedir() might have changed it */ |
28507 |
+ errno = old_errno; |
28508 |
+ } |
28509 |
+ |
28510 |
+ return NULL; |
28511 |
+} |
28512 |
+ |
28513 |
+/* This handles simple 'entry="bar"' type variables. If it is more complex |
28514 |
+ * ('entry="$(pwd)"' or such), it will obviously not work, but current behaviour |
28515 |
+ * should be fine for the type of variables we want. */ |
28516 |
+char *get_cnf_entry(const char *pathname, const char *entry) { |
28517 |
+ char *buf = NULL; |
28518 |
+ char *tmp_buf = NULL; |
28519 |
+ char *tmp_p; |
28520 |
+ char *value = NULL; |
28521 |
+ char *token; |
28522 |
+ size_t lenght; |
28523 |
+ int count; |
28524 |
+ int current = 0; |
28525 |
+ |
28526 |
+ |
28527 |
+ if ((NULL == pathname) || (0 == strlen(pathname)) || |
28528 |
+ (NULL == entry) || (0 == strlen(entry))) { |
28529 |
+ DBG_MSG("Invalid argument passed!\n"); |
28530 |
+ errno = EINVAL; |
28531 |
+ return NULL; |
28532 |
+ } |
28533 |
+ |
28534 |
+ /* If it is not a file or symlink pointing to a file, bail */ |
28535 |
+ if (!is_file(pathname, 1)) { |
28536 |
+ DBG_MSG("Given pathname is not a file or do not exist!\n"); |
28537 |
+ /* FIXME: Might need to set this to something better? */ |
28538 |
+ errno = ENOENT; |
28539 |
+ return NULL; |
28540 |
+ } |
28541 |
+ |
28542 |
+ if (-1 == file_map(pathname, &buf, &lenght)) { |
28543 |
+ DBG_MSG("Could not open config file for reading!\n"); |
28544 |
+ return NULL; |
28545 |
+ } |
28546 |
+ |
28547 |
+ while (current < lenght) { |
28548 |
+ count = buf_get_line(buf, lenght, current); |
28549 |
+ |
28550 |
+ tmp_buf = strndup(&buf[current], count); |
28551 |
+ if (NULL == tmp_buf) { |
28552 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
28553 |
+ goto error; |
28554 |
+ } |
28555 |
+ tmp_p = tmp_buf; |
28556 |
+ |
28557 |
+ /* Strip leading spaces/tabs */ |
28558 |
+ while ((tmp_p[0] == ' ') || (tmp_p[0] == '\t')) |
28559 |
+ tmp_p++; |
28560 |
+ |
28561 |
+ /* Get entry and value */ |
28562 |
+ token = strsep(&tmp_p, "="); |
28563 |
+ /* Bogus entry or value */ |
28564 |
+ if (NULL == token) |
28565 |
+ goto _continue; |
28566 |
+ |
28567 |
+ /* Make sure we have a string that is larger than 'entry', and |
28568 |
+ * the first part equals 'entry' */ |
28569 |
+ if ((strlen(token) > 0) && (0 == strcmp(entry, token))) |
28570 |
+ { |
28571 |
+ do { |
28572 |
+ /* Bash variables are usually quoted */ |
28573 |
+ token = strsep(&tmp_p, "\"\'"); |
28574 |
+ /* If quoted, the first match will be "" */ |
28575 |
+ } while ((NULL != token) && (0 == strlen(token))); |
28576 |
+ |
28577 |
+ /* We have a 'entry='. We respect bash rules, so NULL |
28578 |
+ * value for now (if not already) */ |
28579 |
+ if (NULL == token) { |
28580 |
+ /* We might have 'entry=' and later 'entry="bar"', |
28581 |
+ * so just continue for now ... we will handle |
28582 |
+ * it below when 'value == NULL' */ |
28583 |
+ if (NULL != value) { |
28584 |
+ free(value); |
28585 |
+ value = NULL; |
28586 |
+ } |
28587 |
+ goto _continue; |
28588 |
+ } |
28589 |
+ |
28590 |
+ /* If we have already allocated 'value', free it */ |
28591 |
+ if (NULL != value) |
28592 |
+ free(value); |
28593 |
+ |
28594 |
+ value = strndup(token, strlen(token)); |
28595 |
+ if (NULL == value) |
28596 |
+ /* errno = ENOMEM */ |
28597 |
+ goto error; |
28598 |
+ |
28599 |
+ /* We do not break, as there might be more than one entry |
28600 |
+ * defined, and as bash uses the last, so should we */ |
28601 |
+ /* break; */ |
28602 |
+ } |
28603 |
+ |
28604 |
+_continue: |
28605 |
+ current += count + 1; |
28606 |
+ free(tmp_buf); |
28607 |
+ /* Set to NULL in case we error out above and have |
28608 |
+ * to free below */ |
28609 |
+ tmp_buf = NULL; |
28610 |
+ } |
28611 |
+ |
28612 |
+ |
28613 |
+ if (NULL == value) { |
28614 |
+ DBG_MSG("Failed to get value for config entry '%s'!\n", entry); |
28615 |
+ errno = ENOMSG; |
28616 |
+ goto error; |
28617 |
+ } |
28618 |
+ |
28619 |
+ file_unmap(buf, lenght); |
28620 |
+ |
28621 |
+ return value; |
28622 |
+ |
28623 |
+error: |
28624 |
+ free(tmp_buf); |
28625 |
+ free(value); |
28626 |
+ |
28627 |
+ if (NULL != buf) { |
28628 |
+ int old_errno = errno; |
28629 |
+ file_unmap(buf, lenght); |
28630 |
+ /* unmmap() might have changed it */ |
28631 |
+ errno = old_errno; |
28632 |
+ } |
28633 |
+ |
28634 |
+ return NULL; |
28635 |
+} |
28636 |
+ |
28637 |
+ |
28638 |
+/* |
28639 |
+ * Below three functions (file_map, file_unmap and buf_get_line) are |
28640 |
+ * from udev-050 (udev_utils.c). |
28641 |
+ * (Some are slightly modified, please check udev for originals.) |
28642 |
+ * |
28643 |
+ * Copyright (C) 2004 Kay Sievers <kay@××××.org> |
28644 |
+ * |
28645 |
+ * This program is free software; you can redistribute it and/or modify it |
28646 |
+ * under the terms of the GNU General Public License as published by the |
28647 |
+ * Free Software Foundation version 2 of the License. |
28648 |
+ * |
28649 |
+ * This program is distributed in the hope that it will be useful, but |
28650 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
28651 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
28652 |
+ * General Public License for more details. |
28653 |
+ * |
28654 |
+ * You should have received a copy of the GNU General Public License along |
28655 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
28656 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
28657 |
+ * |
28658 |
+ */ |
28659 |
+ |
28660 |
+int file_map(const char *filename, char **buf, size_t *bufsize) |
28661 |
+{ |
28662 |
+ struct stat stats; |
28663 |
+ int fd; |
28664 |
+ int old_errno; |
28665 |
+ |
28666 |
+ fd = open(filename, O_RDONLY); |
28667 |
+ if (fd < 0) { |
28668 |
+ DBG_MSG("Failed to open file!\n"); |
28669 |
+ return -1; |
28670 |
+ } |
28671 |
+ |
28672 |
+ if (fstat(fd, &stats) < 0) { |
28673 |
+ DBG_MSG("Failed to stat file!\n"); |
28674 |
+ old_errno = errno; |
28675 |
+ close(fd); |
28676 |
+ /* close() might have changed it */ |
28677 |
+ errno = old_errno; |
28678 |
+ return -1; |
28679 |
+ } |
28680 |
+ |
28681 |
+ *buf = mmap(NULL, stats.st_size, PROT_READ, MAP_SHARED, fd, 0); |
28682 |
+ if (*buf == MAP_FAILED) { |
28683 |
+ DBG_MSG("Failed to mmap file!\n"); |
28684 |
+ old_errno = errno; |
28685 |
+ close(fd); |
28686 |
+ /* close() might have changed it */ |
28687 |
+ errno = old_errno; |
28688 |
+ return -1; |
28689 |
+ } |
28690 |
+ *bufsize = stats.st_size; |
28691 |
+ |
28692 |
+ close(fd); |
28693 |
+ |
28694 |
+ return 0; |
28695 |
+} |
28696 |
+ |
28697 |
+void file_unmap(char *buf, size_t bufsize) |
28698 |
+{ |
28699 |
+ munmap(buf, bufsize); |
28700 |
+} |
28701 |
+ |
28702 |
+size_t buf_get_line(char *buf, size_t buflen, size_t cur) |
28703 |
+{ |
28704 |
+ size_t count = 0; |
28705 |
+ |
28706 |
+ for (count = cur; count < buflen && buf[count] != '\n'; count++); |
28707 |
+ |
28708 |
+ return count - cur; |
28709 |
+} |
28710 |
+ |
28711 |
|
28712 |
Added: trunk/baselayout-prefix/src/core/misc.h |
28713 |
=================================================================== |
28714 |
--- trunk/baselayout-prefix/src/core/misc.h (rev 0) |
28715 |
+++ trunk/baselayout-prefix/src/core/misc.h 2011-03-31 14:11:17 UTC (rev 1682) |
28716 |
@@ -0,0 +1,288 @@ |
28717 |
+/* |
28718 |
+ * misc.h |
28719 |
+ * |
28720 |
+ * Miscellaneous macro's and functions. |
28721 |
+ * |
28722 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
28723 |
+ * |
28724 |
+ * |
28725 |
+ * This program is free software; you can redistribute it and/or modify it |
28726 |
+ * under the terms of the GNU General Public License as published by the |
28727 |
+ * Free Software Foundation version 2 of the License. |
28728 |
+ * |
28729 |
+ * This program is distributed in the hope that it will be useful, but |
28730 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
28731 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
28732 |
+ * General Public License for more details. |
28733 |
+ * |
28734 |
+ * You should have received a copy of the GNU General Public License along |
28735 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
28736 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
28737 |
+ * |
28738 |
+ * $Header$ |
28739 |
+ */ |
28740 |
+ |
28741 |
+#ifndef _MISC_H |
28742 |
+#define _MISC_H |
28743 |
+ |
28744 |
+#include <sys/stat.h> |
28745 |
+#include <sys/types.h> |
28746 |
+ |
28747 |
+/* Gentoo style e* printing macro's */ |
28748 |
+#define EINFO(_args...) \ |
28749 |
+ do { \ |
28750 |
+ int old_errno = errno; \ |
28751 |
+ printf(" \033[32;01m*\033[0m " _args); \ |
28752 |
+ errno = old_errno; \ |
28753 |
+ } while (0) |
28754 |
+ |
28755 |
+#define EWARN(_args...) \ |
28756 |
+ do { \ |
28757 |
+ int old_errno = errno; \ |
28758 |
+ printf(" \033[33;01m*\033[0m " _args); \ |
28759 |
+ errno = old_errno; \ |
28760 |
+ } while (0) |
28761 |
+ |
28762 |
+#define EERROR(_args...) \ |
28763 |
+ do { \ |
28764 |
+ int old_errno = errno; \ |
28765 |
+ fprintf(stderr, " \033[31;01m*\033[0m " _args); \ |
28766 |
+ errno = old_errno; \ |
28767 |
+ } while (0) |
28768 |
+ |
28769 |
+/* Return true if filename '_name' ends in '_ext' */ |
28770 |
+#define CHECK_FILE_EXTENSION(_name, _ext) \ |
28771 |
+ (strlen(_name) > strlen(_ext) && \ |
28772 |
+ 0 == strncmp(&_name[strlen(_name) - strlen(_ext)], \ |
28773 |
+ _ext, strlen(_ext))) |
28774 |
+ |
28775 |
+/* For each '_char' in '_string', inc '_count' */ |
28776 |
+#define COUNT_CHAR_UP(_string, _char, _count) \ |
28777 |
+ do { \ |
28778 |
+ int _i; \ |
28779 |
+ for (_i = 0;_i < strlen(_string);_i++) \ |
28780 |
+ if (_string[_i] == _char) \ |
28781 |
+ _count++; \ |
28782 |
+ } while (0) |
28783 |
+ |
28784 |
+/* For each '_char' in '_string', dec '_count' */ |
28785 |
+#define COUNT_CHAR_DN(_string, _char, _count) \ |
28786 |
+ do { \ |
28787 |
+ int _i; \ |
28788 |
+ for (_i = 0;_i < strlen(_string);_i++) \ |
28789 |
+ if (_string[_i] == _char) \ |
28790 |
+ _count--; \ |
28791 |
+ } while (0) |
28792 |
+ |
28793 |
+/* Add a new item to a string list. If the pointer to the list is NULL, |
28794 |
+ * allocate enough memory for the amount of entries needed. Ditto for |
28795 |
+ * when it already exists, but we add one more entry than it can |
28796 |
+ * contain. The list is NULL terminated. |
28797 |
+ * NOTE: _only_ memory for the list are allocated, and not for the items - that |
28798 |
+ * should be done by relevant code (unlike STRING_LIST_DEL that will |
28799 |
+ * free the memory) */ |
28800 |
+#define STRING_LIST_ADD(_string_list, _item, _error) \ |
28801 |
+ do { \ |
28802 |
+ char **_tmp_p; \ |
28803 |
+ int _i = 0; \ |
28804 |
+ if ((NULL == _item) || (0 == strlen(_item))) { \ |
28805 |
+ DBG_MSG("Invalid argument passed!\n"); \ |
28806 |
+ errno = EINVAL; \ |
28807 |
+ goto _error; \ |
28808 |
+ } \ |
28809 |
+ while ((NULL != _string_list) && (NULL != _string_list[_i])) { \ |
28810 |
+ _i++; \ |
28811 |
+ } \ |
28812 |
+ /* Amount of entries + new + terminator */ \ |
28813 |
+ _tmp_p = realloc(_string_list, sizeof(char *) * (_i + 2)); \ |
28814 |
+ if (NULL == _tmp_p) { \ |
28815 |
+ DBG_MSG("Failed to reallocate list!\n"); \ |
28816 |
+ goto _error; \ |
28817 |
+ } \ |
28818 |
+ _string_list = _tmp_p; \ |
28819 |
+ _string_list[_i] = _item; \ |
28820 |
+ /* Terminator */ \ |
28821 |
+ _string_list[_i+1] = NULL; \ |
28822 |
+ } while (0) |
28823 |
+ |
28824 |
+/* Add a new item to a string list (foundamental the same as above), but make |
28825 |
+ * sure we have all the items alphabetically sorted. */ |
28826 |
+#define STRING_LIST_ADD_SORT(_string_list, _item, _error) \ |
28827 |
+ do { \ |
28828 |
+ char **_tmp_p; \ |
28829 |
+ char *_str_p1; \ |
28830 |
+ char *_str_p2; \ |
28831 |
+ int _i = 0; \ |
28832 |
+ if ((NULL == _item) || (0 == strlen(_item))) { \ |
28833 |
+ DBG_MSG("Invalid argument passed!\n"); \ |
28834 |
+ errno = EINVAL; \ |
28835 |
+ goto _error; \ |
28836 |
+ } \ |
28837 |
+ while ((NULL != _string_list) && (NULL != _string_list[_i])) \ |
28838 |
+ _i++; \ |
28839 |
+ /* Amount of entries + new + terminator */ \ |
28840 |
+ _tmp_p = realloc(_string_list, sizeof(char *) * (_i + 2)); \ |
28841 |
+ if (NULL == _tmp_p) { \ |
28842 |
+ DBG_MSG("Failed to reallocate list!\n"); \ |
28843 |
+ goto _error; \ |
28844 |
+ } \ |
28845 |
+ _string_list = _tmp_p; \ |
28846 |
+ if (0 == _i) \ |
28847 |
+ /* Needed so that the end NULL will propagate |
28848 |
+ * (iow, make sure our 'NULL != _str_p1' test below |
28849 |
+ * do not fail) */ \ |
28850 |
+ _string_list[_i] = NULL; \ |
28851 |
+ /* Actual terminator that needs adding */ \ |
28852 |
+ _string_list[_i+1] = NULL; \ |
28853 |
+ _i = 0; \ |
28854 |
+ /* See where we should insert the new item to have it all \ |
28855 |
+ * alphabetically sorted */ \ |
28856 |
+ while (NULL != _string_list[_i]) { \ |
28857 |
+ if (strcmp(_string_list[_i], _item) > 0) { \ |
28858 |
+ break; \ |
28859 |
+ } \ |
28860 |
+ _i++; \ |
28861 |
+ } \ |
28862 |
+ /* Now just insert the new item, and shift the rest one over. |
28863 |
+ * '_str_p2' is temporary storage to swap the indexes in a loop, |
28864 |
+ * and 'str_p1' is used to store the old value across the loop */ \ |
28865 |
+ _str_p1 = _string_list[_i]; \ |
28866 |
+ _string_list[_i] = _item; \ |
28867 |
+ do { \ |
28868 |
+ _i++;\ |
28869 |
+ _str_p2 = _string_list[_i]; \ |
28870 |
+ _string_list[_i] = _str_p1; \ |
28871 |
+ _str_p1 = _str_p2; \ |
28872 |
+ } while (NULL != _str_p1); \ |
28873 |
+ } while (0) |
28874 |
+ |
28875 |
+/* Delete one entry from the string list, and shift the rest down if the entry |
28876 |
+ * was not at the end. For now we do not resize the amount of entries the |
28877 |
+ * string list can contain, and free the memory for the matching item */ |
28878 |
+#define STRING_LIST_DEL(_string_list, _item, _error) \ |
28879 |
+ do { \ |
28880 |
+ int _i = 0; \ |
28881 |
+ if ((NULL == _item) || (0 == strlen(_item)) || \ |
28882 |
+ (NULL == _string_list)) { \ |
28883 |
+ DBG_MSG("Invalid argument passed!\n"); \ |
28884 |
+ errno = EINVAL; \ |
28885 |
+ goto _error; \ |
28886 |
+ } \ |
28887 |
+ while (NULL != _string_list[_i]) { \ |
28888 |
+ if (0 == strcmp(_item, _string_list[_i])) \ |
28889 |
+ break; \ |
28890 |
+ else \ |
28891 |
+ _i++; \ |
28892 |
+ } \ |
28893 |
+ if (NULL == _string_list[_i]) { \ |
28894 |
+ DBG_MSG("Invalid argument passed!\n"); \ |
28895 |
+ errno = EINVAL; \ |
28896 |
+ goto _error; \ |
28897 |
+ } \ |
28898 |
+ free(_string_list[_i]); \ |
28899 |
+ /* Shift all the following items one forward */ \ |
28900 |
+ do { \ |
28901 |
+ _string_list[_i] = _string_list[_i+1]; \ |
28902 |
+ /* This stupidity is to shutup gcc */ \ |
28903 |
+ _i++; \ |
28904 |
+ } while (NULL != _string_list[_i]); \ |
28905 |
+ } while (0) |
28906 |
+ |
28907 |
+/* Step through each entry in the string list, setting '_pos' to the |
28908 |
+ * beginning of the entry. '_counter' is used by the macro as index, |
28909 |
+ * but should not be used by code as index (or if really needed, then |
28910 |
+ * it should usually by +1 from what you expect, and should only be |
28911 |
+ * used in the scope of the macro) */ |
28912 |
+#define STRING_LIST_FOR_EACH(_string_list, _pos, _counter) \ |
28913 |
+ if ((NULL != _string_list) && (0 == (_counter = 0))) \ |
28914 |
+ while (NULL != (_pos = _string_list[_counter++])) |
28915 |
+ |
28916 |
+/* Same as above (with the same warning about '_counter'). Now we just |
28917 |
+ * have '_next' that are also used for indexing. Once again rather refrain |
28918 |
+ * from using it if not absolutely needed. The major difference to above, |
28919 |
+ * is that it should be safe from having the item removed from under you. */ |
28920 |
+#define STRING_LIST_FOR_EACH_SAFE(_string_list, _pos, _next, _counter) \ |
28921 |
+ if ((NULL != _string_list) && (0 == (_counter = 0))) \ |
28922 |
+ /* First part of the while checks if this is the |
28923 |
+ * first loop, and if so setup _pos and _next |
28924 |
+ * and increment _counter */ \ |
28925 |
+ while ((((0 == _counter) && \ |
28926 |
+ (NULL != (_pos = _string_list[_counter])) && \ |
28927 |
+ (_pos != (_next = _string_list[++_counter]))) || \ |
28928 |
+ /* Second part is when it is not the first loop |
28929 |
+ * and _pos was not removed from under us. We |
28930 |
+ * just increment _counter, and setup _pos and |
28931 |
+ * _next */ \ |
28932 |
+ ((0 != _counter) && \ |
28933 |
+ (_pos == _string_list[_counter-1]) && \ |
28934 |
+ (_next == _string_list[_counter]) && \ |
28935 |
+ (NULL != (_pos = _string_list[_counter])) && \ |
28936 |
+ (_pos != (_next = _string_list[++_counter]))) || \ |
28937 |
+ /* Last part is when _pos was removed from under |
28938 |
+ * us. We basically just setup _pos and _next, |
28939 |
+ * but leave _counter alone */ \ |
28940 |
+ ((0 != _counter) && \ |
28941 |
+ (_pos != _string_list[_counter-1]) && \ |
28942 |
+ (_next == _string_list[_counter-1]) && \ |
28943 |
+ (NULL != (_pos = _string_list[_counter-1])) && \ |
28944 |
+ (_pos != (_next = _string_list[_counter]))))) |
28945 |
+ |
28946 |
+/* Just free the whole string list */ |
28947 |
+#define STRING_LIST_FREE(_string_list) \ |
28948 |
+ do { \ |
28949 |
+ if (NULL != _string_list) { \ |
28950 |
+ int _i = 0; \ |
28951 |
+ while (NULL != _string_list[_i]) \ |
28952 |
+ free(_string_list[_i++]); \ |
28953 |
+ free(_string_list); \ |
28954 |
+ _string_list = NULL; \ |
28955 |
+ } \ |
28956 |
+ } while (0) |
28957 |
+ |
28958 |
+/* String functions. Return a string on success, or NULL on error |
28959 |
+ * or no action taken. On error errno will be set.*/ |
28960 |
+char *memrepchr(char **str, char old, char _new, size_t size); |
28961 |
+/* Concat two paths adding '/' if needed. Memory will be allocated |
28962 |
+ * with the malloc() call. */ |
28963 |
+char *strcatpaths(const char *pathname1, const char *pathname2); |
28964 |
+ |
28965 |
+/* Compat functions for GNU extensions */ |
28966 |
+char *strndup(const char *str, size_t size); |
28967 |
+/* Same as basename(3), but do not modify path */ |
28968 |
+char *gbasename(const char *path); |
28969 |
+ |
28970 |
+/* The following functions do not care about errors - they only return |
28971 |
+ * 1 if 'pathname' exist, and is the type requested, or else 0. |
28972 |
+ * They also might clear errno */ |
28973 |
+int exists(const char *pathname); |
28974 |
+int is_file(const char *pathname, int follow_link); |
28975 |
+int is_link(const char *pathname); |
28976 |
+int is_dir(const char *pathname, int follow_link); |
28977 |
+ |
28978 |
+/* The following function do not care about errors - it only returns |
28979 |
+ * the mtime of 'pathname' if it exists, and is the type requested, |
28980 |
+ * or else 0. It also might clear errno */ |
28981 |
+time_t get_mtime(const char *pathname, int follow_link); |
28982 |
+ |
28983 |
+/* The following functions return 0 on success, or -1 with errno set on error. */ |
28984 |
+#ifdef __KLIBC__ |
28985 |
+int remove(const char *pathname); |
28986 |
+#endif |
28987 |
+int mktree(const char *pathname, mode_t mode); |
28988 |
+int rmtree(const char *pathname); |
28989 |
+ |
28990 |
+/* The following return a pointer on success, or NULL with errno set on error. |
28991 |
+ * If it returned NULL, but errno is not set, then there was no error, but |
28992 |
+ * there is nothing to return. */ |
28993 |
+char **ls_dir(const char *pathname, int hidden); |
28994 |
+char *get_cnf_entry(const char *pathname, const char *entry); |
28995 |
+ |
28996 |
+/* Below three functions (file_map, file_unmap and buf_get_line) are from |
28997 |
+ * udev-050 (udev_utils.c). Please see misc.c for copyright info. |
28998 |
+ * (Some are slightly modified, please check udev for originals.) */ |
28999 |
+int file_map(const char *filename, char **buf, size_t *bufsize); |
29000 |
+void file_unmap(char *buf, size_t bufsize); |
29001 |
+size_t buf_get_line(char *buf, size_t buflen, size_t cur); |
29002 |
+ |
29003 |
+#endif /* _MISC_H */ |
29004 |
+ |
29005 |
|
29006 |
Added: trunk/baselayout-prefix/src/core/parse.c |
29007 |
=================================================================== |
29008 |
--- trunk/baselayout-prefix/src/core/parse.c (rev 0) |
29009 |
+++ trunk/baselayout-prefix/src/core/parse.c 2011-03-31 14:11:17 UTC (rev 1682) |
29010 |
@@ -0,0 +1,1033 @@ |
29011 |
+/* |
29012 |
+ * parse.c |
29013 |
+ * |
29014 |
+ * Parser for Gentoo style rc-scripts. |
29015 |
+ * |
29016 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
29017 |
+ * |
29018 |
+ * |
29019 |
+ * This program is free software; you can redistribute it and/or modify it |
29020 |
+ * under the terms of the GNU General Public License as published by the |
29021 |
+ * Free Software Foundation version 2 of the License. |
29022 |
+ * |
29023 |
+ * This program is distributed in the hope that it will be useful, but |
29024 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
29025 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
29026 |
+ * General Public License for more details. |
29027 |
+ * |
29028 |
+ * You should have received a copy of the GNU General Public License along |
29029 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
29030 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
29031 |
+ * |
29032 |
+ * $Header$ |
29033 |
+ */ |
29034 |
+ |
29035 |
+#include <errno.h> |
29036 |
+#include <string.h> |
29037 |
+#include <stddef.h> |
29038 |
+#include <stdio.h> |
29039 |
+#include <stdlib.h> |
29040 |
+#include <signal.h> |
29041 |
+#include <sys/types.h> |
29042 |
+#include <sys/stat.h> |
29043 |
+#include <sys/wait.h> |
29044 |
+#include <unistd.h> |
29045 |
+#include <fcntl.h> |
29046 |
+#include <signal.h> |
29047 |
+ |
29048 |
+#include "debug.h" |
29049 |
+#include "depend.h" |
29050 |
+#include "list.h" |
29051 |
+#include "misc.h" |
29052 |
+#include "parse.h" |
29053 |
+#include "simple-regex.h" |
29054 |
+ |
29055 |
+#define READ_PIPE 0 |
29056 |
+#define WRITE_PIPE 1 |
29057 |
+ |
29058 |
+#define PARSE_BUFFER_SIZE 256 |
29059 |
+ |
29060 |
+#define OUTPUT_MAX_LINE_LENGHT 256 |
29061 |
+#define OUTPUT_BUFFER_SIZE (60 * 1024) |
29062 |
+ |
29063 |
+/* void PRINT_TO_BUFFER(char **_buf, int _count, label _error, format) */ |
29064 |
+#define PRINT_TO_BUFFER(_buf, _count, _error, _output...) \ |
29065 |
+ do { \ |
29066 |
+ int _i = 0; \ |
29067 |
+ /* FIXME: Might do something more dynamic here */ \ |
29068 |
+ if (OUTPUT_BUFFER_SIZE < (_count + OUTPUT_MAX_LINE_LENGHT)) { \ |
29069 |
+ errno = ENOMEM; \ |
29070 |
+ DBG_MSG("Output buffer size too small!\n"); \ |
29071 |
+ goto _error; \ |
29072 |
+ } \ |
29073 |
+ _i = sprintf(&((*_buf)[_count]), _output); \ |
29074 |
+ if (0 < _i) \ |
29075 |
+ _count += _i + 1; \ |
29076 |
+ } while (0) |
29077 |
+ |
29078 |
+LIST_HEAD(rcscript_list); |
29079 |
+ |
29080 |
+size_t parse_rcscript(char *scriptname, time_t mtime, char **data, size_t index); |
29081 |
+ |
29082 |
+size_t parse_print_start(char **data, size_t index); |
29083 |
+size_t parse_print_header(char *scriptname, time_t mtime, char **data, size_t index); |
29084 |
+size_t parse_print_body(char *scriptname, char **data, size_t index); |
29085 |
+size_t parse_print_end(char **data, size_t index); |
29086 |
+ |
29087 |
+int get_rcscripts(void) { |
29088 |
+ rcscript_info_t *info; |
29089 |
+ char **file_list = NULL; |
29090 |
+ char *rcscript; |
29091 |
+ char *confd_file = NULL; |
29092 |
+ int count; |
29093 |
+ |
29094 |
+ file_list = ls_dir(INITD_DIR_NAME, 0); |
29095 |
+ if (NULL == file_list) { |
29096 |
+ DBG_MSG("'%s' is empty!\n", INITD_DIR_NAME); |
29097 |
+ return -1; |
29098 |
+ } |
29099 |
+ |
29100 |
+ STRING_LIST_FOR_EACH(file_list, rcscript, count) { |
29101 |
+ /* Is it a file? */ |
29102 |
+ if ((!is_file(rcscript, 1)) || |
29103 |
+ /* Do not process scripts, source or backup files. */ |
29104 |
+ (CHECK_FILE_EXTENSION(rcscript, ".c")) || |
29105 |
+ (CHECK_FILE_EXTENSION(rcscript, ".bak")) || |
29106 |
+ (CHECK_FILE_EXTENSION(rcscript, "~"))) |
29107 |
+ { |
29108 |
+ DBG_MSG("'%s' is not a valid rc-script!\n", |
29109 |
+ gbasename(rcscript)); |
29110 |
+ } else { |
29111 |
+ DBG_MSG("Adding rc-script '%s' to list.\n", |
29112 |
+ gbasename(rcscript)); |
29113 |
+ |
29114 |
+ info = malloc(sizeof(rcscript_info_t)); |
29115 |
+ if (NULL == info) { |
29116 |
+ DBG_MSG("Failed to allocate rcscript_info_t!\n"); |
29117 |
+ goto error; |
29118 |
+ } |
29119 |
+ |
29120 |
+ /* Copy the name */ |
29121 |
+ info->filename = strndup(rcscript, strlen(rcscript)); |
29122 |
+ if (NULL == info->filename) { |
29123 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
29124 |
+ goto loop_error; |
29125 |
+ } |
29126 |
+ |
29127 |
+ /* Get the modification time */ |
29128 |
+ info->mtime = get_mtime(rcscript, 1); |
29129 |
+ if (0 == info->mtime) { |
29130 |
+ DBG_MSG("Failed to get modification time for '%s'!\n", |
29131 |
+ rcscript); |
29132 |
+ /* We do not care if it fails - we will pick up |
29133 |
+ * later if there is a problem with the file */ |
29134 |
+ } |
29135 |
+ |
29136 |
+ /* File name for the conf.d config file (if any) */ |
29137 |
+ confd_file = strcatpaths(CONFD_DIR_NAME, |
29138 |
+ gbasename(rcscript)); |
29139 |
+ if (NULL == confd_file) { |
29140 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
29141 |
+ goto loop_error; |
29142 |
+ } |
29143 |
+ |
29144 |
+ /* Get the modification time of the conf.d file |
29145 |
+ * (if any exists) */ |
29146 |
+ info->confd_mtime = get_mtime(confd_file, 1); |
29147 |
+ if (0 == info->confd_mtime) { |
29148 |
+ DBG_MSG("Failed to get modification time for '%s'!\n", |
29149 |
+ confd_file); |
29150 |
+ /* We do not care that it fails, as not all |
29151 |
+ * rc-scripts will have conf.d config files */ |
29152 |
+ } |
29153 |
+ |
29154 |
+ free(confd_file); |
29155 |
+ |
29156 |
+ list_add_tail(&info->node, &rcscript_list); |
29157 |
+ |
29158 |
+ continue; |
29159 |
+ |
29160 |
+loop_error: |
29161 |
+ if (NULL != info) |
29162 |
+ free(info->filename); |
29163 |
+ free(info); |
29164 |
+ |
29165 |
+ goto error; |
29166 |
+ } |
29167 |
+ } |
29168 |
+ |
29169 |
+ /* Final check if we have some entries */ |
29170 |
+ if (NULL == file_list[0]) { |
29171 |
+ DBG_MSG("No rc-scripts to parse!\n"); |
29172 |
+ errno = ENOENT; |
29173 |
+ goto error; |
29174 |
+ } |
29175 |
+ |
29176 |
+ STRING_LIST_FREE(file_list); |
29177 |
+ |
29178 |
+ return 0; |
29179 |
+ |
29180 |
+error: |
29181 |
+ STRING_LIST_FREE(file_list); |
29182 |
+ |
29183 |
+ return -1; |
29184 |
+} |
29185 |
+ |
29186 |
+/* Returns 0 if we do not need to regen the cache file, else -1 with |
29187 |
+ * errno set if something went wrong */ |
29188 |
+int check_rcscripts_mtime(char *cachefile) { |
29189 |
+ rcscript_info_t *info; |
29190 |
+ time_t cache_mtime; |
29191 |
+ time_t rc_conf_mtime; |
29192 |
+ time_t rc_confd_mtime; |
29193 |
+ |
29194 |
+ if ((NULL == cachefile) || (0 == strlen(cachefile))) { |
29195 |
+ DBG_MSG("Invalid argument passed!\n"); |
29196 |
+ errno = EINVAL; |
29197 |
+ return -1; |
29198 |
+ } |
29199 |
+ |
29200 |
+ cache_mtime = get_mtime(cachefile, 1); |
29201 |
+ if (0 == cache_mtime) { |
29202 |
+ DBG_MSG("Could not get modification time for cache file '%s'!\n", |
29203 |
+ cachefile); |
29204 |
+ return -1; |
29205 |
+ } |
29206 |
+ |
29207 |
+ /* Get and compare mtime for RC_CONF_FILE_NAME with that of cachefile */ |
29208 |
+ rc_conf_mtime = get_mtime(RC_CONF_FILE_NAME, 1); |
29209 |
+ if (rc_conf_mtime > cache_mtime) { |
29210 |
+ DBG_MSG("'%s' have a later modification time than '%s'.\n", |
29211 |
+ RC_CONF_FILE_NAME, cachefile); |
29212 |
+ return -1; |
29213 |
+ } |
29214 |
+ /* Get and compare mtime for RC_CONFD_FILE_NAME with that of cachefile */ |
29215 |
+ rc_confd_mtime = get_mtime(RC_CONFD_FILE_NAME, 1); |
29216 |
+ if (rc_confd_mtime > cache_mtime) { |
29217 |
+ DBG_MSG("'%s' have a later modification time than '%s'.\n", |
29218 |
+ RC_CONFD_FILE_NAME, cachefile); |
29219 |
+ return -1; |
29220 |
+ } |
29221 |
+ |
29222 |
+ /* Get and compare mtime for each rc-script and its conf.d config file |
29223 |
+ * with that of cachefile */ |
29224 |
+ list_for_each_entry(info, &rcscript_list, node) { |
29225 |
+ if ((info->mtime > cache_mtime) || |
29226 |
+ (info->confd_mtime > cache_mtime)) { |
29227 |
+ DBG_MSG("'%s' have a later modification time than '%s'.\n", |
29228 |
+ info->filename, cachefile); |
29229 |
+ return -1; |
29230 |
+ } |
29231 |
+ } |
29232 |
+ |
29233 |
+ return 0; |
29234 |
+} |
29235 |
+ |
29236 |
+/* Return count on success, -1 on error. If it was critical, errno will be set. */ |
29237 |
+size_t parse_rcscript(char *scriptname, time_t mtime, char **data, size_t index) { |
29238 |
+ regex_data_t tmp_data; |
29239 |
+ char *buf = NULL; |
29240 |
+ char *tmp_buf = NULL; |
29241 |
+ size_t write_count = index; |
29242 |
+ size_t lenght; |
29243 |
+ int count; |
29244 |
+ int current = 0; |
29245 |
+ |
29246 |
+ if ((NULL == scriptname) || (0 == strlen(scriptname))) { |
29247 |
+ DBG_MSG("Invalid argument passed!\n"); |
29248 |
+ errno = EINVAL; |
29249 |
+ return -1; |
29250 |
+ } |
29251 |
+ |
29252 |
+ if (-1 == file_map(scriptname, &buf, &lenght)) { |
29253 |
+ DBG_MSG("Could not open '%s' for reading!\n", |
29254 |
+ gbasename(scriptname)); |
29255 |
+ return -1; |
29256 |
+ } |
29257 |
+ |
29258 |
+ while (current < lenght) { |
29259 |
+ count = buf_get_line(buf, lenght, current); |
29260 |
+ |
29261 |
+ tmp_buf = strndup(&buf[current], count); |
29262 |
+ if (NULL == tmp_buf) { |
29263 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
29264 |
+ goto error; |
29265 |
+ } |
29266 |
+ |
29267 |
+ if (0 == current) { |
29268 |
+ /* Check if it starts with '#!/sbin/runscript' */ |
29269 |
+ DO_REGEX(tmp_data, tmp_buf, |
29270 |
+ "[ \t]*#![ \t]*/sbin/runscript[ \t]*.*", error); |
29271 |
+ if (REGEX_FULL_MATCH != tmp_data.match) { |
29272 |
+ DBG_MSG("'%s' is not a valid rc-script!\n", |
29273 |
+ gbasename(scriptname)); |
29274 |
+ errno = 0; |
29275 |
+ goto error; |
29276 |
+ } |
29277 |
+ |
29278 |
+ /* We do not want rc-scripts ending in '.sh' */ |
29279 |
+ if (CHECK_FILE_EXTENSION(scriptname, ".sh")) { |
29280 |
+ EWARN("'%s' is invalid (should not end with '.sh')!\n", |
29281 |
+ gbasename(scriptname)); |
29282 |
+ errno = 0; |
29283 |
+ goto error; |
29284 |
+ } |
29285 |
+ DBG_MSG("Parsing '%s'.\n", gbasename(scriptname)); |
29286 |
+ |
29287 |
+ write_count = parse_print_header(gbasename(scriptname), |
29288 |
+ mtime, data, write_count); |
29289 |
+ if (-1 == write_count) { |
29290 |
+ DBG_MSG("Failed to call parse_print_header()!\n"); |
29291 |
+ goto error; |
29292 |
+ } |
29293 |
+ |
29294 |
+ goto _continue; |
29295 |
+ } |
29296 |
+ |
29297 |
+ /* Check for lines with comments, and skip them */ |
29298 |
+ DO_REGEX(tmp_data, tmp_buf, "^[ \t]*#", error); |
29299 |
+ if (REGEX_MATCH(tmp_data)) |
29300 |
+ goto _continue; |
29301 |
+ |
29302 |
+ /* If the line contains 'depend()', set 'got_depend' */ |
29303 |
+ DO_REGEX(tmp_data, tmp_buf, "depend[ \t]*()[ \t]*{?", error); |
29304 |
+ if (REGEX_MATCH(tmp_data)) { |
29305 |
+ DBG_MSG("Got 'depend()' function.\n"); |
29306 |
+ |
29307 |
+ write_count = parse_print_body(gbasename(scriptname), |
29308 |
+ data, write_count); |
29309 |
+ if (-1 == write_count) { |
29310 |
+ DBG_MSG("Failed to call parse_print_body()!\n"); |
29311 |
+ goto error; |
29312 |
+ } |
29313 |
+ |
29314 |
+ /* Need to have the 'source', as parse_cache() checks for |
29315 |
+ * second arg */ |
29316 |
+ PRINT_TO_BUFFER(data, write_count, error, |
29317 |
+ " . \"%s\" >/dev/null 2>&1 || echo \"FAILED source\"\n", |
29318 |
+ scriptname); |
29319 |
+ |
29320 |
+ write_count = parse_print_end(data, write_count); |
29321 |
+ if (-1 == write_count) { |
29322 |
+ DBG_MSG("Failed to call parse_print_end()!\n"); |
29323 |
+ goto error; |
29324 |
+ } |
29325 |
+ |
29326 |
+ /* Make sure this is the last loop */ |
29327 |
+ current += lenght; |
29328 |
+ goto _continue; |
29329 |
+ } |
29330 |
+ |
29331 |
+_continue: |
29332 |
+ current += count + 1; |
29333 |
+ free(tmp_buf); |
29334 |
+ } |
29335 |
+ |
29336 |
+ file_unmap(buf, lenght); |
29337 |
+ |
29338 |
+ return write_count; |
29339 |
+ |
29340 |
+error: |
29341 |
+ free(tmp_buf); |
29342 |
+ if (NULL != buf) { |
29343 |
+ int old_errno = errno; |
29344 |
+ file_unmap(buf, lenght); |
29345 |
+ /* file_unmap() might have changed it */ |
29346 |
+ errno = old_errno; |
29347 |
+ } |
29348 |
+ |
29349 |
+ return -1; |
29350 |
+} |
29351 |
+ |
29352 |
+ |
29353 |
+size_t generate_stage1(char **data) { |
29354 |
+ rcscript_info_t *info; |
29355 |
+ size_t write_count = 0; |
29356 |
+ size_t tmp_count; |
29357 |
+ |
29358 |
+ write_count = parse_print_start(data, write_count); |
29359 |
+ if (-1 == write_count) { |
29360 |
+ DBG_MSG("Failed to call parse_print_start()!\n"); |
29361 |
+ return -1; |
29362 |
+ } |
29363 |
+ |
29364 |
+ list_for_each_entry(info, &rcscript_list, node) { |
29365 |
+ tmp_count = parse_rcscript(info->filename, info->mtime, data, write_count); |
29366 |
+ if (-1 == tmp_count) { |
29367 |
+ DBG_MSG("Failed to parse '%s'!\n", |
29368 |
+ gbasename(info->filename)); |
29369 |
+ |
29370 |
+ /* If 'errno' is set, it is critical (hopefully) */ |
29371 |
+ if (0 != errno) |
29372 |
+ return -1; |
29373 |
+ } else { |
29374 |
+ write_count = tmp_count; |
29375 |
+ } |
29376 |
+ } |
29377 |
+ |
29378 |
+ return write_count; |
29379 |
+} |
29380 |
+ |
29381 |
+/* Empty signal handler for SIGPIPE */ |
29382 |
+static void sig_handler(int signum) { |
29383 |
+ return; |
29384 |
+} |
29385 |
+ |
29386 |
+/* Returns data's lenght on success, else -1 on error. */ |
29387 |
+size_t generate_stage2(char **data) { |
29388 |
+ /* parent_pfds is used to send data to the parent |
29389 |
+ * (thus the parent only use the read pipe, and the |
29390 |
+ * child uses the write pipe) |
29391 |
+ */ |
29392 |
+ int parent_pfds[2]; |
29393 |
+ /* child_pfds is used to send data to the child |
29394 |
+ * (thus the child only use the read pipe, and the |
29395 |
+ * parent uses the write pipe) |
29396 |
+ */ |
29397 |
+ int child_pfds[2]; |
29398 |
+ pid_t child_pid; |
29399 |
+ size_t write_count = 0; |
29400 |
+ int old_errno = 0; |
29401 |
+ |
29402 |
+ /* Pipe to send data to parent */ |
29403 |
+ if (-1 == pipe(parent_pfds)) { |
29404 |
+ DBG_MSG("Failed to open 'parent_pfds' pipe!\n"); |
29405 |
+ goto error; |
29406 |
+ } |
29407 |
+ /* Pipe to send data to childd */ |
29408 |
+ if (-1 == pipe(child_pfds)) { |
29409 |
+ DBG_MSG("Failed to open 'child_pfds' pipe!\n"); |
29410 |
+ /* Close parent_pfds */ |
29411 |
+ goto error_c_parent; |
29412 |
+ } |
29413 |
+ |
29414 |
+ /* Zero data */ |
29415 |
+ *data = NULL; |
29416 |
+ |
29417 |
+ child_pid = fork(); |
29418 |
+ if (-1 == child_pid) { |
29419 |
+ DBG_MSG("Failed to fork()!\n"); |
29420 |
+ /* Close all pipes */ |
29421 |
+ goto error_c_all; |
29422 |
+ } |
29423 |
+ if (0 == child_pid) { |
29424 |
+ /*** |
29425 |
+ *** In child |
29426 |
+ ***/ |
29427 |
+ |
29428 |
+ char *const argv[] = { |
29429 |
+ "bash", |
29430 |
+ "--noprofile", |
29431 |
+ "--norc", |
29432 |
+ "--", |
29433 |
+ NULL |
29434 |
+ }; |
29435 |
+ |
29436 |
+ /* Close the sides of the pipes we do not use */ |
29437 |
+ close(child_pfds[WRITE_PIPE]); /* Only used for reading */ |
29438 |
+ close(parent_pfds[READ_PIPE]); /* Only used for writing */ |
29439 |
+ |
29440 |
+ /* dup2 child side read pipe to STDIN */ |
29441 |
+ dup2(child_pfds[READ_PIPE], STDIN_FILENO); |
29442 |
+ /* dup2 child side write pipe to STDOUT */ |
29443 |
+ dup2(parent_pfds[WRITE_PIPE], STDOUT_FILENO); |
29444 |
+ |
29445 |
+ /* We need to be in INITD_DIR_NAME for 'before'/'after' '*' to work */ |
29446 |
+ if (-1 == chdir(INITD_DIR_NAME)) { |
29447 |
+ DBG_MSG("Failed to chdir to '%s'!\n", INITD_DIR_NAME); |
29448 |
+ exit(1); |
29449 |
+ } |
29450 |
+ |
29451 |
+ if (-1 == execv(SHELL_PARSER, argv)) { |
29452 |
+ DBG_MSG("Failed to execv %s!\n", SHELL_PARSER); |
29453 |
+ exit(1); |
29454 |
+ } |
29455 |
+ } else { |
29456 |
+ /*** |
29457 |
+ *** In parent |
29458 |
+ ***/ |
29459 |
+ |
29460 |
+ struct sigaction act_new; |
29461 |
+ struct sigaction act_old; |
29462 |
+ struct timeval tv; |
29463 |
+#if defined(USE_WRITE_SELECT) |
29464 |
+ fd_set write_fds; |
29465 |
+#endif |
29466 |
+ fd_set read_fds; |
29467 |
+ char buf[PARSE_BUFFER_SIZE+1]; |
29468 |
+ char *stage1_data = NULL; |
29469 |
+ size_t stage1_write_count = 0; |
29470 |
+ size_t stage1_written = 0; |
29471 |
+#if defined(USE_WRITE_SELECT) |
29472 |
+ int max_write_fds = child_pfds[WRITE_PIPE] + 1; |
29473 |
+#endif |
29474 |
+ int max_read_fds = parent_pfds[READ_PIPE] + 1; |
29475 |
+ int status = 0; |
29476 |
+ int read_count; |
29477 |
+ int closed_write_pipe = 0; |
29478 |
+ int tmp_pid = 0; |
29479 |
+ |
29480 |
+ DBG_MSG("Child pid = %i\n", child_pid); |
29481 |
+ |
29482 |
+ /* Set signal handler for SIGPIPE to empty in case bash errors |
29483 |
+ * out. It will then close the write pipe, and instead of us |
29484 |
+ * getting SIGPIPE, we can handle the write error like normal. |
29485 |
+ */ |
29486 |
+ memset(&act_new, 0x00, sizeof(act_new)); |
29487 |
+ act_new.sa_handler = (void (*) (int))sig_handler; |
29488 |
+ sigemptyset (&act_new.sa_mask); |
29489 |
+ act_new.sa_flags = 0; |
29490 |
+ sigaction(SIGPIPE, &act_new, &act_old); |
29491 |
+ |
29492 |
+ /* Close the sides of the pipes we do not use */ |
29493 |
+ close(parent_pfds[WRITE_PIPE]); /* Only used for reading */ |
29494 |
+ close(child_pfds[READ_PIPE]); /* Only used for writing */ |
29495 |
+ |
29496 |
+ stage1_data = malloc(OUTPUT_BUFFER_SIZE + 1); |
29497 |
+ if (NULL == stage1_data) { |
29498 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
29499 |
+ goto error_c_p_side; |
29500 |
+ } |
29501 |
+ |
29502 |
+ /* Pipe parse_rcscripts() to bash */ |
29503 |
+ stage1_write_count = generate_stage1(&stage1_data); |
29504 |
+ if (-1 == stage1_write_count) { |
29505 |
+ DBG_MSG("Failed to generate stage1!\n"); |
29506 |
+ goto error_c_p_side; |
29507 |
+ } |
29508 |
+ |
29509 |
+#if 0 |
29510 |
+ int tmp_fd = open("bar", O_CREAT | O_TRUNC | O_RDWR, 0600); |
29511 |
+ write(tmp_fd, stage1_data, stage1_write_count); |
29512 |
+ close(tmp_fd); |
29513 |
+#endif |
29514 |
+ |
29515 |
+ /* Do setup for select() */ |
29516 |
+ tv.tv_sec = 0; /* We do not want to wait for select() */ |
29517 |
+ tv.tv_usec = 0; /* Same thing here */ |
29518 |
+#if defined(USE_WRITE_SELECT) |
29519 |
+ FD_ZERO(&write_fds); |
29520 |
+ FD_SET(child_pfds[WRITE_PIPE], &write_fds); |
29521 |
+#endif |
29522 |
+ FD_ZERO(&read_fds); |
29523 |
+ FD_SET(parent_pfds[READ_PIPE], &read_fds); |
29524 |
+ |
29525 |
+ do { |
29526 |
+#if defined(USE_WRITE_SELECT) |
29527 |
+ fd_set wwrite_fds = write_fds; |
29528 |
+#endif |
29529 |
+ fd_set wread_fds = read_fds; |
29530 |
+ int tmp_count = 0; |
29531 |
+#if defined(USE_WRITE_SELECT) |
29532 |
+ int do_write = 0; |
29533 |
+#endif |
29534 |
+ int do_read = 0; |
29535 |
+ |
29536 |
+ /* Check if we can read from parent_pfds[READ_PIPE] */ |
29537 |
+ select(max_read_fds, &wread_fds, NULL, NULL, &tv); |
29538 |
+ do_read = FD_ISSET(parent_pfds[READ_PIPE], &wread_fds); |
29539 |
+ |
29540 |
+ /* While there is data to be written */ |
29541 |
+ if (stage1_written < stage1_write_count) { |
29542 |
+#if defined(USE_WRITE_SELECT) |
29543 |
+ /* Check if we can write */ |
29544 |
+ select(max_write_fds, NULL, &wwrite_fds, |
29545 |
+ NULL, &tv); |
29546 |
+ do_write = FD_ISSET(child_pfds[WRITE_PIPE], |
29547 |
+ &wwrite_fds); |
29548 |
+ |
29549 |
+ /* If we can write, or there is nothing to |
29550 |
+ * read, keep feeding the write pipe */ |
29551 |
+ if (do_write || !do_read) { |
29552 |
+#else |
29553 |
+ if (!do_read) { |
29554 |
+#endif |
29555 |
+ tmp_count = write(child_pfds[WRITE_PIPE], |
29556 |
+ &stage1_data[stage1_written], |
29557 |
+ strlen(&stage1_data[stage1_written])); |
29558 |
+ if (-1 == tmp_count) { |
29559 |
+ DBG_MSG("Error writing to child_pfds[WRITE_PIPE]!\n"); |
29560 |
+ goto failed; |
29561 |
+ } |
29562 |
+ /* What was written before, plus what |
29563 |
+ * we wrote now as well as the ending |
29564 |
+ * '\0' of the line */ |
29565 |
+ stage1_written += tmp_count + 1; |
29566 |
+ |
29567 |
+ /* Close the write pipe if we done |
29568 |
+ * writing to get a EOF signaled to |
29569 |
+ * bash */ |
29570 |
+ if (stage1_written >= stage1_write_count) { |
29571 |
+ closed_write_pipe = 1; |
29572 |
+ close(child_pfds[WRITE_PIPE]); |
29573 |
+ } |
29574 |
+ } |
29575 |
+ } |
29576 |
+ |
29577 |
+ if (do_read) { |
29578 |
+ read_count = read(parent_pfds[READ_PIPE], buf, |
29579 |
+ PARSE_BUFFER_SIZE); |
29580 |
+ if (-1 == read_count) { |
29581 |
+ DBG_MSG("Error reading parent_pfds[READ_PIPE]!\n"); |
29582 |
+ goto failed; |
29583 |
+ } |
29584 |
+ if (read_count > 0) { |
29585 |
+ char *tmp_p; |
29586 |
+ |
29587 |
+ tmp_p = realloc(*data, write_count + |
29588 |
+ read_count); |
29589 |
+ if (NULL == tmp_p) { |
29590 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
29591 |
+ goto failed; |
29592 |
+ } |
29593 |
+ |
29594 |
+ memcpy(&tmp_p[write_count], buf, |
29595 |
+ read_count); |
29596 |
+ |
29597 |
+ *data = tmp_p; |
29598 |
+ write_count += read_count; |
29599 |
+ } |
29600 |
+ } |
29601 |
+ tmp_pid = waitpid(child_pid, &status, WNOHANG); |
29602 |
+ } while (0 == tmp_pid); |
29603 |
+ |
29604 |
+failed: |
29605 |
+ /* Set old_errno to disable child exit code checking below */ |
29606 |
+ if (0 != errno) |
29607 |
+ old_errno = errno; |
29608 |
+ |
29609 |
+ free(stage1_data); |
29610 |
+ |
29611 |
+ if (0 == closed_write_pipe) |
29612 |
+ close(child_pfds[WRITE_PIPE]); |
29613 |
+ close(parent_pfds[READ_PIPE]); |
29614 |
+ |
29615 |
+ /* Restore the old signal handler for SIGPIPE */ |
29616 |
+ sigaction(SIGPIPE, &act_old, NULL); |
29617 |
+ |
29618 |
+ if (tmp_pid != child_pid) |
29619 |
+ /* Wait for bash to finish */ |
29620 |
+ waitpid(child_pid, &status, 0); |
29621 |
+ /* If old_errno is set, we had an error in the read loop, so do |
29622 |
+ * not worry about the child's exit code */ |
29623 |
+ if (0 == old_errno) { |
29624 |
+ if ((!WIFEXITED(status)) || (0 != WEXITSTATUS(status))) { |
29625 |
+ DBG_MSG("Bash failed with status 0x%x!\n", status); |
29626 |
+ goto error; |
29627 |
+ } |
29628 |
+ } else { |
29629 |
+ /* Right, we had an error, so set errno, and exit */ |
29630 |
+ errno = old_errno; |
29631 |
+ goto error; |
29632 |
+ } |
29633 |
+ } |
29634 |
+ |
29635 |
+ return write_count; |
29636 |
+ |
29637 |
+ /* Close parent side pipes */ |
29638 |
+error_c_p_side: |
29639 |
+ old_errno = errno; |
29640 |
+ close(child_pfds[WRITE_PIPE]); |
29641 |
+ close(parent_pfds[READ_PIPE]); |
29642 |
+ /* close() might have changed it */ |
29643 |
+ errno = old_errno; |
29644 |
+ goto error; |
29645 |
+ |
29646 |
+ /* Close all pipes */ |
29647 |
+error_c_all: |
29648 |
+ old_errno = errno; |
29649 |
+ close(child_pfds[READ_PIPE]); |
29650 |
+ close(child_pfds[WRITE_PIPE]); |
29651 |
+ /* close() might have changed it */ |
29652 |
+ errno = old_errno; |
29653 |
+ |
29654 |
+ /* Only close parent's pipes */ |
29655 |
+error_c_parent: |
29656 |
+ old_errno = errno; |
29657 |
+ close(parent_pfds[READ_PIPE]); |
29658 |
+ close(parent_pfds[WRITE_PIPE]); |
29659 |
+ /* close() might have changed it */ |
29660 |
+ errno = old_errno; |
29661 |
+ |
29662 |
+error: |
29663 |
+ return -1; |
29664 |
+} |
29665 |
+ |
29666 |
+int write_legacy_stage3(FILE *output) { |
29667 |
+ service_info_t *info; |
29668 |
+ char *service; |
29669 |
+ int count; |
29670 |
+ int index = 0; |
29671 |
+ int dep_count; |
29672 |
+ int i; |
29673 |
+ |
29674 |
+ if (-1 == fileno(output)) { |
29675 |
+ DBG_MSG("Bad output stream!\n"); |
29676 |
+ return -1; |
29677 |
+ } |
29678 |
+ |
29679 |
+ fprintf(output, "rc_type_ineed=2\n"); |
29680 |
+ fprintf(output, "rc_type_needsme=3\n"); |
29681 |
+ fprintf(output, "rc_type_iuse=4\n"); |
29682 |
+ fprintf(output, "rc_type_usesme=5\n"); |
29683 |
+ fprintf(output, "rc_type_ibefore=6\n"); |
29684 |
+ fprintf(output, "rc_type_iafter=7\n"); |
29685 |
+ fprintf(output, "rc_type_broken=8\n"); |
29686 |
+ fprintf(output, "rc_type_mtime=9\n"); |
29687 |
+ fprintf(output, "rc_index_scale=10\n\n"); |
29688 |
+ fprintf(output, "declare -a RC_DEPEND_TREE\n\n"); |
29689 |
+ |
29690 |
+ list_for_each_entry(info, &service_info_list, node) { |
29691 |
+ index++; |
29692 |
+ } |
29693 |
+ if (0 == index) { |
29694 |
+ EERROR("No services to generate dependency tree for!\n"); |
29695 |
+ return -1; |
29696 |
+ } |
29697 |
+ |
29698 |
+ fprintf(output, "RC_DEPEND_TREE[0]=%i\n\n", index); |
29699 |
+ |
29700 |
+ index = 1; |
29701 |
+ |
29702 |
+ list_for_each_entry(info, &service_info_list, node) { |
29703 |
+#if 0 |
29704 |
+ /* Make it easier to compare old depscan.sh output and this |
29705 |
+ * output as it puts 'net' right in the middle */ |
29706 |
+ if (0 == strcmp("net", info->name)) |
29707 |
+ continue; |
29708 |
+#endif |
29709 |
+ fprintf(output, "RC_DEPEND_TREE[%i]=\"%s\"\n", index*11, info->name); |
29710 |
+ |
29711 |
+ for (i = 0;i <= BROKEN;i++) { |
29712 |
+ dep_count = 0; |
29713 |
+ |
29714 |
+ fprintf(output, "RC_DEPEND_TREE[%i+%i]=", (index * 11), (i + 2)); |
29715 |
+ |
29716 |
+ STRING_LIST_FOR_EACH(info->depend_info[i], service, count) { |
29717 |
+ if (0 == dep_count) |
29718 |
+ fprintf(output, "\"%s", service); |
29719 |
+ else |
29720 |
+ fprintf(output, " %s", service); |
29721 |
+ |
29722 |
+ dep_count++; |
29723 |
+ } |
29724 |
+ |
29725 |
+ if (dep_count > 0) |
29726 |
+ fprintf(output, "\"\n"); |
29727 |
+ else |
29728 |
+ fprintf(output, "\n"); |
29729 |
+ } |
29730 |
+ |
29731 |
+ fprintf(output, "RC_DEPEND_TREE[%i+9]=", index*11); |
29732 |
+ fprintf(output, "\n"); |
29733 |
+ |
29734 |
+ fprintf(output, "RC_DEPEND_TREE[%i+10]=\"%li\"\n\n", index*11, |
29735 |
+ info->mtime); |
29736 |
+ index++; |
29737 |
+ } |
29738 |
+ |
29739 |
+ fprintf(output, "RC_GOT_DEPTREE_INFO=\"yes\"\n"); |
29740 |
+ |
29741 |
+ info = service_get_virtual("logger"); |
29742 |
+ if (NULL == info) { |
29743 |
+ DBG_MSG("No service provides the 'logger' logger virtual!\n"); |
29744 |
+ fprintf(output, "\nLOGGER_SERVICE=\n"); |
29745 |
+ } else { |
29746 |
+ fprintf(output, "\nLOGGER_SERVICE=\"%s\"\n", info->name); |
29747 |
+ } |
29748 |
+ |
29749 |
+ |
29750 |
+ return 0; |
29751 |
+} |
29752 |
+ |
29753 |
+int parse_cache(const char *data, size_t lenght) { |
29754 |
+ service_info_t *info; |
29755 |
+ service_type_t type = ALL_SERVICE_TYPE_T; |
29756 |
+ char *tmp_buf = NULL; |
29757 |
+ char *rc_name = NULL; |
29758 |
+ char *tmp_p; |
29759 |
+ char *token; |
29760 |
+ char *field; |
29761 |
+ int count; |
29762 |
+ int current = 0; |
29763 |
+ int retval; |
29764 |
+ |
29765 |
+ if ((NULL == data) || (lenght <= 0)) { |
29766 |
+ DBG_MSG("Invalid argument passed!\n"); |
29767 |
+ errno = EINVAL; |
29768 |
+ goto error; |
29769 |
+ } |
29770 |
+ |
29771 |
+ while (current < lenght) { |
29772 |
+ count = buf_get_line((char *)data, lenght, current); |
29773 |
+ |
29774 |
+ tmp_buf = strndup(&data[current], count); |
29775 |
+ if (NULL == tmp_buf) { |
29776 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
29777 |
+ goto error; |
29778 |
+ } |
29779 |
+ tmp_p = tmp_buf; |
29780 |
+ |
29781 |
+ /* Strip leading spaces/tabs */ |
29782 |
+ while ((tmp_p[0] == ' ') || (tmp_p[0] == '\t')) |
29783 |
+ tmp_p++; |
29784 |
+ |
29785 |
+ /* Get FIELD name and FIELD value */ |
29786 |
+ token = strsep(&tmp_p, " "); |
29787 |
+ |
29788 |
+ /* FIELD name empty/bogus? */ |
29789 |
+ if ((NULL == token) || (0 == strlen(token)) || |
29790 |
+ /* We got an empty FIELD value */ |
29791 |
+ (NULL == tmp_p) || (0 == strlen(tmp_p))) { |
29792 |
+ DBG_MSG("Parsing stopped due to short read!\n"); |
29793 |
+ errno = EMSGSIZE; |
29794 |
+ goto error; |
29795 |
+ } |
29796 |
+ |
29797 |
+ if (0 == strcmp(token, FIELD_RCSCRIPT)) { |
29798 |
+ DBG_MSG("Field = '%s', value = '%s'\n", token, tmp_p); |
29799 |
+ |
29800 |
+ /* Add the service to the list, and initialize all data */ |
29801 |
+ retval = service_add(tmp_p); |
29802 |
+ if (-1 == retval) { |
29803 |
+ DBG_MSG("Failed to add %s to service list!\n", |
29804 |
+ tmp_p); |
29805 |
+ goto error; |
29806 |
+ } |
29807 |
+ |
29808 |
+ info = service_get_info(tmp_p); |
29809 |
+ if (NULL == info) { |
29810 |
+ DBG_MSG("Failed to get info for '%s'!\n", tmp_p); |
29811 |
+ goto error; |
29812 |
+ } |
29813 |
+ /* Save the rc-script name for next passes of loop */ |
29814 |
+ rc_name = info->name; |
29815 |
+ |
29816 |
+ goto _continue; |
29817 |
+ } |
29818 |
+ |
29819 |
+ if (NULL == rc_name) { |
29820 |
+ DBG_MSG("Other fields should come after '%s'!\n", FIELD_RCSCRIPT); |
29821 |
+ goto error; |
29822 |
+ } |
29823 |
+ |
29824 |
+ if (0 == strcmp(token, FIELD_FAILED)) { |
29825 |
+ EWARN("'%s' has syntax errors, please correct!\n", rc_name); |
29826 |
+ /* FIXME: Need to think about what to do syntax BROKEN |
29827 |
+ * services */ |
29828 |
+ retval = service_add_dependency(rc_name, rc_name, BROKEN); |
29829 |
+ if (-1 == retval) { |
29830 |
+ DBG_MSG("Failed to add dependency '%s' to service '%s', type '%s'!\n", |
29831 |
+ token, rc_name, field); |
29832 |
+ goto error; |
29833 |
+ } |
29834 |
+ goto _continue; |
29835 |
+ } |
29836 |
+ |
29837 |
+ if (0 == strcmp(token, FIELD_NEED)) { |
29838 |
+ type = NEED; |
29839 |
+ goto have_dep_field; |
29840 |
+ } |
29841 |
+ |
29842 |
+ if (0 == strcmp(token, FIELD_USE)) { |
29843 |
+ type = USE; |
29844 |
+ goto have_dep_field; |
29845 |
+ } |
29846 |
+ |
29847 |
+ if (0 == strcmp(token, FIELD_BEFORE)) { |
29848 |
+ type = BEFORE; |
29849 |
+ goto have_dep_field; |
29850 |
+ } |
29851 |
+ |
29852 |
+ if (0 == strcmp(token, FIELD_AFTER)) { |
29853 |
+ type = AFTER; |
29854 |
+ goto have_dep_field; |
29855 |
+ } |
29856 |
+ |
29857 |
+ if (0 == strcmp(token, FIELD_PROVIDE)) { |
29858 |
+ type = PROVIDE; |
29859 |
+ goto have_dep_field; |
29860 |
+ } |
29861 |
+ |
29862 |
+ if (type < ALL_SERVICE_TYPE_T) { |
29863 |
+have_dep_field: |
29864 |
+ /* Get the first value * |
29865 |
+ * As the values are passed to a bash function, and we |
29866 |
+ * then use 'echo $*' to parse them, they should only |
29867 |
+ * have one space between each value ... */ |
29868 |
+ token = strsep(&tmp_p, " "); |
29869 |
+ |
29870 |
+ /* Get the correct type name */ |
29871 |
+ field = service_type_names[type]; |
29872 |
+ |
29873 |
+ while (NULL != token) { |
29874 |
+ DBG_MSG("Field = '%s', service = '%s', value = '%s'\n", |
29875 |
+ field, rc_name, token); |
29876 |
+ |
29877 |
+ retval = service_add_dependency(rc_name, token, type); |
29878 |
+ if (-1 == retval) { |
29879 |
+ DBG_MSG("Failed to add dependency '%s' to service '%s', type '%s'!\n", |
29880 |
+ token, rc_name, field); |
29881 |
+ goto error; |
29882 |
+ } |
29883 |
+ |
29884 |
+ /* Get the next value (if any) */ |
29885 |
+ token = strsep(&tmp_p, " "); |
29886 |
+ } |
29887 |
+ |
29888 |
+ goto _continue; |
29889 |
+ } |
29890 |
+ |
29891 |
+ if (0 == strcmp(token, FIELD_MTIME)) { |
29892 |
+ time_t mtime = 0; |
29893 |
+ |
29894 |
+ /* Just use the first value, and ignore the rest */ |
29895 |
+ token = strsep(&tmp_p, " "); |
29896 |
+ |
29897 |
+ if (NULL != token) |
29898 |
+ mtime = atoi(token); |
29899 |
+ |
29900 |
+ retval = service_set_mtime(rc_name, mtime); |
29901 |
+ if (-1 == retval) { |
29902 |
+ DBG_MSG("Failed to set mtime for service '%s'!\n", |
29903 |
+ rc_name); |
29904 |
+ goto error; |
29905 |
+ } |
29906 |
+ |
29907 |
+ /* Some debugging in case we have some corruption or |
29908 |
+ * other issues */ |
29909 |
+ token = strsep(&tmp_p, " "); |
29910 |
+ if (NULL != token) |
29911 |
+ DBG_MSG("Too many falues for field '%s'!\n", |
29912 |
+ FIELD_MTIME); |
29913 |
+ |
29914 |
+ goto _continue; |
29915 |
+ } |
29916 |
+ |
29917 |
+ /* Fall through */ |
29918 |
+ DBG_MSG("Unknown FIELD in data!\n"); |
29919 |
+ |
29920 |
+_continue: |
29921 |
+ type = ALL_SERVICE_TYPE_T; |
29922 |
+ current += count + 1; |
29923 |
+ free(tmp_buf); |
29924 |
+ /* Do not free 'rc_name', as it should be consistant |
29925 |
+ * across loops */ |
29926 |
+ } |
29927 |
+ |
29928 |
+ return 0; |
29929 |
+ |
29930 |
+error: |
29931 |
+ free(tmp_buf); |
29932 |
+ |
29933 |
+ return -1; |
29934 |
+} |
29935 |
+ |
29936 |
+size_t parse_print_start(char **data, size_t index) { |
29937 |
+ size_t write_count = index; |
29938 |
+ |
29939 |
+ PRINT_TO_BUFFER(data, write_count, error, ". /sbin/functions.sh\n"); |
29940 |
+ PRINT_TO_BUFFER(data, write_count, error, "[ -e /etc/rc.conf ] && . /etc/rc.conf\n\n"); |
29941 |
+// PRINT_TO_BUFFER(data, write_count, error, "set -e\n\n"); |
29942 |
+ PRINT_TO_BUFFER(data, write_count, error, "need() {\n"); |
29943 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ -n \"$*\" ] && echo \"NEED $*\"; return 0\n"); |
29944 |
+ PRINT_TO_BUFFER(data, write_count, error, "}\n\n"); |
29945 |
+ PRINT_TO_BUFFER(data, write_count, error, "use() {\n"); |
29946 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ -n \"$*\" ] && echo \"USE $*\"; return 0\n"); |
29947 |
+ PRINT_TO_BUFFER(data, write_count, error, "}\n\n"); |
29948 |
+ PRINT_TO_BUFFER(data, write_count, error, "before() {\n"); |
29949 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ -n \"$*\" ] && echo \"BEFORE $*\"; return 0\n"); |
29950 |
+ PRINT_TO_BUFFER(data, write_count, error, "}\n\n"); |
29951 |
+ PRINT_TO_BUFFER(data, write_count, error, "after() {\n"); |
29952 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ -n \"$*\" ] && echo \"AFTER $*\"; return 0\n"); |
29953 |
+ PRINT_TO_BUFFER(data, write_count, error, "}\n\n"); |
29954 |
+ PRINT_TO_BUFFER(data, write_count, error, "provide() {\n"); |
29955 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ -n \"$*\" ] && echo \"PROVIDE $*\"; return 0\n"); |
29956 |
+ PRINT_TO_BUFFER(data, write_count, error, "}\n\n"); |
29957 |
+ |
29958 |
+ return write_count; |
29959 |
+ |
29960 |
+error: |
29961 |
+ return -1; |
29962 |
+} |
29963 |
+ |
29964 |
+size_t parse_print_header(char *scriptname, time_t mtime, char **data, size_t index) { |
29965 |
+ size_t write_count = index; |
29966 |
+ |
29967 |
+ PRINT_TO_BUFFER(data, write_count, error, "#*** %s ***\n\n", scriptname); |
29968 |
+ PRINT_TO_BUFFER(data, write_count, error, "myservice=\"%s\"\n", scriptname); |
29969 |
+ PRINT_TO_BUFFER(data, write_count, error, "echo \"RCSCRIPT ${myservice}\"\n\n"); |
29970 |
+ PRINT_TO_BUFFER(data, write_count, error, "echo \"MTIME %li\"\n\n", mtime); |
29971 |
+ |
29972 |
+ return write_count; |
29973 |
+ |
29974 |
+error: |
29975 |
+ return -1; |
29976 |
+} |
29977 |
+ |
29978 |
+size_t parse_print_body(char *scriptname, char **data, size_t index) { |
29979 |
+ size_t write_count = index; |
29980 |
+ char *tmp_buf = NULL; |
29981 |
+ char *tmp_ptr; |
29982 |
+ char *base; |
29983 |
+ char *ext; |
29984 |
+ |
29985 |
+ tmp_buf = strndup(scriptname, strlen(scriptname)); |
29986 |
+ if (NULL == tmp_buf) { |
29987 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
29988 |
+ goto error; |
29989 |
+ } |
29990 |
+ |
29991 |
+ /* |
29992 |
+ * Rather do the next block in C than bash, in case we want to |
29993 |
+ * use ash or another shell in the place of bash |
29994 |
+ */ |
29995 |
+ |
29996 |
+ /* bash: base="${myservice%%.*}" */ |
29997 |
+ base = tmp_buf; |
29998 |
+ tmp_ptr = strchr(tmp_buf, '.'); |
29999 |
+ if (NULL != tmp_ptr) { |
30000 |
+ tmp_ptr[0] = '\0'; |
30001 |
+ tmp_ptr++; |
30002 |
+ } else { |
30003 |
+ tmp_ptr = tmp_buf; |
30004 |
+ } |
30005 |
+ /* bash: ext="${myservice##*.}" */ |
30006 |
+ ext = strrchr(tmp_ptr, '.'); |
30007 |
+ if (NULL == ext) |
30008 |
+ ext = tmp_ptr; |
30009 |
+ |
30010 |
+ PRINT_TO_BUFFER(data, write_count, error, "\n"); |
30011 |
+ PRINT_TO_BUFFER(data, write_count, error, " # Get settings for rc-script ...\n"); |
30012 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ -e \"/etc/conf.d/${myservice}\" ] && \\\n"); |
30013 |
+ PRINT_TO_BUFFER(data, write_count, error, " . \"/etc/conf.d/${myservice}\"\n"); |
30014 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ -e /etc/conf.d/net ] && \\\n"); |
30015 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ \"%s\" = \"net\" ] && \\\n", base); |
30016 |
+ PRINT_TO_BUFFER(data, write_count, error, " [ \"%s\" != \"${myservice}\" ] && \\\n", ext); |
30017 |
+ PRINT_TO_BUFFER(data, write_count, error, " . /etc/conf.d/net\n"); |
30018 |
+ PRINT_TO_BUFFER(data, write_count, error, " depend() {\n"); |
30019 |
+ PRINT_TO_BUFFER(data, write_count, error, " return 0\n"); |
30020 |
+ PRINT_TO_BUFFER(data, write_count, error, " }\n\n"); |
30021 |
+ PRINT_TO_BUFFER(data, write_count, error, " # Actual depend() function ...\n"); |
30022 |
+ |
30023 |
+ free(tmp_buf); |
30024 |
+ |
30025 |
+ return write_count; |
30026 |
+ |
30027 |
+error: |
30028 |
+ return -1; |
30029 |
+} |
30030 |
+ |
30031 |
+size_t parse_print_end(char **data, size_t index) { |
30032 |
+ size_t write_count = index; |
30033 |
+ |
30034 |
+ PRINT_TO_BUFFER(data, write_count, error, "\n"); |
30035 |
+ PRINT_TO_BUFFER(data, write_count, error, " depend\n"); |
30036 |
+ PRINT_TO_BUFFER(data, write_count, error, "\n\n"); |
30037 |
+ |
30038 |
+ return write_count; |
30039 |
+ |
30040 |
+error: |
30041 |
+ return -1; |
30042 |
+} |
30043 |
+ |
30044 |
|
30045 |
Added: trunk/baselayout-prefix/src/core/parse.h |
30046 |
=================================================================== |
30047 |
--- trunk/baselayout-prefix/src/core/parse.h (rev 0) |
30048 |
+++ trunk/baselayout-prefix/src/core/parse.h 2011-03-31 14:11:17 UTC (rev 1682) |
30049 |
@@ -0,0 +1,110 @@ |
30050 |
+/* |
30051 |
+ * parse.h |
30052 |
+ * |
30053 |
+ * Parser for Gentoo style rc-scripts. |
30054 |
+ * |
30055 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
30056 |
+ * |
30057 |
+ * |
30058 |
+ * This program is free software; you can redistribute it and/or modify it |
30059 |
+ * under the terms of the GNU General Public License as published by the |
30060 |
+ * Free Software Foundation version 2 of the License. |
30061 |
+ * |
30062 |
+ * This program is distributed in the hope that it will be useful, but |
30063 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
30064 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
30065 |
+ * General Public License for more details. |
30066 |
+ * |
30067 |
+ * You should have received a copy of the GNU General Public License along |
30068 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
30069 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
30070 |
+ * |
30071 |
+ * $Header$ |
30072 |
+ */ |
30073 |
+ |
30074 |
+#ifndef _PARSE_H |
30075 |
+#define _PARSE_H |
30076 |
+ |
30077 |
+#include <sys/types.h> |
30078 |
+#include "list.h" |
30079 |
+ |
30080 |
+#define RC_CONF_FILE_NAME "/etc/rc.conf" |
30081 |
+#define RC_CONFD_FILE_NAME "/etc/conf.d/rc" |
30082 |
+#define INITD_DIR_NAME "/etc/init.d/" |
30083 |
+#define CONFD_DIR_NAME "/etc/conf.d/" |
30084 |
+ |
30085 |
+#define SVCDIR_CONFIG_ENTRY "svcdir" |
30086 |
+ |
30087 |
+#define SHELL_PARSER "/bin/bash" |
30088 |
+ |
30089 |
+#define LEGACY_CACHE_FILE_NAME "deptree" |
30090 |
+ |
30091 |
+#define FIELD_RCSCRIPT "RCSCRIPT" |
30092 |
+#define FIELD_NEED "NEED" |
30093 |
+#define FIELD_USE "USE" |
30094 |
+#define FIELD_BEFORE "BEFORE" |
30095 |
+#define FIELD_AFTER "AFTER" |
30096 |
+#define FIELD_PROVIDE "PROVIDE" |
30097 |
+#define FIELD_MTIME "MTIME" |
30098 |
+#define FIELD_FAILED "FAILED" |
30099 |
+ |
30100 |
+typedef struct { |
30101 |
+ struct list_head node; |
30102 |
+ |
30103 |
+ char *filename; |
30104 |
+ time_t mtime; |
30105 |
+ time_t confd_mtime; |
30106 |
+} rcscript_info_t; |
30107 |
+ |
30108 |
+struct list_head rcscript_list; |
30109 |
+ |
30110 |
+int get_rcscripts(void); |
30111 |
+int check_rcscripts_mtime(char *cachefile); |
30112 |
+size_t generate_stage1(char **data); |
30113 |
+size_t generate_stage2(char **data); |
30114 |
+size_t read_stage2(char **data); |
30115 |
+int write_stage2(FILE *outfile); |
30116 |
+size_t generate_stage3(char **data); |
30117 |
+size_t read_stage3(char **data); |
30118 |
+int write_stage3(FILE *outfile); |
30119 |
+int write_legacy_stage3(FILE *output); |
30120 |
+int parse_cache(const char *data, size_t lenght); |
30121 |
+ |
30122 |
+/* |
30123 |
+ * get_rcscripts() |
30124 |
+ * | |
30125 |
+ * V |
30126 |
+ * check_rcscripts_mtime() ------------------------------> read_stage3() |
30127 |
+ * | | |
30128 |
+ * | | |
30129 |
+ * V V |
30130 |
+ * generate_stage1() (Called by generate_stage2()) parse_cache() |
30131 |
+ * | | |
30132 |
+ * | | |
30133 |
+ * V | |
30134 |
+ * generate_stage2() ----> write_stage2() (Debugging) | |
30135 |
+ * | | |
30136 |
+ * | | |
30137 |
+ * | === parse_cache() | |
30138 |
+ * V | | | |
30139 |
+ * generate_stage3() ==| | | |
30140 |
+ * | | | | |
30141 |
+ * | | V | |
30142 |
+ * | === service_resolve_dependencies() | |
30143 |
+ * | | |
30144 |
+ * | | |
30145 |
+ * |-------> write_legacy_stage3() (Proof of Concept | |
30146 |
+ * | or Debugging) | |
30147 |
+ * | | |
30148 |
+ * V | |
30149 |
+ * write_stage3() | |
30150 |
+ * | | |
30151 |
+ * | V |
30152 |
+ * |<------------------------------------------------------- |
30153 |
+ * | |
30154 |
+ * V |
30155 |
+ * |
30156 |
+ */ |
30157 |
+ |
30158 |
+#endif /* _PARSE_H */ |
30159 |
+ |
30160 |
|
30161 |
Added: trunk/baselayout-prefix/src/core/simple-regex.c |
30162 |
=================================================================== |
30163 |
--- trunk/baselayout-prefix/src/core/simple-regex.c (rev 0) |
30164 |
+++ trunk/baselayout-prefix/src/core/simple-regex.c 2011-03-31 14:11:17 UTC (rev 1682) |
30165 |
@@ -0,0 +1,854 @@ |
30166 |
+/* |
30167 |
+ * simple_regex.c |
30168 |
+ * |
30169 |
+ * Simle regex library. |
30170 |
+ * |
30171 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
30172 |
+ * |
30173 |
+ * |
30174 |
+ * This program is free software; you can redistribute it and/or modify it |
30175 |
+ * under the terms of the GNU General Public License as published by the |
30176 |
+ * Free Software Foundation version 2 of the License. |
30177 |
+ * |
30178 |
+ * This program is distributed in the hope that it will be useful, but |
30179 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
30180 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
30181 |
+ * General Public License for more details. |
30182 |
+ * |
30183 |
+ * You should have received a copy of the GNU General Public License along |
30184 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
30185 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
30186 |
+ * |
30187 |
+ * $Header$ |
30188 |
+ */ |
30189 |
+ |
30190 |
+/* |
30191 |
+ * Some notes: |
30192 |
+ * |
30193 |
+ * - This is a very simple regex library (read: return a match if some string |
30194 |
+ * matches some regex). It is probably not POSIX (if there are a POSIX or |
30195 |
+ * other standard) compatible. |
30196 |
+ * |
30197 |
+ * - I primarily wrote it to _not_ use glibc type regex functions, in case we |
30198 |
+ * might want to use it in code that have to be linked agaist klibc, etc. |
30199 |
+ * |
30200 |
+ * - It really is not optimized in any way yet. |
30201 |
+ * |
30202 |
+ * - Supported operators are: |
30203 |
+ * |
30204 |
+ * '.', '?', '*', '+' - So called 'wildcards' |
30205 |
+ * '[a-z]', '[^a-z]' - Basic 'lists'. Note that 'a-z' just specify that |
30206 |
+ * it supports basic lists as well as sequences .. |
30207 |
+ * The '^' is for an inverted list of course. |
30208 |
+ * '^', '$' - The 'from start' and 'to end' operators. If these |
30209 |
+ * are not used at the start ('^') or end ('$') of the |
30210 |
+ * regex, they will be treated as normal characters |
30211 |
+ * (this of course exclude the use of '^' in a 'list'). |
30212 |
+ * |
30213 |
+ * - If an invalid argument was passed, the functions returns 0 with |
30214 |
+ * 'regex_data-match == 0' (no error with no match) rather than -1. It may |
30215 |
+ * not be consistant with other practices, but I personally do not feel it is |
30216 |
+ * a critical error for these types of functions, and there are debugging you |
30217 |
+ * can enable to verify that there are no such issues. |
30218 |
+ * |
30219 |
+ * - __somefunction() is usually a helper function for somefunction(). I guess |
30220 |
+ * recursion might be an alternative, but I try to avoid it. |
30221 |
+ * |
30222 |
+ * - In general if we are matching a 'wildcard' ('*', '+' or '?'), a 'word' |
30223 |
+ * (read: some part of the regex that do not contain a 'wildcard' or 'list') |
30224 |
+ * will have a greater 'weight' than the 'wildcard'. This means that we |
30225 |
+ * will only continue to evaluate the 'wildcard' until the following 'word' |
30226 |
+ * (if any) matches. Currently this do not hold true for a 'list' not |
30227 |
+ * followed by a 'wildcard' - I might fix this in future. |
30228 |
+ * |
30229 |
+ */ |
30230 |
+ |
30231 |
+#include <errno.h> |
30232 |
+#include <stdio.h> |
30233 |
+#include <stdlib.h> |
30234 |
+#include <string.h> |
30235 |
+ |
30236 |
+#include "debug.h" |
30237 |
+#include "misc.h" |
30238 |
+#include "simple-regex.h" |
30239 |
+ |
30240 |
+/* Macro to check if a regex_data_t pointer is valid */ |
30241 |
+#define CHECK_REGEX_DATA_P(_regex_data, _on_error) \ |
30242 |
+ do { \ |
30243 |
+ if ((NULL == _regex_data) || \ |
30244 |
+ (NULL == _regex_data->data) || \ |
30245 |
+ /* We do not check for this, as it might still \ |
30246 |
+ * provide a match ('*' or '?' wildcard) */ \ |
30247 |
+ /* (0 == strlen(_regex_data->data)) || */ \ |
30248 |
+ (NULL == _regex_data->regex) || \ |
30249 |
+ (0 == strlen(_regex_data->regex))) {\ |
30250 |
+ DBG_MSG("Invalid argument passed!\n"); \ |
30251 |
+ goto _on_error; \ |
30252 |
+ } \ |
30253 |
+ } while (0) |
30254 |
+ |
30255 |
+size_t get_word(const char *regex, char **r_word); |
30256 |
+int match_word(regex_data_t *regex_data); |
30257 |
+size_t get_list_size(const char *regex); |
30258 |
+size_t get_list(const char *regex, char **r_list); |
30259 |
+int __match_list(regex_data_t *regex_data); |
30260 |
+int match_list(regex_data_t *regex_data); |
30261 |
+size_t get_wildcard(const char *regex, char *r_wildcard); |
30262 |
+int __match_wildcard(regex_data_t *regex_data, |
30263 |
+int (*match_func)(regex_data_t *regex_data), const char *regex); |
30264 |
+int match_wildcard(regex_data_t *regex_data); |
30265 |
+int __match(regex_data_t *regex_data); |
30266 |
+ |
30267 |
+/* |
30268 |
+ * Return values for match_* functions |
30269 |
+ * |
30270 |
+ * 0 - There was no error. If there was a match, regex_data->match |
30271 |
+ * - will be > 0 (this is the definitive check - if not true, the |
30272 |
+ * - other values of the struct may be bogus), regex_data->count |
30273 |
+ * - will be the amount of data that was matched (might be 0 for |
30274 |
+ * - some wildcards), and regex_data->r_count will be > 0. |
30275 |
+ * |
30276 |
+ * -1 - An error occured. Check errno for more info. |
30277 |
+ * |
30278 |
+ */ |
30279 |
+ |
30280 |
+size_t get_word(const char *regex, char **r_word) { |
30281 |
+ char *r_list; |
30282 |
+ char *tmp_p; |
30283 |
+ size_t count = 0; |
30284 |
+ size_t tmp_count; |
30285 |
+ |
30286 |
+ /* NULL string means we do not have a word */ |
30287 |
+ if ((NULL == regex) || (0 == strlen(regex))) { |
30288 |
+ DBG_MSG("Invalid argument passed!\n"); |
30289 |
+ return 0; |
30290 |
+ } |
30291 |
+ |
30292 |
+ *r_word = malloc(strlen(regex) + 1); |
30293 |
+ if (NULL == r_word) { |
30294 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
30295 |
+ return 0; |
30296 |
+ } |
30297 |
+ tmp_p = *r_word; |
30298 |
+ |
30299 |
+ while (strlen(regex) > 0) { |
30300 |
+ switch (regex[0]) { |
30301 |
+ case '*': |
30302 |
+ case '+': |
30303 |
+ case '?': |
30304 |
+ /* If its a wildcard, backup one step */ |
30305 |
+ *--tmp_p = '\0'; |
30306 |
+ count--; |
30307 |
+ return count; |
30308 |
+ case '[': |
30309 |
+ tmp_count = get_list(regex, &r_list); |
30310 |
+ free(r_list); |
30311 |
+ /* In theory should not happen, but you never know |
30312 |
+ * what may happen in future ... */ |
30313 |
+ if (-1 == tmp_count) |
30314 |
+ goto error; |
30315 |
+ |
30316 |
+ /* Bail if we have a list */ |
30317 |
+ if (tmp_count > 0) { |
30318 |
+ tmp_p[0] = '\0'; |
30319 |
+ return count; |
30320 |
+ } |
30321 |
+ default: |
30322 |
+ *tmp_p++ = *regex++; |
30323 |
+ count++; |
30324 |
+ break; |
30325 |
+ } |
30326 |
+ } |
30327 |
+ |
30328 |
+ tmp_p[0] = '\0'; |
30329 |
+ |
30330 |
+ return count; |
30331 |
+ |
30332 |
+error: |
30333 |
+ free(*r_word); |
30334 |
+ |
30335 |
+ return -1; |
30336 |
+} |
30337 |
+ |
30338 |
+int match_word(regex_data_t *regex_data) { |
30339 |
+ char *data_p = regex_data->data; |
30340 |
+ char *r_word = NULL, *r_word_p; |
30341 |
+ size_t count = 0; |
30342 |
+ |
30343 |
+ CHECK_REGEX_DATA_P(regex_data, exit); |
30344 |
+ |
30345 |
+ count = get_word(regex_data->regex, &r_word); |
30346 |
+ if (-1 == count) |
30347 |
+ goto error; |
30348 |
+ if (0 == count) |
30349 |
+ goto exit; |
30350 |
+ r_word_p = r_word; |
30351 |
+ |
30352 |
+ while ((strlen(data_p) > 0) && (strlen(r_word_p) > 0 )) { |
30353 |
+ /* If 'r_word' is not 100% part of 'string', we do not have |
30354 |
+ * a match. If its a '.', it matches no matter what. */ |
30355 |
+ if ((data_p[0] != r_word_p[0]) && (r_word_p[0] != '.')) { |
30356 |
+ count = 0; |
30357 |
+ goto exit; |
30358 |
+ } |
30359 |
+ |
30360 |
+ data_p++; |
30361 |
+ r_word_p++; |
30362 |
+ } |
30363 |
+ |
30364 |
+ /* If 'string' is shorter than 'r_word', we do not have a match */ |
30365 |
+ if ((0 == strlen(data_p)) && (0 < strlen(r_word_p))) { |
30366 |
+ count = 0; |
30367 |
+ goto exit; |
30368 |
+ } |
30369 |
+ |
30370 |
+exit: |
30371 |
+ /* Fill in our structure */ |
30372 |
+ if (0 == count) |
30373 |
+ regex_data->match = REGEX_NO_MATCH; |
30374 |
+ else if (strlen(regex_data->data) == count) |
30375 |
+ regex_data->match = REGEX_FULL_MATCH; |
30376 |
+ else |
30377 |
+ regex_data->match = REGEX_PARTIAL_MATCH; |
30378 |
+ if (regex_data->match != REGEX_NO_MATCH) |
30379 |
+ regex_data->where = regex_data->data; |
30380 |
+ else |
30381 |
+ regex_data->where = NULL; |
30382 |
+ regex_data->count = count; |
30383 |
+ regex_data->r_count = count; |
30384 |
+ |
30385 |
+ free(r_word); |
30386 |
+ return 0; |
30387 |
+ |
30388 |
+error: |
30389 |
+ regex_data->match = REGEX_NO_MATCH; |
30390 |
+ |
30391 |
+ free(r_word); |
30392 |
+ return -1; |
30393 |
+} |
30394 |
+ |
30395 |
+size_t get_list_size(const char *regex) { |
30396 |
+ size_t count = 0; |
30397 |
+ |
30398 |
+ /* NULL string means we do not have a list */ |
30399 |
+ if ((NULL == regex) || (0 == strlen(regex)) || (regex[0] != '[')) { |
30400 |
+ DBG_MSG("Invalid argument passed!\n"); |
30401 |
+ return 0; |
30402 |
+ } |
30403 |
+ |
30404 |
+ regex++; |
30405 |
+ |
30406 |
+ while ((strlen(regex) > 0) && (regex[0] != ']')) { |
30407 |
+ /* We have a sequence (x-y) */ |
30408 |
+ if ((regex[0] == '-') && (regex[1] != ']') && |
30409 |
+ (strlen(regex) >= 2) && (regex[-1] < regex[1])) |
30410 |
+ { |
30411 |
+ /* Add current + diff in sequence */ |
30412 |
+ count += regex[1] - regex[-1]; |
30413 |
+ /* Take care of '-' and next char */ |
30414 |
+ regex += 2; |
30415 |
+ } else { |
30416 |
+ regex++; |
30417 |
+ count++; |
30418 |
+ } |
30419 |
+ } |
30420 |
+ |
30421 |
+ return count; |
30422 |
+} |
30423 |
+ |
30424 |
+size_t get_list(const char *regex, char **r_list) { |
30425 |
+ char *tmp_buf = NULL; |
30426 |
+ size_t count = 0; |
30427 |
+ size_t size; |
30428 |
+ |
30429 |
+ /* NULL string means we do not have a list */ |
30430 |
+ if ((NULL == regex) || (0 == strlen(regex))) { |
30431 |
+ DBG_MSG("Invalid argument passed!\n"); |
30432 |
+ return 0; |
30433 |
+ } |
30434 |
+ |
30435 |
+ /* Bail if we do not have a list. Do not add debugging, as |
30436 |
+ * it is very noisy (used a lot when we call match_list() in |
30437 |
+ * __match() and match() to test for list matching) */ |
30438 |
+ if (regex[0] != '[') |
30439 |
+ return 0; |
30440 |
+ |
30441 |
+ size = get_list_size(regex); |
30442 |
+ if (0 == size) { |
30443 |
+ /* Should not be an issue, but just in case */ |
30444 |
+ DBG_MSG("0 returned by get_list_size.\n"); |
30445 |
+ return 0; |
30446 |
+ } |
30447 |
+ |
30448 |
+ *r_list = malloc(size + 1); |
30449 |
+ if (NULL == *r_list) { |
30450 |
+ DBG_MSG("Failed to allocate buffer!\n"); |
30451 |
+ return -1; |
30452 |
+ } |
30453 |
+ tmp_buf = *r_list; |
30454 |
+ |
30455 |
+ /* Take care of '[' */ |
30456 |
+ regex++; |
30457 |
+ count++; |
30458 |
+ |
30459 |
+ while ((strlen(regex) > 0) && (regex[0] != ']')) { |
30460 |
+ /* We have a sequence (x-y) */ |
30461 |
+ if ((regex[0] == '-') && (regex[1] != ']') && |
30462 |
+ (strlen(regex) >= 2) && (regex[-1] < regex[1])) |
30463 |
+ { |
30464 |
+ |
30465 |
+ /* Fill in missing chars in sequence */ |
30466 |
+ while (tmp_buf[-1] < regex[1]) { |
30467 |
+ tmp_buf[0] = (char)(tmp_buf[-1] + 1); |
30468 |
+ tmp_buf++; |
30469 |
+ /* We do not increase count */ |
30470 |
+ } |
30471 |
+ /* Take care of '-' and next char */ |
30472 |
+ count += 2; |
30473 |
+ regex += 2; |
30474 |
+ } else { |
30475 |
+ *tmp_buf++ = *regex++; |
30476 |
+ count++; |
30477 |
+ } |
30478 |
+ } |
30479 |
+ |
30480 |
+ tmp_buf[0] = '\0'; |
30481 |
+ /* Take care of ']' */ |
30482 |
+ count++; |
30483 |
+ |
30484 |
+ /* We do not have a list as it does not end in ']' */ |
30485 |
+ if (regex[0] != ']') { |
30486 |
+ count = 0; |
30487 |
+ free(*r_list); |
30488 |
+ } |
30489 |
+ |
30490 |
+ return count; |
30491 |
+} |
30492 |
+ |
30493 |
+/* If the first is the '^' character, everything but the list is matched |
30494 |
+ * NOTE: We only evaluate _ONE_ data character at a time!! */ |
30495 |
+int __match_list(regex_data_t *regex_data) { |
30496 |
+ regex_data_t tmp_data; |
30497 |
+ char *data_p = regex_data->data; |
30498 |
+ char *list_p = regex_data->regex; |
30499 |
+ char test_regex[2] = { '\0', '\0' }; |
30500 |
+ int invert = 0; |
30501 |
+ int match; |
30502 |
+ int retval; |
30503 |
+ |
30504 |
+ CHECK_REGEX_DATA_P(regex_data, failed); |
30505 |
+ |
30506 |
+ if (list_p[0] == '^') { |
30507 |
+ /* We need to invert the match */ |
30508 |
+ invert = 1; |
30509 |
+ /* Make sure '^' is not part of our list */ |
30510 |
+ list_p++; |
30511 |
+ } |
30512 |
+ |
30513 |
+ if (invert) |
30514 |
+ /* All should be a match if not in the list */ |
30515 |
+ match = 1; |
30516 |
+ else |
30517 |
+ /* We only have a match if in the list */ |
30518 |
+ match = 0; |
30519 |
+ |
30520 |
+ while (strlen(list_p) > 0) { |
30521 |
+ test_regex[0] = list_p[0]; |
30522 |
+ |
30523 |
+ FILL_REGEX_DATA(tmp_data, data_p, test_regex); |
30524 |
+ retval = match_word(&tmp_data); |
30525 |
+ if (-1 == retval) |
30526 |
+ goto error; |
30527 |
+ |
30528 |
+ if (REGEX_MATCH(tmp_data)) { |
30529 |
+ if (invert) |
30530 |
+ /* If we exclude the list from |
30531 |
+ * characters we try to match, we |
30532 |
+ * have a match until one of the |
30533 |
+ * list is found. */ |
30534 |
+ match = 0; |
30535 |
+ else |
30536 |
+ /* If not, we have to keep looking |
30537 |
+ * until one from the list match |
30538 |
+ * before we have a match */ |
30539 |
+ match = 1; |
30540 |
+ break; |
30541 |
+ } |
30542 |
+ list_p++; |
30543 |
+ } |
30544 |
+ |
30545 |
+ /* Fill in our structure */ |
30546 |
+ if (match) { |
30547 |
+ regex_data->match = REGEX_PARTIAL_MATCH; |
30548 |
+ regex_data->where = regex_data->data; |
30549 |
+ regex_data->count = 1; |
30550 |
+ /* This one is more cosmetic, as match_list() will |
30551 |
+ * do the right thing */ |
30552 |
+ regex_data->r_count = 0; /* strlen(regex_data->regex); */ |
30553 |
+ } else { |
30554 |
+failed: |
30555 |
+ regex_data->match = REGEX_NO_MATCH; |
30556 |
+ regex_data->where = NULL; |
30557 |
+ regex_data->count = 0; |
30558 |
+ regex_data->r_count = 0; |
30559 |
+ } |
30560 |
+ |
30561 |
+ return 0; |
30562 |
+ |
30563 |
+error: |
30564 |
+ regex_data->match = REGEX_NO_MATCH; |
30565 |
+ |
30566 |
+ return -1; |
30567 |
+} |
30568 |
+ |
30569 |
+int match_list(regex_data_t *regex_data) { |
30570 |
+ regex_data_t tmp_data; |
30571 |
+ char *data_p = regex_data->data; |
30572 |
+ char *list_p = regex_data->regex; |
30573 |
+ char *r_list = NULL; |
30574 |
+ size_t r_count = 0; |
30575 |
+ int retval; |
30576 |
+ |
30577 |
+ CHECK_REGEX_DATA_P(regex_data, failed); |
30578 |
+ |
30579 |
+ r_count = get_list(list_p, &r_list); |
30580 |
+ if (-1 == r_count) |
30581 |
+ goto error; |
30582 |
+ if (0 == r_count) |
30583 |
+ goto failed; |
30584 |
+ |
30585 |
+ FILL_REGEX_DATA(tmp_data, data_p, &list_p[r_count-1]); |
30586 |
+ retval = __match_wildcard(&tmp_data, __match_list, r_list); |
30587 |
+ if (-1 == retval) |
30588 |
+ goto error; |
30589 |
+ if (REGEX_MATCH(tmp_data)) { |
30590 |
+ /* This should be 2 ('word' + 'wildcard'), so just remove |
30591 |
+ * the wildcard */ |
30592 |
+ tmp_data.r_count--; |
30593 |
+ goto exit; |
30594 |
+ } |
30595 |
+ |
30596 |
+ FILL_REGEX_DATA(tmp_data, data_p, r_list); |
30597 |
+ retval = __match_list(&tmp_data); |
30598 |
+ if (-1 == retval) |
30599 |
+ goto error; |
30600 |
+ if (REGEX_MATCH(tmp_data)) |
30601 |
+ goto exit; |
30602 |
+ |
30603 |
+failed: |
30604 |
+ /* We will fill in regex_data below */ |
30605 |
+ tmp_data.match = REGEX_NO_MATCH; |
30606 |
+ tmp_data.where = NULL; |
30607 |
+ tmp_data.count = 0; |
30608 |
+ tmp_data.r_count = 0; |
30609 |
+ |
30610 |
+exit: |
30611 |
+ /* Fill in our structure */ |
30612 |
+ regex_data->match = tmp_data.match; |
30613 |
+ regex_data->where = tmp_data.where; |
30614 |
+ regex_data->count = tmp_data.count; |
30615 |
+ if (regex_data->match != REGEX_NO_MATCH) |
30616 |
+ /* tmp_data.r_count for __match_wildcard will take care of the |
30617 |
+ * wildcard, and tmp_data.r_count for __match_list will be 0 */ |
30618 |
+ regex_data->r_count = r_count + tmp_data.r_count; |
30619 |
+ else |
30620 |
+ regex_data->r_count = 0; |
30621 |
+ |
30622 |
+ free(r_list); |
30623 |
+ return 0; |
30624 |
+ |
30625 |
+error: |
30626 |
+ regex_data->match = REGEX_NO_MATCH; |
30627 |
+ |
30628 |
+ free(r_list); |
30629 |
+ return -1; |
30630 |
+} |
30631 |
+ |
30632 |
+size_t get_wildcard(const char *regex, char *r_wildcard) { |
30633 |
+ /* NULL regex means we do not have a wildcard */ |
30634 |
+ if ((NULL == regex) || (0 == strlen(regex))) { |
30635 |
+ DBG_MSG("Invalid argument passed!\n"); |
30636 |
+ return 0; |
30637 |
+ } |
30638 |
+ |
30639 |
+ r_wildcard[0] = regex[0]; |
30640 |
+ r_wildcard[2] = '\0'; |
30641 |
+ |
30642 |
+ switch (regex[1]) { |
30643 |
+ case '*': |
30644 |
+ case '+': |
30645 |
+ case '?': |
30646 |
+ r_wildcard[1] = regex[1]; |
30647 |
+ break; |
30648 |
+ default: |
30649 |
+ r_wildcard[0] = '\0'; |
30650 |
+ return 0; |
30651 |
+ } |
30652 |
+ |
30653 |
+ return strlen(r_wildcard); |
30654 |
+} |
30655 |
+ |
30656 |
+int __match_wildcard(regex_data_t *regex_data, int (*match_func)(regex_data_t *regex_data), const char *regex) { |
30657 |
+ regex_data_t tmp_data; |
30658 |
+ char *data_p = regex_data->data; |
30659 |
+ char *wildcard_p = regex_data->regex; |
30660 |
+ char r_wildcard[3]; |
30661 |
+ size_t count = 0; |
30662 |
+ size_t r_count = 0; |
30663 |
+ int is_match = 0; |
30664 |
+ int retval; |
30665 |
+ |
30666 |
+ CHECK_REGEX_DATA_P(regex_data, exit); |
30667 |
+ |
30668 |
+ if (NULL == match_func) { |
30669 |
+ DBG_MSG("NULL match_func was passed!\n"); |
30670 |
+ goto exit; |
30671 |
+ } |
30672 |
+ |
30673 |
+ r_count = get_wildcard(wildcard_p, r_wildcard); |
30674 |
+ if (0 == r_count) |
30675 |
+ goto exit; |
30676 |
+ |
30677 |
+ FILL_REGEX_DATA(tmp_data, data_p, (char *)regex); |
30678 |
+ retval = match_func(&tmp_data); |
30679 |
+ if (-1 == retval) |
30680 |
+ goto error; |
30681 |
+ |
30682 |
+ switch (r_wildcard[1]) { |
30683 |
+ case '*': |
30684 |
+ case '?': |
30685 |
+ /* '*' and '?' always matches */ |
30686 |
+ is_match = 1; |
30687 |
+ case '+': |
30688 |
+ /* We need to match all of them */ |
30689 |
+ do { |
30690 |
+ /* If we have at least one match for '+', or none |
30691 |
+ * for '*' or '?', check if we have a word or list match. |
30692 |
+ * We do this because a word weights more than a wildcard */ |
30693 |
+ if ((strlen(wildcard_p) > 2) && ((count > 0) || |
30694 |
+ (r_wildcard[1] == '*') || (r_wildcard[1] == '?'))) |
30695 |
+ { |
30696 |
+ regex_data_t tmp_data2; |
30697 |
+#if 0 |
30698 |
+ printf("data_p = %s, wildcard_p = %s\n", data_p, wildcard_p); |
30699 |
+#endif |
30700 |
+ |
30701 |
+ FILL_REGEX_DATA(tmp_data2, data_p, &wildcard_p[2]); |
30702 |
+ retval = match(&tmp_data2); |
30703 |
+ if (-1 == retval) |
30704 |
+ goto error; |
30705 |
+ |
30706 |
+ if (/* '.' might be a special case ... */ |
30707 |
+ /* (wildcard_p[2] != '.') && */ |
30708 |
+ (REGEX_MATCH(tmp_data2) && |
30709 |
+ (REGEX_FULL_MATCH == tmp_data2.match))) { |
30710 |
+ goto exit; |
30711 |
+ } |
30712 |
+ } |
30713 |
+ |
30714 |
+ if (REGEX_MATCH(tmp_data)) { |
30715 |
+ data_p += tmp_data.count; |
30716 |
+ count += tmp_data.count; |
30717 |
+ is_match = 1; |
30718 |
+ |
30719 |
+ FILL_REGEX_DATA(tmp_data, data_p, (char *)regex); |
30720 |
+ retval = match_func(&tmp_data); |
30721 |
+ if (-1 == retval) |
30722 |
+ goto error; |
30723 |
+ } |
30724 |
+ /* Only once for '?' */ |
30725 |
+ } while ((REGEX_MATCH(tmp_data)) && (r_wildcard[1] != '?')); |
30726 |
+ |
30727 |
+ break; |
30728 |
+ default: |
30729 |
+ /* No wildcard */ |
30730 |
+ break; |
30731 |
+ } |
30732 |
+ |
30733 |
+exit: |
30734 |
+ /* Fill in our structure */ |
30735 |
+ /* We can still have a match ('*' and '?'), although count == 0 */ |
30736 |
+ if ((0 == count) && (0 == is_match)) |
30737 |
+ regex_data->match = REGEX_NO_MATCH; |
30738 |
+ else if (strlen(regex_data->data) == count) |
30739 |
+ regex_data->match = REGEX_FULL_MATCH; |
30740 |
+ else |
30741 |
+ regex_data->match = REGEX_PARTIAL_MATCH; |
30742 |
+ if (regex_data->match != REGEX_NO_MATCH) |
30743 |
+ regex_data->where = regex_data->data; |
30744 |
+ else |
30745 |
+ regex_data->where = NULL; |
30746 |
+ regex_data->count = count; |
30747 |
+ regex_data->r_count = r_count; |
30748 |
+ |
30749 |
+ return 0; |
30750 |
+ |
30751 |
+error: |
30752 |
+ regex_data->match = REGEX_NO_MATCH; |
30753 |
+ |
30754 |
+ return -1; |
30755 |
+} |
30756 |
+ |
30757 |
+int match_wildcard(regex_data_t *regex_data) { |
30758 |
+ regex_data_t tmp_data; |
30759 |
+ char *data_p = regex_data->data; |
30760 |
+ char *wildcard_p = regex_data->regex; |
30761 |
+ char r_wildcard[3]; |
30762 |
+ size_t r_count; |
30763 |
+ int retval; |
30764 |
+ |
30765 |
+ CHECK_REGEX_DATA_P(regex_data, failed); |
30766 |
+ |
30767 |
+ /* Invalid wildcard - we need a character + a regex operator */ |
30768 |
+ if (strlen(wildcard_p) < 2) |
30769 |
+ goto failed; |
30770 |
+ |
30771 |
+ r_count = get_wildcard(wildcard_p, r_wildcard); |
30772 |
+ if (0 == r_count) |
30773 |
+ goto failed; |
30774 |
+ |
30775 |
+ /* Needed so that match_word() will not bail if it sees the wildcard */ |
30776 |
+ r_wildcard[1] = '\0'; |
30777 |
+ |
30778 |
+ FILL_REGEX_DATA(tmp_data, data_p, wildcard_p); |
30779 |
+ retval = __match_wildcard(&tmp_data, match_word, r_wildcard); |
30780 |
+ if (-1 == retval) |
30781 |
+ goto error; |
30782 |
+ if (REGEX_MATCH(tmp_data)) |
30783 |
+ goto exit; |
30784 |
+ |
30785 |
+failed: |
30786 |
+ /* We will fill in regex_data below */ |
30787 |
+ tmp_data.match = REGEX_NO_MATCH; |
30788 |
+ tmp_data.where = NULL; |
30789 |
+ tmp_data.count = 0; |
30790 |
+ tmp_data.r_count = 0; |
30791 |
+ |
30792 |
+exit: |
30793 |
+ /* Fill in our structure */ |
30794 |
+ regex_data->match = tmp_data.match; |
30795 |
+ regex_data->where = tmp_data.where; |
30796 |
+ regex_data->count = tmp_data.count; |
30797 |
+ regex_data->r_count = tmp_data.r_count; |
30798 |
+ |
30799 |
+ return 0; |
30800 |
+ |
30801 |
+error: |
30802 |
+ regex_data->match = REGEX_NO_MATCH; |
30803 |
+ |
30804 |
+ return -1; |
30805 |
+} |
30806 |
+ |
30807 |
+int __match(regex_data_t *regex_data) { |
30808 |
+ regex_data_t tmp_data; |
30809 |
+ char *data_p = regex_data->data; |
30810 |
+ char *regex_p = regex_data->regex; |
30811 |
+ size_t count = 0; |
30812 |
+ size_t r_count = 0; |
30813 |
+ int match = 0; |
30814 |
+ int retval; |
30815 |
+ |
30816 |
+ CHECK_REGEX_DATA_P(regex_data, failed); |
30817 |
+ |
30818 |
+ while (strlen(regex_p) > 0) { |
30819 |
+#if 0 |
30820 |
+ printf("data_p = '%s', regex_p = '%s'\n", data_p, regex_p); |
30821 |
+#endif |
30822 |
+ |
30823 |
+ FILL_REGEX_DATA(tmp_data, data_p, regex_p); |
30824 |
+ retval = match_list(&tmp_data); |
30825 |
+ if (-1 == retval) |
30826 |
+ goto error; |
30827 |
+ if (REGEX_MATCH(tmp_data)) |
30828 |
+ goto match; |
30829 |
+ |
30830 |
+ FILL_REGEX_DATA(tmp_data, data_p, regex_p); |
30831 |
+ retval = match_wildcard(&tmp_data); |
30832 |
+ if (-1 == retval) |
30833 |
+ goto error; |
30834 |
+ if (REGEX_MATCH(tmp_data)) |
30835 |
+ goto match; |
30836 |
+ |
30837 |
+ FILL_REGEX_DATA(tmp_data, data_p, regex_p); |
30838 |
+ retval = match_word(&tmp_data); |
30839 |
+ if (-1 == retval) |
30840 |
+ goto error; |
30841 |
+ if (REGEX_MATCH(tmp_data)) |
30842 |
+ goto match; |
30843 |
+ |
30844 |
+ break; |
30845 |
+ |
30846 |
+match: |
30847 |
+ data_p += tmp_data.count; |
30848 |
+ count += tmp_data.count; |
30849 |
+ regex_p += tmp_data.r_count; |
30850 |
+ r_count += tmp_data.r_count; |
30851 |
+ match = 1; |
30852 |
+ |
30853 |
+ /* Check that we do not go out of bounds */ |
30854 |
+ if (((data_p - regex_data->data) > strlen(regex_data->data)) || |
30855 |
+ ((regex_p - regex_data->regex) > strlen(regex_data->regex))) |
30856 |
+ goto failed; |
30857 |
+ } |
30858 |
+ |
30859 |
+ /* We could not match the whole regex (data too short?) */ |
30860 |
+ if (0 != strlen(regex_p)) |
30861 |
+ goto failed; |
30862 |
+ |
30863 |
+ goto exit; |
30864 |
+ |
30865 |
+failed: |
30866 |
+ /* We will fill in regex_data below */ |
30867 |
+ count = 0; |
30868 |
+ r_count = 0; |
30869 |
+ match = 0; |
30870 |
+ |
30871 |
+exit: |
30872 |
+ /* Fill in our structure */ |
30873 |
+ /* We can still have a match ('*' and '?'), although count == 0 */ |
30874 |
+ if ((0 == count) && (0 == match)) |
30875 |
+ regex_data->match = REGEX_NO_MATCH; |
30876 |
+ else if (strlen(regex_data->data) == count) |
30877 |
+ regex_data->match = REGEX_FULL_MATCH; |
30878 |
+ else |
30879 |
+ regex_data->match = REGEX_PARTIAL_MATCH; |
30880 |
+ if (regex_data->match != REGEX_NO_MATCH) |
30881 |
+ regex_data->where = regex_data->data; |
30882 |
+ else |
30883 |
+ regex_data->where = NULL; |
30884 |
+ regex_data->count = count; |
30885 |
+ regex_data->r_count = r_count; |
30886 |
+ |
30887 |
+ return 0; |
30888 |
+ |
30889 |
+error: |
30890 |
+ regex_data->match = REGEX_NO_MATCH; |
30891 |
+ |
30892 |
+ return -1; |
30893 |
+} |
30894 |
+ |
30895 |
+int match(regex_data_t *regex_data) { |
30896 |
+ regex_data_t tmp_data; |
30897 |
+ char *data_p = regex_data->data; |
30898 |
+ char *regex_p; |
30899 |
+ char *tmp_buf = NULL; |
30900 |
+ int from_start = 0; |
30901 |
+ int to_end = 0; |
30902 |
+ int retval; |
30903 |
+ |
30904 |
+ CHECK_REGEX_DATA_P(regex_data, failed); |
30905 |
+ |
30906 |
+ /* We might be modifying regex_p, so make a copy */ |
30907 |
+ tmp_buf = strndup(regex_data->regex, strlen(regex_data->regex)); |
30908 |
+ if (NULL == tmp_buf) { |
30909 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
30910 |
+ goto error; |
30911 |
+ } |
30912 |
+ regex_p = tmp_buf; |
30913 |
+ |
30914 |
+ /* Should we only match from the start? */ |
30915 |
+ if (regex_p[0] == '^') { |
30916 |
+ regex_p++; |
30917 |
+ from_start = 1; |
30918 |
+ } |
30919 |
+ |
30920 |
+ /* Should we match up to the end? */ |
30921 |
+ if (regex_p[strlen(regex_p) - 1] == '$') { |
30922 |
+ regex_p[strlen(regex_p) - 1] = '\0'; |
30923 |
+ to_end = 1; |
30924 |
+ } |
30925 |
+ |
30926 |
+ do { |
30927 |
+ FILL_REGEX_DATA(tmp_data, data_p, regex_p); |
30928 |
+ retval = __match(&tmp_data); |
30929 |
+ if (-1 == retval) |
30930 |
+ goto error; |
30931 |
+ } while ((strlen(data_p++) > 0) && |
30932 |
+ (!REGEX_MATCH(tmp_data)) && (0 == from_start)); |
30933 |
+ |
30934 |
+ /* Compensate for above extra inc */ |
30935 |
+ data_p--; |
30936 |
+ |
30937 |
+ /* Fill in our structure */ |
30938 |
+ if (REGEX_MATCH(tmp_data)) { |
30939 |
+ /* Check if we had an '$' at the end of the regex, and |
30940 |
+ * verify that we still have a match */ |
30941 |
+ if ((1 == to_end) && (tmp_data.count != strlen(data_p))) { |
30942 |
+ goto failed; |
30943 |
+ } |
30944 |
+ |
30945 |
+ if ((data_p == regex_data->data) && |
30946 |
+ (tmp_data.match == REGEX_FULL_MATCH)) |
30947 |
+ regex_data->match = REGEX_FULL_MATCH; |
30948 |
+ else |
30949 |
+ regex_data->match = REGEX_PARTIAL_MATCH; |
30950 |
+ regex_data->where = data_p; |
30951 |
+ regex_data->count = tmp_data.count; |
30952 |
+ regex_data->r_count = tmp_data.r_count; |
30953 |
+ if (1 == from_start) |
30954 |
+ regex_data->r_count++; |
30955 |
+ if (1 == to_end) |
30956 |
+ regex_data->r_count++; |
30957 |
+ } else { |
30958 |
+failed: |
30959 |
+ regex_data->match = REGEX_NO_MATCH; |
30960 |
+ regex_data->where = NULL; |
30961 |
+ regex_data->count = 0; |
30962 |
+ regex_data->r_count = 0; |
30963 |
+ } |
30964 |
+ |
30965 |
+ free(tmp_buf); |
30966 |
+ |
30967 |
+ return 0; |
30968 |
+ |
30969 |
+error: |
30970 |
+ regex_data->match = REGEX_NO_MATCH; |
30971 |
+ free(tmp_buf); |
30972 |
+ |
30973 |
+ return -1; |
30974 |
+} |
30975 |
+ |
30976 |
+#if 0 |
30977 |
+int main() { |
30978 |
+ regex_data_t tmp_data; |
30979 |
+ FILE *rcscript; |
30980 |
+ char regex[] = "^[ \t]*[d-p]+d[ \t]*(+)[ \t]*{$"; |
30981 |
+ char tempstr[255]; |
30982 |
+ int retval; |
30983 |
+ |
30984 |
+ rcscript = fopen("acpid", "r"); |
30985 |
+ if (NULL == rcscript) { |
30986 |
+ printf("%s", "Error opening file!"); |
30987 |
+ return 1; |
30988 |
+ } |
30989 |
+ |
30990 |
+ while (0 != fgets(tempstr, 254, rcscript)) { |
30991 |
+ if (tempstr[strlen(tempstr) - 1] == '\n') |
30992 |
+ tempstr[strlen(tempstr) - 1] = '\0'; |
30993 |
+ |
30994 |
+ FILL_REGEX_DATA(tmp_data, tempstr, regex); |
30995 |
+ retval = match(&tmp_data); |
30996 |
+ if (-1 != retval) { |
30997 |
+ if (REGEX_MATCH(tmp_data)) { |
30998 |
+ printf("*** string = '%s' ***\n", tempstr); |
30999 |
+ printf("*** regex = '%s' ***\n", regex); |
31000 |
+ |
31001 |
+ if (REGEX_FULL_MATCH == tmp_data.match) |
31002 |
+ printf("match (full): '%s', %i\n", tmp_data.where, tmp_data.count); |
31003 |
+ else |
31004 |
+ printf("match: '%s', %i\n", tmp_data.where, tmp_data.count); |
31005 |
+ |
31006 |
+ } else { |
31007 |
+ printf("%s", "No match\n"); |
31008 |
+ } |
31009 |
+ } else { |
31010 |
+ printf("%s", "Error during match\n"); |
31011 |
+ } |
31012 |
+ } |
31013 |
+ |
31014 |
+ fclose(rcscript); |
31015 |
+ |
31016 |
+ return 0; |
31017 |
+} |
31018 |
+#endif |
31019 |
+ |
31020 |
|
31021 |
Added: trunk/baselayout-prefix/src/core/simple-regex.h |
31022 |
=================================================================== |
31023 |
--- trunk/baselayout-prefix/src/core/simple-regex.h (rev 0) |
31024 |
+++ trunk/baselayout-prefix/src/core/simple-regex.h 2011-03-31 14:11:17 UTC (rev 1682) |
31025 |
@@ -0,0 +1,86 @@ |
31026 |
+/* |
31027 |
+ * simple_regex.h |
31028 |
+ * |
31029 |
+ * Simle regex library. |
31030 |
+ * |
31031 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
31032 |
+ * |
31033 |
+ * |
31034 |
+ * This program is free software; you can redistribute it and/or modify it |
31035 |
+ * under the terms of the GNU General Public License as published by the |
31036 |
+ * Free Software Foundation version 2 of the License. |
31037 |
+ * |
31038 |
+ * This program is distributed in the hope that it will be useful, but |
31039 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
31040 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
31041 |
+ * General Public License for more details. |
31042 |
+ * |
31043 |
+ * You should have received a copy of the GNU General Public License along |
31044 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
31045 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
31046 |
+ * |
31047 |
+ * $Header$ |
31048 |
+ */ |
31049 |
+ |
31050 |
+#ifndef _SIMPLE_REGEX_H |
31051 |
+#define _SIMPLE_REGEX_H |
31052 |
+ |
31053 |
+#define REGEX_NO_MATCH 0 /* We have no match */ |
31054 |
+#define REGEX_PARTIAL_MATCH 1 /* Some of the string matches the regex */ |
31055 |
+#define REGEX_FULL_MATCH 2 /* The whole string matches the regex */ |
31056 |
+ |
31057 |
+/* Macro to fill in .data and .regex */ |
31058 |
+#define FILL_REGEX_DATA(_regex_data, _string, _regex) \ |
31059 |
+ do { \ |
31060 |
+ _regex_data.data = _string; \ |
31061 |
+ _regex_data.regex = _regex; \ |
31062 |
+ } while (0) |
31063 |
+ |
31064 |
+/* Fill in _regex_data with _data and _regex, on failure goto _error */ |
31065 |
+#define DO_REGEX(_regex_data, _data, _regex, _error) \ |
31066 |
+ do { \ |
31067 |
+ FILL_REGEX_DATA(_regex_data, _data, _regex); \ |
31068 |
+ if (-1 == match(&_regex_data)) { \ |
31069 |
+ DBG_MSG("Could not do regex match!\n"); \ |
31070 |
+ goto _error; \ |
31071 |
+ } \ |
31072 |
+ } while (0) |
31073 |
+ |
31074 |
+/* Evaluate to true if we have some kind of match */ |
31075 |
+#define REGEX_MATCH(_regex_data) \ |
31076 |
+ ((REGEX_FULL_MATCH == _regex_data.match) || \ |
31077 |
+ (REGEX_PARTIAL_MATCH == _regex_data.match)) |
31078 |
+ |
31079 |
+/* Same as above, but for use when _regex_data is a pointer */ |
31080 |
+#define REGEX_MATCH_P(_regex_data) \ |
31081 |
+ ((REGEX_FULL_MATCH == _regex_data->match) || \ |
31082 |
+ (REGEX_PARTIAL_MATCH == _regex_data->match)) |
31083 |
+ |
31084 |
+typedef struct { |
31085 |
+ char *data; /* String to perform regex operation on */ |
31086 |
+ char *regex; /* String containing regex to use */ |
31087 |
+ int match; /* Will be set if there was a match. Check |
31088 |
+ * REGEX_*_MATCH above for possible values */ |
31089 |
+ char *where; /* Pointer to where match starts in data */ |
31090 |
+ size_t count; /* Count characters from data matched by regex */ |
31091 |
+ size_t r_count; /* Count characters of regex used for match. This |
31092 |
+ * should normally be the lenght of regex, but might |
31093 |
+ * not be for some internal functions ... */ |
31094 |
+} regex_data_t; |
31095 |
+ |
31096 |
+/* |
31097 |
+ * Return: |
31098 |
+ * |
31099 |
+ * 0 - There was no error. If there was a match, regex_data->match |
31100 |
+ * - will be > 0 (this is the definitive check - if not true, the |
31101 |
+ * - other values of the struct may be bogus), regex_data->count |
31102 |
+ * - will be the amount of data that was matched (might be 0 for |
31103 |
+ * - some wildcards), and regex_data->r_count will be > 0. |
31104 |
+ * |
31105 |
+ * -1 - An error occured. Check errno for more info. |
31106 |
+ * |
31107 |
+ */ |
31108 |
+int match(regex_data_t *regex_data); |
31109 |
+ |
31110 |
+#endif /* _SIMPLE_REGEX_H */ |
31111 |
+ |
31112 |
|
31113 |
Added: trunk/baselayout-prefix/src/core/test-regex.c |
31114 |
=================================================================== |
31115 |
--- trunk/baselayout-prefix/src/core/test-regex.c (rev 0) |
31116 |
+++ trunk/baselayout-prefix/src/core/test-regex.c 2011-03-31 14:11:17 UTC (rev 1682) |
31117 |
@@ -0,0 +1,80 @@ |
31118 |
+/* |
31119 |
+ * test-regex.c |
31120 |
+ * |
31121 |
+ * Test for the simple-regex module. |
31122 |
+ * |
31123 |
+ * Copyright (C) 2004,2005 Martin Schlemmer <azarah@××××××××××××.org> |
31124 |
+ * |
31125 |
+ * |
31126 |
+ * This program is free software; you can redistribute it and/or modify it |
31127 |
+ * under the terms of the GNU General Public License as published by the |
31128 |
+ * Free Software Foundation version 2 of the License. |
31129 |
+ * |
31130 |
+ * This program is distributed in the hope that it will be useful, but |
31131 |
+ * WITHOUT ANY WARRANTY; without even the implied warranty of |
31132 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
31133 |
+ * General Public License for more details. |
31134 |
+ * |
31135 |
+ * You should have received a copy of the GNU General Public License along |
31136 |
+ * with this program; if not, write to the Free Software Foundation, Inc., |
31137 |
+ * 675 Mass Ave, Cambridge, MA 02139, USA. |
31138 |
+ * |
31139 |
+ * $Header$ |
31140 |
+ */ |
31141 |
+ |
31142 |
+#include <errno.h> |
31143 |
+#include <stdio.h> |
31144 |
+#include <stdlib.h> |
31145 |
+#include <string.h> |
31146 |
+ |
31147 |
+#include "debug.h" |
31148 |
+#include "simple-regex.h" |
31149 |
+ |
31150 |
+char *test_data[] = { |
31151 |
+ /* string, pattern, match (1 = yes, 0 = no) */ |
31152 |
+ "ab", "a?[ab]b", "1", |
31153 |
+ "abb", "a?[ab]b", "1", |
31154 |
+ "aab", "a?[ab]b", "1", |
31155 |
+ "a", "a?a?a?a", "1", |
31156 |
+ "aa", "a?a?a?a", "1", |
31157 |
+ "aa", "a?a?a?aa", "1", |
31158 |
+ "aaa", "a?a?a?aa", "1", |
31159 |
+ "ab", "[ab]*", "1", |
31160 |
+ "abc", "[ab]*.", "1", |
31161 |
+ "ab", "[ab]*b+", "1", |
31162 |
+ "ab", "a?[ab]*b+", "1", |
31163 |
+ "aaaaaaaaaaaaaaaaaaaaaaa", "a*b", "0", |
31164 |
+ "aaaaaaaaabaaabbaaaaaa", "a*b+a*b*ba+", "1", |
31165 |
+ "ababababab", "a.*", "1", |
31166 |
+ "baaaaaaaab", "a*", "0", |
31167 |
+ NULL |
31168 |
+}; |
31169 |
+ |
31170 |
+int main() { |
31171 |
+ regex_data_t tmp_data; |
31172 |
+ char buf[256], string[100], regex[100]; |
31173 |
+ int i; |
31174 |
+ |
31175 |
+ for (i = 0; NULL != test_data[i]; i += 3) { |
31176 |
+ snprintf(string, 99, "'%s'", test_data[i]); |
31177 |
+ snprintf(regex, 99, "'%s'", test_data[i + 1]); |
31178 |
+ snprintf(buf, 255, "string = %s, pattern = %s", string, regex); |
31179 |
+ printf("%-60s", buf); |
31180 |
+ DO_REGEX(tmp_data, test_data[i], test_data[i + 1], error); |
31181 |
+ if (REGEX_MATCH(tmp_data) && (REGEX_FULL_MATCH == tmp_data.match)) { |
31182 |
+ if (0 != strncmp(test_data[i + 2], "1", 1)) |
31183 |
+ goto error; |
31184 |
+ } else { |
31185 |
+ if (0 != strncmp(test_data[i + 2], "0", 1)) |
31186 |
+ goto error; |
31187 |
+ } |
31188 |
+ |
31189 |
+ printf("%s\n", "[ \033[32;01mOK\033[0m ]"); |
31190 |
+ } |
31191 |
+ |
31192 |
+ return 0; |
31193 |
+error: |
31194 |
+ printf("%s\n", "[ \033[31;01m!!\033[0m ]"); |
31195 |
+ |
31196 |
+ return 1; |
31197 |
+} |
31198 |
|
31199 |
Added: trunk/baselayout-prefix/src/env_whitelist |
31200 |
=================================================================== |
31201 |
--- trunk/baselayout-prefix/src/env_whitelist (rev 0) |
31202 |
+++ trunk/baselayout-prefix/src/env_whitelist 2011-03-31 14:11:17 UTC (rev 1682) |
31203 |
@@ -0,0 +1,47 @@ |
31204 |
+# /lib/rcscripts/conf.d/env_whitelist: System environment whitelist for rc-system |
31205 |
+ |
31206 |
+# See /etc/conf.d/env_whitelist for details. |
31207 |
+ |
31208 |
+# |
31209 |
+# Internal variables needed for operation of rc-system |
31210 |
+# |
31211 |
+# NB: Do not modify below this line if you do not know what you are doing!! |
31212 |
+# |
31213 |
+ |
31214 |
+# Hotplug |
31215 |
+IN_HOTPLUG |
31216 |
+ |
31217 |
+# RC network script support |
31218 |
+IN_BACKGROUND |
31219 |
+RC_INTERFACE_KEEP_CONFIG |
31220 |
+ |
31221 |
+# Default shell stuff |
31222 |
+SHELL |
31223 |
+USER |
31224 |
+HOME |
31225 |
+TERM |
31226 |
+ |
31227 |
+# Language variables |
31228 |
+LANG |
31229 |
+LC_CTYPE |
31230 |
+LC_NUMERIC |
31231 |
+LC_TIME |
31232 |
+LC_COLLATE |
31233 |
+LC_MONETARY |
31234 |
+LC_MESSAGES |
31235 |
+LC_PAPER |
31236 |
+LC_NAME |
31237 |
+LC_ADDRESS |
31238 |
+LC_TELEPHONE |
31239 |
+LC_MEASUREMENT |
31240 |
+LC_IDENTIFICATION |
31241 |
+LC_ALL |
31242 |
+ |
31243 |
+# From /sbin/init |
31244 |
+PATH |
31245 |
+INIT_HALT |
31246 |
+INIT_VERSION |
31247 |
+RUNLEVEL |
31248 |
+PREVLEVEL |
31249 |
+CONSOLE |
31250 |
+ |
31251 |
|
31252 |
Added: trunk/baselayout-prefix/src/filefuncs/Makefile |
31253 |
=================================================================== |
31254 |
--- trunk/baselayout-prefix/src/filefuncs/Makefile (rev 0) |
31255 |
+++ trunk/baselayout-prefix/src/filefuncs/Makefile 2011-03-31 14:11:17 UTC (rev 1682) |
31256 |
@@ -0,0 +1,17 @@ |
31257 |
+CC = gcc |
31258 |
+LD = gcc |
31259 |
+ |
31260 |
+TARGETS = filefuncs.so |
31261 |
+ |
31262 |
+all: $(TARGETS) |
31263 |
+ |
31264 |
+filefuncs.o: filefuncs.c |
31265 |
+ $(CC) -shared -Wall -DHAVE_CONFIG_H -c -O -fPIC -I/usr/include/awk $^ |
31266 |
+ |
31267 |
+filefuncs.so: filefuncs.o |
31268 |
+ $(LD) -o $@ -shared $^ |
31269 |
+ |
31270 |
+clean: |
31271 |
+ rm -f $(TARGETS) |
31272 |
+ rm -f *.o *~ core |
31273 |
+ |
31274 |
|
31275 |
Added: trunk/baselayout-prefix/src/filefuncs/filefuncs.c |
31276 |
=================================================================== |
31277 |
--- trunk/baselayout-prefix/src/filefuncs/filefuncs.c (rev 0) |
31278 |
+++ trunk/baselayout-prefix/src/filefuncs/filefuncs.c 2011-03-31 14:11:17 UTC (rev 1682) |
31279 |
@@ -0,0 +1,486 @@ |
31280 |
+/* |
31281 |
+ * filefuncs.c - Builtin functions that provide initial minimal iterface |
31282 |
+ * to the file system. |
31283 |
+ * |
31284 |
+ * Arnold Robbins, update for 3.1, Mon Nov 23 12:53:39 EST 1998 |
31285 |
+ */ |
31286 |
+ |
31287 |
+/* |
31288 |
+ * Copyright (C) 2001 the Free Software Foundation, Inc. |
31289 |
+ * |
31290 |
+ * This file is part of GAWK, the GNU implementation of the |
31291 |
+ * AWK Programming Language. |
31292 |
+ * |
31293 |
+ * GAWK is free software; you can redistribute it and/or modify |
31294 |
+ * it under the terms of the GNU General Public License as published by |
31295 |
+ * the Free Software Foundation; either version 2 of the License, or |
31296 |
+ * (at your option) any later version. |
31297 |
+ * |
31298 |
+ * GAWK is distributed in the hope that it will be useful, |
31299 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
31300 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
31301 |
+ * GNU General Public License for more details. |
31302 |
+ * |
31303 |
+ * You should have received a copy of the GNU General Public License |
31304 |
+ * along with this program; if not, write to the Free Software |
31305 |
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
31306 |
+ */ |
31307 |
+ |
31308 |
+/* |
31309 |
+ * Copyright 1999-2004 Gentoo Foundation |
31310 |
+ * Distributed under the terms of the GNU General Public License v2 |
31311 |
+ * Author: Martin Schlemmer <azarah@g.o>, Nov 2002 |
31312 |
+ * $Header$ |
31313 |
+ * |
31314 |
+ * Extended with: do_symlink() |
31315 |
+ * do_unlink() |
31316 |
+ * do_mkdir() |
31317 |
+ * do_rmdir() |
31318 |
+ * |
31319 |
+ * for use in the Gentoo rcscripts |
31320 |
+ * |
31321 |
+ */ |
31322 |
+ |
31323 |
+#include "awk.h" |
31324 |
+ |
31325 |
+#include <unistd.h> |
31326 |
+#include <sys/sysmacros.h> |
31327 |
+ |
31328 |
+/* do_chdir --- provide dynamically loaded chdir() builtin for gawk */ |
31329 |
+ |
31330 |
+static NODE * |
31331 |
+do_chdir(tree) |
31332 |
+NODE *tree; |
31333 |
+{ |
31334 |
+ NODE *newdir; |
31335 |
+ int ret = -1; |
31336 |
+ |
31337 |
+ if (do_lint && tree->param_cnt > 1) |
31338 |
+ lintwarn("chdir: called with too many arguments"); |
31339 |
+ |
31340 |
+ newdir = get_argument(tree, 0); |
31341 |
+ if (newdir != NULL) { |
31342 |
+ (void) force_string(newdir); |
31343 |
+ ret = chdir(newdir->stptr); |
31344 |
+ if (ret < 0) |
31345 |
+ update_ERRNO(); |
31346 |
+ |
31347 |
+ free_temp(newdir); |
31348 |
+ } else if (do_lint) |
31349 |
+ lintwarn("chdir: called with no arguments"); |
31350 |
+ |
31351 |
+ |
31352 |
+ /* Set the return value */ |
31353 |
+ set_value(tmp_number((AWKNUM) ret)); |
31354 |
+ |
31355 |
+ /* Just to make the interpreter happy */ |
31356 |
+ return tmp_number((AWKNUM) 0); |
31357 |
+} |
31358 |
+ |
31359 |
+/* do_symlink --- provide dynamically loaded symlink() builtin for gawk */ |
31360 |
+ |
31361 |
+static NODE * |
31362 |
+do_symlink(tree) |
31363 |
+NODE *tree; |
31364 |
+{ |
31365 |
+ NODE *oldpath, *newpath; |
31366 |
+ int ret = -1; |
31367 |
+ |
31368 |
+ if (do_lint && tree->param_cnt > 2) |
31369 |
+ lintwarn("symlink: called with too many arguments"); |
31370 |
+ |
31371 |
+ oldpath = get_argument(tree, 0); |
31372 |
+ newpath = get_argument(tree, 1); |
31373 |
+ if ((oldpath != NULL) && (newpath)) { |
31374 |
+ (void) force_string(oldpath); |
31375 |
+ (void) force_string(newpath); |
31376 |
+ ret = symlink(oldpath->stptr, newpath->stptr); |
31377 |
+ if (ret < 0) |
31378 |
+ update_ERRNO(); |
31379 |
+ |
31380 |
+ free_temp(oldpath); |
31381 |
+ free_temp(newpath); |
31382 |
+ } else if (do_lint) |
31383 |
+ lintwarn("symlink: called with not enough arguments"); |
31384 |
+ |
31385 |
+ /* Set the return value */ |
31386 |
+ set_value(tmp_number((AWKNUM) ret)); |
31387 |
+ |
31388 |
+ /* Just to make the interpreter happy */ |
31389 |
+ return tmp_number((AWKNUM) 0); |
31390 |
+} |
31391 |
+ |
31392 |
+/* do_unlink --- provide dynamically loaded unlink() builtin for gawk */ |
31393 |
+ |
31394 |
+static NODE * |
31395 |
+do_unlink(tree) |
31396 |
+NODE *tree; |
31397 |
+{ |
31398 |
+ NODE *pathname; |
31399 |
+ int ret = -1; |
31400 |
+ |
31401 |
+ if (do_lint && tree->param_cnt > 1) |
31402 |
+ lintwarn("unlink: called with too many arguments"); |
31403 |
+ |
31404 |
+ pathname = get_argument(tree, 0); |
31405 |
+ if (pathname != NULL) { |
31406 |
+ (void) force_string(pathname); |
31407 |
+ ret = unlink(pathname->stptr); |
31408 |
+ if (ret < 0) |
31409 |
+ update_ERRNO(); |
31410 |
+ |
31411 |
+ free_temp(pathname); |
31412 |
+ } else if (do_lint) |
31413 |
+ lintwarn("unlink: called with no arguments"); |
31414 |
+ |
31415 |
+ /* Set the return value */ |
31416 |
+ set_value(tmp_number((AWKNUM) ret)); |
31417 |
+ |
31418 |
+ /* Just to make the interpreter happy */ |
31419 |
+ return tmp_number((AWKNUM) 0); |
31420 |
+} |
31421 |
+ |
31422 |
+/* do_mkdir --- provide dynamically loaded mkdir() builtin for gawk */ |
31423 |
+ |
31424 |
+static NODE * |
31425 |
+do_mkdir(tree) |
31426 |
+NODE *tree; |
31427 |
+{ |
31428 |
+ NODE *pathname, *mode; |
31429 |
+ int ret = -1; |
31430 |
+ |
31431 |
+ if (do_lint && tree->param_cnt > 2) |
31432 |
+ lintwarn("mkdir: called with too many arguments"); |
31433 |
+ |
31434 |
+ pathname = get_argument(tree, 0); |
31435 |
+ mode = get_argument(tree, 1); |
31436 |
+ if ((pathname != NULL) && (mode != NULL)) { |
31437 |
+ (void) force_string(pathname); |
31438 |
+ (void) force_number(mode); |
31439 |
+ ret = mkdir(pathname->stptr, mode->numbr); |
31440 |
+ if (ret < 0) |
31441 |
+ update_ERRNO(); |
31442 |
+ |
31443 |
+ free_temp(pathname); |
31444 |
+ free_temp(mode); |
31445 |
+ } else if (do_lint) |
31446 |
+ lintwarn("mkdir: called with not enough arguments"); |
31447 |
+ |
31448 |
+ /* Set the return value */ |
31449 |
+ set_value(tmp_number((AWKNUM) ret)); |
31450 |
+ |
31451 |
+ /* Just to make the interpreter happy */ |
31452 |
+ return tmp_number((AWKNUM) 0); |
31453 |
+} |
31454 |
+ |
31455 |
+/* do_rmdir --- provide dynamically loaded rmdir() builtin for gawk */ |
31456 |
+ |
31457 |
+static NODE * |
31458 |
+do_rmdir(tree) |
31459 |
+NODE *tree; |
31460 |
+{ |
31461 |
+ NODE *pathname; |
31462 |
+ int ret = -1; |
31463 |
+ |
31464 |
+ if (do_lint && tree->param_cnt > 1) |
31465 |
+ lintwarn("rmdir: called with too many arguments"); |
31466 |
+ |
31467 |
+ pathname = get_argument(tree, 0); |
31468 |
+ if (pathname != NULL) { |
31469 |
+ (void) force_string(pathname); |
31470 |
+ ret = rmdir(pathname->stptr); |
31471 |
+ if (ret < 0) |
31472 |
+ update_ERRNO(); |
31473 |
+ |
31474 |
+ free_temp(pathname); |
31475 |
+ } else if (do_lint) |
31476 |
+ lintwarn("rmdir: called with no arguments"); |
31477 |
+ |
31478 |
+ /* Set the return value */ |
31479 |
+ set_value(tmp_number((AWKNUM) ret)); |
31480 |
+ |
31481 |
+ /* Just to make the interpreter happy */ |
31482 |
+ return tmp_number((AWKNUM) 0); |
31483 |
+} |
31484 |
+ |
31485 |
+/* format_mode --- turn a stat mode field into something readable */ |
31486 |
+ |
31487 |
+static char * |
31488 |
+format_mode(fmode) |
31489 |
+unsigned long fmode; |
31490 |
+{ |
31491 |
+ static char outbuf[12]; |
31492 |
+ int i; |
31493 |
+ |
31494 |
+ strcpy(outbuf, "----------"); |
31495 |
+ /* first, get the file type */ |
31496 |
+ i = 0; |
31497 |
+ switch (fmode & S_IFMT) { |
31498 |
+#ifdef S_IFSOCK |
31499 |
+ case S_IFSOCK: |
31500 |
+ outbuf[i] = 's'; |
31501 |
+ break; |
31502 |
+#endif |
31503 |
+#ifdef S_IFLNK |
31504 |
+ case S_IFLNK: |
31505 |
+ outbuf[i] = 'l'; |
31506 |
+ break; |
31507 |
+#endif |
31508 |
+ case S_IFREG: |
31509 |
+ outbuf[i] = '-'; /* redundant */ |
31510 |
+ break; |
31511 |
+ case S_IFBLK: |
31512 |
+ outbuf[i] = 'b'; |
31513 |
+ break; |
31514 |
+ case S_IFDIR: |
31515 |
+ outbuf[i] = 'd'; |
31516 |
+ break; |
31517 |
+#ifdef S_IFDOOR /* Solaris weirdness */ |
31518 |
+ case S_IFDOOR: |
31519 |
+ outbuf[i] = 'D'; |
31520 |
+ break; |
31521 |
+#endif /* S_IFDOOR */ |
31522 |
+ case S_IFCHR: |
31523 |
+ outbuf[i] = 'c'; |
31524 |
+ break; |
31525 |
+#ifdef S_IFIFO |
31526 |
+ case S_IFIFO: |
31527 |
+ outbuf[i] = 'p'; |
31528 |
+ break; |
31529 |
+#endif |
31530 |
+ } |
31531 |
+ |
31532 |
+ i++; |
31533 |
+ if ((fmode & S_IRUSR) != 0) |
31534 |
+ outbuf[i] = 'r'; |
31535 |
+ i++; |
31536 |
+ if ((fmode & S_IWUSR) != 0) |
31537 |
+ outbuf[i] = 'w'; |
31538 |
+ i++; |
31539 |
+ if ((fmode & S_IXUSR) != 0) |
31540 |
+ outbuf[i] = 'x'; |
31541 |
+ i++; |
31542 |
+ |
31543 |
+ if ((fmode & S_IRGRP) != 0) |
31544 |
+ outbuf[i] = 'r'; |
31545 |
+ i++; |
31546 |
+ if ((fmode & S_IWGRP) != 0) |
31547 |
+ outbuf[i] = 'w'; |
31548 |
+ i++; |
31549 |
+ if ((fmode & S_IXGRP) != 0) |
31550 |
+ outbuf[i] = 'x'; |
31551 |
+ i++; |
31552 |
+ |
31553 |
+ if ((fmode & S_IROTH) != 0) |
31554 |
+ outbuf[i] = 'r'; |
31555 |
+ i++; |
31556 |
+ if ((fmode & S_IWOTH) != 0) |
31557 |
+ outbuf[i] = 'w'; |
31558 |
+ i++; |
31559 |
+ if ((fmode & S_IXOTH) != 0) |
31560 |
+ outbuf[i] = 'x'; |
31561 |
+ i++; |
31562 |
+ |
31563 |
+ outbuf[i] = '\0'; |
31564 |
+ |
31565 |
+ if ((fmode & S_ISUID) != 0) { |
31566 |
+ if (outbuf[3] == 'x') |
31567 |
+ outbuf[3] = 's'; |
31568 |
+ else |
31569 |
+ outbuf[3] = 'S'; |
31570 |
+ } |
31571 |
+ |
31572 |
+ /* setgid without execute == locking */ |
31573 |
+ if ((fmode & S_ISGID) != 0) { |
31574 |
+ if (outbuf[6] == 'x') |
31575 |
+ outbuf[6] = 's'; |
31576 |
+ else |
31577 |
+ outbuf[6] = 'l'; |
31578 |
+ } |
31579 |
+ |
31580 |
+ if ((fmode & S_ISVTX) != 0) { |
31581 |
+ if (outbuf[9] == 'x') |
31582 |
+ outbuf[9] = 't'; |
31583 |
+ else |
31584 |
+ outbuf[9] = 'T'; |
31585 |
+ } |
31586 |
+ |
31587 |
+ return outbuf; |
31588 |
+} |
31589 |
+ |
31590 |
+/* do_stat --- provide a stat() function for gawk */ |
31591 |
+ |
31592 |
+static NODE * |
31593 |
+do_stat(tree) |
31594 |
+NODE *tree; |
31595 |
+{ |
31596 |
+ NODE *file, *array; |
31597 |
+ struct stat sbuf; |
31598 |
+ int ret; |
31599 |
+ NODE **aptr; |
31600 |
+ char *pmode; /* printable mode */ |
31601 |
+ char *type = "unknown"; |
31602 |
+ |
31603 |
+ /* check arg count */ |
31604 |
+ if (tree->param_cnt != 2) |
31605 |
+ fatal( |
31606 |
+ "stat: called with incorrect number of arguments (%d), should be 2", |
31607 |
+ tree->param_cnt); |
31608 |
+ |
31609 |
+ /* directory is first arg, array to hold results is second */ |
31610 |
+ file = get_argument(tree, 0); |
31611 |
+ array = get_argument(tree, 1); |
31612 |
+ |
31613 |
+ /* empty out the array */ |
31614 |
+ assoc_clear(array); |
31615 |
+ |
31616 |
+ /* lstat the file, if error, set ERRNO and return */ |
31617 |
+ (void) force_string(file); |
31618 |
+ ret = lstat(file->stptr, & sbuf); |
31619 |
+ if (ret < 0) { |
31620 |
+ update_ERRNO(); |
31621 |
+ |
31622 |
+ set_value(tmp_number((AWKNUM) ret)); |
31623 |
+ |
31624 |
+ free_temp(file); |
31625 |
+ return tmp_number((AWKNUM) 0); |
31626 |
+ } |
31627 |
+ |
31628 |
+ /* fill in the array */ |
31629 |
+ aptr = assoc_lookup(array, tmp_string("name", 4), FALSE); |
31630 |
+ *aptr = dupnode(file); |
31631 |
+ |
31632 |
+ aptr = assoc_lookup(array, tmp_string("dev", 3), FALSE); |
31633 |
+ *aptr = make_number((AWKNUM) sbuf.st_dev); |
31634 |
+ |
31635 |
+ aptr = assoc_lookup(array, tmp_string("ino", 3), FALSE); |
31636 |
+ *aptr = make_number((AWKNUM) sbuf.st_ino); |
31637 |
+ |
31638 |
+ aptr = assoc_lookup(array, tmp_string("mode", 4), FALSE); |
31639 |
+ *aptr = make_number((AWKNUM) sbuf.st_mode); |
31640 |
+ |
31641 |
+ aptr = assoc_lookup(array, tmp_string("nlink", 5), FALSE); |
31642 |
+ *aptr = make_number((AWKNUM) sbuf.st_nlink); |
31643 |
+ |
31644 |
+ aptr = assoc_lookup(array, tmp_string("uid", 3), FALSE); |
31645 |
+ *aptr = make_number((AWKNUM) sbuf.st_uid); |
31646 |
+ |
31647 |
+ aptr = assoc_lookup(array, tmp_string("gid", 3), FALSE); |
31648 |
+ *aptr = make_number((AWKNUM) sbuf.st_gid); |
31649 |
+ |
31650 |
+ aptr = assoc_lookup(array, tmp_string("size", 4), FALSE); |
31651 |
+ *aptr = make_number((AWKNUM) sbuf.st_size); |
31652 |
+ |
31653 |
+ aptr = assoc_lookup(array, tmp_string("blocks", 6), FALSE); |
31654 |
+ *aptr = make_number((AWKNUM) sbuf.st_blocks); |
31655 |
+ |
31656 |
+ aptr = assoc_lookup(array, tmp_string("atime", 5), FALSE); |
31657 |
+ *aptr = make_number((AWKNUM) sbuf.st_atime); |
31658 |
+ |
31659 |
+ aptr = assoc_lookup(array, tmp_string("mtime", 5), FALSE); |
31660 |
+ *aptr = make_number((AWKNUM) sbuf.st_mtime); |
31661 |
+ |
31662 |
+ aptr = assoc_lookup(array, tmp_string("ctime", 5), FALSE); |
31663 |
+ *aptr = make_number((AWKNUM) sbuf.st_ctime); |
31664 |
+ |
31665 |
+ /* for block and character devices, add rdev, major and minor numbers */ |
31666 |
+ if (S_ISBLK(sbuf.st_mode) || S_ISCHR(sbuf.st_mode)) { |
31667 |
+ aptr = assoc_lookup(array, tmp_string("rdev", 4), FALSE); |
31668 |
+ *aptr = make_number((AWKNUM) sbuf.st_rdev); |
31669 |
+ |
31670 |
+ aptr = assoc_lookup(array, tmp_string("major", 5), FALSE); |
31671 |
+ *aptr = make_number((AWKNUM) major(sbuf.st_rdev)); |
31672 |
+ |
31673 |
+ aptr = assoc_lookup(array, tmp_string("minor", 5), FALSE); |
31674 |
+ *aptr = make_number((AWKNUM) minor(sbuf.st_rdev)); |
31675 |
+ } |
31676 |
+ |
31677 |
+#ifdef HAVE_ST_BLKSIZE |
31678 |
+ aptr = assoc_lookup(array, tmp_string("blksize", 7), FALSE); |
31679 |
+ *aptr = make_number((AWKNUM) sbuf.st_blksize); |
31680 |
+#endif /* HAVE_ST_BLKSIZE */ |
31681 |
+ |
31682 |
+ aptr = assoc_lookup(array, tmp_string("pmode", 5), FALSE); |
31683 |
+ pmode = format_mode(sbuf.st_mode); |
31684 |
+ *aptr = make_string(pmode, strlen(pmode)); |
31685 |
+ |
31686 |
+ /* for symbolic links, add a linkval field */ |
31687 |
+ if (S_ISLNK(sbuf.st_mode)) { |
31688 |
+ char buf[BUFSIZ*2]; |
31689 |
+ int linksize; |
31690 |
+ |
31691 |
+ linksize = readlink(file->stptr, buf, sizeof buf); |
31692 |
+ /* should make this smarter */ |
31693 |
+ if (linksize == sizeof(buf)) |
31694 |
+ fatal("size of symbolic link too big"); |
31695 |
+ buf[linksize] = '\0'; |
31696 |
+ |
31697 |
+ aptr = assoc_lookup(array, tmp_string("linkval", 7), FALSE); |
31698 |
+ *aptr = make_string(buf, linksize); |
31699 |
+ } |
31700 |
+ |
31701 |
+ /* add a type field */ |
31702 |
+ switch (sbuf.st_mode & S_IFMT) { |
31703 |
+#ifdef S_IFSOCK |
31704 |
+ case S_IFSOCK: |
31705 |
+ type = "socket"; |
31706 |
+ break; |
31707 |
+#endif |
31708 |
+#ifdef S_IFLNK |
31709 |
+ case S_IFLNK: |
31710 |
+ type = "symlink"; |
31711 |
+ break; |
31712 |
+#endif |
31713 |
+ case S_IFREG: |
31714 |
+ type = "file"; |
31715 |
+ break; |
31716 |
+ case S_IFBLK: |
31717 |
+ type = "blockdev"; |
31718 |
+ break; |
31719 |
+ case S_IFDIR: |
31720 |
+ type = "directory"; |
31721 |
+ break; |
31722 |
+#ifdef S_IFDOOR |
31723 |
+ case S_IFDOOR: |
31724 |
+ type = "door"; |
31725 |
+ break; |
31726 |
+#endif |
31727 |
+ case S_IFCHR: |
31728 |
+ type = "chardev"; |
31729 |
+ break; |
31730 |
+#ifdef S_IFIFO |
31731 |
+ case S_IFIFO: |
31732 |
+ type = "fifo"; |
31733 |
+ break; |
31734 |
+#endif |
31735 |
+ } |
31736 |
+ |
31737 |
+ aptr = assoc_lookup(array, tmp_string("type", 4), FALSE); |
31738 |
+ *aptr = make_string(type, strlen(type)); |
31739 |
+ |
31740 |
+ free_temp(file); |
31741 |
+ |
31742 |
+ /* Set the return value */ |
31743 |
+ set_value(tmp_number((AWKNUM) ret)); |
31744 |
+ |
31745 |
+ /* Just to make the interpreter happy */ |
31746 |
+ return tmp_number((AWKNUM) 0); |
31747 |
+} |
31748 |
+ |
31749 |
+/* dlload --- load new builtins in this library */ |
31750 |
+ |
31751 |
+NODE * |
31752 |
+dlload(tree, dl) |
31753 |
+NODE *tree; |
31754 |
+void *dl; |
31755 |
+{ |
31756 |
+ make_builtin("chdir", do_chdir, 1); |
31757 |
+ make_builtin("symlink", do_symlink, 2); |
31758 |
+ make_builtin("unlink", do_unlink, 1); |
31759 |
+ make_builtin("mkdir", do_mkdir, 2); |
31760 |
+ make_builtin("rmdir", do_rmdir, 1); |
31761 |
+ make_builtin("stat", do_stat, 2); |
31762 |
+ |
31763 |
+ return tmp_number((AWKNUM) 0); |
31764 |
+} |
31765 |
+ |
31766 |
|
31767 |
Added: trunk/baselayout-prefix/src/headers.h |
31768 |
=================================================================== |
31769 |
--- trunk/baselayout-prefix/src/headers.h (rev 0) |
31770 |
+++ trunk/baselayout-prefix/src/headers.h 2011-03-31 14:11:17 UTC (rev 1682) |
31771 |
@@ -0,0 +1,26 @@ |
31772 |
+/* |
31773 |
+ * header.h |
31774 |
+ * Dirty little file to include header files w/out autotools. |
31775 |
+ * |
31776 |
+ * Copyright 1999-2004 Gentoo Foundation |
31777 |
+ * Distributed under the terms of the GNU General Public License v2 |
31778 |
+ * $Header$ |
31779 |
+ */ |
31780 |
+ |
31781 |
+/* Common includes */ |
31782 |
+#define HAVE_TIOCNOTTY |
31783 |
+#define HAVE_SETSID |
31784 |
+ |
31785 |
+/* OS-specific includes */ |
31786 |
+#if defined(__GLIBC__) |
31787 |
+# define HAVE_SYS_SYSMACROS_H |
31788 |
+# define HAVE_ERROR_H |
31789 |
+#endif |
31790 |
+ |
31791 |
+/* Now we actually include crap ;) */ |
31792 |
+#ifdef HAVE_ERROR_H |
31793 |
+# include <error.h> |
31794 |
+#endif |
31795 |
+#ifdef HAVE_SYS_SYSMACROS_H |
31796 |
+# include <sys/sysmacros.h> |
31797 |
+#endif |
31798 |
|
31799 |
Added: trunk/baselayout-prefix/src/runscript.c |
31800 |
=================================================================== |
31801 |
--- trunk/baselayout-prefix/src/runscript.c (rev 0) |
31802 |
+++ trunk/baselayout-prefix/src/runscript.c 2011-03-31 14:11:17 UTC (rev 1682) |
31803 |
@@ -0,0 +1,254 @@ |
31804 |
+/* |
31805 |
+ * runscript.c |
31806 |
+ * Handle launching of Gentoo init scripts. |
31807 |
+ * |
31808 |
+ * Copyright 1999-2006 Gentoo Foundation |
31809 |
+ * Distributed under the terms of the GNU General Public License v2 |
31810 |
+ */ |
31811 |
+ |
31812 |
+#include <stdio.h> |
31813 |
+#include <stdlib.h> |
31814 |
+#include <unistd.h> |
31815 |
+#include <string.h> |
31816 |
+#include <errno.h> |
31817 |
+#include <sys/types.h> |
31818 |
+#include <sys/wait.h> |
31819 |
+#include <dlfcn.h> |
31820 |
+ |
31821 |
+#include "core/debug.h" |
31822 |
+#include "core/misc.h" |
31823 |
+ |
31824 |
+#ifndef LIBDIR |
31825 |
+# define LIBDIR "lib" |
31826 |
+#endif |
31827 |
+ |
31828 |
+#define SBIN_RC "/sbin/rc" |
31829 |
+#define PROFILE_ENV "/etc/profile.env" |
31830 |
+#define RCSCRIPTS_LIB "/" LIBDIR "/rcscripts" |
31831 |
+#define SYS_WHITELIST RCSCRIPTS_LIB "/conf.d/env_whitelist" |
31832 |
+#define USR_WHITELIST "/etc/conf.d/env_whitelist" |
31833 |
+#define RCSCRIPT_HELP RCSCRIPTS_LIB "/sh/rc-help.sh" |
31834 |
+#define SELINUX_LIB RCSCRIPTS_LIB "/runscript_selinux.so" |
31835 |
+#define SOFTLEVEL "SOFTLEVEL" |
31836 |
+ |
31837 |
+#define DEFAULT_PATH "PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin" |
31838 |
+ |
31839 |
+#define IS_SBIN_RC() (0 == strcmp(caller, SBIN_RC)) |
31840 |
+ |
31841 |
+static void (*selinux_run_init_old) (void); |
31842 |
+static void (*selinux_run_init_new) (int argc, char **argv); |
31843 |
+ |
31844 |
+extern char **environ; |
31845 |
+ |
31846 |
+void setup_selinux(int argc, char **argv) |
31847 |
+{ |
31848 |
+ void *lib_handle = NULL; |
31849 |
+ |
31850 |
+ lib_handle = dlopen(SELINUX_LIB, RTLD_NOW | RTLD_GLOBAL); |
31851 |
+ if (NULL != lib_handle) { |
31852 |
+ selinux_run_init_old = dlsym(lib_handle, "selinux_runscript"); |
31853 |
+ selinux_run_init_new = dlsym(lib_handle, "selinux_runscript2"); |
31854 |
+ |
31855 |
+ /* Use new run_init if it exists, else fall back to old */ |
31856 |
+ if (NULL != selinux_run_init_new) |
31857 |
+ selinux_run_init_new(argc, argv); |
31858 |
+ else if (NULL != selinux_run_init_old) |
31859 |
+ selinux_run_init_old(); |
31860 |
+ else { |
31861 |
+ /* This shouldnt happen... probably corrupt lib */ |
31862 |
+ fprintf(stderr, "Run_init is missing from runscript_selinux.so!\n"); |
31863 |
+ exit(127); |
31864 |
+ } |
31865 |
+ } |
31866 |
+} |
31867 |
+ |
31868 |
+char **get_whitelist(char **whitelist, char *filename) |
31869 |
+{ |
31870 |
+ char *buf = NULL; |
31871 |
+ char *tmp_buf = NULL; |
31872 |
+ char *tmp_p = NULL; |
31873 |
+ char *token = NULL; |
31874 |
+ size_t lenght = 0; |
31875 |
+ int count = 0; |
31876 |
+ int current = 0; |
31877 |
+ |
31878 |
+ if (-1 == file_map(filename, &buf, &lenght)) |
31879 |
+ return NULL; |
31880 |
+ |
31881 |
+ while (current < lenght) { |
31882 |
+ count = buf_get_line(buf, lenght, current); |
31883 |
+ |
31884 |
+ tmp_buf = strndup(&buf[current], count); |
31885 |
+ if (NULL == tmp_buf) { |
31886 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
31887 |
+ goto error; |
31888 |
+ } |
31889 |
+ tmp_p = tmp_buf; |
31890 |
+ |
31891 |
+ /* Strip leading spaces/tabs */ |
31892 |
+ while ((tmp_p[0] == ' ') || (tmp_p[0] == '\t')) |
31893 |
+ tmp_p++; |
31894 |
+ |
31895 |
+ /* Get entry - we do not want comments, and only the first word |
31896 |
+ * on a line is valid */ |
31897 |
+ token = strsep(&tmp_p, "# \t"); |
31898 |
+ if (NULL != token && '\0' != token[0]) { |
31899 |
+ tmp_p = strndup(token, strlen(token)); |
31900 |
+ STRING_LIST_ADD(whitelist, tmp_p, error); |
31901 |
+ } |
31902 |
+ |
31903 |
+ current += count + 1; |
31904 |
+ free(tmp_buf); |
31905 |
+ /* Set to NULL in case we error out above and have |
31906 |
+ * to free below */ |
31907 |
+ tmp_buf = NULL; |
31908 |
+ } |
31909 |
+ |
31910 |
+ |
31911 |
+ file_unmap(buf, lenght); |
31912 |
+ |
31913 |
+ return whitelist; |
31914 |
+ |
31915 |
+error: |
31916 |
+ if (NULL != tmp_buf) |
31917 |
+ free(tmp_buf); |
31918 |
+ file_unmap(buf, lenght); |
31919 |
+ STRING_LIST_FREE(whitelist); |
31920 |
+ |
31921 |
+ return NULL; |
31922 |
+} |
31923 |
+ |
31924 |
+char **filter_environ(char *caller) |
31925 |
+{ |
31926 |
+ char **myenv = NULL; |
31927 |
+ char **whitelist = NULL; |
31928 |
+ char *env_name = NULL; |
31929 |
+ int check_profile = 1; |
31930 |
+ int count = 0; |
31931 |
+ |
31932 |
+ if (NULL != getenv(SOFTLEVEL) && !IS_SBIN_RC()) |
31933 |
+ /* Called from /sbin/rc, but not /sbin/rc itself, so current |
31934 |
+ * environment should be fine */ |
31935 |
+ return environ; |
31936 |
+ |
31937 |
+ if (1 == is_file(SYS_WHITELIST, 1)) |
31938 |
+ whitelist = get_whitelist(whitelist, SYS_WHITELIST); |
31939 |
+ else |
31940 |
+ EWARN("System environment whitelist missing!\n"); |
31941 |
+ |
31942 |
+ if (1 == is_file(USR_WHITELIST, 1)) |
31943 |
+ whitelist = get_whitelist(whitelist, USR_WHITELIST); |
31944 |
+ |
31945 |
+ if (NULL == whitelist) |
31946 |
+ /* If no whitelist is present, revert to old behaviour */ |
31947 |
+ return environ; |
31948 |
+ |
31949 |
+ if (1 != is_file(PROFILE_ENV, 1)) |
31950 |
+ /* XXX: Maybe warn here? */ |
31951 |
+ check_profile = 0; |
31952 |
+ |
31953 |
+ STRING_LIST_FOR_EACH(whitelist, env_name, count) { |
31954 |
+ char *env_var = NULL; |
31955 |
+ char *tmp_p = NULL; |
31956 |
+ int env_len = 0; |
31957 |
+ |
31958 |
+ env_var = getenv(env_name); |
31959 |
+ if (NULL != env_var) |
31960 |
+ goto add_entry; |
31961 |
+ |
31962 |
+ if (1 == check_profile) { |
31963 |
+ char *tmp_env_name = NULL; |
31964 |
+ int tmp_len = 0; |
31965 |
+ |
31966 |
+ /* The entries in PROFILE_ENV is of the form: |
31967 |
+ * export VAR_NAME=value */ |
31968 |
+ tmp_len = strlen(env_name) + strlen("export ") + 1; |
31969 |
+ tmp_env_name = calloc(tmp_len, sizeof(char *)); |
31970 |
+ if (NULL == tmp_env_name) { |
31971 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
31972 |
+ goto error; |
31973 |
+ } |
31974 |
+ snprintf(tmp_env_name, tmp_len, "export %s", env_name); |
31975 |
+ |
31976 |
+ /* Clear errno so that subsequent calls do not trigger |
31977 |
+ * DBG_MSG */ |
31978 |
+ errno = 0; |
31979 |
+ env_var = get_cnf_entry(PROFILE_ENV, tmp_env_name); |
31980 |
+ free(tmp_env_name); |
31981 |
+ if (NULL == env_var && ENOMSG != errno) |
31982 |
+ goto error; |
31983 |
+ else if (NULL != env_var) |
31984 |
+ goto add_entry; |
31985 |
+ } |
31986 |
+ |
31987 |
+ continue; |
31988 |
+ |
31989 |
+add_entry: |
31990 |
+ env_len = strlen(env_name) + strlen(env_var) + 2; |
31991 |
+ tmp_p = calloc(env_len, sizeof(char *)); |
31992 |
+ if (NULL == tmp_p) { |
31993 |
+ DBG_MSG("Failed to allocate temporary buffer!\n"); |
31994 |
+ goto error; |
31995 |
+ } |
31996 |
+ snprintf(tmp_p, env_len, "%s=%s", env_name, env_var); |
31997 |
+ STRING_LIST_ADD(myenv, tmp_p, error); |
31998 |
+ } |
31999 |
+ |
32000 |
+ STRING_LIST_FREE(whitelist); |
32001 |
+ |
32002 |
+ if (NULL == myenv) |
32003 |
+ /* If all else fails, just add a default PATH */ |
32004 |
+ STRING_LIST_ADD(myenv, strdup(DEFAULT_PATH), error); |
32005 |
+ |
32006 |
+ return myenv; |
32007 |
+ |
32008 |
+error: |
32009 |
+ STRING_LIST_FREE(myenv); |
32010 |
+ STRING_LIST_FREE(whitelist); |
32011 |
+ |
32012 |
+ return NULL; |
32013 |
+} |
32014 |
+ |
32015 |
+int main(int argc, char *argv[]) |
32016 |
+{ |
32017 |
+ char *myargs[32]; |
32018 |
+ char **myenv = NULL; |
32019 |
+ char *caller = argv[1]; |
32020 |
+ int new = 1; |
32021 |
+ |
32022 |
+ /* Need to be /bin/bash, else BASH is invalid */ |
32023 |
+ myargs[0] = "/bin/bash"; |
32024 |
+ while (argv[new] != 0) { |
32025 |
+ myargs[new] = argv[new]; |
32026 |
+ new++; |
32027 |
+ } |
32028 |
+ myargs[new] = NULL; |
32029 |
+ |
32030 |
+ /* Do not do help for /sbin/rc */ |
32031 |
+ if ((argc < 2) || (argc < 3 && !IS_SBIN_RC())) { |
32032 |
+ execv(RCSCRIPT_HELP, myargs); |
32033 |
+ exit(1); |
32034 |
+ } |
32035 |
+ |
32036 |
+ /* Setup a filtered environment according to the whitelist */ |
32037 |
+ myenv = filter_environ(caller); |
32038 |
+ if (NULL == myenv) { |
32039 |
+ EWARN("%s: Failed to filter the environment!\n", caller); |
32040 |
+ /* XXX: Might think to bail here, but it could mean the system |
32041 |
+ * is rendered unbootable, so rather not */ |
32042 |
+ myenv = environ; |
32043 |
+ } |
32044 |
+ |
32045 |
+ /* Ok, we are ready to go, so setup selinux if applicable */ |
32046 |
+ setup_selinux(argc, argv); |
32047 |
+ |
32048 |
+ if (!IS_SBIN_RC()) { |
32049 |
+ if (execve("/sbin/runscript.sh", myargs, myenv) < 0) |
32050 |
+ exit(1); |
32051 |
+ } else { |
32052 |
+ if (execve("/bin/bash", myargs, myenv) < 0) |
32053 |
+ exit(1); |
32054 |
+ } |
32055 |
+ |
32056 |
+ return 0; |
32057 |
+} |
32058 |
|
32059 |
Added: trunk/baselayout-prefix/src/start-stop-daemon.c |
32060 |
=================================================================== |
32061 |
--- trunk/baselayout-prefix/src/start-stop-daemon.c (rev 0) |
32062 |
+++ trunk/baselayout-prefix/src/start-stop-daemon.c 2011-03-31 14:11:17 UTC (rev 1682) |
32063 |
@@ -0,0 +1,1430 @@ |
32064 |
+/* |
32065 |
+ * A rewrite of the original Debian's start-stop-daemon Perl script |
32066 |
+ * in C (faster - it is executed many times during system startup). |
32067 |
+ * |
32068 |
+ * Written by Marek Michalkiewicz <marekm@×××××××××××××××××××××××.pl>, |
32069 |
+ * public domain. Based conceptually on start-stop-daemon.pl, by Ian |
32070 |
+ * Jackson <ijackson@××××××××××.edu>. May be used and distributed |
32071 |
+ * freely for any purpose. Changes by Christian Schwarz |
32072 |
+ * <schwarz@××××××××××××.de>, to make output conform to the Debian |
32073 |
+ * Console Message Standard, also placed in public domain. Minor |
32074 |
+ * changes by Klee Dienes <klee@××××××.org>, also placed in the Public |
32075 |
+ * Domain. |
32076 |
+ * |
32077 |
+ * Changes by Ben Collins <bcollins@××××××.org>, added --chuid, --background |
32078 |
+ * and --make-pidfile options, placed in public domain aswell. |
32079 |
+ * |
32080 |
+ * Port to OpenBSD by Sontri Tomo Huynh <huynh.29@×××.edu> |
32081 |
+ * and Andreas Schuldei <andreas@××××××××.org> |
32082 |
+ * |
32083 |
+ * Changes by Ian Jackson: added --retry (and associated rearrangements). |
32084 |
+ * |
32085 |
+ * |
32086 |
+ * Changes by Quequero <quequero@××××××.it>: |
32087 |
+ * Added -e|--env for setting an environment variable before starting the |
32088 |
+ * process. |
32089 |
+ * Moved --make-pidfile after chrooting process (pid file will be wrote in |
32090 |
+ * new root if -r option is used!). |
32091 |
+ * Daemon binary will be stat()ed correctly if it's going to be chrooted |
32092 |
+ * with -r|--chroot. |
32093 |
+ * |
32094 |
+ */ |
32095 |
+ |
32096 |
+#define VERSION "1.13.11+gentoo" |
32097 |
+ |
32098 |
+#define NONRETURNPRINTFFORMAT(x, y) \ |
32099 |
+ __attribute__((noreturn, format(printf, x, y))) |
32100 |
+#define NONRETURNING \ |
32101 |
+ __attribute__((noreturn)) |
32102 |
+ |
32103 |
+#if defined(linux) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) |
32104 |
+# define OSLinux |
32105 |
+#elif defined(__GNU__) |
32106 |
+# define OSHURD |
32107 |
+#elif defined(__sparc__) |
32108 |
+# define OSsunos |
32109 |
+#elif defined(OPENBSD) || defined(__OpenBSD__) |
32110 |
+# define OSOpenBSD |
32111 |
+#elif defined(hpux) |
32112 |
+# define OShpux |
32113 |
+#elif defined(__FreeBSD__) |
32114 |
+# define OSFreeBSD |
32115 |
+#elif defined(__NetBSD__) |
32116 |
+# define OSNetBSD |
32117 |
+#elif defined(__APPLE__) |
32118 |
+# define OSDarwin |
32119 |
+#else |
32120 |
+# error Unknown architecture - cannot build start-stop-daemon |
32121 |
+#endif |
32122 |
+ |
32123 |
+#define MIN_POLL_INTERVAL 20000 /*us*/ |
32124 |
+ |
32125 |
+#if defined(OSHURD) |
32126 |
+# include <hurd.h> |
32127 |
+# include <ps.h> |
32128 |
+#endif |
32129 |
+ |
32130 |
+#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin) |
32131 |
+#include <sys/param.h> |
32132 |
+#include <sys/user.h> |
32133 |
+#include <sys/proc.h> |
32134 |
+#include <sys/stat.h> |
32135 |
+#include <sys/sysctl.h> |
32136 |
+#include <sys/types.h> |
32137 |
+ |
32138 |
+#include <err.h> |
32139 |
+#include <kvm.h> |
32140 |
+#include <limits.h> |
32141 |
+#endif |
32142 |
+ |
32143 |
+#if defined(OShpux) |
32144 |
+#include <sys/param.h> |
32145 |
+#include <sys/pstat.h> |
32146 |
+#endif |
32147 |
+ |
32148 |
+#include <errno.h> |
32149 |
+#include <stdio.h> |
32150 |
+#include <stdlib.h> |
32151 |
+#include <string.h> |
32152 |
+#include <stdarg.h> |
32153 |
+#include <signal.h> |
32154 |
+#include <sys/stat.h> |
32155 |
+#include <dirent.h> |
32156 |
+#include <sys/time.h> |
32157 |
+#include <unistd.h> |
32158 |
+#include <getopt.h> |
32159 |
+#include <pwd.h> |
32160 |
+#include <grp.h> |
32161 |
+#include <sys/ioctl.h> |
32162 |
+#include <sys/types.h> |
32163 |
+#include <sys/termios.h> |
32164 |
+#include <fcntl.h> |
32165 |
+#include <limits.h> |
32166 |
+#include <assert.h> |
32167 |
+#include <ctype.h> |
32168 |
+ |
32169 |
+#include <stddef.h> |
32170 |
+ |
32171 |
+#include "headers.h" |
32172 |
+ |
32173 |
+#ifdef HURD_IHASH_H |
32174 |
+# include <hurd/ihash.h> |
32175 |
+#endif |
32176 |
+ |
32177 |
+static int testmode = 0; |
32178 |
+static int quietmode = 0; |
32179 |
+static int exitnodo = 1; |
32180 |
+static int start = 0; |
32181 |
+static int stop = 0; |
32182 |
+static int background = 0; |
32183 |
+static int mpidfile = 0; |
32184 |
+static int signal_nr = 15; |
32185 |
+static const char *signal_str = NULL; |
32186 |
+static int user_id = -1; |
32187 |
+static int runas_uid = -1; |
32188 |
+static int runas_gid = -1; |
32189 |
+static char *env = NULL; |
32190 |
+static const char *userspec = NULL; |
32191 |
+static char *changeuser = NULL; |
32192 |
+static const char *changegroup = NULL; |
32193 |
+static char *changeroot = NULL; |
32194 |
+static const char *changedir = "/"; |
32195 |
+static const char *cmdname = NULL; |
32196 |
+static char *execname = NULL; |
32197 |
+static char *startas = NULL; |
32198 |
+static const char *pidfile = NULL; |
32199 |
+static char what_stop[1024]; |
32200 |
+static const char *schedule_str = NULL; |
32201 |
+static const char *progname = ""; |
32202 |
+static int nicelevel = 0; |
32203 |
+ |
32204 |
+static struct stat exec_stat; |
32205 |
+#if defined(OSHURD) |
32206 |
+static struct proc_stat_list *procset = NULL; |
32207 |
+#endif |
32208 |
+ |
32209 |
+ |
32210 |
+struct pid_list { |
32211 |
+ struct pid_list *next; |
32212 |
+ pid_t pid; |
32213 |
+}; |
32214 |
+ |
32215 |
+static struct pid_list *found = NULL; |
32216 |
+static struct pid_list *killed = NULL; |
32217 |
+ |
32218 |
+struct schedule_item { |
32219 |
+ enum { sched_timeout, sched_signal, sched_goto, sched_forever } type; |
32220 |
+ int value; /* seconds, signal no., or index into array */ |
32221 |
+ /* sched_forever is only seen within parse_schedule and callees */ |
32222 |
+}; |
32223 |
+ |
32224 |
+static int schedule_length; |
32225 |
+static struct schedule_item *schedule = NULL; |
32226 |
+ |
32227 |
+static void *xmalloc(int size); |
32228 |
+static void push(struct pid_list **list, pid_t pid); |
32229 |
+static void do_help(void); |
32230 |
+static void parse_options(int argc, char * const *argv); |
32231 |
+static int pid_is_user(pid_t pid, uid_t uid); |
32232 |
+static int pid_is_cmd(pid_t pid, const char *name); |
32233 |
+static void check(pid_t pid); |
32234 |
+static void do_pidfile(const char *name); |
32235 |
+static void do_stop(int signal_nr, int quietmode, |
32236 |
+ int *n_killed, int *n_notkilled, int retry_nr); |
32237 |
+#if defined(OSLinux) || defined(OShpux) |
32238 |
+static int pid_is_exec(pid_t pid, const struct stat *esb); |
32239 |
+#endif |
32240 |
+ |
32241 |
+#ifdef __GNUC__ |
32242 |
+static void fatal(const char *format, ...) |
32243 |
+ NONRETURNPRINTFFORMAT(1, 2); |
32244 |
+static void badusage(const char *msg) |
32245 |
+ NONRETURNING; |
32246 |
+#else |
32247 |
+static void fatal(const char *format, ...); |
32248 |
+static void badusage(const char *msg); |
32249 |
+#endif |
32250 |
+ |
32251 |
+/* This next part serves only to construct the TVCALC macro, which |
32252 |
+ * is used for doing arithmetic on struct timeval's. It works like this: |
32253 |
+ * TVCALC(result, expression); |
32254 |
+ * where result is a struct timeval (and must be an lvalue) and |
32255 |
+ * expression is the single expression for both components. In this |
32256 |
+ * expression you can use the special values TVELEM, which when fed a |
32257 |
+ * const struct timeval* gives you the relevant component, and |
32258 |
+ * TVADJUST. TVADJUST is necessary when subtracting timevals, to make |
32259 |
+ * it easier to renormalise. Whenver you subtract timeval elements, |
32260 |
+ * you must make sure that TVADJUST is added to the result of the |
32261 |
+ * subtraction (before any resulting multiplication or what have you). |
32262 |
+ * TVELEM must be linear in TVADJUST. |
32263 |
+ */ |
32264 |
+typedef long tvselector(const struct timeval*); |
32265 |
+static long tvselector_sec(const struct timeval *tv) { return tv->tv_sec; } |
32266 |
+static long tvselector_usec(const struct timeval *tv) { return tv->tv_usec; } |
32267 |
+#define TVCALC_ELEM(result, expr, sec, adj) \ |
32268 |
+{ \ |
32269 |
+ const long TVADJUST = adj; \ |
32270 |
+ long (*const TVELEM)(const struct timeval*) = tvselector_##sec; \ |
32271 |
+ (result).tv_##sec = (expr); \ |
32272 |
+} |
32273 |
+#define TVCALC(result,expr) \ |
32274 |
+do { \ |
32275 |
+ TVCALC_ELEM(result, expr, sec, (-1)); \ |
32276 |
+ TVCALC_ELEM(result, expr, usec, (+1000000)); \ |
32277 |
+ (result).tv_sec += (result).tv_usec / 1000000; \ |
32278 |
+ (result).tv_usec %= 1000000; \ |
32279 |
+} while(0) |
32280 |
+ |
32281 |
+ |
32282 |
+static void |
32283 |
+fatal(const char *format, ...) |
32284 |
+{ |
32285 |
+ va_list arglist; |
32286 |
+ |
32287 |
+ fprintf(stderr, "%s: ", progname); |
32288 |
+ va_start(arglist, format); |
32289 |
+ vfprintf(stderr, format, arglist); |
32290 |
+ va_end(arglist); |
32291 |
+ fprintf(stderr, " (%s)\n", strerror (errno)); |
32292 |
+ exit(2); |
32293 |
+} |
32294 |
+ |
32295 |
+ |
32296 |
+static void * |
32297 |
+xmalloc(int size) |
32298 |
+{ |
32299 |
+ void *ptr; |
32300 |
+ |
32301 |
+ ptr = malloc(size); |
32302 |
+ if (ptr) |
32303 |
+ return ptr; |
32304 |
+ fatal("malloc(%d) failed", size); |
32305 |
+} |
32306 |
+ |
32307 |
+ |
32308 |
+static void |
32309 |
+xgettimeofday(struct timeval *tv) |
32310 |
+{ |
32311 |
+ if (gettimeofday(tv,0) != 0) |
32312 |
+ fatal("gettimeofday failed: %s", strerror(errno)); |
32313 |
+} |
32314 |
+ |
32315 |
+ |
32316 |
+static void |
32317 |
+push(struct pid_list **list, pid_t pid) |
32318 |
+{ |
32319 |
+ struct pid_list *p; |
32320 |
+ |
32321 |
+ p = xmalloc(sizeof(*p)); |
32322 |
+ p->next = *list; |
32323 |
+ p->pid = pid; |
32324 |
+ *list = p; |
32325 |
+} |
32326 |
+ |
32327 |
+static void |
32328 |
+clear(struct pid_list **list) |
32329 |
+{ |
32330 |
+ struct pid_list *here, *next; |
32331 |
+ |
32332 |
+ for (here = *list; here != NULL; here = next) { |
32333 |
+ next = here->next; |
32334 |
+ free(here); |
32335 |
+ } |
32336 |
+ |
32337 |
+ *list = NULL; |
32338 |
+} |
32339 |
+ |
32340 |
+static void |
32341 |
+do_help(void) |
32342 |
+{ |
32343 |
+ printf( |
32344 |
+"start-stop-daemon " VERSION " for Debian - small and fast C version written by\n" |
32345 |
+"Marek Michalkiewicz <marekm@×××××××××××××××××××××××.pl>, public domain.\n" |
32346 |
+"\n" |
32347 |
+"Usage:\n" |
32348 |
+" start-stop-daemon -S|--start options ... -- arguments ...\n" |
32349 |
+" start-stop-daemon -K|--stop options ...\n" |
32350 |
+" start-stop-daemon -H|--help\n" |
32351 |
+" start-stop-daemon -V|--version\n" |
32352 |
+"\n" |
32353 |
+"Options (at least one of --exec|--pidfile|--user is required):\n" |
32354 |
+" -x|--exec <executable> program to start/check if it is running\n" |
32355 |
+" -p|--pidfile <pid-file> pid file to check\n" |
32356 |
+" -c|--chuid <name|uid[:group|gid]>\n" |
32357 |
+" change to this user/group before starting process\n" |
32358 |
+" -u|--user <username>|<uid> stop processes owned by this user\n" |
32359 |
+" -g|--group <group|gid> run process as this group\n" |
32360 |
+" -n|--name <process-name> stop processes with this name\n" |
32361 |
+" -s|--signal <signal> signal to send (default TERM)\n" |
32362 |
+" -a|--startas <pathname> program to start (default is <executable>)\n" |
32363 |
+" -C|--chdir <directory> Change to <directory>(default is /)\n" |
32364 |
+" -N|--nicelevel <incr> add incr to the process's nice level\n" |
32365 |
+" -b|--background force the process to detach\n" |
32366 |
+" -m|--make-pidfile create the pidfile before starting\n" |
32367 |
+" -R|--retry <schedule> check whether processes die, and retry\n" |
32368 |
+" -e|--env <env-name> set an environment variable (PWD=\"/\")\n" |
32369 |
+" -r|--chroot <path> chroot process to given directory\n" |
32370 |
+" -t|--test test mode, don't do anything\n" |
32371 |
+" -o|--oknodo exit status 0 (not 1) if nothing done\n" |
32372 |
+" -q|--quiet be more quiet\n" |
32373 |
+" -v|--verbose be more verbose\n" |
32374 |
+"Retry <schedule> is <item>|/<item>/... where <item> is one of\n" |
32375 |
+" -<signal-num>|[-]<signal-name> send that signal\n" |
32376 |
+" <timeout> wait that many seconds\n" |
32377 |
+" forever repeat remainder forever\n" |
32378 |
+"or <schedule> may be just <timeout>, meaning <signal>/<timeout>/KILL/<timeout>\n" |
32379 |
+"\n" |
32380 |
+"Exit status: 0 = done 1 = nothing done (=> 0 if --oknodo)\n" |
32381 |
+" 3 = trouble 2 = with --retry, processes wouldn't die\n"); |
32382 |
+} |
32383 |
+ |
32384 |
+ |
32385 |
+static void |
32386 |
+badusage(const char *msg) |
32387 |
+{ |
32388 |
+ if (msg) |
32389 |
+ fprintf(stderr, "%s: %s\n", progname, msg); |
32390 |
+ fprintf(stderr, "Try `%s --help' for more information.\n", progname); |
32391 |
+ exit(3); |
32392 |
+} |
32393 |
+ |
32394 |
+struct sigpair { |
32395 |
+ const char *name; |
32396 |
+ int signal; |
32397 |
+}; |
32398 |
+ |
32399 |
+const struct sigpair siglist[] = { |
32400 |
+ { "ABRT", SIGABRT }, |
32401 |
+ { "ALRM", SIGALRM }, |
32402 |
+ { "FPE", SIGFPE }, |
32403 |
+ { "HUP", SIGHUP }, |
32404 |
+ { "ILL", SIGILL }, |
32405 |
+ { "INT", SIGINT }, |
32406 |
+ { "KILL", SIGKILL }, |
32407 |
+ { "PIPE", SIGPIPE }, |
32408 |
+ { "QUIT", SIGQUIT }, |
32409 |
+ { "SEGV", SIGSEGV }, |
32410 |
+ { "TERM", SIGTERM }, |
32411 |
+ { "USR1", SIGUSR1 }, |
32412 |
+ { "USR2", SIGUSR2 }, |
32413 |
+ { "CHLD", SIGCHLD }, |
32414 |
+ { "CONT", SIGCONT }, |
32415 |
+ { "STOP", SIGSTOP }, |
32416 |
+ { "TSTP", SIGTSTP }, |
32417 |
+ { "TTIN", SIGTTIN }, |
32418 |
+ { "TTOU", SIGTTOU } |
32419 |
+}; |
32420 |
+ |
32421 |
+static int parse_integer(const char *string, int *value_r) { |
32422 |
+ unsigned long ul; |
32423 |
+ char *ep; |
32424 |
+ |
32425 |
+ if (!string[0]) |
32426 |
+ return -1; |
32427 |
+ |
32428 |
+ ul= strtoul(string,&ep,10); |
32429 |
+ if (ul > INT_MAX || *ep != '\0') |
32430 |
+ return -1; |
32431 |
+ |
32432 |
+ *value_r= ul; |
32433 |
+ return 0; |
32434 |
+} |
32435 |
+ |
32436 |
+static int parse_signal(const char *signal_str, int *signal_nr) |
32437 |
+{ |
32438 |
+ unsigned int i; |
32439 |
+ |
32440 |
+ if (parse_integer(signal_str, signal_nr) == 0) |
32441 |
+ return 0; |
32442 |
+ |
32443 |
+ for (i = 0; i < sizeof (siglist) / sizeof (siglist[0]); i++) { |
32444 |
+ if (strcmp (signal_str, siglist[i].name) == 0) { |
32445 |
+ *signal_nr = siglist[i].signal; |
32446 |
+ return 0; |
32447 |
+ } |
32448 |
+ } |
32449 |
+ return -1; |
32450 |
+} |
32451 |
+ |
32452 |
+static void |
32453 |
+parse_schedule_item(const char *string, struct schedule_item *item) { |
32454 |
+ const char *after_hyph; |
32455 |
+ |
32456 |
+ if (!strcmp(string,"forever")) { |
32457 |
+ item->type = sched_forever; |
32458 |
+ } else if (isdigit(string[0])) { |
32459 |
+ item->type = sched_timeout; |
32460 |
+ if (parse_integer(string, &item->value) != 0) |
32461 |
+ badusage("invalid timeout value in schedule"); |
32462 |
+ } else if ((after_hyph = string + (string[0] == '-')) && |
32463 |
+ parse_signal(after_hyph, &item->value) == 0) { |
32464 |
+ item->type = sched_signal; |
32465 |
+ } else { |
32466 |
+ badusage("invalid schedule item (must be [-]<signal-name>, " |
32467 |
+ "-<signal-number>, <timeout> or `forever'"); |
32468 |
+ } |
32469 |
+} |
32470 |
+ |
32471 |
+static void |
32472 |
+parse_schedule(const char *schedule_str) { |
32473 |
+ char item_buf[20]; |
32474 |
+ const char *slash; |
32475 |
+ int count, repeatat; |
32476 |
+ ptrdiff_t str_len; |
32477 |
+ |
32478 |
+ count = 0; |
32479 |
+ for (slash = schedule_str; *slash; slash++) |
32480 |
+ if (*slash == '/') |
32481 |
+ count++; |
32482 |
+ |
32483 |
+ schedule_length = (count == 0) ? 4 : count+1; |
32484 |
+ schedule = xmalloc(sizeof(*schedule) * schedule_length); |
32485 |
+ |
32486 |
+ if (count == 0) { |
32487 |
+ schedule[0].type = sched_signal; |
32488 |
+ schedule[0].value = signal_nr; |
32489 |
+ parse_schedule_item(schedule_str, &schedule[1]); |
32490 |
+ if (schedule[1].type != sched_timeout) { |
32491 |
+ badusage ("--retry takes timeout, or schedule list" |
32492 |
+ " of at least two items"); |
32493 |
+ } |
32494 |
+ schedule[2].type = sched_signal; |
32495 |
+ schedule[2].value = SIGKILL; |
32496 |
+ schedule[3]= schedule[1]; |
32497 |
+ } else { |
32498 |
+ count = 0; |
32499 |
+ repeatat = -1; |
32500 |
+ while (schedule_str != NULL) { |
32501 |
+ slash = strchr(schedule_str,'/'); |
32502 |
+ str_len = slash ? slash - schedule_str : strlen(schedule_str); |
32503 |
+ if (str_len >= (ptrdiff_t)sizeof(item_buf)) |
32504 |
+ badusage("invalid schedule item: far too long" |
32505 |
+ " (you must delimit items with slashes)"); |
32506 |
+ memcpy(item_buf, schedule_str, str_len); |
32507 |
+ item_buf[str_len] = 0; |
32508 |
+ schedule_str = slash ? slash+1 : NULL; |
32509 |
+ |
32510 |
+ parse_schedule_item(item_buf, &schedule[count]); |
32511 |
+ if (schedule[count].type == sched_forever) { |
32512 |
+ if (repeatat >= 0) |
32513 |
+ badusage("invalid schedule: `forever'" |
32514 |
+ " appears more than once"); |
32515 |
+ repeatat = count; |
32516 |
+ continue; |
32517 |
+ } |
32518 |
+ count++; |
32519 |
+ } |
32520 |
+ if (repeatat >= 0) { |
32521 |
+ schedule[count].type = sched_goto; |
32522 |
+ schedule[count].value = repeatat; |
32523 |
+ count++; |
32524 |
+ } |
32525 |
+ assert(count == schedule_length); |
32526 |
+ } |
32527 |
+} |
32528 |
+ |
32529 |
+static void |
32530 |
+parse_options(int argc, char * const *argv) |
32531 |
+{ |
32532 |
+ static struct option longopts[] = { |
32533 |
+ { "help", 0, NULL, 'H'}, |
32534 |
+ { "stop", 0, NULL, 'K'}, |
32535 |
+ { "start", 0, NULL, 'S'}, |
32536 |
+ { "version", 0, NULL, 'V'}, |
32537 |
+ { "startas", 1, NULL, 'a'}, |
32538 |
+ { "env", 1, NULL, 'e'}, |
32539 |
+ { "name", 1, NULL, 'n'}, |
32540 |
+ { "oknodo", 0, NULL, 'o'}, |
32541 |
+ { "pidfile", 1, NULL, 'p'}, |
32542 |
+ { "quiet", 0, NULL, 'q'}, |
32543 |
+ { "signal", 1, NULL, 's'}, |
32544 |
+ { "test", 0, NULL, 't'}, |
32545 |
+ { "user", 1, NULL, 'u'}, |
32546 |
+ { "group", 1, NULL, 'g'}, |
32547 |
+ { "chroot", 1, NULL, 'r'}, |
32548 |
+ { "verbose", 0, NULL, 'v'}, |
32549 |
+ { "exec", 1, NULL, 'x'}, |
32550 |
+ { "chuid", 1, NULL, 'c'}, |
32551 |
+ { "nicelevel", 1, NULL, 'N'}, |
32552 |
+ { "background", 0, NULL, 'b'}, |
32553 |
+ { "make-pidfile", 0, NULL, 'm'}, |
32554 |
+ { "retry", 1, NULL, 'R'}, |
32555 |
+ { "chdir", 1, NULL, 'd'}, |
32556 |
+ { NULL, 0, NULL, 0} |
32557 |
+ }; |
32558 |
+ int c; |
32559 |
+ |
32560 |
+ for (;;) { |
32561 |
+ c = getopt_long(argc, argv, "HKSVa:n:op:qr:e:s:tu:vx:c:N:bmR:g:d:", |
32562 |
+ longopts, (int *) 0); |
32563 |
+ if (c == -1) |
32564 |
+ break; |
32565 |
+ switch (c) { |
32566 |
+ case 'H': /* --help */ |
32567 |
+ do_help(); |
32568 |
+ exit(0); |
32569 |
+ case 'K': /* --stop */ |
32570 |
+ stop = 1; |
32571 |
+ break; |
32572 |
+ case 'S': /* --start */ |
32573 |
+ start = 1; |
32574 |
+ break; |
32575 |
+ case 'V': /* --version */ |
32576 |
+ printf("start-stop-daemon " VERSION "\n"); |
32577 |
+ exit(0); |
32578 |
+ case 'a': /* --startas <pathname> */ |
32579 |
+ startas = optarg; |
32580 |
+ break; |
32581 |
+ case 'n': /* --name <process-name> */ |
32582 |
+ cmdname = optarg; |
32583 |
+ break; |
32584 |
+ case 'o': /* --oknodo */ |
32585 |
+ exitnodo = 0; |
32586 |
+ break; |
32587 |
+ case 'p': /* --pidfile <pid-file> */ |
32588 |
+ pidfile = optarg; |
32589 |
+ break; |
32590 |
+ case 'q': /* --quiet */ |
32591 |
+ quietmode = 1; |
32592 |
+ break; |
32593 |
+ case 's': /* --signal <signal> */ |
32594 |
+ signal_str = optarg; |
32595 |
+ break; |
32596 |
+ case 't': /* --test */ |
32597 |
+ testmode = 1; |
32598 |
+ break; |
32599 |
+ case 'u': /* --user <username>|<uid> */ |
32600 |
+ userspec = optarg; |
32601 |
+ break; |
32602 |
+ case 'v': /* --verbose */ |
32603 |
+ quietmode = -1; |
32604 |
+ break; |
32605 |
+ case 'x': /* --exec <executable> */ |
32606 |
+ execname = optarg; |
32607 |
+ break; |
32608 |
+ case 'c': /* --chuid <username>|<uid> */ |
32609 |
+ /* we copy the string just in case we need the |
32610 |
+ * argument later. */ |
32611 |
+ changeuser = strdup(optarg); |
32612 |
+ changeuser = strtok(changeuser, ":"); |
32613 |
+ changegroup = strtok(NULL, ":"); |
32614 |
+ break; |
32615 |
+ case 'g': /* --group <group>|<gid> */ |
32616 |
+ changegroup = optarg; |
32617 |
+ break; |
32618 |
+ case 'r': /* --chroot /new/root */ |
32619 |
+ changeroot = optarg; |
32620 |
+ break; |
32621 |
+ case 'e': /* --env <env-name> */ |
32622 |
+ env = optarg; |
32623 |
+ break; |
32624 |
+ case 'N': /* --nice */ |
32625 |
+ nicelevel = atoi(optarg); |
32626 |
+ break; |
32627 |
+ case 'b': /* --background */ |
32628 |
+ background = 1; |
32629 |
+ break; |
32630 |
+ case 'm': /* --make-pidfile */ |
32631 |
+ mpidfile = 1; |
32632 |
+ break; |
32633 |
+ case 'R': /* --retry <schedule>|<timeout> */ |
32634 |
+ schedule_str = optarg; |
32635 |
+ break; |
32636 |
+ case 'd': /* --chdir /new/dir */ |
32637 |
+ changedir = optarg; |
32638 |
+ break; |
32639 |
+ default: |
32640 |
+ badusage(NULL); /* message printed by getopt */ |
32641 |
+ } |
32642 |
+ } |
32643 |
+ |
32644 |
+ if (signal_str != NULL) { |
32645 |
+ if (parse_signal (signal_str, &signal_nr) != 0) |
32646 |
+ badusage("signal value must be numeric or name" |
32647 |
+ " of signal (KILL, INT, ...)"); |
32648 |
+ } |
32649 |
+ |
32650 |
+ if (schedule_str != NULL) { |
32651 |
+ parse_schedule(schedule_str); |
32652 |
+ } |
32653 |
+ |
32654 |
+ if (start == stop) |
32655 |
+ badusage("need one of --start or --stop"); |
32656 |
+ |
32657 |
+ if (!execname && !pidfile && !userspec && !cmdname) |
32658 |
+ badusage("need at least one of --exec, --pidfile, --user or --name"); |
32659 |
+ |
32660 |
+ if (!startas) |
32661 |
+ startas = execname; |
32662 |
+ |
32663 |
+ if (start && !startas) |
32664 |
+ badusage("--start needs --exec or --startas"); |
32665 |
+ |
32666 |
+ if (mpidfile && pidfile == NULL) |
32667 |
+ badusage("--make-pidfile is only relevant with --pidfile"); |
32668 |
+ |
32669 |
+ if (background && !start) |
32670 |
+ badusage("--background is only relevant with --start"); |
32671 |
+ |
32672 |
+} |
32673 |
+ |
32674 |
+#if defined(OSLinux) |
32675 |
+static int |
32676 |
+pid_is_exec(pid_t pid, const struct stat *esb) |
32677 |
+{ |
32678 |
+ struct stat sb; |
32679 |
+ char buf[32]; |
32680 |
+ |
32681 |
+ sprintf(buf, "/proc/%d/exe", pid); |
32682 |
+ if (stat(buf, &sb) != 0) |
32683 |
+ return 0; |
32684 |
+ return (sb.st_dev == esb->st_dev && sb.st_ino == esb->st_ino); |
32685 |
+} |
32686 |
+ |
32687 |
+ |
32688 |
+static int |
32689 |
+pid_is_user(pid_t pid, uid_t uid) |
32690 |
+{ |
32691 |
+ struct stat sb; |
32692 |
+ char buf[32]; |
32693 |
+ |
32694 |
+ sprintf(buf, "/proc/%d", pid); |
32695 |
+ if (stat(buf, &sb) != 0) |
32696 |
+ return 0; |
32697 |
+ return (sb.st_uid == uid); |
32698 |
+} |
32699 |
+ |
32700 |
+ |
32701 |
+static int |
32702 |
+pid_is_cmd(pid_t pid, const char *name) |
32703 |
+{ |
32704 |
+ char buf[32]; |
32705 |
+ FILE *f; |
32706 |
+ int c; |
32707 |
+ |
32708 |
+ sprintf(buf, "/proc/%d/stat", pid); |
32709 |
+ f = fopen(buf, "r"); |
32710 |
+ if (!f) |
32711 |
+ return 0; |
32712 |
+ while ((c = getc(f)) != EOF && c != '(') |
32713 |
+ ; |
32714 |
+ if (c != '(') { |
32715 |
+ fclose(f); |
32716 |
+ return 0; |
32717 |
+ } |
32718 |
+ /* this hopefully handles command names containing ')' */ |
32719 |
+ while ((c = getc(f)) != EOF && c == *name) |
32720 |
+ name++; |
32721 |
+ fclose(f); |
32722 |
+ return (c == ')' && *name == '\0'); |
32723 |
+} |
32724 |
+#endif /* OSLinux */ |
32725 |
+ |
32726 |
+ |
32727 |
+#if defined(OSHURD) |
32728 |
+static void |
32729 |
+init_procset(void) |
32730 |
+{ |
32731 |
+ struct ps_context *context; |
32732 |
+ error_t err; |
32733 |
+ |
32734 |
+ err = ps_context_create(getproc(), &context); |
32735 |
+ if (err) |
32736 |
+ error(1, err, "ps_context_create"); |
32737 |
+ |
32738 |
+ err = proc_stat_list_create(context, &procset); |
32739 |
+ if (err) |
32740 |
+ error(1, err, "proc_stat_list_create"); |
32741 |
+ |
32742 |
+ err = proc_stat_list_add_all(procset, 0, 0); |
32743 |
+ if (err) |
32744 |
+ error(1, err, "proc_stat_list_add_all"); |
32745 |
+} |
32746 |
+ |
32747 |
+static struct proc_stat * |
32748 |
+get_proc_stat (pid_t pid, ps_flags_t flags) |
32749 |
+{ |
32750 |
+ struct proc_stat *ps; |
32751 |
+ ps_flags_t wanted_flags = PSTAT_PID | flags; |
32752 |
+ |
32753 |
+ if (!procset) |
32754 |
+ init_procset(); |
32755 |
+ |
32756 |
+ ps = proc_stat_list_pid_proc_stat(procset, pid); |
32757 |
+ if (!ps) |
32758 |
+ return NULL; |
32759 |
+ if (proc_stat_set_flags(ps, wanted_flags)) |
32760 |
+ return NULL; |
32761 |
+ if ((proc_stat_flags(ps) & wanted_flags) != wanted_flags) |
32762 |
+ return NULL; |
32763 |
+ |
32764 |
+ return ps; |
32765 |
+} |
32766 |
+ |
32767 |
+static int |
32768 |
+pid_is_user(pid_t pid, uid_t uid) |
32769 |
+{ |
32770 |
+ struct proc_stat *ps; |
32771 |
+ |
32772 |
+ ps = get_proc_stat(pid, PSTAT_OWNER_UID); |
32773 |
+ return ps && proc_stat_owner_uid(ps) == uid; |
32774 |
+} |
32775 |
+ |
32776 |
+static int |
32777 |
+pid_is_cmd(pid_t pid, const char *name) |
32778 |
+{ |
32779 |
+ struct proc_stat *ps; |
32780 |
+ |
32781 |
+ ps = get_proc_stat(pid, PSTAT_ARGS); |
32782 |
+ return ps && !strcmp(proc_stat_args(ps), name); |
32783 |
+} |
32784 |
+ |
32785 |
+static int |
32786 |
+pid_is_running(pid_t pid) |
32787 |
+{ |
32788 |
+ return get_proc_stat(pid, 0) != NULL; |
32789 |
+} |
32790 |
+ |
32791 |
+#else /* !OSHURD */ |
32792 |
+ |
32793 |
+static int |
32794 |
+pid_is_running(pid_t pid) |
32795 |
+{ |
32796 |
+ struct stat sb; |
32797 |
+ char buf[32]; |
32798 |
+ |
32799 |
+ sprintf(buf, "/proc/%d", pid); |
32800 |
+ if (stat(buf, &sb) != 0) { |
32801 |
+ if (errno!=ENOENT) |
32802 |
+ fatal("Error stating %s: %s", buf, strerror(errno)); |
32803 |
+ return 0; |
32804 |
+ } |
32805 |
+ |
32806 |
+ return 1; |
32807 |
+} |
32808 |
+ |
32809 |
+#endif /* OSHURD */ |
32810 |
+ |
32811 |
+static void |
32812 |
+check(pid_t pid) |
32813 |
+{ |
32814 |
+#if defined(OSLinux) || defined(OShpux) |
32815 |
+ if (execname && !pid_is_exec(pid, &exec_stat)) |
32816 |
+ return; |
32817 |
+#elif defined(OSHURD) || defined(OSFreeBSD) || defined(OSNetBSD) || defined(OSDarwin) |
32818 |
+ /* I will try this to see if it works */ |
32819 |
+ if (execname && !pid_is_cmd(pid, execname)) |
32820 |
+ return; |
32821 |
+#endif |
32822 |
+ if (userspec && !pid_is_user(pid, user_id)) |
32823 |
+ return; |
32824 |
+ if (cmdname && !pid_is_cmd(pid, cmdname)) |
32825 |
+ return; |
32826 |
+ if (start && !pid_is_running(pid)) |
32827 |
+ return; |
32828 |
+ push(&found, pid); |
32829 |
+} |
32830 |
+ |
32831 |
+static void |
32832 |
+do_pidfile(const char *name) |
32833 |
+{ |
32834 |
+ FILE *f; |
32835 |
+ pid_t pid; |
32836 |
+ |
32837 |
+ f = fopen(name, "r"); |
32838 |
+ if (f) { |
32839 |
+ if (fscanf(f, "%d", &pid) == 1) |
32840 |
+ check(pid); |
32841 |
+ fclose(f); |
32842 |
+ } else if (errno != ENOENT) |
32843 |
+ fatal("open pidfile %s: %s", name, strerror(errno)); |
32844 |
+ |
32845 |
+} |
32846 |
+ |
32847 |
+/* WTA: this needs to be an autoconf check for /proc/pid existance. |
32848 |
+ */ |
32849 |
+ |
32850 |
+#if defined(OSLinux) || defined (OSsunos) || defined(OSfreebsd) |
32851 |
+static void |
32852 |
+do_procinit(void) |
32853 |
+{ |
32854 |
+ DIR *procdir; |
32855 |
+ struct dirent *entry; |
32856 |
+ int foundany; |
32857 |
+ pid_t pid; |
32858 |
+ |
32859 |
+ procdir = opendir("/proc"); |
32860 |
+ if (!procdir) |
32861 |
+ fatal("opendir /proc: %s", strerror(errno)); |
32862 |
+ |
32863 |
+ foundany = 0; |
32864 |
+ while ((entry = readdir(procdir)) != NULL) { |
32865 |
+ if (sscanf(entry->d_name, "%d", &pid) != 1) |
32866 |
+ continue; |
32867 |
+ foundany++; |
32868 |
+ check(pid); |
32869 |
+ } |
32870 |
+ closedir(procdir); |
32871 |
+ if (!foundany) |
32872 |
+ fatal("nothing in /proc - not mounted?"); |
32873 |
+} |
32874 |
+#endif /* OSLinux */ |
32875 |
+ |
32876 |
+ |
32877 |
+#if defined(OSHURD) |
32878 |
+static int |
32879 |
+check_proc_stat (struct proc_stat *ps) |
32880 |
+{ |
32881 |
+ check(ps->pid); |
32882 |
+ return 0; |
32883 |
+} |
32884 |
+ |
32885 |
+static void |
32886 |
+do_procinit(void) |
32887 |
+{ |
32888 |
+ if (!procset) |
32889 |
+ init_procset(); |
32890 |
+ |
32891 |
+ proc_stat_list_for_each (procset, check_proc_stat); |
32892 |
+} |
32893 |
+#endif /* OSHURD */ |
32894 |
+ |
32895 |
+ |
32896 |
+#if defined(OSOpenBSD) || defined(OSFreeBSD) || defined(OSNetBSD) |
32897 |
+ |
32898 |
+# if defined(OSNetBSD) |
32899 |
+# define _KINFO_PROC2 kinfo_proc2 |
32900 |
+# define _GET_KINFO_UID(kp) (kp->p_ruid) |
32901 |
+# define _GET_KINFO_COMM(kp) (kp->p_comm) |
32902 |
+# else |
32903 |
+# define _KINFO_PROC2 kinfo_proc |
32904 |
+# define _GET_KINFO_UID(kp) (kp->ki_ruid) |
32905 |
+# define _GET_KINFO_COMM(kp) (kp->ki_comm) |
32906 |
+# endif |
32907 |
+ |
32908 |
+static int |
32909 |
+pid_is_cmd(pid_t pid, const char *name) |
32910 |
+{ |
32911 |
+ kvm_t *kd; |
32912 |
+ int nentries, argv_len=0; |
32913 |
+ struct kinfo_proc *kp; |
32914 |
+ char errbuf[_POSIX2_LINE_MAX], buf[_POSIX2_LINE_MAX]; |
32915 |
+ char **pid_argv_p; |
32916 |
+ char *start_argv_0_p, *end_argv_0_p; |
32917 |
+ |
32918 |
+ kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); |
32919 |
+ if (kd == 0) |
32920 |
+ errx(1, "%s", errbuf); |
32921 |
+ if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0) |
32922 |
+ errx(1, "%s", kvm_geterr(kd)); |
32923 |
+ if ((pid_argv_p = kvm_getargv(kd, kp, argv_len)) == 0) |
32924 |
+ errx(1, "%s", kvm_geterr(kd)); |
32925 |
+ |
32926 |
+ start_argv_0_p = *pid_argv_p; |
32927 |
+ /* find and compare string */ |
32928 |
+ |
32929 |
+ /* find end of argv[0] then copy and cut of str there. */ |
32930 |
+ if ((end_argv_0_p = strchr(*pid_argv_p, ' ')) == 0 ) |
32931 |
+ /* There seems to be no space, so we have the command |
32932 |
+ * allready in its desired form. */ |
32933 |
+ start_argv_0_p = *pid_argv_p; |
32934 |
+ else { |
32935 |
+ /* Tests indicate that this never happens, since |
32936 |
+ * kvm_getargv itselfe cuts of tailing stuff. This is |
32937 |
+ * not what the manpage says, however. */ |
32938 |
+ strncpy(buf, *pid_argv_p, (end_argv_0_p - start_argv_0_p)); |
32939 |
+ buf[(end_argv_0_p - start_argv_0_p) + 1] = '\0'; |
32940 |
+ start_argv_0_p = buf; |
32941 |
+ } |
32942 |
+ |
32943 |
+ if (strlen(name) != strlen(start_argv_0_p)) |
32944 |
+ return 0; |
32945 |
+ return (strcmp(name, start_argv_0_p) == 0) ? 1 : 0; |
32946 |
+} |
32947 |
+ |
32948 |
+static int |
32949 |
+pid_is_user(pid_t pid, uid_t uid) |
32950 |
+{ |
32951 |
+ kvm_t *kd; |
32952 |
+ int nentries; /* Value not used */ |
32953 |
+ uid_t proc_uid; |
32954 |
+ struct _KINFO_PROC2 *kp; |
32955 |
+ char errbuf[_POSIX2_LINE_MAX]; |
32956 |
+ |
32957 |
+ kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); |
32958 |
+ if (kd == 0) |
32959 |
+ errx(1, "%s", errbuf); |
32960 |
+ if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0) |
32961 |
+ errx(1, "%s", kvm_geterr(kd)); |
32962 |
+ if (_GET_KINFO_UID(kp)) |
32963 |
+ kvm_read(kd, (u_long)&(_GET_KINFO_UID(kp)), |
32964 |
+ &proc_uid, sizeof(uid_t)); |
32965 |
+ else |
32966 |
+ return 0; |
32967 |
+ return (proc_uid == (uid_t)uid); |
32968 |
+} |
32969 |
+ |
32970 |
+static int |
32971 |
+pid_is_exec(pid_t pid, const char *name) |
32972 |
+{ |
32973 |
+ kvm_t *kd; |
32974 |
+ int nentries; |
32975 |
+ struct _KINFO_PROC2 *kp; |
32976 |
+ char errbuf[_POSIX2_LINE_MAX], *pidexec; |
32977 |
+ |
32978 |
+ kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf); |
32979 |
+ if (kd == 0) |
32980 |
+ errx(1, "%s", errbuf); |
32981 |
+ if ((kp = kvm_getprocs(kd, KERN_PROC_PID, pid, &nentries)) == 0) |
32982 |
+ errx(1, "%s", kvm_geterr(kd)); |
32983 |
+ pidexec = _GET_KINFO_COMM(kp); |
32984 |
+ if (strlen(name) != strlen(pidexec)) |
32985 |
+ return 0; |
32986 |
+ return (strcmp(name, pidexec) == 0) ? 1 : 0; |
32987 |
+} |
32988 |
+ |
32989 |
+ |
32990 |
+static void |
32991 |
+do_procinit(void) |
32992 |
+{ |
32993 |
+ /* Nothing to do */ |
32994 |
+} |
32995 |
+ |
32996 |
+#endif /* OSOpenBSD */ |
32997 |
+ |
32998 |
+#if defined(OSDarwin) |
32999 |
+int |
33000 |
+pid_is_user(pid_t pid, uid_t uid) |
33001 |
+{ |
33002 |
+ int mib[4]; |
33003 |
+ size_t size; |
33004 |
+ struct kinfo_proc ki; |
33005 |
+ |
33006 |
+ size = sizeof(ki); |
33007 |
+ mib[0] = CTL_KERN; |
33008 |
+ mib[1] = KERN_PROC; |
33009 |
+ mib[2] = KERN_PROC_PID; |
33010 |
+ mib[3] = pid; |
33011 |
+ if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0) |
33012 |
+ errx(1, "%s", "Failure calling sysctl"); |
33013 |
+ return (uid == ki.kp_eproc.e_pcred.p_ruid); |
33014 |
+} |
33015 |
+ |
33016 |
+static int |
33017 |
+pid_is_cmd(pid_t pid, const char *name) |
33018 |
+{ |
33019 |
+ int mib[4]; |
33020 |
+ size_t size; |
33021 |
+ struct kinfo_proc ki; |
33022 |
+ |
33023 |
+ size = sizeof(ki); |
33024 |
+ mib[0] = CTL_KERN; |
33025 |
+ mib[1] = KERN_PROC; |
33026 |
+ mib[2] = KERN_PROC_PID; |
33027 |
+ mib[3] = pid; |
33028 |
+ if (sysctl(mib, 4, &ki, &size, NULL, 0) < 0) |
33029 |
+ errx(1, "%s", "Failure calling sysctl"); |
33030 |
+ return (!strncmp(name, ki.kp_proc.p_comm, MAXCOMLEN)); |
33031 |
+} |
33032 |
+ |
33033 |
+static void |
33034 |
+do_procinit(void) |
33035 |
+{ |
33036 |
+ int mib[3]; |
33037 |
+ size_t size; |
33038 |
+ int nprocs, ret, i; |
33039 |
+ struct kinfo_proc *procs = NULL, *newprocs; |
33040 |
+ |
33041 |
+ mib[0] = CTL_KERN; |
33042 |
+ mib[1] = KERN_PROC; |
33043 |
+ mib[2] = KERN_PROC_ALL; |
33044 |
+ ret = sysctl(mib, 3, NULL, &size, NULL, 0); |
33045 |
+ /* Allocate enough memory for entire process table */ |
33046 |
+ do { |
33047 |
+ size += size / 10; |
33048 |
+ newprocs = realloc(procs, size); |
33049 |
+ if (newprocs == NULL) { |
33050 |
+ if (procs) |
33051 |
+ free(procs); |
33052 |
+ errx(1, "%s", "Could not reallocate memory"); |
33053 |
+ } |
33054 |
+ procs = newprocs; |
33055 |
+ ret = sysctl(mib, 3, procs, &size, NULL, 0); |
33056 |
+ } while (ret >= 0 && errno == ENOMEM); |
33057 |
+ |
33058 |
+ if (ret < 0) |
33059 |
+ errx(1, "%s", "Failure calling sysctl"); |
33060 |
+ |
33061 |
+ /* Verify size of proc structure */ |
33062 |
+ if (size % sizeof(struct kinfo_proc) != 0) |
33063 |
+ errx(1, "%s", "proc size mismatch, userland out of sync with kernel"); |
33064 |
+ nprocs = size / sizeof(struct kinfo_proc); |
33065 |
+ for (i = 0; i < nprocs; i++) { |
33066 |
+ check(procs[i].kp_proc.p_pid); |
33067 |
+ } |
33068 |
+} |
33069 |
+#endif /* OSDarwin */ |
33070 |
+ |
33071 |
+#if defined(OShpux) |
33072 |
+static int |
33073 |
+pid_is_user(pid_t pid, uid_t uid) |
33074 |
+{ |
33075 |
+ struct pst_status pst; |
33076 |
+ |
33077 |
+ if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0) |
33078 |
+ return 0; |
33079 |
+ return ((uid_t) pst.pst_uid == uid); |
33080 |
+} |
33081 |
+ |
33082 |
+static int |
33083 |
+pid_is_cmd(pid_t pid, const char *name) |
33084 |
+{ |
33085 |
+ struct pst_status pst; |
33086 |
+ |
33087 |
+ if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0) |
33088 |
+ return 0; |
33089 |
+ return (strcmp(pst.pst_ucomm, name) == 0); |
33090 |
+} |
33091 |
+ |
33092 |
+static int |
33093 |
+pid_is_exec(pid_t pid, const struct stat *esb) |
33094 |
+{ |
33095 |
+ struct pst_status pst; |
33096 |
+ |
33097 |
+ if (pstat_getproc(&pst, sizeof(pst), (size_t) 0, (int) pid) < 0) |
33098 |
+ return 0; |
33099 |
+ return ((dev_t) pst.pst_text.psf_fsid.psfs_id == esb->st_dev |
33100 |
+ && (ino_t) pst.pst_text.psf_fileid == esb->st_ino); |
33101 |
+} |
33102 |
+ |
33103 |
+static void |
33104 |
+do_procinit(void) |
33105 |
+{ |
33106 |
+ struct pst_status pst[10]; |
33107 |
+ int i, count; |
33108 |
+ int idx = 0; |
33109 |
+ |
33110 |
+ while ((count = pstat_getproc(pst, sizeof(pst[0]), 10, idx)) > 0) { |
33111 |
+ for (i = 0; i < count; i++) |
33112 |
+ check(pst[i].pst_pid); |
33113 |
+ idx = pst[count - 1].pst_idx + 1; |
33114 |
+ } |
33115 |
+} |
33116 |
+#endif /* OShpux */ |
33117 |
+ |
33118 |
+ |
33119 |
+static void |
33120 |
+do_findprocs(void) |
33121 |
+{ |
33122 |
+ clear(&found); |
33123 |
+ |
33124 |
+ if (pidfile) |
33125 |
+ do_pidfile(pidfile); |
33126 |
+ else |
33127 |
+ do_procinit(); |
33128 |
+} |
33129 |
+ |
33130 |
+/* return 1 on failure */ |
33131 |
+static void |
33132 |
+do_stop(int signal_nr, int quietmode, int *n_killed, int *n_notkilled, int retry_nr) |
33133 |
+{ |
33134 |
+ struct pid_list *p; |
33135 |
+ |
33136 |
+ do_findprocs(); |
33137 |
+ |
33138 |
+ *n_killed = 0; |
33139 |
+ *n_notkilled = 0; |
33140 |
+ |
33141 |
+ if (!found) |
33142 |
+ return; |
33143 |
+ |
33144 |
+ clear(&killed); |
33145 |
+ |
33146 |
+ for (p = found; p; p = p->next) { |
33147 |
+ if (testmode) { |
33148 |
+ printf("Would send signal %d to %d.\n", |
33149 |
+ signal_nr, p->pid); |
33150 |
+ (*n_killed)++; |
33151 |
+ } else if (kill(p->pid, signal_nr) == 0) { |
33152 |
+ push(&killed, p->pid); |
33153 |
+ (*n_killed)++; |
33154 |
+ } else { |
33155 |
+ printf("%s: warning: failed to kill %d: %s\n", |
33156 |
+ progname, p->pid, strerror(errno)); |
33157 |
+ (*n_notkilled)++; |
33158 |
+ } |
33159 |
+ } |
33160 |
+ if (quietmode < 0 && killed) { |
33161 |
+ printf("Stopped %s (pid", what_stop); |
33162 |
+ for (p = killed; p; p = p->next) |
33163 |
+ printf(" %d", p->pid); |
33164 |
+ putchar(')'); |
33165 |
+ if (retry_nr > 0) |
33166 |
+ printf(", retry #%d", retry_nr); |
33167 |
+ printf(".\n"); |
33168 |
+ } |
33169 |
+} |
33170 |
+ |
33171 |
+ |
33172 |
+static void |
33173 |
+set_what_stop(const char *str) |
33174 |
+{ |
33175 |
+ strncpy(what_stop, str, sizeof(what_stop)); |
33176 |
+ what_stop[sizeof(what_stop)-1] = '\0'; |
33177 |
+} |
33178 |
+ |
33179 |
+static int |
33180 |
+run_stop_schedule(void) |
33181 |
+{ |
33182 |
+ int r, position, n_killed, n_notkilled, value, ratio, anykilled, retry_nr; |
33183 |
+ struct timeval stopat, before, after, interval, maxinterval; |
33184 |
+ |
33185 |
+ if (testmode) { |
33186 |
+ if (schedule != NULL) { |
33187 |
+ printf("Ignoring --retry in test mode\n"); |
33188 |
+ schedule = NULL; |
33189 |
+ } |
33190 |
+ } |
33191 |
+ |
33192 |
+ if (cmdname) |
33193 |
+ set_what_stop(cmdname); |
33194 |
+ else if (execname) |
33195 |
+ set_what_stop(execname); |
33196 |
+ else if (pidfile) |
33197 |
+ sprintf(what_stop, "process in pidfile `%.200s'", pidfile); |
33198 |
+ else if (userspec) |
33199 |
+ sprintf(what_stop, "process(es) owned by `%.200s'", userspec); |
33200 |
+ else |
33201 |
+ fatal("internal error, please report"); |
33202 |
+ |
33203 |
+ anykilled = 0; |
33204 |
+ retry_nr = 0; |
33205 |
+ |
33206 |
+ if (schedule == NULL) { |
33207 |
+ do_stop(signal_nr, quietmode, &n_killed, &n_notkilled, 0); |
33208 |
+ if (n_notkilled > 0 && quietmode <= 0) |
33209 |
+ printf("%d pids were not killed\n", n_notkilled); |
33210 |
+ if (n_killed) |
33211 |
+ anykilled = 1; |
33212 |
+ goto x_finished; |
33213 |
+ } |
33214 |
+ |
33215 |
+ for (position = 0; position < schedule_length; ) { |
33216 |
+ value= schedule[position].value; |
33217 |
+ n_notkilled = 0; |
33218 |
+ |
33219 |
+ switch (schedule[position].type) { |
33220 |
+ |
33221 |
+ case sched_goto: |
33222 |
+ position = value; |
33223 |
+ continue; |
33224 |
+ |
33225 |
+ case sched_signal: |
33226 |
+ do_stop(value, quietmode, &n_killed, &n_notkilled, retry_nr++); |
33227 |
+ if (!n_killed) |
33228 |
+ goto x_finished; |
33229 |
+ else |
33230 |
+ anykilled = 1; |
33231 |
+ goto next_item; |
33232 |
+ |
33233 |
+ case sched_timeout: |
33234 |
+ /* We want to keep polling for the processes, to see if they've exited, |
33235 |
+ * or until the timeout expires. |
33236 |
+ * |
33237 |
+ * This is a somewhat complicated algorithm to try to ensure that we |
33238 |
+ * notice reasonably quickly when all the processes have exited, but |
33239 |
+ * don't spend too much CPU time polling. In particular, on a fast |
33240 |
+ * machine with quick-exiting daemons we don't want to delay system |
33241 |
+ * shutdown too much, whereas on a slow one, or where processes are |
33242 |
+ * taking some time to exit, we want to increase the polling |
33243 |
+ * interval. |
33244 |
+ * |
33245 |
+ * The algorithm is as follows: we measure the elapsed time it takes |
33246 |
+ * to do one poll(), and wait a multiple of this time for the next |
33247 |
+ * poll. However, if that would put us past the end of the timeout |
33248 |
+ * period we wait only as long as the timeout period, but in any case |
33249 |
+ * we always wait at least MIN_POLL_INTERVAL (20ms). The multiple |
33250 |
+ * (`ratio') starts out as 2, and increases by 1 for each poll to a |
33251 |
+ * maximum of 10; so we use up to between 30% and 10% of the |
33252 |
+ * machine's resources (assuming a few reasonable things about system |
33253 |
+ * performance). |
33254 |
+ */ |
33255 |
+ xgettimeofday(&stopat); |
33256 |
+ stopat.tv_sec += value; |
33257 |
+ ratio = 1; |
33258 |
+ for (;;) { |
33259 |
+ xgettimeofday(&before); |
33260 |
+ if (timercmp(&before,&stopat,>)) |
33261 |
+ goto next_item; |
33262 |
+ |
33263 |
+ do_stop(0, 1, &n_killed, &n_notkilled, 0); |
33264 |
+ if (!n_killed) |
33265 |
+ goto x_finished; |
33266 |
+ |
33267 |
+ xgettimeofday(&after); |
33268 |
+ |
33269 |
+ if (!timercmp(&after,&stopat,<)) |
33270 |
+ goto next_item; |
33271 |
+ |
33272 |
+ if (ratio < 10) |
33273 |
+ ratio++; |
33274 |
+ |
33275 |
+ TVCALC(interval, ratio * (TVELEM(&after) - TVELEM(&before) + TVADJUST)); |
33276 |
+ TVCALC(maxinterval, TVELEM(&stopat) - TVELEM(&after) + TVADJUST); |
33277 |
+ |
33278 |
+ if (timercmp(&interval,&maxinterval,>)) |
33279 |
+ interval = maxinterval; |
33280 |
+ |
33281 |
+ if (interval.tv_sec == 0 && |
33282 |
+ interval.tv_usec <= MIN_POLL_INTERVAL) |
33283 |
+ interval.tv_usec = MIN_POLL_INTERVAL; |
33284 |
+ |
33285 |
+ r = select(0,0,0,0,&interval); |
33286 |
+ if (r < 0 && errno != EINTR) |
33287 |
+ fatal("select() failed for pause: %s", |
33288 |
+ strerror(errno)); |
33289 |
+ } |
33290 |
+ |
33291 |
+ default: |
33292 |
+ assert(!"schedule[].type value must be valid"); |
33293 |
+ |
33294 |
+ } |
33295 |
+ |
33296 |
+ next_item: |
33297 |
+ position++; |
33298 |
+ } |
33299 |
+ |
33300 |
+ if (quietmode <= 0) |
33301 |
+ printf("Program %s, %d process(es), refused to die.\n", |
33302 |
+ what_stop, n_killed); |
33303 |
+ |
33304 |
+ return 2; |
33305 |
+ |
33306 |
+x_finished: |
33307 |
+ if (!anykilled) { |
33308 |
+ if (quietmode <= 0) |
33309 |
+ printf("No %s found running; none killed.\n", what_stop); |
33310 |
+ return exitnodo; |
33311 |
+ } else { |
33312 |
+ return 0; |
33313 |
+ } |
33314 |
+} |
33315 |
+ |
33316 |
+ |
33317 |
+int |
33318 |
+main(int argc, char **argv) |
33319 |
+{ |
33320 |
+ int devnull_fd = -1; |
33321 |
+#ifdef HAVE_TIOCNOTTY |
33322 |
+ int tty_fd = -1; |
33323 |
+#endif |
33324 |
+ progname = argv[0]; |
33325 |
+ |
33326 |
+ parse_options(argc, argv); |
33327 |
+ argc -= optind; |
33328 |
+ argv += optind; |
33329 |
+ |
33330 |
+ if (changeroot == NULL) { |
33331 |
+ if (execname && stat(execname, &exec_stat)) |
33332 |
+ fatal("stat %s: %s", execname, strerror(errno)); |
33333 |
+ } else { |
33334 |
+ if (execname) { |
33335 |
+ char *tmp = NULL; |
33336 |
+ |
33337 |
+ tmp = malloc(strlen(changeroot) + strlen(execname) + 1); |
33338 |
+ strncpy(tmp, changeroot, strlen(changeroot)); |
33339 |
+ strncat(tmp, execname, strlen(execname)); |
33340 |
+ |
33341 |
+ if (stat(tmp, &exec_stat)) { |
33342 |
+ fatal("stat %s: %s", tmp, strerror(errno)); |
33343 |
+ free(tmp); |
33344 |
+ } else { |
33345 |
+ free(tmp); |
33346 |
+ } |
33347 |
+ } |
33348 |
+ } |
33349 |
+ |
33350 |
+ if (userspec && sscanf(userspec, "%d", &user_id) != 1) { |
33351 |
+ struct passwd *pw; |
33352 |
+ |
33353 |
+ pw = getpwnam(userspec); |
33354 |
+ if (!pw) |
33355 |
+ fatal("user `%s' not found\n", userspec); |
33356 |
+ |
33357 |
+ user_id = pw->pw_uid; |
33358 |
+ } |
33359 |
+ |
33360 |
+ if (changegroup && sscanf(changegroup, "%d", &runas_gid) != 1) { |
33361 |
+ struct group *gr = getgrnam(changegroup); |
33362 |
+ if (!gr) |
33363 |
+ fatal("group `%s' not found\n", changegroup); |
33364 |
+ runas_gid = gr->gr_gid; |
33365 |
+ } |
33366 |
+ if (changeuser && sscanf(changeuser, "%d", &runas_uid) != 1) { |
33367 |
+ struct passwd *pw = getpwnam(changeuser); |
33368 |
+ if (!pw) |
33369 |
+ fatal("user `%s' not found\n", changeuser); |
33370 |
+ runas_uid = pw->pw_uid; |
33371 |
+ if (changegroup == NULL) { /* pass the default group of this user */ |
33372 |
+ changegroup = ""; /* just empty */ |
33373 |
+ runas_gid = pw->pw_gid; |
33374 |
+ } |
33375 |
+ } |
33376 |
+ |
33377 |
+ if (stop) { |
33378 |
+ int i = run_stop_schedule(); |
33379 |
+ exit(i); |
33380 |
+ } |
33381 |
+ |
33382 |
+ do_findprocs(); |
33383 |
+ |
33384 |
+ if (found) { |
33385 |
+ if (quietmode <= 0) |
33386 |
+ printf("%s already running.\n", execname ? execname : "process"); |
33387 |
+ exit(exitnodo); |
33388 |
+ } |
33389 |
+ if (testmode) { |
33390 |
+ printf("Would start %s ", startas); |
33391 |
+ while (argc-- > 0) |
33392 |
+ printf("%s ", *argv++); |
33393 |
+ if (changeuser != NULL) { |
33394 |
+ printf(" (as user %s[%d]", changeuser, runas_uid); |
33395 |
+ if (changegroup != NULL) |
33396 |
+ printf(", and group %s[%d])", changegroup, runas_gid); |
33397 |
+ else |
33398 |
+ printf(")"); |
33399 |
+ } |
33400 |
+ if (changeroot != NULL) |
33401 |
+ printf(" in directory %s", changeroot); |
33402 |
+ if (nicelevel) |
33403 |
+ printf(", and add %i to the priority", nicelevel); |
33404 |
+ printf(".\n"); |
33405 |
+ exit(0); |
33406 |
+ } |
33407 |
+ if (quietmode < 0) |
33408 |
+ printf("Starting %s...\n", startas); |
33409 |
+ *--argv = startas; |
33410 |
+ if (background) { /* ok, we need to detach this process */ |
33411 |
+ int i; |
33412 |
+ if (quietmode < 0) |
33413 |
+ printf("Detaching to start %s...", startas); |
33414 |
+ i = fork(); |
33415 |
+ if (i<0) { |
33416 |
+ fatal("Unable to fork.\n"); |
33417 |
+ } |
33418 |
+ if (i) { /* parent */ |
33419 |
+ if (quietmode < 0) |
33420 |
+ printf("done.\n"); |
33421 |
+ exit(0); |
33422 |
+ } |
33423 |
+ /* child continues here */ |
33424 |
+ |
33425 |
+#ifdef HAVE_TIOCNOTTY |
33426 |
+ tty_fd=open("/dev/tty", O_RDWR); |
33427 |
+#endif |
33428 |
+ devnull_fd=open("/dev/null", O_RDWR); |
33429 |
+ } |
33430 |
+ if (nicelevel) { |
33431 |
+ errno=0; |
33432 |
+ if ((nice(nicelevel)==-1) && (errno!=0)) |
33433 |
+ fatal("Unable to alter nice level by %i: %s", nicelevel, |
33434 |
+ strerror(errno)); |
33435 |
+ } |
33436 |
+ if (changeroot != NULL) { |
33437 |
+ if (chdir(changeroot) < 0) |
33438 |
+ fatal("Unable to chdir() to %s", changeroot); |
33439 |
+ if (chroot(changeroot) < 0) |
33440 |
+ fatal("Unable to chroot() to %s", changeroot); |
33441 |
+ } |
33442 |
+ if (chdir(changedir) < 0) |
33443 |
+ fatal("Unable to chdir() to %s", changedir); |
33444 |
+ if (mpidfile && pidfile != NULL) { /* user wants _us_ to make the pidfile :) */ |
33445 |
+ FILE *pidf = fopen(pidfile, "w"); |
33446 |
+ pid_t pidt = getpid(); |
33447 |
+ if (pidf == NULL) |
33448 |
+ fatal("Unable to open pidfile `%s' for writing: %s", pidfile, |
33449 |
+ strerror(errno)); |
33450 |
+ fprintf(pidf, "%d\n", pidt); |
33451 |
+ fclose(pidf); |
33452 |
+ } |
33453 |
+ if (changeuser != NULL) { |
33454 |
+ if (setgid(runas_gid)) |
33455 |
+ fatal("Unable to set gid to %d", runas_gid); |
33456 |
+ if (initgroups(changeuser, runas_gid)) |
33457 |
+ fatal("Unable to set initgroups() with gid %d", runas_gid); |
33458 |
+ if (setuid(runas_uid)) |
33459 |
+ fatal("Unable to set uid to %s", changeuser); |
33460 |
+ } |
33461 |
+ if (env != NULL) { |
33462 |
+ if(putenv(env)) |
33463 |
+ fatal("Unable to set variable: %s", env); |
33464 |
+ } |
33465 |
+ if (background) { /* continue background setup */ |
33466 |
+ int i; |
33467 |
+#ifdef HAVE_TIOCNOTTY |
33468 |
+ /* change tty */ |
33469 |
+ ioctl(tty_fd, TIOCNOTTY, 0); |
33470 |
+ close(tty_fd); |
33471 |
+#endif |
33472 |
+ umask(022); /* set a default for dumb programs */ |
33473 |
+ dup2(devnull_fd,0); /* stdin */ |
33474 |
+ dup2(devnull_fd,1); /* stdout */ |
33475 |
+ dup2(devnull_fd,2); /* stderr */ |
33476 |
+#if defined(OShpux) |
33477 |
+ /* now close all extra fds */ |
33478 |
+ for (i=sysconf(_SC_OPEN_MAX)-1; i>=3; --i) close(i); |
33479 |
+#else |
33480 |
+ /* now close all extra fds */ |
33481 |
+ for (i=getdtablesize()-1; i>=3; --i) close(i); |
33482 |
+#endif |
33483 |
+ |
33484 |
+ /* create a new session */ |
33485 |
+#ifdef HAVE_SETSID |
33486 |
+ setsid(); |
33487 |
+#else |
33488 |
+ setpgid(0,0); |
33489 |
+#endif |
33490 |
+ } |
33491 |
+ execv(startas, argv); |
33492 |
+ fatal("Unable to start %s: %s", startas, strerror(errno)); |
33493 |
+} |