diff options
Diffstat (limited to 'src/rc/openrc-shutdown.c')
-rw-r--r-- | src/rc/openrc-shutdown.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c index 4dcd7e16..ec240b2a 100644 --- a/src/rc/openrc-shutdown.c +++ b/src/rc/openrc-shutdown.c @@ -330,16 +330,29 @@ int main(int argc, char **argv) unlink(nologin_file); unlink(shutdown_pid); if (do_halt) { - sysvinit_runlevel('0'); - send_cmd("halt"); + if (exists("/run/initctl")) { + sysvinit_setenv("INIT_HALT", "HALT"); + sysvinit_runlevel('0'); + } else + send_cmd("halt"); } else if (do_kexec) send_cmd("kexec"); - else if (do_poweroff) - send_cmd("poweroff"); - else if (do_reboot) { - sysvinit_runlevel('6'); + else if (do_poweroff) { + if (exists("/run/initctl")) { + sysvinit_setenv("INIT_HALT", "POWEROFF"); + sysvinit_runlevel('0'); + } else + send_cmd("poweroff"); + } else if (do_reboot) { + if (exists("/run/initctl")) + sysvinit_runlevel('6'); + else send_cmd("reboot"); - } else if (do_single) - send_cmd("single"); + } else if (do_single) { + if (exists("/run/initctl")) + sysvinit_runlevel('S'); + else + send_cmd("single"); + } return 0; } |