Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 372585 - sys-apps/openrc: switch runlevels without stopping started services not in new runlevel
Summary: sys-apps/openrc: switch runlevels without stopping started services not in ne...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Hosted Projects
Classification: Unclassified
Component: OpenRC (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: OpenRC Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 439098
  Show dependency tree
 
Reported: 2011-06-22 14:22 UTC by Robert Forsman
Modified: 2013-08-14 06:48 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Forsman 2011-06-22 14:22:25 UTC
I have a laptop whose network connection can be wired, wifi, or GSM.  I have configured it to boot to the nonetwork level.  I then use sudo to start the network appropriate for my location and start all the services that depend on the network.  At the end of the script I have "sudo telinit 3" .  Under the old rc system this was just a bookkeeping step to tell init that I was non longer in the nonetwork run level.

Since I upgraded to openrc, this now STOPS my network, crippling all my services.  I assume that's because openrc is more aggressive about stopping services that are not mentioned in /etc/runlevels/default .

How do i express to openrc that I need it to leave one of the network services running, but I am not sure which one will be running at any moment?


Reproducible: Always

Steps to Reproduce:
1. /etc/init.d/net.ppp2 start
2. telinit 3
3. watch openrc kill net.ppp2

1. /etc/init.d/net.eth0 start
2. telinit 3
3. watch openrc kill net.ppp2



Expected Results:  
I need it to leave whatever network service I picked running.
Comment 1 SpanKY gentoo-dev 2011-06-29 19:06:49 UTC
this is expected behavior when using `rc <runlevel>`.  i dont think there are any flags atm to tell openrc to not stop services that arent part of the runlevel you selected.

i thought this was how baselayout-1 worked too, but maybe there was different behavior when being run through init.
Comment 2 William Hubbs gentoo-dev 2011-07-27 15:46:14 UTC
All,

The runscript man page states that if you add -stop to the keywords line
of a service, that service will not stop if you switch runlevels.

It would be an easy fix for me to add that to net.lo if desirable so
that the network will not come down if you switch runlevels.
Comment 3 Robert Forsman 2011-08-02 19:55:41 UTC
I'm not sure making the -stop change on a global basis would be the right thing to do.  I assume there are plenty of people who want "telinit 2" to turn off all their networks.  Otherwise openrc would not have been coded this way.

My complaint is that there appears to be no documented way to express that "telinit 3" includes a network service, but I can't designate a single one to be the right one all the time.

I just added -stop to the keyword line in my net.lo for myself.  It wouldn't be the first time I edited an init script that got upgraded to do something I didn't want.
Comment 4 SpanKY gentoo-dev 2011-08-06 10:55:55 UTC
(In reply to comment #2)

adding "-stop" to any installed init.d script is a bad idea.  this is purely a user knob.  but since openrc already supports this in its core, sounds like adding a command line option for it should be easy.

rc --no-auto-stop <runlevel>

(In reply to comment #3)

"network" behavior wrt sysv init levels is purely a user concoction.  i dont think it's necessary to try and dream up specific hacks for this.

also, it sounds like you dont know about setting rc_keyword in /etc/conf.d/net.  please read runscript(8).
Comment 5 William Hubbs gentoo-dev 2011-08-31 00:01:35 UTC
(In reply to comment #3)
> I'm not sure making the -stop change on a global basis would be the right thing
> to do.  I assume there are plenty of people who want "telinit 2" to turn off
> all their networks.  Otherwise openrc would not have been coded this way.
> 
> My complaint is that there appears to be no documented way to express that
> "telinit 3" includes a network service, but I can't designate a single one to
> be the right one all the time.
> 
> I just added -stop to the keyword line in my net.lo for myself.  It wouldn't be
> the first time I edited an init script that got upgraded to do something I
> didn't want.

After checking the information in Mike's comment above, I found that you can do the following in /etc/conf.d/net:

rc_net_eth0_keyword="-stop"
rc_net_ppp2_keyword="-stop"
...

for all of the network interfaces you  do not want to stop when you switch runlevels.

I recommend this approach over modifying net.lo.

(In reply to comment #4)
> (In reply to comment #2)
> 
> adding "-stop" to any installed init.d script is a bad idea.  this is purely a
> user knob.  but since openrc already supports this in its core, sounds like
> adding a command line option for it should be easy.
> 
> rc --no-auto-stop <runlevel>

Are you sure we want this on a global basis? If not I don't think we  should have a command line option since users can control it with the rc_*_keyword variables.
Comment 6 SpanKY gentoo-dev 2011-09-17 23:05:35 UTC
(In reply to comment #5)

i think being able to temporarily specify a value for the knob on a global basis makes sense.  however, it's purely up to the user as to when they want to employ it.  if Robert is fine with putting -stop in all of the conf.d files for the services he wants to keep running, then perhaps we can delay the work.
Comment 7 William Hubbs gentoo-dev 2013-04-27 17:28:51 UTC
There is an rc_nostop setting in rc.conf.
If you have something like rc_nostop="foo bar bas" set, foo bar and bas will not stop when you change runlevels.
Does that satisfy this bug?
Comment 8 William Hubbs gentoo-dev 2013-04-28 01:47:08 UTC
I am now testing a patch which will add a --no-stop command line option
to rc.
Comment 9 William Hubbs gentoo-dev 2013-04-28 18:11:19 UTC
Now rc has a new -n/--no-stop command line option which means do not
stop any services that are not in the runlevel we are switching to.
This is fixed in commit 10a4385.
The fix will be included in OpenRC-0.12.
Comment 10 William Hubbs gentoo-dev 2013-08-14 06:48:25 UTC
OpenRC-0.12 is out with this switch included.