-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·369 lines (327 loc) · 12.7 KB
/
uninstall.sh
File metadata and controls
executable file
·369 lines (327 loc) · 12.7 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
#!/bin/bash
# EverMemOS Uninstaller
#
# Usage:
# ./uninstall.sh
#
# What this does (reverse order of install.sh):
# 0. Stops EverMemOS backend and kv-server (if running)
# 0b. Removes Docker containers AND volumes (docker-compose down -v)
# 7 (kv-server): Deletes config_testnet_turbo.toml, zgs_kv binary, db/, kv.DB, kv_*.log
# 6 (reverse): Deletes .0g_secrets
# 6b. Removes EverMemOS hooks and env vars from ~/.claude/settings.json
# 6c. Removes EverMemOS plugin from OpenCode (~/.config/opencode/)
# 6d. Removes EverMemOS plugin from OpenClaw (~/.openclaw/openclaw.json)
# 6a. Removes EverMemOS skills from ~/.claude/skills/
# 5b. Deletes runtime files in logs/ (evermemos_*.log, evermemos.pid)
# 5a. Deletes .env
# 3. Deletes .venv/
set -e
# ── Resolve project root (works when called from any directory) ──────────────
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# ── Detect docker compose command ────────────────────────────────────────────
if command -v docker-compose &>/dev/null; then
COMPOSE_CMD="docker-compose"
else
COMPOSE_CMD="docker compose"
fi
echo ""
echo "============================================================"
echo " EverMemOS Uninstaller"
echo "============================================================"
echo ""
# ── Step 0: Stop all running services ────────────────────────────────────────
echo "▶ Stopping running services..."
echo ""
# Stop EverMemOS backend
python3 scripts/service_manager.py stop 2>/dev/null || true
if pgrep -f "src/run.py" > /dev/null 2>&1; then
pkill -TERM -f "src/run.py" 2>/dev/null || true
sleep 2
pkill -KILL -f "src/run.py" 2>/dev/null || true
echo " ✅ EverMemOS backend stopped"
else
echo " ℹ️ EverMemOS backend was not running"
fi
# Stop kv-server
if pgrep -f "zgs_kv" > /dev/null 2>&1; then
pkill -f "zgs_kv" 2>/dev/null || true
echo " ✅ kv-server stopped"
else
echo " ℹ️ kv-server was not running"
fi
# ── Step 0b: Remove Docker containers and volumes ────────────────────────────
echo ""
echo "▶ Removing Docker containers and volumes..."
echo ""
if [ -n "$($COMPOSE_CMD ps -q 2>/dev/null)" ]; then
echo " 🗑️ Running: $COMPOSE_CMD down -v"
$COMPOSE_CMD down -v
echo " ✅ Containers and volumes removed"
else
# Containers may not be listed by ps -q if already removed, but try anyway
# to ensure volumes are cleaned up
$COMPOSE_CMD down -v 2>/dev/null && echo " ✅ Containers and volumes removed" || echo " ℹ️ No containers found, skipping"
fi
# ── 0g_kv_server cleanup (binary + config + runtime data) ────────────────────
echo ""
echo "▶ Removing 0g_kv_server files..."
KV_DIR="$SCRIPT_DIR/0g_kv_server"
for target in "$KV_DIR/zgs_kv" "$KV_DIR/config_testnet_turbo.toml" "$KV_DIR/db" "$KV_DIR/kv.DB"; do
if [ -e "$target" ]; then
rm -rf "$target"
echo " ✅ Deleted $target"
else
echo " ℹ️ $target not found, skipping"
fi
done
kv_log_count=0
for f in "$KV_DIR"/kv_*.log; do
[ -f "$f" ] || continue
rm "$f"
echo " ✅ Deleted $f"
kv_log_count=$((kv_log_count + 1))
done
[ "$kv_log_count" -eq 0 ] && echo " ℹ️ No kv log files found, skipping"
# ── Step 7 (reverse): Delete .0g_secrets and .evermemos_remote_secrets ────────
echo ""
echo "▶ Removing secrets files..."
if [ -f "$SCRIPT_DIR/.0g_secrets" ]; then
rm "$SCRIPT_DIR/.0g_secrets"
echo " ✅ Deleted .0g_secrets"
else
echo " ℹ️ .0g_secrets not found, skipping"
fi
if [ -f "$SCRIPT_DIR/.evermemos_remote_secrets" ]; then
rm "$SCRIPT_DIR/.evermemos_remote_secrets"
echo " ✅ Deleted .evermemos_remote_secrets"
else
echo " ℹ️ .evermemos_remote_secrets not found, skipping"
fi
# ── Step 6b (reverse): Remove hooks and env vars from ~/.claude/settings.json ─
echo ""
echo "▶ Removing EverMemOS hooks from ~/.claude/settings.json..."
python3 - <<'EOF'
import json
from pathlib import Path
settings_path = Path.home() / ".claude" / "settings.json"
if not settings_path.exists():
print(" ℹ️ ~/.claude/settings.json not found, skipping")
exit(0)
with open(settings_path, "r", encoding="utf-8") as f:
settings = json.load(f)
# Remove EverMemOS hooks
hook_scripts = {
"hook_session_start.py",
"hook_user_prompt.py",
"hook_tool_use.py",
"hook_stop.py",
"hook_session_end.py",
}
removed_hooks = 0
hooks = settings.get("hooks", {})
for event in list(hooks.keys()):
original_len = len(hooks[event])
hooks[event] = [
group for group in hooks[event]
if not any(
script in h.get("command", "")
for h in group.get("hooks", [])
for script in hook_scripts
)
]
removed = original_len - len(hooks[event])
if removed:
removed_hooks += removed
print(f" ✅ Removed hook: {event}")
if not hooks[event]:
del hooks[event]
# Remove EverMemOS env vars
evermemos_env_keys = {"API_BASE_URL", "EVERMEMOS_API_KEY", "MEMORY_USER_ID", "EVERMEMOS_GROUP_ID"}
env = settings.get("env", {})
removed_env = [k for k in evermemos_env_keys if k in env]
for k in removed_env:
del env[k]
print(f" ✅ Removed env var: {k}")
if not env:
settings.pop("env", None)
if removed_hooks == 0 and not removed_env:
print(" ℹ️ No EverMemOS hooks or env vars found, skipping")
else:
with open(settings_path, "w", encoding="utf-8") as f:
json.dump(settings, f, indent=2, ensure_ascii=False)
f.write("\n")
print(" ✅ Updated ~/.claude/settings.json")
EOF
# ── OpenCode plugin removal ───────────────────────────────────────────────────
echo ""
echo "▶ Removing EverMemOS plugin from ~/.config/opencode/..."
# Remove plugin directory
OPENCODE_PLUGIN_DIR="$HOME/.config/opencode/plugins/evermemos"
if [ -d "$OPENCODE_PLUGIN_DIR" ]; then
rm -rf "$OPENCODE_PLUGIN_DIR"
echo " ✅ Deleted $OPENCODE_PLUGIN_DIR"
else
echo " ℹ️ $OPENCODE_PLUGIN_DIR not found, skipping"
fi
# Remove remote config file written by remote_setup.py
OPENCODE_EVERMEMOS_CONFIG="$HOME/.config/opencode/evermemos.json"
if [ -f "$OPENCODE_EVERMEMOS_CONFIG" ]; then
rm -f "$OPENCODE_EVERMEMOS_CONFIG"
echo " ✅ Deleted $OPENCODE_EVERMEMOS_CONFIG"
else
echo " ℹ️ $OPENCODE_EVERMEMOS_CONFIG not found, skipping"
fi
# Remove plugin entry from ~/.config/opencode/opencode.json
python3 - <<'EOF'
import json
from pathlib import Path
config_path = Path.home() / ".config" / "opencode" / "opencode.json"
if not config_path.exists():
print(" ℹ️ ~/.config/opencode/opencode.json not found, skipping")
exit(0)
with open(config_path, "r", encoding="utf-8") as f:
config = json.load(f)
plugins = config.get("plugin", [])
evermemos_entries = [p for p in plugins if "evermemos" in p]
if not evermemos_entries:
print(" ℹ️ No EverMemOS plugin entry found in opencode.json, skipping")
exit(0)
config["plugin"] = [p for p in plugins if "evermemos" not in p]
if not config["plugin"]:
del config["plugin"]
with open(config_path, "w", encoding="utf-8") as f:
json.dump(config, f, indent=2, ensure_ascii=False)
f.write("\n")
for entry in evermemos_entries:
print(f" ✅ Removed plugin entry: {entry}")
print(" ✅ Updated ~/.config/opencode/opencode.json")
EOF
# ── OpenClaw plugin removal ───────────────────────────────────────────────────
echo ""
echo "▶ Removing EverMemOS plugin from OpenClaw..."
# Try CLI uninstall first (non-fatal — may not be supported or plugin already gone)
if command -v openclaw &>/dev/null; then
openclaw plugins uninstall evermemos-openclaw 2>/dev/null \
&& echo " ✅ openclaw plugins uninstall evermemos-openclaw succeeded" \
|| echo " ℹ️ openclaw plugins uninstall returned non-zero (may already be gone), continuing"
fi
# Patch ~/.openclaw/openclaw.json to remove entries + load path
python3 - <<'EOF'
import json
from pathlib import Path
config_path = Path.home() / ".openclaw" / "openclaw.json"
if not config_path.exists():
print(" ℹ️ ~/.openclaw/openclaw.json not found, skipping")
exit(0)
try:
with open(config_path, "r", encoding="utf-8") as f:
config = json.load(f)
except (json.JSONDecodeError, OSError) as e:
print(f" ⚠️ Could not read ~/.openclaw/openclaw.json: {e}, skipping")
exit(0)
changed = False
plugins = config.get("plugins", {})
# Remove entries.evermemos-openclaw
entries = plugins.get("entries", {})
if "evermemos-openclaw" in entries:
del entries["evermemos-openclaw"]
print(" ✅ Removed plugins.entries.evermemos-openclaw")
changed = True
else:
print(" ℹ️ plugins.entries.evermemos-openclaw not found, skipping")
# Remove evermemos path from plugins.load.paths
load = plugins.get("load", {})
paths = load.get("paths", [])
new_paths = [p for p in paths if "evermemos" not in p and "0g-memory/openclaw-skills" not in p]
if len(new_paths) < len(paths):
load["paths"] = new_paths
print(f" ✅ Removed evermemos path from plugins.load.paths")
changed = True
else:
print(" ℹ️ No evermemos path found in plugins.load.paths, skipping")
if not changed:
exit(0)
try:
tmp = config_path.with_suffix(".json.tmp")
with open(tmp, "w", encoding="utf-8") as f:
json.dump(config, f, indent=2, ensure_ascii=False)
f.write("\n")
tmp.replace(config_path)
print(" ✅ Updated ~/.openclaw/openclaw.json")
except OSError as e:
print(f" ⚠️ Failed to write ~/.openclaw/openclaw.json: {e}")
EOF
# ── Step 6a (reverse): Remove EverMemOS skills from ~/.claude/skills/ ─────────
echo ""
echo "▶ Removing EverMemOS skills from ~/.claude/skills/..."
SKILLS_DIR="$HOME/.claude/skills"
found=false
for skill_dir in "$SKILLS_DIR"/evermemos*/; do
if [ -d "$skill_dir" ]; then
rm -rf "$skill_dir"
echo " ✅ Deleted $skill_dir"
found=true
fi
done
if [ "$found" = false ]; then
echo " ℹ️ No EverMemOS skills found in $SKILLS_DIR, skipping"
fi
# ── Step 5b (reverse): Delete runtime-generated files in logs/ ───────────────
echo ""
echo "▶ Removing runtime files in logs/..."
LOG_DIR="$SCRIPT_DIR/logs"
if [ -d "$LOG_DIR" ]; then
# Remove all timestamped log files
log_count=0
for f in "$LOG_DIR"/evermemos_*.log; do
[ -f "$f" ] || continue
rm "$f"
echo " ✅ Deleted $f"
log_count=$((log_count + 1))
done
[ "$log_count" -eq 0 ] && echo " ℹ️ No log files found, skipping"
# Remove PID file
if [ -f "$LOG_DIR/evermemos.pid" ]; then
rm "$LOG_DIR/evermemos.pid"
echo " ✅ Deleted $LOG_DIR/evermemos.pid"
else
echo " ℹ️ evermemos.pid not found, skipping"
fi
else
echo " ℹ️ logs/ directory not found, skipping"
fi
# ── Step 5a (reverse): Delete .env ───────────────────────────────────────────
echo ""
echo "▶ Removing .env..."
if [ -f "$SCRIPT_DIR/.env" ]; then
rm "$SCRIPT_DIR/.env"
echo " ✅ Deleted .env"
else
echo " ℹ️ .env not found, skipping"
fi
# ── Step 3 (reverse): Delete .venv/ ──────────────────────────────────────────
echo ""
echo "▶ Removing .venv/..."
if [ -d "$SCRIPT_DIR/.venv" ]; then
rm -rf "$SCRIPT_DIR/.venv"
echo " ✅ Deleted .venv/"
else
echo " ℹ️ .venv/ not found, skipping"
fi
# ── Done ──────────────────────────────────────────────────────────────────────
echo ""
echo "============================================================"
echo " ✅ Uninstall complete!"
echo ""
echo " ⚠️ If Claude Code is running, restart it so the"
echo " removed hooks take effect."
echo ""
echo " ⚠️ If OpenCode is running, restart it so the"
echo " removed plugin takes effect."
echo ""
echo " ⚠️ If OpenClaw is running, restart the gateway so the"
echo " removed plugin takes effect: openclaw gateway restart"
echo "============================================================"
echo ""