diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-10-27 23:14:23 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-10-27 23:17:49 -0400 |
commit | ebc5788e88eb9e1ebd032bd61507c196142acbab (patch) | |
tree | 634ef6f7ce31767770c0e105186f56f1dabfe7f6 /src/core | |
parent | 127d5fd1563a74411aaceeadd251f98fd52216d7 (diff) |
manager: print warning on console before reboot
It will be printed even if a prompt is blocking other messages.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/failure-action.c | 20 | ||||
-rw-r--r-- | src/core/manager.c | 2 | ||||
-rw-r--r-- | src/core/manager.h | 1 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/core/failure-action.c b/src/core/failure-action.c index 941747429f..ce522a4e4f 100644 --- a/src/core/failure-action.c +++ b/src/core/failure-action.c @@ -29,6 +29,13 @@ #include "special.h" #include "failure-action.h" +static void log_and_status(Manager *m, const char *message) { + log_warning("%s", message); + manager_status_printf(m, STATUS_TYPE_EMERGENCY, + ANSI_HIGHLIGHT_RED_ON " !! " ANSI_HIGHLIGHT_OFF, + "%s", message); +} + int failure_action( Manager *m, FailureAction action, @@ -57,7 +64,7 @@ int failure_action( case FAILURE_ACTION_REBOOT: { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; - log_warning("Rebooting as result of failure."); + log_and_status(m, "Rebooting as result of failure."); update_reboot_param_file(reboot_arg); r = manager_add_job_by_name(m, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE, true, &error, NULL); @@ -68,13 +75,14 @@ int failure_action( } case FAILURE_ACTION_REBOOT_FORCE: - log_warning("Forcibly rebooting as result of failure."); + log_and_status(m, "Forcibly rebooting as result of failure."); + update_reboot_param_file(reboot_arg); m->exit_code = MANAGER_REBOOT; break; case FAILURE_ACTION_REBOOT_IMMEDIATE: - log_warning("Rebooting immediately as result of failure."); + log_and_status(m, "Rebooting immediately as result of failure."); sync(); @@ -90,7 +98,7 @@ int failure_action( case FAILURE_ACTION_POWEROFF: { _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL; - log_warning("Powering off as result of failure."); + log_and_status(m, "Powering off as result of failure."); r = manager_add_job_by_name(m, JOB_START, SPECIAL_POWEROFF_TARGET, JOB_REPLACE, true, &error, NULL); if (r < 0) @@ -100,12 +108,12 @@ int failure_action( } case FAILURE_ACTION_POWEROFF_FORCE: - log_warning("Forcibly powering off as result of failure."); + log_and_status(m, "Forcibly powering off as result of failure."); m->exit_code = MANAGER_POWEROFF; break; case FAILURE_ACTION_POWEROFF_IMMEDIATE: - log_warning("Powering off immediately as result of failure."); + log_and_status(m, "Powering off immediately as result of failure."); sync(); diff --git a/src/core/manager.c b/src/core/manager.c index 859631d3f6..d427d88d4e 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -2944,7 +2944,7 @@ static bool manager_get_show_status(Manager *m, StatusType type) { return false; /* If we cannot find out the status properly, just proceed. */ - if (manager_check_ask_password(m) > 0) + if (type != STATUS_TYPE_EMERGENCY && manager_check_ask_password(m) > 0) return false; if (m->show_status > 0) diff --git a/src/core/manager.h b/src/core/manager.h index d0c0f58d0b..ab7254849c 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -63,6 +63,7 @@ typedef enum ManagerExitCode { typedef enum StatusType { STATUS_TYPE_EPHEMERAL, STATUS_TYPE_NORMAL, + STATUS_TYPE_EMERGENCY, } StatusType; #include "unit.h" |