Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 68190 - Idea for network initscripts.
Summary: Idea for network initscripts.
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords:
: 97602 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-10-19 12:22 UTC by Bjarke Istrup Pedersen (RETIRED)
Modified: 2005-08-30 06:07 UTC (History)
7 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
/usr/sbin/ifplugd.action (ifplugd.action,2.02 KB, text/plain)
2004-12-22 13:49 UTC, Thomas Bettler
Details
/usr/sbin/ifplugd.action (ifplugd.action,2.13 KB, text/plain)
2004-12-22 14:03 UTC, Thomas Bettler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Bjarke Istrup Pedersen (RETIRED) gentoo-dev 2004-10-19 12:22:24 UTC
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:
Comment 1 Thomas Bettler 2004-12-22 13:47:04 UTC
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
Comment 2 Thomas Bettler 2004-12-22 13:49:00 UTC
Created attachment 46660 [details]
/usr/sbin/ifplugd.action

This is my proposition to auto-start/stop services depending on net.
Comment 3 Thomas Bettler 2004-12-22 14:03:32 UTC
Created attachment 46663 [details]
/usr/sbin/ifplugd.action

Oh, some lines were obsolete
Comment 4 Donnie Berkholz (RETIRED) gentoo-dev 2005-02-05 11:35:47 UTC
Thought you guys might be interested.
Comment 5 Henrik Brix Andersen 2005-02-05 12:59:57 UTC
This can easily be achieved by adding a postup() function to /etc/conf.d/net when using baselayout-1.11.x.
Comment 6 Thomas Bettler 2005-02-06 16:50:01 UTC
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.
Comment 7 Thomas Bettler 2005-02-06 17:01:58 UTC
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
#}
Comment 8 Roy Marples (RETIRED) gentoo-dev 2005-04-13 16:00:55 UTC
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.
Comment 9 Thomas Bettler 2005-04-17 08:13:14 UTC
Wow, just great. Thats really lovely!
Thanks for your hint.
Comment 10 Thomas Bettler 2005-04-24 15:29:17 UTC
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.
Comment 11 Paweł Hajdan, Jr. (RETIRED) gentoo-dev 2005-07-02 05:18:07 UTC
*** Bug 97602 has been marked as a duplicate of this bug. ***
Comment 12 Roy Marples (RETIRED) gentoo-dev 2005-08-30 06:07:14 UTC
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.