aboutsummaryrefslogtreecommitdiff
path: root/src/rc
diff options
context:
space:
mode:
authorBenda Xu <heroxbd@gentoo.org>2014-01-13 09:18:40 -0600
committerWilliam Hubbs <w.d.hubbs@gmail.com>2014-01-13 10:41:38 -0600
commitabadaa04abe1833c6016f203e5d10168002bd8d3 (patch)
treea9666807053df7295b0a2be2ec32581efa6f03bc /src/rc
parent54ab12d2186d907ea8d7d882b6a9e0536fcc8f5c (diff)
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
Diffstat (limited to 'src/rc')
-rw-r--r--src/rc/rc-update.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/rc/rc-update.c b/src/rc/rc-update.c
index 88856370..d16af1b2 100644
--- a/src/rc/rc-update.c
+++ b/src/rc/rc-update.c
@@ -199,13 +199,15 @@ show(RC_STRINGLIST *runlevels, bool verbose)
"Usage: rc-update [options] add <service> [<runlevel>...]\n" \
" or: rc-update [options] del <service> [<runlevel>...]\n" \
" or: rc-update [options] [show [<runlevel>...]]"
-#define getoptstring "su" getoptstring_COMMON
+#define getoptstring "asu" getoptstring_COMMON
static const struct option longopts[] = {
+ { "all", 0, NULL, 'a' },
{ "stack", 0, NULL, 's' },
{ "update", 0, NULL, 'u' },
longopts_COMMON
};
static const char * const longopts_help[] = {
+ "Process all runlevels",
"Stack a runlevel instead of a service",
"Force an update of the dependency tree",
longopts_help_COMMON
@@ -225,7 +227,7 @@ rc_update(int argc, char **argv)
char *service = NULL;
char *p;
int action = 0;
- bool verbose = false, stack = false;
+ bool verbose = false, stack = false, all_runlevels = false;
int opt;
int retval = EXIT_FAILURE;
int num_updated = 0;
@@ -235,6 +237,9 @@ rc_update(int argc, char **argv)
while ((opt = getopt_long(argc, argv, getoptstring,
longopts, (int *)0)) != -1)
switch (opt) {
+ case 'a':
+ all_runlevels = true;
+ break;
case 's':
stack = true;
break;
@@ -306,6 +311,10 @@ rc_update(int argc, char **argv)
eerror ("%s: no service specified", applet);
else {
if (action & DOADD) {
+ if (all_runlevels) {
+ rc_stringlist_free(runlevels);
+ eerrorx("%s: the -a option is invalid with add", applet);
+ }
actfunc = stack ? addstack : add;
} else if (action & DODELETE) {
actfunc = stack ? delstack : delete;
@@ -315,9 +324,14 @@ rc_update(int argc, char **argv)
}
if (!TAILQ_FIRST(runlevels)) {
- p = rc_runlevel_get();
- rc_stringlist_add(runlevels, p);
- free(p);
+ if (all_runlevels) {
+ free(runlevels);
+ runlevels = rc_runlevel_list();
+ } else {
+ p = rc_runlevel_get();
+ rc_stringlist_add(runlevels, p);
+ free(p);
+ }
}
if (!TAILQ_FIRST(runlevels)) {