Gentoo Archives: gentoo-dev

From: "Kevin F. Quinn" <ml@××××××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] baselayout-1.11.12-r2 request for testers
Date: Thu, 26 May 2005 18:29:51
Message-Id: XWRDA7.2008734459IYSR0X@kevquinn.com
In Reply to: Re: [gentoo-dev] baselayout-1.11.12-r2 request for testers by Roy Marples
1 On 26/5/2005 15:33:10, Roy Marples (uberlord@g.o) wrote:
2 > On Thu, 2005-05-26 at 15:04 +0200, Kevin F. Quinn wrote:
3 > > I'm trying it on a laptop that connects to various different networks
4 > > depending on the weather. I figured this would be a useful test as
5 > > it's a less common configuration. It connects mostly via different
6 > > docking stations. I use udev to rename ethernet devices according to
7 > > MAC address (the ethernet devices are in the docking stations).
8 > > Hotplug then runs the appropriately named network script via net.agent
9 > > to start the service. Critically, the various net.* scripts are
10 > > therefore -not- in any runlevel.
11 > >
12 > > This hotplugging of the network devices all kicks off early on - well
13 > > before the boot level has finished. The new /sbin/runscript.sh simply
14 > > drops the addition of the network device if the boot level hasn't
15 > > finished - leaving me with no network (or at least, a network that has
16 > > to be started manually). For now, I've commented out the check in
17 > > /sbin/runscript.sh, and it all works ok. I don't know what this will
18 > > break; obviously the check wasn't added just for laughs!
19 > >
20 >
21 >
22 > emerge ifplugd and get that to monitor your interfaces. It will bring
23 > them up/down when a cable is inserted/removed.
24 > You'll probably have to tell it to not fail if the interfaces don't
25 > exist as you're using udev to rename them.
26 >
27 > A better solution would be to allow configuration via MAC address, which
28 > we may put into baselayout-1.12.0
29
30 Thanks for the suggestions. I didn't want to go the ifplugd route as the interfaces don't appear/disappear while the system is running. I've thought a bit about this, and it occurs to me that what I really want is for the hotplug-initiated scripts that runscript.sh doesn't want to do at boot, deferred to default (rather than just dropped).
31
32 I've implemented this in a simple fashion:
33
34 ========
35 --- runscript.sh.orig 2005-05-26 20:02:37.000000000 +0200
36 +++ runscript.sh 2005-05-26 20:06:28.000000000 +0200
37 @@ -45,8 +45,9 @@
38 # has completed
39 if [[ ${NETSERVICE} == "yes" && ${IFACE} != "lo" ]] ; then
40 if [[ -z ${mylevel} || ${mylevel} == ${BOOTLEVEL} ]] ; then
41 - eerror "$0: cannot start until the runlevel "${BOOTLEVEL}" has completed"
42 - exit 1
43 + echo $* >> ${svcdir}/deferred
44 + ewarn "$0: deferring, service not suitable for runlevel "${BOOTLEVEL}"."
45 + exit 0
46 fi
47 fi
48 ========
49
50
51 with the following in /etc/init.d/deferred:
52
53
54 ========
55 #!/sbin/runscript
56 # Copyright 1999-2005 Gentoo Foundation
57 # Distributed under the terms of the GNU General Public License v2
58 # $Header: $
59
60 dodeferred() {
61 local myline myservice
62 if [[ -f ${svcdir}/deferred ]]; then
63 while read myline; do
64 myservice=${myline%% *}
65 ${myservice} $1
66 done < ${svcdir}/deferred
67 fi
68 }
69
70 start() {
71 dodeferred start
72 }
73
74 stop() {
75 dodeferred stop
76 /bin/rm -f ${svcdir}/deferred
77 }
78
79 restart() {
80 dodeferred restart
81 }
82 ========
83
84 'rc-update add deferred default' ensures the deferred startups happen when the default runlevel is entered, and are not done if the kernel parameters indicate startup shouldn't continue past the boot runlevel. Continuing manually to the default level catches the deferred startups automatically.
85
86 The 'deferred' script above doesn't deal with runscript options (--quiet etc), and it may be better to do the 'rm ${svcdir}/deferred' somehwere else, but it illustrates the idea.
87
88 > > On a somewhat related matter, I have bluetooth stuff installed, which
89 > > is also started by hotplug/pcmcia. In order to prevent it being
90 > > stopped by changing runlevels, I've made a softlink to net.bluetooth
91 > > and started that in my hotplug config instead of 'bluetooth'. Bit of
92 > > a hack, relying on the fact /sbin/rc does not automatically stop
93 > > anything that begins with "net.". Is there a tidier way to prevent
94 > > /sbin/rc from messing with services started & stopped via hotplug?
95 >
96 > Try experimenting with the RC_STRICT_NET_CHECKING in /etc/conf.d/rc
97
98 My problem here (such that it is) is that the only way for a service to survive a runtime level transition, if it is started by hotplug, is to call it 'net.<something>'. Deferring it (as above) solves the transition problem. Of course, it might be worth having a "not-at-boot" indication feature for init scripts, rather than having them named net.<something> :)
99
100 Kev.
101
102
103
104 --
105 gentoo-dev@g.o mailing list