aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-08-28 13:06:44 +0000
committerRoy Marples <roy@marples.name>2007-08-28 13:06:44 +0000
commit144d9653e11918390f2d2ae73b11e07cf312d2fa (patch)
treed126a4313e7b3d6a18de16ad3a5b67654fa4bb3d /src
parent849b983c3fb6abec364d5e9e2519ef4ba1ea5df9 (diff)
Undocument pause action, fix --nodeps and --ifstarted, #190045.
Diffstat (limited to 'src')
-rw-r--r--src/rc.c7
-rw-r--r--src/runscript.c46
2 files changed, 31 insertions, 22 deletions
diff --git a/src/rc.c b/src/rc.c
index 08d75262..4cb03491 100644
--- a/src/rc.c
+++ b/src/rc.c
@@ -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);