sync-cleo 2026-04-10 12:50
This commit is contained in:
Executable
+24
@@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Run on Amun or Cleo to set up vault sync
|
||||||
|
AGENT_NAME="${1:-amun}"
|
||||||
|
VAULT_DIR="/root/.openclaw/workspace/obsidian-vault"
|
||||||
|
GIT_REMOTE="${2:-https://github.com/YOUR_GITHUB/obsidian-shared-vault.git}"
|
||||||
|
|
||||||
|
if [ -d "$VAULT_DIR/.git" ]; then
|
||||||
|
echo "[$AGENT_NAME] Vault exists, pulling latest..."
|
||||||
|
cd "$VAULT_DIR"
|
||||||
|
git pull origin master
|
||||||
|
else
|
||||||
|
echo "[$AGENT_NAME] Cloning vault..."
|
||||||
|
git clone "$GIT_REMOTE" "$VAULT_DIR"
|
||||||
|
cd "$VAULT_DIR"
|
||||||
|
git config user.name "$AGENT_NAME"
|
||||||
|
git config user.email "$AGENT_NAME@openclaw"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create agent-specific dir
|
||||||
|
mkdir -p "$VAULT_DIR/agent-$AGENT_NAME"
|
||||||
|
|
||||||
|
# Add cron job for 5-min sync
|
||||||
|
(crontab -l 2>/dev/null | grep -v sync-vault; echo "*/5 * * * * /root/.openclaw/workspace/obsidian-vault/sync-vault.sh $AGENT_NAME >> /root/.openclaw/workspace/obsidian-vault/sync.log 2>&1") | crontab -
|
||||||
|
echo "[$AGENT_NAME] Vault setup complete, cron job added"
|
||||||
Executable
+8
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd /root/.openclaw/workspace/obsidian-vault
|
||||||
|
git pull origin main >/dev/null 2>&1
|
||||||
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
|
git add -A
|
||||||
|
git commit -m "sync-cleo $(date '+%Y-%m-%d %H:%M')" >/dev/null 2>&1
|
||||||
|
git push origin main >/dev/null 2>&1
|
||||||
|
fi
|
||||||
Executable
+60
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#===============================================
|
||||||
|
# obsidian-vault sync script
|
||||||
|
# All 3 agents run this every 5 minutes
|
||||||
|
#===============================================
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
AGENT="${1:-horus}"
|
||||||
|
VAULT_DIR="/root/.openclaw/workspace/obsidian-vault"
|
||||||
|
STATE_FILE="$VAULT_DIR/agent-openclaw/vault-state.json"
|
||||||
|
LOG_FILE="$VAULT_DIR/agent-shared/daily/$(date +%Y-%m-%d).md"
|
||||||
|
|
||||||
|
cd "$VAULT_DIR"
|
||||||
|
|
||||||
|
# Update daily log
|
||||||
|
mkdir -p "$VAULT_DIR/agent-shared/daily"
|
||||||
|
if [ ! -f "$LOG_FILE" ]; then
|
||||||
|
cat > "$LOG_FILE" << EOF
|
||||||
|
# Daily Log — $(date +%Y-%m-%d)
|
||||||
|
|
||||||
|
## Agents Active Today
|
||||||
|
- Horus
|
||||||
|
- Amun
|
||||||
|
- Cleo
|
||||||
|
|
||||||
|
## Session Activity
|
||||||
|
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if dirty
|
||||||
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
|
echo "[$AGENT] Vault has changes — committing..."
|
||||||
|
git add -A
|
||||||
|
git commit -m "chore: $AGENT sync $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||||
|
|
||||||
|
# Push if remote exists
|
||||||
|
if git remote get-url origin &>/dev/null; then
|
||||||
|
git pull --rebase origin master 2>/dev/null || true
|
||||||
|
git push origin master 2>/dev/null || echo "[$AGENT] Push failed (offline?)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update vault state
|
||||||
|
python3 -c "
|
||||||
|
import json
|
||||||
|
with open('$STATE_FILE', 'r') as f:
|
||||||
|
s = json.load(f)
|
||||||
|
s['agents']['$AGENT']['last_commit'] = '$(git rev-parse HEAD)'
|
||||||
|
s['agents']['$AGENT']['dirty'] = False
|
||||||
|
s['last_sync'] = '$(date -u +%Y-%m-%dT%H:%M:%SZ)'
|
||||||
|
with open('$STATE_FILE', 'w') as f:
|
||||||
|
json.dump(s, f, indent=2)
|
||||||
|
"
|
||||||
|
echo "[$AGENT] Sync complete"
|
||||||
|
else
|
||||||
|
# Pull latest from others
|
||||||
|
if git remote get-url origin &>/dev/null; then
|
||||||
|
git pull origin master 2>/dev/null && echo "[$AGENT] Pulled latest" || echo "[$AGENT] Pull failed or no remote"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
VAULT="/root/.openclaw/workspace/obsidian-vault"
|
||||||
|
cd "$VAULT"
|
||||||
|
git pull origin main >/dev/null 2>&1
|
||||||
|
if [ -n "$(git status --porcelain)" ]; then
|
||||||
|
git add -A
|
||||||
|
git commit -m "sync $(date '+%Y-%m-%d %H:%M')" >/dev/null 2>&1
|
||||||
|
git push origin main >/dev/null 2>&1
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user