diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-06-18 02:28:35 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-06-18 02:28:35 +0200 |
commit | ef2f1067d0ca0e6d7346aa3e082048821b670b54 (patch) | |
tree | a7842328e351cf04affebfecfb516eb950e72cae /src/systemctl.c | |
parent | 139be57d9441b5c890e1e4ee69e15aad03276fde (diff) |
systemctl: warn users via wall that the system goes down
Diffstat (limited to 'src/systemctl.c')
-rw-r--r-- | src/systemctl.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/systemctl.c b/src/systemctl.c index 850efe2dd4..aad9ba039b 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -53,7 +53,6 @@ enum action { ACTION_HALT, ACTION_POWEROFF, ACTION_REBOOT, - ACTION_RUNLEVEL1, ACTION_RUNLEVEL2, ACTION_RUNLEVEL3, ACTION_RUNLEVEL4, @@ -117,6 +116,20 @@ static int columns(void) { } +static void warn_wall(void) { + 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_RESCUE] = "The system is going down to rescue mode NOW!" + }; + + if (!table[arg_action]) + return; + + utmp_wall(table[arg_action]); +} + static int list_units(DBusConnection *bus, char **args, unsigned n) { DBusMessage *m = NULL, *reply = NULL; DBusError error; @@ -662,7 +675,6 @@ static int start_unit(DBusConnection *bus, char **args, unsigned n) { [ACTION_HALT] = "halt.target", [ACTION_POWEROFF] = "poweroff.target", [ACTION_REBOOT] = "reboot.target", - [ACTION_RUNLEVEL1] = "runlevel1.target", [ACTION_RUNLEVEL2] = "runlevel2.target", [ACTION_RUNLEVEL3] = "runlevel3.target", [ACTION_RUNLEVEL4] = "runlevel4.target", @@ -1648,7 +1660,7 @@ static int telinit_parse_argv(int argc, char *argv[]) { } table[] = { { '0', ACTION_POWEROFF }, { '6', ACTION_REBOOT }, - { '1', ACTION_RUNLEVEL1 }, + { '1', ACTION_RESCUE }, { '2', ACTION_RUNLEVEL2 }, { '3', ACTION_RUNLEVEL3 }, { '4', ACTION_RUNLEVEL4 }, @@ -1907,6 +1919,8 @@ static int reload_with_fallback(DBusConnection *bus) { static int start_with_fallback(DBusConnection *bus) { int r; + warn_wall(); + if (bus) { /* First, try systemd via D-Bus. */ if ((r = start_unit(bus, NULL, 0)) > 0) @@ -1929,6 +1943,8 @@ static int halt_main(DBusConnection *bus) { if (!arg_immediate) return start_with_fallback(bus); + warn_wall(); + if (!arg_no_wtmp) if ((r = utmp_put_shutdown(0)) < 0) log_warning("Failed to write utmp record: %s", strerror(-r)); @@ -2028,7 +2044,6 @@ int main(int argc, char*argv[]) { retval = halt_main(bus) < 0; break; - case ACTION_RUNLEVEL1: case ACTION_RUNLEVEL2: case ACTION_RUNLEVEL3: case ACTION_RUNLEVEL4: |