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:
@@ -9,12 +9,13 @@ if [ -f "$HOME/.restic-env" ]; then
|
|||||||
. "$HOME/.restic-env"
|
. "$HOME/.restic-env"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load .env file if present (for Gotify variables)
|
# Extract Gotify variables from .env file if not set (ignore comments and empty lines)
|
||||||
if [ -f ".env" ]; then
|
if [ -z "$GOTIFY_URL" ] && [ -f ".env" ]; then
|
||||||
# shellcheck source=/dev/null
|
GOTIFY_URL=$(grep -v '^#' .env | grep -v '^$' | grep '^GOTIFY_URL=' | head -1 | cut -d'=' -f2- | tr -d '"' | tr -d "'" | xargs || echo "")
|
||||||
set -a
|
fi
|
||||||
. ".env"
|
|
||||||
set +a
|
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
|
fi
|
||||||
|
|
||||||
# Extract Gotify variables from docker-compose.yml if not set
|
# Extract Gotify variables from docker-compose.yml if not set
|
||||||
|
|||||||
Reference in New Issue
Block a user