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