chore: final EOD repository hygiene and untracked files

Co-authored-by: Junie <junie@jetbrains.com>
This commit is contained in:
mw
2026-03-22 11:30:14 +01:00
co-authored by Junie
parent a839772032
commit f54fc1d9cd
7 changed files with 129 additions and 2 deletions
+64
View File
@@ -0,0 +1,64 @@
#!/bin/bash
# OpenClaw Connection Repair Watcher
LOG_FILE="$HOME/.openclaw/logs/repair.log"
HEALTH_URL="http://127.0.0.1:18789/health"
REMOTE_HOST="100.64.0.39"
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
log() {
echo "[$TIMESTAMP] $1" >> "$LOG_FILE"
}
check_health() {
# Attempt to fetch health status with a short timeout
HEALTH_STATUS=$(curl -s -m 5 "$HEALTH_URL")
if [[ "$HEALTH_STATUS" == *'"ok":true'* ]]; then
return 0
else
return 1
fi
}
check_remote() {
# Check if remote host is reachable via Tailscale
if ping -c 1 -W 2 "$REMOTE_HOST" > /dev/null 2>&1; then
return 0
else
return 1
fi
}
repair() {
log "Connection loss detected. Attempting repair..."
# Restart SSH tunnel first
log "Restarting ai.openclaw.ssh-tunnel..."
launchctl stop ai.openclaw.ssh-tunnel 2>/dev/null
launchctl start ai.openclaw.ssh-tunnel
# Wait a bit for the tunnel to establish
sleep 5
# Restart OpenClaw node
log "Restarting ai.openclaw.node..."
launchctl stop ai.openclaw.node 2>/dev/null
launchctl start ai.openclaw.node
log "Repair attempt completed."
}
# Main Watcher Logic
log "Starting health check..."
if ! check_health; then
log "Health check failed for $HEALTH_URL"
if ! check_remote; then
log "Remote host $REMOTE_HOST is unreachable. Is Tailscale connected?"
else
repair
fi
else
# Connection is healthy, log and exit
log "Health check passed. Connection is healthy."
exit 0
fi