Check required vars before using them
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alexander Schäferdiek 2023-01-25 16:13:13 +01:00
parent 71977c9dca
commit c4816b054b

View file

@ -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"