diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | conf.d/rc | 5 | ||||
-rwxr-xr-x | sh/rc-help.sh | 2 | ||||
-rw-r--r-- | src/rc.c | 7 | ||||
-rw-r--r-- | src/runscript.c | 46 |
5 files changed, 36 insertions, 25 deletions
@@ -3,6 +3,7 @@ 28 Aug 2007; Roy Marples <uberlord@gentoo.org>: + Undocument pause action, fix --nodeps and --ifstarted, #190045. Fix ksoftlevel handling, #190420. 26 Aug 2007; Mike Frysinger <vapier@gentoo.org>: @@ -75,7 +75,8 @@ RC_FORCE_AUTO="no" #RC_ULIMIT="-u 30" # It's possible to define extra dependencies for services like so +#RC_CONFIG="/etc/foo" #RC_NEED="openvpn" #RC_USE="net.eth0" - - +#RC_AFTER="clock" +#RC_BEFORE="local" diff --git a/sh/rc-help.sh b/sh/rc-help.sh index 789537cf..5e2de1c7 100755 --- a/sh/rc-help.sh +++ b/sh/rc-help.sh @@ -32,7 +32,7 @@ else NL= fi -default_opts="describe start stop restart pause zap" +default_opts="describe start stop restart zap" extra_opts="$(. "${myscript}" 2>/dev/null ; echo "${opts}")" if [ "${BE_VERBOSE}" = "yes" ] ; then @@ -977,8 +977,11 @@ int main (int argc, char **argv) strcmp (PREVLEVEL, "S") == 0 || strcmp (PREVLEVEL, "N") == 0)) { - if (get_ksoftlevel (ksoftbuffer, sizeof (ksoftbuffer))) - newlevel = ksoftbuffer; + /* Try not to join boot and ksoftlevels together */ + if (! newlevel || + strcmp (newlevel, getenv ("RC_BOOTLEVEL")) != 0) + if (get_ksoftlevel (ksoftbuffer, sizeof (ksoftbuffer))) + newlevel = ksoftbuffer; } else if (! RUNLEVEL || (strcmp (RUNLEVEL, "1") != 0 && strcmp (RUNLEVEL, "S") != 0 && diff --git a/src/runscript.c b/src/runscript.c index 6a2c4079..5a91b791 100644 --- a/src/runscript.c +++ b/src/runscript.c @@ -830,7 +830,7 @@ static void svc_stop (bool deps) rc_service_in_runlevel (service, RC_LEVEL_BOOT)) ewarn ("WARNING: you are stopping a boot service"); - if (deps || ! rc_service_state (service, rc_service_wasinactive)) { + if (deps && ! rc_service_state (service, rc_service_wasinactive)) { int depoptions = RC_DEP_TRACE; char *svc; int i; @@ -977,18 +977,18 @@ static void svc_restart (bool deps) restart_services = NULL; } -#define getoptstring "dCDNqvh" +#include "_usage.h" +#define getoptstring "dDqsv" getoptstring_COMMON static struct option longopts[] = { { "debug", 0, NULL, 'd'}, - { "nocolor", 0, NULL, 'C'}, - { "nocolour", 0, NULL, 'C'}, + { "ifstarted", 0, NULL, 's'}, { "nodeps", 0, NULL, 'D'}, { "quiet", 0, NULL, 'q'}, { "verbose", 0, NULL, 'v'}, - { "help", 0, NULL, 'h'}, + longopts_COMMON { NULL, 0, NULL, 0} }; -// #include "_usage.c" +#include "_usage.c" int runscript (int argc, char **argv) { @@ -1124,6 +1124,10 @@ int runscript (int argc, char **argv) execl (RCSCRIPT_HELP, RCSCRIPT_HELP, service, (char *) NULL); eerrorx ("%s: failed to exec `" RCSCRIPT_HELP "': %s", applet, strerror (errno)); + case 's': + if (! rc_service_state (service, rc_service_started)) + exit (EXIT_FAILURE); + break; case 'C': setenv ("RC_NOCOLOR", "yes", 1); break; @@ -1137,7 +1141,7 @@ int runscript (int argc, char **argv) setenv ("RC_VERBOSE", "yes", 1); break; default: - exit (EXIT_FAILURE); + usage (EXIT_FAILURE); } /* Save the IN_BACKGROUND env flag so it's ONLY passed to the service @@ -1240,23 +1244,25 @@ int runscript (int argc, char **argv) } else if (strcmp (optarg, "start") == 0) { svc_start (deps); } else if (strcmp (optarg, "stop") == 0) { - if (in_background) + if (deps && in_background) get_started_services (); svc_stop (deps); - if (! in_background && - ! rc_runlevel_stopping () && - rc_service_state (service, rc_service_stopped)) - uncoldplug (); - - if (in_background && - rc_service_state (service, rc_service_inactive)) - { - int j; - STRLIST_FOREACH (restart_services, svc, j) - if (rc_service_state (svc, rc_service_stopped)) - rc_schedule_start_service (service, svc); + if (deps) { + if (! in_background && + ! rc_runlevel_stopping () && + rc_service_state (service, rc_service_stopped)) + uncoldplug (); + + if (in_background && + rc_service_state (service, rc_service_inactive)) + { + int j; + STRLIST_FOREACH (restart_services, svc, j) + if (rc_service_state (svc, rc_service_stopped)) + rc_schedule_start_service (service, svc); + } } } else if (strcmp (optarg, "zap") == 0) { einfo ("Manually resetting %s to stopped state", applet); |