Shows the scheduled shutdown action and time if there's one.
<literal>now</literal>.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--show</option></term>
+
+ <listitem><para>Show a pending shutdown action and time if
+ there is any.</para></listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
" -k Don't halt/power-off/reboot, just send warnings\n"
" --no-wall Don't send wall message before halt/power-off/reboot\n"
" -c Cancel a pending shutdown\n"
+ " --show Show pending shutdown\n"
"\nSee the %s for details.\n",
program_invocation_short_name,
ansi_highlight(),
int shutdown_parse_argv(int argc, char *argv[]) {
enum {
ARG_HELP = 0x100,
- ARG_NO_WALL
+ ARG_NO_WALL,
+ ARG_SHOW
};
static const struct option options[] = {
{ "reboot", no_argument, NULL, 'r' },
{ "kexec", no_argument, NULL, 'K' }, /* not documented extension */
{ "no-wall", no_argument, NULL, ARG_NO_WALL },
+ { "show", no_argument, NULL, ARG_SHOW },
{}
};
arg_action = ACTION_CANCEL_SHUTDOWN;
break;
+ case ARG_SHOW:
+ arg_action = ACTION_SHOW_SHUTDOWN;
+ break;
+
case '?':
return -EINVAL;
#endif
}
+int logind_show_shutdown(void) {
+#if ENABLE_LOGIND
+ _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
+ sd_bus *bus;
+ const char *action = NULL;
+ uint64_t elapse;
+ int r;
+
+ r = acquire_bus(BUS_FULL, &bus);
+ if (r < 0)
+ return r;
+
+ r = bus_get_property(bus, bus_login_mgr, "ScheduledShutdown", &error, &reply, "(st)");
+ if (r < 0)
+ return log_error_errno(r, "Failed to query scheduled shutdown: %s", bus_error_message(&error, r));
+
+ r = sd_bus_message_read(reply, "(st)", &action, &elapse);
+ if (r < 0)
+ return r;
+
+ if (isempty(action))
+ return log_error_errno(SYNTHETIC_ERRNO(ENODATA), "No scheduled shutdown.");
+
+ log_info("%s scheduled for %s, use 'shutdown -c' to cancel.",
+ action,
+ FORMAT_TIMESTAMP_STYLE(arg_when, arg_timestamp_style));
+
+ return 0;
+#else
+ return log_error_errno(SYNTHETIC_ERRNO(ENOSYS),
+ "Not compiled with logind support, cannot show scheduled shutdowns.");
+#endif
+}
+
int help_boot_loader_entry(void) {
#if ENABLE_LOGIND
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int logind_schedule_shutdown(void);
int logind_cancel_shutdown(void);
+int logind_show_shutdown(void);
int help_boot_loader_entry(void);
r = logind_cancel_shutdown();
break;
+ case ACTION_SHOW_SHUTDOWN:
+ r = logind_show_shutdown();
+ break;
+
case ACTION_RUNLEVEL:
r = runlevel_main();
break;
ACTION_RUNLEVEL,
ACTION_TELINIT,
ACTION_CANCEL_SHUTDOWN,
+ ACTION_SHOW_SHUTDOWN,
_ACTION_MAX,
_ACTION_INVALID = -EINVAL,
};