diff options
author | Roy Marples <roy@marples.name> | 2008-12-21 01:15:02 +0000 |
---|---|---|
committer | Roy Marples <roy@marples.name> | 2008-12-21 01:15:02 +0000 |
commit | 803dbbf0c808cf8d24b44bf3e944175366ff92a6 (patch) | |
tree | b90e65c31d0f6013ad2470f84a2bfb9162a0c3f5 | |
parent | 9e5e60f2574e1bef168b763e55a3bd5e8ae8d11c (diff) |
Allow rc_runlevel/softlevel to set runlevel from kernel commandline.
-rw-r--r-- | src/rc/rc.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/rc/rc.c b/src/rc/rc.c index 52c1e4d5..8e9cd935 100644 --- a/src/rc/rc.c +++ b/src/rc/rc.c @@ -893,8 +893,8 @@ main(int argc, char **argv) } else { /* We should not use krunevel in sysinit or the boot runlevel */ if (!newlevel || - strcmp(newlevel, RC_LEVEL_SYSINIT) != 0 || - strcmp(newlevel, getenv("RC_BOOTLEVEL")) != 0) + (strcmp(newlevel, RC_LEVEL_SYSINIT) != 0 && + strcmp(newlevel, getenv("RC_BOOTLEVEL")) != 0)) { if (get_krunlevel(krunlevel, sizeof(krunlevel))) { newlevel = krunlevel; @@ -902,10 +902,24 @@ main(int argc, char **argv) } } - if (newlevel && - strcmp(runlevel, newlevel) != 0 && - !rc_runlevel_exists(newlevel)) - eerrorx("%s: is not a valid runlevel", newlevel); + if (newlevel) { + if (strcmp(runlevel, newlevel) != 0 && + !rc_runlevel_exists(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) { @@ -1075,6 +1089,7 @@ main(int argc, char **argv) rc_service_mark(token, RC_SERVICE_STOPPED); free(proc); } + #endif rc_plugin_run(RC_HOOK_RUNLEVEL_START_OUT, runlevel); |