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
30 lines
1.1 KiB
Bash
Executable File
30 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# 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"
|
|
: "${WEBROOT:?usage: git-sync-toggle.sh <webroot> <true|false>}"
|
|
: "${STATE:?usage: git-sync-toggle.sh <webroot> <true|false>}"
|
|
|
|
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
|
|
|
|
if grep -qE '^enabled:' "$FILE"; then
|
|
sed -i -E "s/^enabled:.*/enabled: ${STATE}/" "$FILE"
|
|
else
|
|
printf 'enabled: %s\n' "$STATE" | cat - "$FILE" > "$FILE.tmp" && mv "$FILE.tmp" "$FILE"
|
|
fi
|
|
|
|
echo "git-sync now: $(grep -E '^enabled:' "$FILE") ($FILE)"
|