diff --git a/TODO.md b/TODO.md index c1b52c3b..631c9e71 100644 --- a/TODO.md +++ b/TODO.md @@ -21,7 +21,6 @@ General * Add halt/poweroff/shutdown symlinks to finit and convert reboot, but only install symlinks if these tools don't already exist. * Add support for timed shutdown in Finit, including cancelled shutdown. -* Add reboot, halt, poweroff commands to `initctl` tool * SysV init and systemd use SIGUSR1 to restart their FIFO/D-Bus. Add API restart to SIGHUP callback for the same functionality in Finit. * Add `finit.conf` support for UPS notification (SIGPWR) to start a task diff --git a/initctl.c b/initctl.c index aea6df46..f98e935f 100644 --- a/initctl.c +++ b/initctl.c @@ -276,6 +276,10 @@ static int do_cond(char *cmd) return do_cond_show(NULL); } +static int do_halt (char *UNUSED(arg)) { return kill(1, SIGUSR1); } +static int do_poweroff(char *UNUSED(arg)) { return kill(1, SIGUSR2); } +static int do_reboot (char *UNUSED(arg)) { return kill(1, SIGTERM); } + static int show_version(char *UNUSED(arg)) { puts("v" PACKAGE_VERSION); @@ -413,6 +417,9 @@ static int usage(int rc) " start [:ID] Start service by job# or name, with optional ID\n" " stop [:ID] Stop/Pause a running service by job# or name\n" " restart [:ID] Restart (stop/start) service by job# or name\n" + " reboot Reboot system\n" + " halt Halt system\n" + " poweroff Halt and power off system\n" " version Show Finit version\n\n", __progname); return rc; @@ -431,6 +438,9 @@ int main(int argc, char *argv[]) { "start", do_start }, { "stop", do_stop }, { "restart", do_restart }, + { "reboot", do_reboot }, + { "halt", do_halt }, + { "poweroff", do_poweroff }, { "version", show_version }, { NULL, NULL } };