rc: allow switching runlevels without stopping services
OpenRC, by default, stops all services that are not listed in a runlevel when rc is used to switch runlevels. This adds a -n/--no-stop command line option to rc which tells it to skip stopping the services which are not in the runlevel. Reported-by: gentoo@thoth.purplefrog.com X-Gentoo-Bug: 372585 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=372585
This commit is contained in:
parent
10eabd4d92
commit
10a4385e40
9
man/rc.8
9
man/rc.8
@ -29,16 +29,17 @@
|
|||||||
.Nd stops and starts services for the specified runlevel
|
.Nd stops and starts services for the specified runlevel
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
|
.Op Fl n , -no-stop
|
||||||
.Op Fl o , -override
|
.Op Fl o , -override
|
||||||
.Op Ar runlevel
|
.Op Ar runlevel
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm
|
.Nm
|
||||||
first stops any services that are not for the runlevel and then starts any
|
first stops any services that are not in the specified runlevel unless
|
||||||
services in the runlevel and from stacked runlevels added by
|
--no-stop is specified, then starts any services in the runlevel and
|
||||||
|
stacked runlevels added by
|
||||||
.Nm rc-update
|
.Nm rc-update
|
||||||
that are not currently started.
|
that are not currently started.
|
||||||
If no runlevel is specified then we use the current runlevel the system
|
If no runlevel is specified, we use the current runlevel.
|
||||||
is currently in.
|
|
||||||
.Pp
|
.Pp
|
||||||
There are some special runlevels that you should be aware of:
|
There are some special runlevels that you should be aware of:
|
||||||
.Bl -tag -width "shutdown"
|
.Bl -tag -width "shutdown"
|
||||||
|
10
src/rc/rc.c
10
src/rc/rc.c
@ -729,9 +729,10 @@ handle_bad_signal(int sig)
|
|||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#define usagestring "" \
|
#define usagestring "" \
|
||||||
"Usage: rc [options] [<runlevel>]"
|
"Usage: rc [options] [<runlevel>]"
|
||||||
#define getoptstring "a:o:s:S" getoptstring_COMMON
|
#define getoptstring "a:no:s:S" getoptstring_COMMON
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
{ "applet", 1, NULL, 'a' },
|
{ "applet", 1, NULL, 'a' },
|
||||||
|
{ "no-stop", 0, NULL, 'n' },
|
||||||
{ "override", 1, NULL, 'o' },
|
{ "override", 1, NULL, 'o' },
|
||||||
{ "service", 1, NULL, 's' },
|
{ "service", 1, NULL, 's' },
|
||||||
{ "sys", 0, NULL, 'S' },
|
{ "sys", 0, NULL, 'S' },
|
||||||
@ -739,6 +740,7 @@ static const struct option longopts[] = {
|
|||||||
};
|
};
|
||||||
static const char * const longopts_help[] = {
|
static const char * const longopts_help[] = {
|
||||||
"runs the applet specified by the next argument",
|
"runs the applet specified by the next argument",
|
||||||
|
"do not stop any services",
|
||||||
"override the next runlevel to change into\n"
|
"override the next runlevel to change into\n"
|
||||||
"when leaving single user or boot runlevels",
|
"when leaving single user or boot runlevels",
|
||||||
"runs the service specified with the rest\nof the arguments",
|
"runs the service specified with the rest\nof the arguments",
|
||||||
@ -762,6 +764,7 @@ main(int argc, char **argv)
|
|||||||
int opt;
|
int opt;
|
||||||
bool parallel;
|
bool parallel;
|
||||||
int regen = 0;
|
int regen = 0;
|
||||||
|
bool nostop = false;
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
char *proc;
|
char *proc;
|
||||||
char *p;
|
char *p;
|
||||||
@ -812,6 +815,9 @@ main(int argc, char **argv)
|
|||||||
/* Do nothing, actual logic in run_applets, this
|
/* Do nothing, actual logic in run_applets, this
|
||||||
* is a placeholder */
|
* is a placeholder */
|
||||||
break;
|
break;
|
||||||
|
case 'n':
|
||||||
|
nostop = true;
|
||||||
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
if (*optarg == '\0')
|
if (*optarg == '\0')
|
||||||
optarg = NULL;
|
optarg = NULL;
|
||||||
@ -1022,7 +1028,7 @@ main(int argc, char **argv)
|
|||||||
parallel = rc_conf_yesno("rc_parallel");
|
parallel = rc_conf_yesno("rc_parallel");
|
||||||
|
|
||||||
/* Now stop the services that shouldn't be running */
|
/* Now stop the services that shouldn't be running */
|
||||||
if (stop_services)
|
if (stop_services && !nostop)
|
||||||
do_stop_services(newlevel, parallel, going_down);
|
do_stop_services(newlevel, parallel, going_down);
|
||||||
|
|
||||||
/* Wait for our services to finish */
|
/* Wait for our services to finish */
|
||||||
|
Loading…
Reference in New Issue
Block a user