Files
lvmh/deploy/rsync-pi-agent.sh
T

51 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Sync the user's pi config (from dotfiles) into docker/pi-agent/ so the
# worker image bakes it. Filtered: no secrets, no machine-local state.
set -euo pipefail
SRC="${LVMH_PI_AGENT_DIR:-$HOME/.dotfiles/pi/agent}"
DEST="$(dirname "$0")/../docker/pi-agent"
# DEST must exist even without dotfiles: the worker Dockerfile COPYs it
# unconditionally (a missing dir would fail the build).
mkdir -p "$DEST"
if [ ! -f "$SRC/settings.json" ]; then
echo "rsync-pi-agent: $SRC/settings.json not found — skipping dotfiles sync" >&2
exit 0
fi
rsync -a --delete \
--exclude 'auth.json' \
--exclude 'models.json' \
--exclude 'models-store.json' \
--exclude 'sessions/' \
--exclude 'cache/' \
--exclude 'npm/' \
--exclude 'git/' \
--exclude 'trust.json' \
--exclude 'mcp-*' \
--exclude 'run-history*' \
--exclude 'vibes' \
--exclude '*.log' \
--exclude 'scratch/' \
--exclude '.pi/' \
"$SRC/" "$DEST/"
# Container sessions cannot run git: package postinstalls (e.g. husky) — keep
# registry (npm:) packages only in the baked settings.json.
python3 - "$DEST/settings.json" <<'PY'
import json, sys
p = sys.argv[1]
with open(p) as f:
s = json.load(f)
pkgs = s.get("packages") or []
kept = [x for x in pkgs if x.startswith("npm:")]
if pkgs != kept:
s["packages"] = kept
with open(p, "w") as f:
json.dump(s, f, indent=2)
f.write("\n")
print(f"rsync-pi-agent: dropped {len(pkgs) - len(kept)} git: packages from baked settings")
PY
echo "rsync-pi-agent: synced $(find "$DEST" -type f | wc -l) files from $SRC"