From d61de6f3f7f21be1d954a122184cc4c111cf0486 Mon Sep 17 00:00:00 2001 From: Mischa Date: Sat, 4 Jul 2026 23:35:11 +0200 Subject: [PATCH] build: make git-sync toggle + diag env-path aware MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Grav Admin saves plugin config into the active environment's config tree (user/env//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 Claude-Session: https://claude.ai/code/session_01Np4cMQLF77i664CAQXySzU --- Makefile | 5 +++-- scripts/git-sync-toggle.sh | 21 +++++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index a703d86..43af199 100644 --- a/Makefile +++ b/Makefile @@ -167,10 +167,10 @@ remote-upgrade-grav: guard-env $(SSH) "cd $(WEBROOT) && php bin/gpm self-upgrade -y && php bin/grav cache" 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 - $(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 $(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 '=== 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 '=== 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" remote-maintenance-on: guard-env diff --git a/scripts/git-sync-toggle.sh b/scripts/git-sync-toggle.sh index 3f0268c..f1b8189 100755 --- a/scripts/git-sync-toggle.sh +++ b/scripts/git-sync-toggle.sh @@ -1,13 +1,22 @@ #!/bin/bash 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//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" -: "${FILE:?usage: git-sync-toggle.sh }" -: "${STATE:?usage: git-sync-toggle.sh }" +: "${WEBROOT:?usage: git-sync-toggle.sh }" +: "${STATE:?usage: git-sync-toggle.sh }" -if [ ! -f "$FILE" ]; then - echo "ERROR: $FILE not found — is git-sync installed on this server?" >&2 +FILE=$(ls "$WEBROOT"/user/env/*/config/plugins/git-sync.yaml \ + "$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 fi @@ -17,4 +26,4 @@ else printf 'enabled: %s\n' "$STATE" | cat - "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE" fi -echo "git-sync now: $(grep -E '^enabled:' "$FILE")" +echo "git-sync now: $(grep -E '^enabled:' "$FILE") ($FILE)"