Make seed-workspace resilient to permission drift

Retry rsync without --delete on exit 23 so the gateway does not crash-loop if workspace contains root-owned files.
This commit is contained in:
joshp123 2026-02-15 17:15:12 -08:00
parent 6cd6b7fada
commit 833264bbe3

View File

@ -11,7 +11,30 @@ fi
mkdir -p "$dst"
rsync -rlt --delete --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --exclude 'BOOTSTRAP.md' "$src/" "$dst/"
rsync_args=(
-rlt
--delete
"--chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r"
--exclude
BOOTSTRAP.md
"$src/"
"$dst/"
)
set +e
rsync "${rsync_args[@]}"
code=$?
set -e
# rsync exit 23 is "partial transfer" and can happen if workspace contains root-owned
# files/dirs (e.g. manual edits). We prefer starting the gateway with a potentially
# stale workspace over a crash-loop.
if [ "$code" -eq 23 ]; then
echo "seed-workspace: rsync returned 23; retrying without --delete" >&2
rsync -rlt --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r --exclude BOOTSTRAP.md "$src/" "$dst/"
elif [ "$code" -ne 0 ]; then
exit "$code"
fi
if [ -f "/etc/clawdinator/tools.md" ]; then
printf '\n%s\n' "$(cat /etc/clawdinator/tools.md)" >> "$dst/TOOLS.md"