summaryrefslogtreecommitdiff
authorMichal Sekletar <msekleta@redhat.com>2012-07-30 15:25:39 (GMT)
committer Michal Schmidt <mschmidt@redhat.com>2012-08-06 14:25:55 (GMT)
commitdfcc5c33f42554a5293e68e7093da2403e363997 (patch) (side-by-side diff)
treed6f004cd8775200a8d329fc28d365e2063d954cd
parent9cb48731b29f508178731b45b0643c816800c05e (diff)
downloadsystemd-dfcc5c33f42554a5293e68e7093da2403e363997.zip
systemd-dfcc5c33f42554a5293e68e7093da2403e363997.tar.gz
shutdown: allow to specify broadcast message when cancelling shutdown
makes shutdown behaviour more compatible
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/shutdownd/shutdownd.c4
-rw-r--r--src/systemctl/systemctl.c39
2 files changed, 32 insertions, 11 deletions
diff --git a/src/shutdownd/shutdownd.c b/src/shutdownd/shutdownd.c
index d426d98..c074741 100644
--- a/src/shutdownd/shutdownd.c
+++ b/src/shutdownd/shutdownd.c
@@ -136,6 +136,8 @@ static void warn_wall(usec_t n, struct sd_shutdown_command *c) {
prefix = "The system is going down for reboot at ";
else if (c->mode == SD_SHUTDOWN_KEXEC)
prefix = "The system is going down for kexec reboot at ";
+ else if (c->mode == SD_SHUTDOWN_NONE)
+ prefix = "The system shutdown has been cancelled at ";
else
assert_not_reached("Unknown mode!");
@@ -354,6 +356,8 @@ int main(int argc, char *argv[]) {
if (!scheduled(&b.command)) {
log_info("Shutdown canceled.");
+ if (b.command.warn_wall)
+ warn_wall(0, &b.command);
break;
}
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index e74f186..00cd252 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -247,12 +247,13 @@ static int translate_bus_error_to_exit_status(int r, const DBusError *error) {
static void warn_wall(enum action a) {
static const char *table[_ACTION_MAX] = {
- [ACTION_HALT] = "The system is going down for system halt NOW!",
- [ACTION_REBOOT] = "The system is going down for reboot NOW!",
- [ACTION_POWEROFF] = "The system is going down for power-off NOW!",
- [ACTION_KEXEC] = "The system is going down for kexec reboot NOW!",
- [ACTION_RESCUE] = "The system is going down to rescue mode NOW!",
- [ACTION_EMERGENCY] = "The system is going down to emergency mode NOW!"
+ [ACTION_HALT] = "The system is going down for system halt NOW!",
+ [ACTION_REBOOT] = "The system is going down for reboot NOW!",
+ [ACTION_POWEROFF] = "The system is going down for power-off NOW!",
+ [ACTION_KEXEC] = "The system is going down for kexec reboot NOW!",
+ [ACTION_RESCUE] = "The system is going down to rescue mode NOW!",
+ [ACTION_EMERGENCY] = "The system is going down to emergency mode NOW!",
+ [ACTION_CANCEL_SHUTDOWN] = "The system shutdown has been cancelled NOW!"
};
if (arg_no_wall)
@@ -5033,7 +5034,7 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
}
}
- if (argc > optind) {
+ if (argc > optind && arg_action != ACTION_CANCEL_SHUTDOWN) {
r = parse_time_spec(argv[optind], &arg_when);
if (r < 0) {
log_error("Failed to parse time specification: %s", argv[optind]);
@@ -5042,8 +5043,11 @@ static int shutdown_parse_argv(int argc, char *argv[]) {
} else
arg_when = now(CLOCK_REALTIME) + USEC_PER_MINUTE;
- /* We skip the time argument */
- if (argc > optind + 1)
+ if (argc > optind && arg_action == ACTION_CANCEL_SHUTDOWN)
+ /* No time argument for shutdown cancel */
+ arg_wall = argv + optind;
+ else if (argc > optind + 1)
+ /* We skip the time argument */
arg_wall = argv + optind + 1;
optind = argc;
@@ -5822,9 +5826,22 @@ int main(int argc, char*argv[]) {
r = reload_with_fallback(bus);
break;
- case ACTION_CANCEL_SHUTDOWN:
- r = send_shutdownd(0, 0, false, false, NULL);
+ case ACTION_CANCEL_SHUTDOWN: {
+ char *m = NULL;
+
+ if (arg_wall) {
+ m = strv_join(arg_wall, " ");
+ if (!m) {
+ retval = EXIT_FAILURE;
+ goto finish;
+ }
+ }
+ r = send_shutdownd(arg_when, SD_SHUTDOWN_NONE, false, !arg_no_wall, m);
+ if (r < 0)
+ log_warning("Failed to talk to shutdownd, shutdown hasn't been cancelled: %s", strerror(-r));
+ free(m);
break;
+ }
case ACTION_INVALID:
case ACTION_RUNLEVEL: