aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-10-16 17:04:44 +0000
committerRoy Marples <roy@marples.name>2008-10-16 17:04:44 +0000
commit0a39145a5e80274599c4d42ab2901c3b6ec0c979 (patch)
treeaa1ed752fad91ca8c98dd9e67bb57fbbb4bc06d0
parent734e60608a2ef97b239616c00904a4da86042352 (diff)
Include sysinit services even in single user.
-rw-r--r--src/rc/rc.c65
1 files changed, 24 insertions, 41 deletions
diff --git a/src/rc/rc.c b/src/rc/rc.c
index d1446cdb..f268bcb6 100644
--- a/src/rc/rc.c
+++ b/src/rc/rc.c
@@ -621,7 +621,7 @@ static bool runlevel_config(const char *service, const char *level)
return retval;
}
-static void do_stop_services(const char *newlevel, bool going_down, bool parallel)
+static void do_stop_services(const char *newlevel, bool parallel)
{
pid_t pid;
RC_STRING *service, *svc1, *svc2;
@@ -646,14 +646,6 @@ static void do_stop_services(const char *newlevel, bool going_down, bool paralle
continue;
}
- /* We always stop the service when in these runlevels */
- if (going_down || ! start_services) {
- pid = service_stop(service->value);
- if (pid > 0 && ! parallel)
- rc_waitpid(pid);
- continue;
- }
-
/* If we're in the start list then don't bother stopping us */
svc1 = rc_stringlist_find(start_services, service->value);
if (svc1) {
@@ -1024,34 +1016,28 @@ int main(int argc, char **argv)
/* Load our list of hotplugged services */
hotplugged_services = rc_services_in_state(RC_SERVICE_HOTPLUGGED);
- if (strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SINGLE) != 0 &&
- strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SHUTDOWN) != 0 &&
- strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_REBOOT) != 0)
- {
+ if (!going_down ||
+ strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SINGLE) == 0)
start_services = rc_services_in_runlevel(RC_LEVEL_SYSINIT);
- if (strcmp (newlevel ? newlevel : runlevel, RC_LEVEL_SYSINIT)
- != 0)
- {
- /* We need to include the boot runlevel services */
- tmplist = rc_services_in_runlevel(bootlevel);
+ if (!going_down &&
+ strcmp(newlevel ? newlevel : runlevel, RC_LEVEL_SYSINIT) != 0)
+ {
+ /* We need to include the boot runlevel services */
+ tmplist = rc_services_in_runlevel(bootlevel);
+ TAILQ_CONCAT(start_services, tmplist, entries);
+ free(tmplist);
+ if (strcmp (newlevel ? newlevel : runlevel, bootlevel) != 0) {
+ tmplist = rc_services_in_runlevel(newlevel ?
+ newlevel : runlevel);
TAILQ_CONCAT(start_services, tmplist, entries);
free(tmplist);
- if (strcmp (newlevel ? newlevel : runlevel, bootlevel)
- != 0)
- {
- tmplist = rc_services_in_runlevel(newlevel ?
- newlevel :
- runlevel);
- TAILQ_CONCAT(start_services, tmplist, entries);
- free(tmplist);
- }
+ }
- if (hotplugged_services) {
- if (!start_services)
- start_services = rc_stringlist_new();
- TAILQ_FOREACH(service, hotplugged_services, entries)
- rc_stringlist_addu(start_services, service->value);
- }
+ if (hotplugged_services) {
+ if (!start_services)
+ start_services = rc_stringlist_new();
+ TAILQ_FOREACH(service, hotplugged_services, entries)
+ rc_stringlist_addu(start_services, service->value);
}
}
@@ -1059,7 +1045,7 @@ int main(int argc, char **argv)
/* Now stop the services that shouldn't be running */
if (stop_services)
- do_stop_services(newlevel, going_down, parallel);
+ do_stop_services(newlevel, parallel);
/* Wait for our services to finish */
wait_for_services();
@@ -1089,13 +1075,6 @@ int main(int argc, char **argv)
applet, HALTSH, strerror(errno));
}
- /* Single user is done now */
- if (strcmp(runlevel, RC_LEVEL_SINGLE) == 0) {
- if (exists(INTERACTIVE))
- unlink(INTERACTIVE);
- sulogin(false);
- }
-
mkdir(RC_STARTING, 0755);
rc_plugin_run(RC_HOOK_RUNLEVEL_START_IN, runlevel);
hook_out = RC_HOOK_RUNLEVEL_START_OUT;
@@ -1159,5 +1138,9 @@ int main(int argc, char **argv)
if (regen && strcmp(runlevel, bootlevel) == 0)
unlink(RC_DEPTREE_CACHE);
+ /* Single user is done now */
+ if (strcmp(runlevel, RC_LEVEL_SINGLE) == 0)
+ sulogin(false);
+
return EXIT_SUCCESS;
}