initctl: add reboot, halt, and poweroff commands

Simple wrappers for the signals Finit responds to.  Will need complete
rewrite when support for delayed reboot/halt is added.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-08-04 22:45:05 +02:00
parent 6490735ee9
commit baa914e995
2 changed files with 10 additions and 1 deletions
-1
View File
@@ -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
+10
View File
@@ -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 <JOB|NAME>[:ID] Start service by job# or name, with optional ID\n"
" stop <JOB|NAME>[:ID] Stop/Pause a running service by job# or name\n"
" restart <JOB|NAME>[: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 }
};