Retain behavior where rc-update del
warns if nothing changed.
This commit is contained in:
parent
6fc541a9b8
commit
b24e877948
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
Retain behavior where `rc-update del foo` deletes foo from all runlevels.
|
Retain behavior where `rc-update del foo` deletes foo from all runlevels.
|
||||||
|
|
||||||
|
Retain behavior where `rc-update del` warns if nothing changed.
|
||||||
|
|
||||||
24 Sep 2007; Mike Frysinger <vapier@gentoo.org>:
|
24 Sep 2007; Mike Frysinger <vapier@gentoo.org>:
|
||||||
|
|
||||||
Do not require portmap in netmount when nolock option is used with nfs
|
Do not require portmap in netmount when nolock option is used with nfs
|
||||||
|
@ -24,9 +24,14 @@
|
|||||||
|
|
||||||
static char *applet = NULL;
|
static char *applet = NULL;
|
||||||
|
|
||||||
static bool add (const char *runlevel, const char *service)
|
/* Return the number of changes made:
|
||||||
|
* -1 = no changes (error)
|
||||||
|
* 0 = no changes (nothing to do)
|
||||||
|
* 1+ = number of runlevels updated
|
||||||
|
*/
|
||||||
|
static ssize_t add (const char *runlevel, const char *service)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
ssize_t retval = -1;
|
||||||
|
|
||||||
if (! rc_service_exists (service))
|
if (! rc_service_exists (service))
|
||||||
eerror ("%s: service `%s' does not exist", applet, service);
|
eerror ("%s: service `%s' does not exist", applet, service);
|
||||||
@ -35,10 +40,10 @@ static bool add (const char *runlevel, const char *service)
|
|||||||
else if (rc_service_in_runlevel (service, runlevel)) {
|
else if (rc_service_in_runlevel (service, runlevel)) {
|
||||||
ewarn ("%s: %s already installed in runlevel `%s'; skipping",
|
ewarn ("%s: %s already installed in runlevel `%s'; skipping",
|
||||||
applet, service, runlevel);
|
applet, service, runlevel);
|
||||||
retval = true;
|
retval = 0;
|
||||||
} else if (rc_service_add (runlevel, service)) {
|
} else if (rc_service_add (runlevel, service)) {
|
||||||
einfo ("%s added to runlevel %s", service, runlevel);
|
einfo ("%s added to runlevel %s", service, runlevel);
|
||||||
retval = true;
|
retval = 1;
|
||||||
} else
|
} else
|
||||||
eerror ("%s: failed to add service `%s' to runlevel `%s': %s",
|
eerror ("%s: failed to add service `%s' to runlevel `%s': %s",
|
||||||
applet, service, runlevel, strerror (errno));
|
applet, service, runlevel, strerror (errno));
|
||||||
@ -46,14 +51,14 @@ static bool add (const char *runlevel, const char *service)
|
|||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool delete (const char *runlevel, const char *service)
|
static ssize_t delete (const char *runlevel, const char *service)
|
||||||
{
|
{
|
||||||
bool retval = false;
|
ssize_t retval = -1;
|
||||||
|
|
||||||
if (rc_service_in_runlevel (service, runlevel)) {
|
if (rc_service_in_runlevel (service, runlevel)) {
|
||||||
if (rc_service_delete (runlevel, service)) {
|
if (rc_service_delete (runlevel, service)) {
|
||||||
einfo ("%s removed from runlevel %s", service, runlevel);
|
einfo ("%s removed from runlevel %s", service, runlevel);
|
||||||
retval = true;
|
retval = 1;
|
||||||
} else
|
} else
|
||||||
eerror ("%s: failed to remove service `%s' from runlevel `%s': %s",
|
eerror ("%s: failed to remove service `%s' from runlevel `%s': %s",
|
||||||
applet, service, runlevel, strerror (errno));
|
applet, service, runlevel, strerror (errno));
|
||||||
@ -62,7 +67,8 @@ static bool delete (const char *runlevel, const char *service)
|
|||||||
else if (! rc_runlevel_exists (runlevel))
|
else if (! rc_runlevel_exists (runlevel))
|
||||||
eerror ("%s: runlevel `%s' does not exist", applet, runlevel);
|
eerror ("%s: runlevel `%s' does not exist", applet, runlevel);
|
||||||
else
|
else
|
||||||
retval = true;
|
retval = 0;
|
||||||
|
|
||||||
return (retval);
|
return (retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,6 +206,7 @@ int rc_update (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retval = EXIT_SUCCESS;
|
||||||
if (action & DOSHOW) {
|
if (action & DOSHOW) {
|
||||||
if (service)
|
if (service)
|
||||||
rc_strlist_add (&runlevels, service);
|
rc_strlist_add (&runlevels, service);
|
||||||
@ -207,25 +214,30 @@ int rc_update (int argc, char **argv)
|
|||||||
runlevels = rc_get_runlevels ();
|
runlevels = rc_get_runlevels ();
|
||||||
|
|
||||||
show (runlevels, verbose);
|
show (runlevels, verbose);
|
||||||
retval = EXIT_SUCCESS;
|
|
||||||
} else {
|
} else {
|
||||||
if (! service)
|
if (! service)
|
||||||
eerror ("%s: no service specified", applet);
|
eerror ("%s: no service specified", applet);
|
||||||
else if (! rc_service_exists (service))
|
else if (! rc_service_exists (service))
|
||||||
eerror ("%s: service `%s' does not exist", applet, service);
|
eerror ("%s: service `%s' does not exist", applet, service);
|
||||||
else {
|
else {
|
||||||
retval = EXIT_SUCCESS;
|
ssize_t num_updated = 0;
|
||||||
|
ssize_t (*actfunc)(const char *runlevel, const char *service);
|
||||||
|
if (action & DOADD)
|
||||||
|
actfunc = add;
|
||||||
|
else if (action & DODELETE)
|
||||||
|
actfunc = delete;
|
||||||
|
else
|
||||||
|
eerrorx ("%s: invalid action", applet);
|
||||||
if (! runlevels)
|
if (! runlevels)
|
||||||
runlevels = rc_get_runlevels ();
|
runlevels = rc_get_runlevels ();
|
||||||
STRLIST_FOREACH (runlevels, runlevel, i) {
|
STRLIST_FOREACH (runlevels, runlevel, i) {
|
||||||
if (action & DOADD) {
|
ssize_t ret = actfunc (runlevel, service);
|
||||||
if (! add (runlevel, service))
|
if (ret < 0)
|
||||||
retval = EXIT_FAILURE;
|
retval = EXIT_FAILURE;
|
||||||
} else if (action & DODELETE) {
|
num_updated += ret;
|
||||||
if (! delete (runlevel, service))
|
|
||||||
retval = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (retval == EXIT_SUCCESS && num_updated == 0)
|
||||||
|
ewarnx ("%s: service `%s' not found in any of the specified runlevels", applet, service);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user