Skip to content

Commit

Permalink
systemctl: add "systemctl soft-reboot" command
Browse files Browse the repository at this point in the history
  • Loading branch information
poettering committed Jun 2, 2023
1 parent 9edf5af commit 34f21ff
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/systemctl/systemctl-logind.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ int logind_reboot(enum action a) {
[ACTION_POWEROFF] = "PowerOff",
[ACTION_REBOOT] = "Reboot",
[ACTION_KEXEC] = "Reboot",
[ACTION_SOFT_REBOOT] = "Reboot",
[ACTION_HALT] = "Halt",
[ACTION_SUSPEND] = "Suspend",
[ACTION_HIBERNATE] = "Hibernate",
Expand Down Expand Up @@ -80,6 +81,7 @@ int logind_reboot(enum action a) {

SET_FLAG(flags, SD_LOGIND_ROOT_CHECK_INHIBITORS, arg_check_inhibitors > 0);
SET_FLAG(flags, SD_LOGIND_REBOOT_VIA_KEXEC, a == ACTION_KEXEC);
SET_FLAG(flags, SD_LOGIND_SOFT_REBOOT, a == ACTION_SOFT_REBOOT);

r = bus_call_method(bus, bus_login_mgr, method_with_flags, &error, NULL, "t", flags);
if (r >= 0)
Expand Down
1 change: 1 addition & 0 deletions src/systemctl/systemctl-start-special.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ int verb_start_special(int argc, char *argv[], void *userdata) {
case ACTION_REBOOT:
case ACTION_KEXEC:
case ACTION_HALT:
case ACTION_SOFT_REBOOT:
if (arg_when == 0)
r = logind_reboot(a);
else if (arg_when != USEC_INFINITY)
Expand Down
1 change: 1 addition & 0 deletions src/systemctl/systemctl-start-unit.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ const struct action_metadata action_table[_ACTION_MAX] = {
[ACTION_POWEROFF] = { SPECIAL_POWEROFF_TARGET, "poweroff", "replace-irreversibly" },
[ACTION_REBOOT] = { SPECIAL_REBOOT_TARGET, "reboot", "replace-irreversibly" },
[ACTION_KEXEC] = { SPECIAL_KEXEC_TARGET, "kexec", "replace-irreversibly" },
[ACTION_SOFT_REBOOT] = { SPECIAL_SOFT_REBOOT_TARGET, "soft-reboot", "replace-irreversibly" },
[ACTION_RUNLEVEL2] = { SPECIAL_MULTI_USER_TARGET, NULL, "isolate" },
[ACTION_RUNLEVEL3] = { SPECIAL_MULTI_USER_TARGET, NULL, "isolate" },
[ACTION_RUNLEVEL4] = { SPECIAL_MULTI_USER_TARGET, NULL, "isolate" },
Expand Down
1 change: 1 addition & 0 deletions src/systemctl/systemctl-trivial-method.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ int verb_trivial_method(int argc, char *argv[], void *userdata) {
streq(argv[0], "halt") ? "Halt" :
streq(argv[0], "reboot") ? "Reboot" :
streq(argv[0], "kexec") ? "KExec" :
streq(argv[0], "soft-reboot") ? "SoftReboot" :
streq(argv[0], "exit") ? "Exit" :
/* poweroff */ "PowerOff";

Expand Down
7 changes: 5 additions & 2 deletions src/systemctl/systemctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ static int systemctl_help(void) {
" poweroff Shut down and power-off the system\n"
" reboot Shut down and reboot the system\n"
" kexec Shut down and reboot the system with kexec\n"
" soft-reboot Shut down and reboot userspace\n"
" exit [EXIT_CODE] Request user instance or container exit\n"
" switch-root [ROOT [INIT]] Change to a different root file system\n"
" suspend Suspend the system\n"
Expand Down Expand Up @@ -285,8 +286,9 @@ static int systemctl_help(void) {
" --now Start or stop unit after enabling or disabling it\n"
" --dry-run Only print what would be done\n"
" Currently supported by verbs: halt, poweroff, reboot,\n"
" kexec, suspend, hibernate, suspend-then-hibernate,\n"
" hybrid-sleep, default, rescue, emergency, and exit.\n"
" kexec, soft-reboot, suspend, hibernate, \n"
" suspend-then-hibernate, hybrid-sleep, default,\n"
" rescue, emergency, and exit.\n"
" -q --quiet Suppress output\n"
" --no-warn Suppress several warnings shown by default\n"
" --wait For (re)start, wait until service stopped again\n"
Expand Down Expand Up @@ -1180,6 +1182,7 @@ static int systemctl_main(int argc, char *argv[]) {
{ "poweroff", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "reboot", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "kexec", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "soft-reboot", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "suspend", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "hibernate", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
{ "hybrid-sleep", VERB_ANY, 1, VERB_ONLINE_ONLY, verb_start_system_special },
Expand Down
1 change: 1 addition & 0 deletions src/systemctl/systemctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ enum action {
ACTION_POWEROFF,
ACTION_REBOOT,
ACTION_KEXEC,
ACTION_SOFT_REBOOT,
ACTION_EXIT,
ACTION_SUSPEND,
ACTION_HIBERNATE,
Expand Down

0 comments on commit 34f21ff

Please sign in to comment.