Allow rc_runlevel/softlevel to set runlevel from kernel commandline.

This commit is contained in:
Roy Marples 2008-12-21 01:15:02 +00:00
parent 9e5e60f257
commit 803dbbf0c8

View File

@ -893,8 +893,8 @@ main(int argc, char **argv)
} else { } else {
/* We should not use krunevel in sysinit or the boot runlevel */ /* We should not use krunevel in sysinit or the boot runlevel */
if (!newlevel || if (!newlevel ||
strcmp(newlevel, RC_LEVEL_SYSINIT) != 0 || (strcmp(newlevel, RC_LEVEL_SYSINIT) != 0 &&
strcmp(newlevel, getenv("RC_BOOTLEVEL")) != 0) strcmp(newlevel, getenv("RC_BOOTLEVEL")) != 0))
{ {
if (get_krunlevel(krunlevel, sizeof(krunlevel))) { if (get_krunlevel(krunlevel, sizeof(krunlevel))) {
newlevel = krunlevel; newlevel = krunlevel;
@ -902,10 +902,24 @@ main(int argc, char **argv)
} }
} }
if (newlevel && if (newlevel) {
strcmp(runlevel, newlevel) != 0 && if (strcmp(runlevel, newlevel) != 0 &&
!rc_runlevel_exists(newlevel)) !rc_runlevel_exists(newlevel))
eerrorx("%s: is not a valid runlevel", newlevel); eerrorx("%s: not a valid runlevel", newlevel);
#ifdef __linux__
if (strcmp(newlevel, RC_LEVEL_SYSINIT) == 0) {
/* If we requested a runlevel, save it now */
p = proc_getent("rc_runlevel");
if (p == NULL)
p = proc_getent("softlevel");
if (p != NULL) {
set_krunlevel(p);
free(p);
}
}
}
#endif
} }
if (going_down) { if (going_down) {
@ -1075,6 +1089,7 @@ main(int argc, char **argv)
rc_service_mark(token, RC_SERVICE_STOPPED); rc_service_mark(token, RC_SERVICE_STOPPED);
free(proc); free(proc);
} }
#endif #endif
rc_plugin_run(RC_HOOK_RUNLEVEL_START_OUT, runlevel); rc_plugin_run(RC_HOOK_RUNLEVEL_START_OUT, runlevel);