From 2c3c27e251231264b0eb37c968d36f0b4fd3c54b Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sat, 8 Dec 2007 12:10:45 +0000 Subject: [PATCH] Mirror the action of rc-update in baselayout-1, with the exception of adding to the currnet runlevel if no runlevel specified. --- src/rc-update.c | 19 +++++++++++++------ 1 file 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); }