From: Ludwig Nussel Date: Wed, 5 Jan 2022 12:17:50 +0000 (+0100) Subject: systemctl: consistent output for scheduled shutdowns X-Git-Tag: v251-rc1~560^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F22019%2Fhead;p=thirdparty%2Fsystemd.git systemctl: consistent output for scheduled shutdowns Use same terms when scheduling and showing sheduled shutdowns. --- diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c index 114641cdc7a..9eae59ca310 100644 --- a/src/systemctl/systemctl-logind.c +++ b/src/systemctl/systemctl-logind.c @@ -297,7 +297,6 @@ int logind_schedule_shutdown(void) { #if ENABLE_LOGIND _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; const char *action; - const char *log_action; sd_bus *bus; int r; @@ -308,24 +307,19 @@ int logind_schedule_shutdown(void) { switch (arg_action) { case ACTION_HALT: action = "halt"; - log_action = "Shutdown"; break; case ACTION_POWEROFF: action = "poweroff"; - log_action = "Shutdown"; break; case ACTION_KEXEC: action = "kexec"; - log_action = "Reboot via kexec"; break; case ACTION_EXIT: action = "exit"; - log_action = "Shutdown"; break; case ACTION_REBOOT: default: action = "reboot"; - log_action = "Reboot"; break; } @@ -339,9 +333,8 @@ int logind_schedule_shutdown(void) { return log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s", bus_error_message(&error, r)); if (!arg_quiet) - log_info("%s scheduled for %s, use 'shutdown -c' to cancel.", - log_action, - FORMAT_TIMESTAMP_STYLE(arg_when, arg_timestamp_style)); + logind_show_shutdown(); + return 0; #else return log_error_errno(SYNTHETIC_ERRNO(ENOSYS), @@ -396,6 +389,13 @@ int logind_show_shutdown(void) { if (isempty(action)) return log_error_errno(SYNTHETIC_ERRNO(ENODATA), "No scheduled shutdown."); + if (streq(action, "halt") || streq(action, "poweroff") || streq(action, "exit")) + action = "Shutdown"; + else if (streq(action, "kexec")) + action = "Reboot via kexec"; + else if (streq(action, "reboot")) + action = "Reboot"; + log_info("%s scheduled for %s, use 'shutdown -c' to cancel.", action, FORMAT_TIMESTAMP_STYLE(elapse, arg_timestamp_style));