Skip to content

Commit 8e98568

Browse files
committed
systemctl: consistent output for scheduled shutdowns
Use same terms when scheduling and showing sheduled shutdowns.
1 parent 2dbb547 commit 8e98568

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/systemctl/systemctl-logind.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ int logind_schedule_shutdown(void) {
297297
#if ENABLE_LOGIND
298298
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
299299
const char *action;
300-
const char *log_action;
301300
sd_bus *bus;
302301
int r;
303302

@@ -308,24 +307,19 @@ int logind_schedule_shutdown(void) {
308307
switch (arg_action) {
309308
case ACTION_HALT:
310309
action = "halt";
311-
log_action = "Shutdown";
312310
break;
313311
case ACTION_POWEROFF:
314312
action = "poweroff";
315-
log_action = "Shutdown";
316313
break;
317314
case ACTION_KEXEC:
318315
action = "kexec";
319-
log_action = "Reboot via kexec";
320316
break;
321317
case ACTION_EXIT:
322318
action = "exit";
323-
log_action = "Shutdown";
324319
break;
325320
case ACTION_REBOOT:
326321
default:
327322
action = "reboot";
328-
log_action = "Reboot";
329323
break;
330324
}
331325

@@ -339,9 +333,8 @@ int logind_schedule_shutdown(void) {
339333
return log_warning_errno(r, "Failed to call ScheduleShutdown in logind, proceeding with immediate shutdown: %s", bus_error_message(&error, r));
340334

341335
if (!arg_quiet)
342-
log_info("%s scheduled for %s, use 'shutdown -c' to cancel.",
343-
log_action,
344-
FORMAT_TIMESTAMP_STYLE(arg_when, arg_timestamp_style));
336+
logind_show_shutdown();
337+
345338
return 0;
346339
#else
347340
return log_error_errno(SYNTHETIC_ERRNO(ENOSYS),
@@ -396,6 +389,13 @@ int logind_show_shutdown(void) {
396389
if (isempty(action))
397390
return log_error_errno(SYNTHETIC_ERRNO(ENODATA), "No scheduled shutdown.");
398391

392+
if (streq(action, "halt") || streq(action, "poweroff") || streq(action, "exit"))
393+
action = "Shutdown";
394+
else if (streq(action, "kexec"))
395+
action = "Reboot via kexec";
396+
else if (streq(action, "reboot"))
397+
action = "Reboot";
398+
399399
log_info("%s scheduled for %s, use 'shutdown -c' to cancel.",
400400
action,
401401
FORMAT_TIMESTAMP_STYLE(elapse, arg_timestamp_style));

0 commit comments

Comments
 (0)