Files
openclaw/fix-mike-openclaw2.sh
Clawd Bot ca9b510922 chore: align with upstream openclaw/openclaw and overlay local additions
- Reset master to upstream/main (16,697 commits)
- Overlay 2,271 local-only files (skills, tools, workspace, configs, apps)
- Restore IDENTITY.md and USER.md templates
- Build verified, gateway running, Discord working

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 07:40:46 +01:00

102 lines
2.6 KiB
Bash

#!/usr/bin/env bash
# Fix script for mike openclaw2 JSON issue
set -euo pipefail
echo "=== Checking for corrupted JSON files on openclaw2 ==="
# Function to check if a file contains valid JSON
check_json() {
local file=$1
if [ -f "$file" ]; then
echo "Checking $file..."
if ! jq empty "$file" 2>/dev/null; then
echo "❌ CORRUPTED: $file"
return 1
else
echo "✓ Valid: $file"
return 0
fi
else
echo "⊘ Not found: $file"
return 0
fi
}
# Check primary lock file
echo ""
echo "--- Checking primary lock file ---"
if ! check_json /tmp/openclaw-primary.lock; then
echo "Removing corrupted lock file..."
rm -f /tmp/openclaw-primary.lock
echo "✓ Removed /tmp/openclaw-primary.lock"
fi
# Check WhatsApp Web credentials
echo ""
echo "--- Checking WhatsApp Web credentials ---"
CREDS_PATH="$HOME/.openclaw/credentials/creds.json"
if ! check_json "$CREDS_PATH"; then
BACKUP_PATH="$HOME/.openclaw/credentials/creds.json.backup"
if [ -f "$BACKUP_PATH" ]; then
echo "Restoring from backup..."
cp "$BACKUP_PATH" "$CREDS_PATH"
echo "✓ Restored from backup"
else
echo "⚠ No backup found - you may need to re-authenticate"
rm -f "$CREDS_PATH"
fi
fi
# Check session files
echo ""
echo "--- Checking session files ---"
if [ -d "$HOME/.openclaw/sessions" ]; then
for session_file in "$HOME/.openclaw/sessions"/*.json; do
if [ -f "$session_file" ]; then
if ! check_json "$session_file"; then
echo "Removing corrupted session: $session_file"
rm -f "$session_file"
fi
fi
done
fi
# Check gateway logs for JSON errors
echo ""
echo "--- Recent gateway logs (last 50 lines) ---"
if [ -f /tmp/openclaw-gateway.log ]; then
tail -n 50 /tmp/openclaw-gateway.log | grep -i "json\|parse\|syntax" || echo "No JSON errors in recent logs"
fi
# Kill existing gateway
echo ""
echo "--- Stopping existing gateway ---"
pkill -9 -f openclaw-gateway || echo "No existing gateway process found"
# Start gateway
echo ""
echo "--- Starting gateway ---"
nohup openclaw gateway run --bind loopback --port 18789 --force > /tmp/openclaw-gateway.log 2>&1 &
# Wait a bit for startup
sleep 3
# Verify
echo ""
echo "--- Verification ---"
echo "Gateway process:"
pgrep -f openclaw-gateway || echo "⚠ Gateway not running!"
echo ""
echo "Listening ports:"
ss -ltnp | grep 18789 || echo "⚠ Not listening on port 18789!"
echo ""
echo "Recent startup logs:"
tail -n 30 /tmp/openclaw-gateway.log
echo ""
echo "=== Fix complete ==="
echo "Check if mike is online on Discord now"