systemctl: consistent output for scheduled shutdowns

Use same terms when scheduling and showing sheduled shutdowns.
This commit is contained in:
Ludwig Nussel
2022-01-05 13:17:50 +01:00
parent 2dbb54788e
commit 8e98568165

View File

@@ -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));