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.
This commit is contained in:
Hördle Bot
2025-12-07 10:30:37 +01:00
parent e48d823c92
commit 2bf21fd75f

View File

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