aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-12-08 12:10:45 +0000
committerRoy Marples <roy@marples.name>2007-12-08 12:10:45 +0000
commit2c3c27e251231264b0eb37c968d36f0b4fd3c54b (patch)
tree0a116d63101171311c1b160afe373b1a4e993232
parent9a6cfc0a9b455d463ce469fc59beb880ecce5294 (diff)
Mirror the action of rc-update in baselayout-1, with the exception of adding to the currnet runlevel if no runlevel specified.
-rw-r--r--src/rc-update.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/rc-update.c b/src/rc-update.c
index 04f6cdff..ddec0066 100644
--- a/src/rc-update.c
+++ b/src/rc-update.c
@@ -243,26 +243,33 @@ int rc_update (int argc, char **argv)
else {
ssize_t num_updated = 0;
ssize_t (*actfunc)(const char *, const char *);
- if (action & DOADD)
+
+ if (action & DOADD) {
actfunc = add;
- else if (action & DODELETE)
+ if (! runlevels)
+ rc_strlist_add (&runlevels, rc_runlevel_get ());
+ } else if (action & DODELETE) {
actfunc = delete;
- else
+ if (! runlevels)
+ runlevels = rc_runlevel_list ();
+ } else
eerrorx ("%s: invalid action", applet);
+
if (! runlevels)
- runlevels = rc_runlevel_list ();
+ eerrorx ("%s: no runlevels found", applet);
+
STRLIST_FOREACH (runlevels, runlevel, i) {
ssize_t ret = actfunc (runlevel, service);
if (ret < 0)
retval = EXIT_FAILURE;
num_updated += ret;
}
- if (retval == EXIT_SUCCESS && num_updated == 0)
+
+ if (retval == EXIT_SUCCESS && num_updated == 0 && action & DODELETE)
ewarnx ("%s: service `%s' not found in any of the specified runlevels", applet, service);
}
}
rc_strlist_free (runlevels);
-
return (retval);
}