Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Np4cMQLF77i664CAQXySzU
21 lines
558 B
Bash
Executable File
21 lines
558 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
FILE="$1"
|
|
STATE="$2"
|
|
: "${FILE:?usage: git-sync-toggle.sh <git-sync.yaml path> <true|false>}"
|
|
: "${STATE:?usage: git-sync-toggle.sh <git-sync.yaml path> <true|false>}"
|
|
|
|
if [ ! -f "$FILE" ]; then
|
|
echo "ERROR: $FILE not found — is git-sync installed on this server?" >&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")"
|