From c65bd6cc7eb000fa3a40ebb33718752ac259629c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 23 Apr 2024 10:14:41 +0200 Subject: [PATCH] systemctl: set reboot argument for most forms of shutdown, not just plain reboots This doesn't hurt anyway, and is useful now that we propagate the string via sd_notify() too. --- src/systemctl/systemctl-start-special.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/systemctl/systemctl-start-special.c b/src/systemctl/systemctl-start-special.c index d486b406da5..4b99d0c6294 100644 --- a/src/systemctl/systemctl-start-special.c +++ b/src/systemctl/systemctl-start-special.c @@ -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."); -- 2.47.3