From 2bf21fd75f0eaed1529f1cd086676b54e209d46b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=B6rdle=20Bot?= Date: Sun, 7 Dec 2025 10:30:37 +0100 Subject: [PATCH] feat: improve Gotify variable extraction in backup script - Enhanced the loading of Gotify variables from the .env file by adding checks for existing values. - Ensured that only non-empty and non-comment lines are processed for GOTIFY_URL and GOTIFY_APP_TOKEN. --- scripts/backup-restic.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/backup-restic.sh b/scripts/backup-restic.sh index 79c813c..8a2e1de 100755 --- a/scripts/backup-restic.sh +++ b/scripts/backup-restic.sh @@ -9,12 +9,13 @@ if [ -f "$HOME/.restic-env" ]; then . "$HOME/.restic-env" fi -# Load .env file if present (for Gotify variables) -if [ -f ".env" ]; then - # shellcheck source=/dev/null - set -a - . ".env" - set +a +# Extract Gotify variables from .env file if not set (ignore comments and empty lines) +if [ -z "$GOTIFY_URL" ] && [ -f ".env" ]; then + GOTIFY_URL=$(grep -v '^#' .env | grep -v '^$' | grep '^GOTIFY_URL=' | head -1 | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs || echo "") +fi + +if [ -z "$GOTIFY_APP_TOKEN" ] && [ -f ".env" ]; then + GOTIFY_APP_TOKEN=$(grep -v '^#' .env | grep -v '^$' | grep '^GOTIFY_APP_TOKEN=' | head -1 | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs || echo "") fi # Extract Gotify variables from docker-compose.yml if not set