build: make git-sync toggle + diag env-path aware

Grav Admin saves plugin config into the active environment's config tree
(user/env/<host>/config/plugins/) when an env override dir exists — so
git-sync.yaml landed there, not in user/config/plugins/. Update the
toggle script to take a WEBROOT and search both locations (env path
first), and update remote-git-sync-disable/enable to pass WEBROOT.
remote-diag now surfaces git-sync config (secrets redacted) from either
location.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Np4cMQLF77i664CAQXySzU
This commit is contained in:
2026-07-04 23:35:11 +02:00
co-authored by Claude Opus 4.8
parent cc40c23ea8
commit d61de6f3f7
2 changed files with 18 additions and 8 deletions
+3 -2
View File
@@ -167,10 +167,10 @@ remote-upgrade-grav: guard-env
$(SSH) "cd $(WEBROOT) && php bin/gpm self-upgrade -y && php bin/grav cache" $(SSH) "cd $(WEBROOT) && php bin/gpm self-upgrade -y && php bin/grav cache"
remote-git-sync-disable: guard-env remote-git-sync-disable: guard-env
$(SSH) "bash -s -- '$(WEBROOT)/user/config/plugins/git-sync.yaml' false" < scripts/git-sync-toggle.sh $(SSH) "bash -s -- '$(WEBROOT)' false" < scripts/git-sync-toggle.sh
remote-git-sync-enable: guard-env remote-git-sync-enable: guard-env
$(SSH) "bash -s -- '$(WEBROOT)/user/config/plugins/git-sync.yaml' true" < scripts/git-sync-toggle.sh $(SSH) "bash -s -- '$(WEBROOT)' true" < scripts/git-sync-toggle.sh
remote-content-status: guard-env remote-content-status: guard-env
$(SSH) "cd $(WEBROOT)/user && git status --short && echo '--- config diff ---' && git diff -- config/" $(SSH) "cd $(WEBROOT)/user && git status --short && echo '--- config diff ---' && git diff -- config/"
@@ -206,6 +206,7 @@ remote-diag: guard-env
echo '=== api override (enabled/route/session) ==='; grep -nE '^enabled:|^route:|session_enabled:' user/config/plugins/api.yaml 2>&1; \ echo '=== api override (enabled/route/session) ==='; grep -nE '^enabled:|^route:|session_enabled:' user/config/plugins/api.yaml 2>&1; \
echo '=== per-env override present? ==='; for f in user/env/*/config/system.yaml; do echo \"\$$f:\"; cat \"\$$f\" 2>/dev/null | grep -E 'cache:|debug:|auto_reload:'; done; \ echo '=== per-env override present? ==='; for f in user/env/*/config/system.yaml; do echo \"\$$f:\"; cat \"\$$f\" 2>/dev/null | grep -E 'cache:|debug:|auto_reload:'; done; \
echo '=== twig cache populating? (non-empty => cache on) ==='; ls cache/twig/ 2>/dev/null | head -1 || echo '(empty)'; \ echo '=== twig cache populating? (non-empty => cache on) ==='; ls cache/twig/ 2>/dev/null | head -1 || echo '(empty)'; \
echo '=== git-sync config (secrets redacted) ==='; grep -vaiE 'password|token|secret' user/config/plugins/git-sync.yaml user/env/*/config/plugins/git-sync.yaml 2>/dev/null; \
echo '=== grav.log tail ==='; tail -8 logs/grav.log 2>/dev/null" echo '=== grav.log tail ==='; tail -8 logs/grav.log 2>/dev/null"
remote-maintenance-on: guard-env remote-maintenance-on: guard-env
+15 -6
View File
@@ -1,13 +1,22 @@
#!/bin/bash #!/bin/bash
set -e set -e
FILE="$1" # Enable/disable the git-sync plugin by flipping `enabled:` in its config.
#
# git-sync.yaml may live in the per-environment config tree
# (user/env/<host>/config/plugins/) when an env override dir exists — Grav's
# Admin saves config there when an environment is active — otherwise in the
# standard user/config/plugins/. Search both, env path first.
WEBROOT="$1"
STATE="$2" STATE="$2"
: "${FILE:?usage: git-sync-toggle.sh <git-sync.yaml path> <true|false>}" : "${WEBROOT:?usage: git-sync-toggle.sh <webroot> <true|false>}"
: "${STATE:?usage: git-sync-toggle.sh <git-sync.yaml path> <true|false>}" : "${STATE:?usage: git-sync-toggle.sh <webroot> <true|false>}"
if [ ! -f "$FILE" ]; then FILE=$(ls "$WEBROOT"/user/env/*/config/plugins/git-sync.yaml \
echo "ERROR: $FILE not found — is git-sync installed on this server?" >&2 "$WEBROOT"/user/config/plugins/git-sync.yaml 2>/dev/null | head -1)
if [ -z "$FILE" ] || [ ! -f "$FILE" ]; then
echo "ERROR: git-sync.yaml not found under $WEBROOT — is git-sync installed/configured?" >&2
exit 1 exit 1
fi fi
@@ -17,4 +26,4 @@ else
printf 'enabled: %s\n' "$STATE" | cat - "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE" printf 'enabled: %s\n' "$STATE" | cat - "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE"
fi fi
echo "git-sync now: $(grep -E '^enabled:' "$FILE")" echo "git-sync now: $(grep -E '^enabled:' "$FILE") ($FILE)"