diff --git a/logs/brain-sync.log b/logs/brain-sync.log new file mode 100644 index 0000000..62c8150 --- /dev/null +++ b/logs/brain-sync.log @@ -0,0 +1,2 @@ +[2026-04-11 18:09:28] Starting Brain sync... +[2026-04-11 18:09:28] Added 'brain' remote diff --git a/sync-brain.sh b/sync-brain.sh new file mode 100755 index 0000000..6d9278e --- /dev/null +++ b/sync-brain.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Daily Brain Sync to Gitea +# Commits and pushes workspace state to ParzivalTD/Brain repo + +WORKSPACE="/data/.openclaw/workspace" +LOG_FILE="/data/.openclaw/workspace/logs/brain-sync.log" +TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S') + +# Ensure log directory exists +mkdir -p "$(dirname "$LOG_FILE")" + +{ + echo "[$TIMESTAMP] Starting Brain sync..." + + cd "$WORKSPACE" || exit 1 + + # Configure git if needed + git config --global user.email "thelegion@stacklegion.dev" >/dev/null 2>&1 + git config --global user.name "ParzivalTD" >/dev/null 2>&1 + + # Check if remote exists, if not add it + if ! git remote get-url brain >/dev/null 2>&1; then + git remote add brain https://thelegion%40stacklegion.dev:RubiKa1IsHomeNoMore@168.231.66.248:32771/ParzivalTD/Brain.git + echo "[$TIMESTAMP] Added 'brain' remote" + fi + + # Stage changes + git add -A + + # Check if there are changes to commit + if ! git diff-index --quiet HEAD --; then + # Commit changes + git commit -m "Brain sync: $(date +'%Y-%m-%d %H:%M:%S')" >/dev/null 2>&1 + echo "[$TIMESTAMP] Committed changes" + else + echo "[$TIMESTAMP] No changes to commit" + fi + + # Push to Gitea + if git push -u brain master 2>&1; then + echo "[$TIMESTAMP] ✅ Brain sync completed successfully" + else + echo "[$TIMESTAMP] ⚠️ Brain sync push failed (may retry on next sync)" + fi + +} >> "$LOG_FILE" 2>&1 + +exit 0