49 lines
1.4 KiB
Bash
Executable File
49 lines
1.4 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"
|
|
|
|
if [ ! -f "$SRC/settings.json" ]; then
|
|
echo "rsync-pi-agent: $SRC/settings.json not found — skipping dotfiles sync" >&2
|
|
exit 0
|
|
fi
|
|
|
|
mkdir -p "$DEST"
|
|
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"
|