systemctl: set reboot argument for most forms of shutdown, not just plain reboots
authorLennart Poettering <lennart@poettering.net>
Tue, 23 Apr 2024 08:14:41 +0000 (10:14 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 23 Apr 2024 09:04:08 +0000 (11:04 +0200)
This doesn't hurt anyway, and is useful now that we propagate the string
via sd_notify() too.

src/systemctl/systemctl-start-special.c

index d486b406da556cd8e9bd156dd994f454082645d7..4b99d0c62940d6d1518297668312482cfe4f3af6 100644 (file)
@@ -155,14 +155,16 @@ int verb_start_special(int argc, char *argv[], void *userdata) {
                         return r;
         }
 
-        if (a == ACTION_REBOOT) {
-                if (arg_reboot_argument) {
-                        r = update_reboot_parameter_and_warn(arg_reboot_argument, false);
-                        if (r < 0)
-                                return r;
-                }
+        if (arg_reboot_argument && IN_SET(a, ACTION_HALT, ACTION_POWEROFF, ACTION_REBOOT, ACTION_KEXEC)) {
+                /* If we are going through an action that involves systemd-shutdown, let's set the reboot
+                 * parameter, even if it's not a regular reboot. After all we nowadays send the string to
+                 * our supervisor via sd_notify() too. */
+                r = update_reboot_parameter_and_warn(arg_reboot_argument, /* keep= */ false);
+                if (r < 0)
+                        return r;
+        }
 
-        } else if (a == ACTION_KEXEC) {
+        if (a == ACTION_KEXEC) {
                 r = load_kexec_kernel();
                 if (r < 0 && arg_force >= 1)
                         log_notice("Failed to load kexec kernel, continuing without.");