How about creating a method for people using pcmcia and other kinds of hotplugging to say that certain services shall start when a wireless pccard (or a network cabel) is inserted. So, lets say I have a laptop with no builtin NIC, but have a wireless pcmcia card. I would then like the system to start ntp-client, sshd, netmouse etc. when the card is inserted, and stop them when the card is removed again. The same thing comes for other things like ifplugd when i cable is inserted/removed. Maybe some pseudo runlevels / sub runlevel would do it. Reproducible: Always Steps to Reproduce:
ifplugd may be a way to get at least the network going. I changed /usr/sbin/ifplugd.action a little bit to fit my needs and stop/restart the services depending on net
Created attachment 46660 [details] /usr/sbin/ifplugd.action This is my proposition to auto-start/stop services depending on net.
Created attachment 46663 [details] /usr/sbin/ifplugd.action Oh, some lines were obsolete
Thought you guys might be interested.
This can easily be achieved by adding a postup() function to /etc/conf.d/net when using baselayout-1.11.x.
Yes, works great, too. Removed it from ifplugd.action and added it in net config. Propose to put it there as a (#commented out) example.
i.e. like this #postup() { # # This function could be used, for example, to register with a # # dynamic DNS service. Another possibility would be to # # send/receive mail once the interface is brought up. +# +# # Restart services which need net on postup +# runlevel=$(grep "l$(runlevel | awk '{ print $2 }'):" /etc/inittab | awk '{ print $2 }') +# for i in /etc/runlevels/${runlevel}/* +# do +# $i ineed | grep -x "net" > /dev/null && \ +# einfo "restarting $(basename $i)" && $i restart +# done +# +# # Remember to return 0 on success # return 0 #}
A bit simpler postup() { /sbin/rc return 0 } and with many advantages - such as starting up all services that depend on net at the bottom of their chain. For example, "foo" depends on net and "bar" depends on "foo". bar is in the default runlevel, but foo is not. This should start bar whereas I think your code would not.
Wow, just great. Thats really lovely! Thanks for your hint.
Works well, exept of a little design flaw: i.e. at boot $rc default runs. As the postup function is called, $rc runs parallel to the prior instance, to say that the remaining initscripts are called in parallel. Is there a simple way to check, if rc is already called? ps seems an ugly solution, there might be better ones. Your help is welcome, thanks.
*** Bug 97602 has been marked as a duplicate of this bug. ***
rc running in parallel shouldn't matter as we use fifo's when we start and stop services so that if there is an error creating the fifo (say the fifo is already there) then we abort the running of the script.