diff --git a/usr/local/bin/check_updates b/usr/local/bin/check_updates index fedd88d..210c4ee 100755 --- a/usr/local/bin/check_updates +++ b/usr/local/bin/check_updates @@ -5,7 +5,7 @@ usage() { USAGE=$(cat < Found $line"; -done < "$DOCKER_CHECK_LIST_FILE" +done < "$listFileToUse" # check if current status is in array of DOCKER_CHECK_NOTIFY_LEVELS function shouldLog() { diff --git a/usr/local/bin/docker_compose_update b/usr/local/bin/docker_compose_update index cebd83a..3f2c565 100755 --- a/usr/local/bin/docker_compose_update +++ b/usr/local/bin/docker_compose_update @@ -5,7 +5,7 @@ usage() { USAGE=$(cat < Found $line"; -done < "$SYSTEMD_CHECK_LIST_FILE" +done < "$listFileToUse" # get status for a service function checkService() { diff --git a/usr/local/bin/systemd_failure_notify b/usr/local/bin/systemd_failure_notify index 91aac9d..b4ff7e0 100755 --- a/usr/local/bin/systemd_failure_notify +++ b/usr/local/bin/systemd_failure_notify @@ -14,7 +14,7 @@ OnFailure=systemd_failure_notify@%n.service You should place the 's service into systemd's user and systemd's system folder so it can be used by global and user services. -If no CONFIG_FILE is given, HOME/.systemd_failure_notify.conf is used. This fallback option +If no CONFIG_FILE is given, HOME/.systemd_failure_notify.conf or /etc/systemd_failure_notify.conf is used. This fallback option has to exist or the script will exit. Configuration can be done in any file and any pre-defined variable can be overwritten. @@ -43,26 +43,42 @@ SYSTEMD_FAILURE_NOTFY_USER=$(whoami) SYSTEMD_FAILURE_NOTIFY_MAIL_ADDRESS=""; # check for config file -source_config() { - local config=$1; - local configFallback=$2; +apply_config() { + local config=$1; - if [[ ! -f "$config" ]]; then - if [[ ! -f "$configFallback" ]]; then - echo "No config file specified and could not find default in '$configFallback'!"; - echo ""; - usage; - exit 1; - else - config=$configFallback; - fi - fi + if [[ ! -f "$config" ]]; then + echo "No config file specified"; + echo ""; + usage; + exit 1; + fi - set -a; - source "$config"; - set +a; + set -a; + source "$config"; + set +a; } -source_config "$2" "$HOME/.systemd_failure_notify.conf" + +source_config() { + local config=$1; + local configFallback=$2; + local configGlobalFallback=$3; + + if [[ -f "$config" ]]; then + apply_config "$config"; + exit 0; + fi + + if [[ -f "$configFallback" ]]; then + apply_config "$configFallback"; + exit 0; + fi + + if [[ -f "$configGlobalFallback" ]]; then + apply_config "$configGlobalFallback"; + exit 0; + fi +} +source_config "$2" "$HOME/.systemd_failure_notify.conf" "/etc/systemd_failure_notify.conf" SUBJECT="[systemd $SYSTEMD_FAILURE_NOTFY_HOSTNAME for $SYSTEMD_FAILURE_NOTFY_USER] $SYSTEMD_FAILURE_NOTFY_SERVICE RUN FAILED" MESSAGE="$SYSTEMD_FAILURE_NOTFY_SERVICE run failed"