rc-update: add option to remove a service from all runlevels
The -a option,which only applies to the del command, is used to remove a service from all runlevels. X-Gentoo-Bug: 497740 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=497740
This commit is contained in:
parent
54ab12d218
commit
abadaa04ab
@ -21,7 +21,7 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.Dd May 2, 2009
|
.Dd Jan 13, 2014
|
||||||
.Dt RC-UPDATE 8 SMM
|
.Dt RC-UPDATE 8 SMM
|
||||||
.Os OpenRC
|
.Os OpenRC
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -35,6 +35,7 @@
|
|||||||
.Op Ar runlevel ...
|
.Op Ar runlevel ...
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl s , -stack
|
.Op Fl s , -stack
|
||||||
|
.Op Fl a , -all
|
||||||
.Ar delete
|
.Ar delete
|
||||||
.Ar service
|
.Ar service
|
||||||
.Op Ar runlevel ...
|
.Op Ar runlevel ...
|
||||||
@ -86,9 +87,16 @@ If the
|
|||||||
.Fl s , -stack
|
.Fl s , -stack
|
||||||
option is given then we either add or remove the runlevel from the runlevel.
|
option is given then we either add or remove the runlevel from the runlevel.
|
||||||
This allows inheritance of runlevels.
|
This allows inheritance of runlevels.
|
||||||
|
|
||||||
|
If the
|
||||||
|
.Fl a, -all
|
||||||
|
option is given, we remove the service from all runlevels. This is
|
||||||
|
useful, for example, to clean up the dangling symlinks after a service
|
||||||
|
is removed.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr openrc 8 ,
|
.Xr openrc 8 ,
|
||||||
.Xr openrc-run 8 ,
|
.Xr openrc-run 8 ,
|
||||||
.Xr rc-status 8
|
.Xr rc-status 8
|
||||||
.Sh AUTHORS
|
.Sh AUTHORS
|
||||||
.An Roy Marples <roy@marples.name>
|
.An Roy Marples <roy@marples.name>
|
||||||
|
.An The OpenRC Team <openrc@gentoo.org>
|
||||||
|
@ -199,13 +199,15 @@ show(RC_STRINGLIST *runlevels, bool verbose)
|
|||||||
"Usage: rc-update [options] add <service> [<runlevel>...]\n" \
|
"Usage: rc-update [options] add <service> [<runlevel>...]\n" \
|
||||||
" or: rc-update [options] del <service> [<runlevel>...]\n" \
|
" or: rc-update [options] del <service> [<runlevel>...]\n" \
|
||||||
" or: rc-update [options] [show [<runlevel>...]]"
|
" or: rc-update [options] [show [<runlevel>...]]"
|
||||||
#define getoptstring "su" getoptstring_COMMON
|
#define getoptstring "asu" getoptstring_COMMON
|
||||||
static const struct option longopts[] = {
|
static const struct option longopts[] = {
|
||||||
|
{ "all", 0, NULL, 'a' },
|
||||||
{ "stack", 0, NULL, 's' },
|
{ "stack", 0, NULL, 's' },
|
||||||
{ "update", 0, NULL, 'u' },
|
{ "update", 0, NULL, 'u' },
|
||||||
longopts_COMMON
|
longopts_COMMON
|
||||||
};
|
};
|
||||||
static const char * const longopts_help[] = {
|
static const char * const longopts_help[] = {
|
||||||
|
"Process all runlevels",
|
||||||
"Stack a runlevel instead of a service",
|
"Stack a runlevel instead of a service",
|
||||||
"Force an update of the dependency tree",
|
"Force an update of the dependency tree",
|
||||||
longopts_help_COMMON
|
longopts_help_COMMON
|
||||||
@ -225,7 +227,7 @@ rc_update(int argc, char **argv)
|
|||||||
char *service = NULL;
|
char *service = NULL;
|
||||||
char *p;
|
char *p;
|
||||||
int action = 0;
|
int action = 0;
|
||||||
bool verbose = false, stack = false;
|
bool verbose = false, stack = false, all_runlevels = false;
|
||||||
int opt;
|
int opt;
|
||||||
int retval = EXIT_FAILURE;
|
int retval = EXIT_FAILURE;
|
||||||
int num_updated = 0;
|
int num_updated = 0;
|
||||||
@ -235,6 +237,9 @@ rc_update(int argc, char **argv)
|
|||||||
while ((opt = getopt_long(argc, argv, getoptstring,
|
while ((opt = getopt_long(argc, argv, getoptstring,
|
||||||
longopts, (int *)0)) != -1)
|
longopts, (int *)0)) != -1)
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'a':
|
||||||
|
all_runlevels = true;
|
||||||
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
stack = true;
|
stack = true;
|
||||||
break;
|
break;
|
||||||
@ -306,6 +311,10 @@ rc_update(int argc, char **argv)
|
|||||||
eerror ("%s: no service specified", applet);
|
eerror ("%s: no service specified", applet);
|
||||||
else {
|
else {
|
||||||
if (action & DOADD) {
|
if (action & DOADD) {
|
||||||
|
if (all_runlevels) {
|
||||||
|
rc_stringlist_free(runlevels);
|
||||||
|
eerrorx("%s: the -a option is invalid with add", applet);
|
||||||
|
}
|
||||||
actfunc = stack ? addstack : add;
|
actfunc = stack ? addstack : add;
|
||||||
} else if (action & DODELETE) {
|
} else if (action & DODELETE) {
|
||||||
actfunc = stack ? delstack : delete;
|
actfunc = stack ? delstack : delete;
|
||||||
@ -315,9 +324,14 @@ rc_update(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!TAILQ_FIRST(runlevels)) {
|
if (!TAILQ_FIRST(runlevels)) {
|
||||||
p = rc_runlevel_get();
|
if (all_runlevels) {
|
||||||
rc_stringlist_add(runlevels, p);
|
free(runlevels);
|
||||||
free(p);
|
runlevels = rc_runlevel_list();
|
||||||
|
} else {
|
||||||
|
p = rc_runlevel_get();
|
||||||
|
rc_stringlist_add(runlevels, p);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TAILQ_FIRST(runlevels)) {
|
if (!TAILQ_FIRST(runlevels)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user