-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·97 lines (85 loc) · 2.74 KB
/
uninstall.sh
File metadata and controls
executable file
·97 lines (85 loc) · 2.74 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# uninstall.sh — Uninstall correlation-memory plugin from OpenClaw
# Usage: ./uninstall.sh [--force]
set -euo pipefail
PLUGIN_ID="correlation-memory"
OPENCLAW_CONFIG="${OPENCLAW_CONFIG_PATH:-$HOME/.openclaw/openclaw.json}"
BACKUP_DIR="${OPENCLAW_CONFIG}.bak-$(date +%Y%m%d-%H%M%S)"
FORCE="${1:-}"
echo "=== correlation-memory Plugin Uninstaller ==="
echo "Plugin ID: $PLUGIN_ID"
echo "Config: $OPENCLAW_CONFIG"
echo ""
# Check if config exists
if [[ ! -f "$OPENCLAW_CONFIG" ]]; then
echo "❌ Error: OpenClaw config not found at $OPENCLAW_CONFIG"
echo "Is OpenClaw installed?"
exit 1
fi
# Check if plugin is installed
if ! jq -e ".plugins.entries[\"$PLUGIN_ID\"]" "$OPENCLAW_CONFIG" > /dev/null 2>&1; then
echo "⚠️ Plugin '$PLUGIN_ID' not found in config"
echo "It may not be installed, or installed under a different ID"
echo ""
echo "Installed plugins:"
jq -r '.plugins.entries | keys[]' "$OPENCLAW_CONFIG" 2>/dev/null || echo "(none or plugins.entries not found)"
echo ""
read -p "Continue anyway? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 0
fi
fi
# Backup config before modification
echo "📦 Backing up config to $BACKUP_DIR"
cp "$OPENCLAW_CONFIG" "$BACKUP_DIR"
echo "✓ Backup created"
echo ""
# Confirm uninstall
if [[ "$FORCE" != "--force" ]]; then
echo "This will remove the $PLUGIN_ID plugin from your OpenClaw config."
echo "Backup: $BACKUP_DIR"
read -p "Confirm uninstall? [y/N] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 0
fi
else
echo "⚠️ --force flag set — skipping confirmation"
fi
# Remove plugin entry
echo "🗑️ Removing plugin from openclaw.json..."
if jq --arg id "$PLUGIN_ID" 'del(.plugins.entries[$id])' "$OPENCLAW_CONFIG" > "${OPENCLAW_CONFIG}.tmp"; then
mv "${OPENCLAW_CONFIG}.tmp" "$OPENCLAW_CONFIG"
echo "✓ Plugin removed from config"
else
echo "❌ Error: Failed to remove plugin from config"
echo "Backup restored from $BACKUP_DIR"
cp "$BACKUP_DIR" "$OPENCLAW_CONFIG"
exit 1
fi
# Verify removal
if jq -e ".plugins.entries[\"$PLUGIN_ID\"]" "$OPENCLAW_CONFIG" > /dev/null 2>&1; then
echo "❌ Error: Plugin still exists in config after removal"
echo "Backup restored from $BACKUP_DIR"
cp "$BACKUP_DIR" "$OPENCLAW_CONFIG"
exit 1
fi
echo "✓ Verification passed — plugin not in config"
echo ""
# Clean up temporary files
rm -f "${OPENCLAW_CONFIG}.tmp"
echo "=== Uninstall Complete ==="
echo ""
echo "Plugin '$PLUGIN_ID' has been uninstalled."
echo ""
echo "Backup location:"
echo " - Config backup: $BACKUP_DIR"
echo ""
echo "Next steps:"
echo " 1. Restart OpenClaw gateway (if running):"
echo " openclaw gateway restart"
echo " 2. Verify plugin is gone:"
echo " openclaw plugins list"