From c4816b054b949cedfdf327710fdd9ce362ac4ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Sch=C3=A4ferdiek?= Date: Wed, 25 Jan 2023 16:13:13 +0100 Subject: [PATCH] Check required vars before using them --- usr/local/bin/systemd_failure_notify | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/usr/local/bin/systemd_failure_notify b/usr/local/bin/systemd_failure_notify index f9f513c..3a4ac38 100755 --- a/usr/local/bin/systemd_failure_notify +++ b/usr/local/bin/systemd_failure_notify @@ -21,12 +21,8 @@ if [ -z "$SYSTEMD_FAILURE_NOTFY_SERVICE" ]; then exit 1; fi -SYSTEMD_FAILURE_NOTFY_HOSTNAME=$(hostname) -SYSTEMD_FAILURE_NOTFY_USER=$(whoami) - SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED="true"; SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS=""; - SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED="false"; # check for config file @@ -85,6 +81,9 @@ source_config() { source_config "$2" "$HOME/.systemd_failure_notify.conf" "/etc/systemd_failure_notify.conf" check_requirements "$SYSTEMD_FAILURE_NOTIFY_MAIL_ENABLED" "$SYSTEMD_FAILURE_NOTIFY_GOTIFY_ENABLED" +SYSTEMD_FAILURE_NOTFY_HOSTNAME=$(hostname) +SYSTEMD_FAILURE_NOTFY_USER=$(whoami) + SUBJECT="[systemd $SYSTEMD_FAILURE_NOTFY_HOSTNAME for $SYSTEMD_FAILURE_NOTFY_USER] $SYSTEMD_FAILURE_NOTFY_SERVICE RUN FAILED" MESSAGE="$SYSTEMD_FAILURE_NOTFY_SERVICE run failed"