Spaces:
Sleeping
Sleeping
File size: 1,049 Bytes
d41fe21 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/bin/bash
# Periodic workspace sync to HF Dataset
# Commits and pushes workspace changes every SYNC_INTERVAL seconds
# Runs as a background process alongside the gateway
INTERVAL="${SYNC_INTERVAL:-600}" # Default: every 10 minutes
WORKSPACE="/home/node/.openclaw/workspace"
# Wait for workspace to be initialized
sleep 30
if [ ! -d "$WORKSPACE/.git" ]; then
echo "📁 Workspace sync: no git repo found, skipping."
exit 0
fi
echo "🔄 Workspace sync started: syncing every ${INTERVAL}s"
while true; do
sleep "$INTERVAL"
cd "$WORKSPACE" || continue
# Check if there are any changes
git add -A 2>/dev/null
if git diff --cached --quiet 2>/dev/null; then
# No changes
continue
fi
# Commit and push
TIMESTAMP=$(date -u +%Y-%m-%dT%H:%M:%SZ)
if git commit -m "Auto-sync ${TIMESTAMP}" 2>/dev/null; then
if git push origin main 2>/dev/null; then
echo "🔄 Workspace sync: pushed changes (${TIMESTAMP})"
else
echo "🔄 Workspace sync: commit ok, push failed (will retry)"
fi
fi
done
|