]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: add "systemctl soft-reboot" command
authorLennart Poettering <lennart@poettering.net>
Thu, 27 Apr 2023 19:56:20 +0000 (21:56 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 2 Jun 2023 14:49:38 +0000 (16:49 +0200)
src/systemctl/systemctl-logind.c
src/systemctl/systemctl-start-special.c
src/systemctl/systemctl-start-unit.c
src/systemctl/systemctl-trivial-method.c
src/systemctl/systemctl.c
src/systemctl/systemctl.h

index fd8ca09de88fb02864d86193cc61b117ef2432c1..a4486dcce902c3e81390c64aab90f17347436c29 100644 (file)
@@ -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",
@@ -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)
index c6084f373ee947191187e7564a57fa4e8cdbba05..6e2238f2a5ebc94a6ef9e08cbd301991c48bc89a 100644 (file)
@@ -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)
index 3dac7da460b417e357c66e36ba9b12321ed0f962..8268217967ba79429fc9aee71bbd241609847759 100644 (file)
@@ -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"              },
index 5e530f3a143ffbf6c007be8fb248da66d3213838..02a29123e764c064c9da76350d8e2e40d83c01bb 100644 (file)
@@ -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";
 
index b31a59785b2c4a88a826da6228d86573de0223a9..143c8b41b28aa525a41006d1e3d8387b994a10ff 100644 (file)
@@ -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"
@@ -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"
@@ -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    },
index 03645624ee82706630b6d1e058495f3091d3c043..e8ba8f76a07e9b8bc8edeaf0bf464d187c496504 100644 (file)
@@ -16,6 +16,7 @@ enum action {
         ACTION_POWEROFF,
         ACTION_REBOOT,
         ACTION_KEXEC,
+        ACTION_SOFT_REBOOT,
         ACTION_EXIT,
         ACTION_SUSPEND,
         ACTION_HIBERNATE,