]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: consistent output for scheduled shutdowns 22019/head
authorLudwig Nussel <ludwig.nussel@suse.de>
Wed, 5 Jan 2022 12:17:50 +0000 (13:17 +0100)
committerLudwig Nussel <ludwig.nussel@suse.de>
Mon, 10 Jan 2022 08:09:50 +0000 (09:09 +0100)
Use same terms when scheduling and showing sheduled shutdowns.

src/systemctl/systemctl-logind.c

index 114641cdc7a5d9d37ebee704820667febc4c6467..9eae59ca31050675dcd39bb515be8bced35fface 100644 (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));