-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathuninstall.sh
More file actions
165 lines (138 loc) ยท 5.91 KB
/
Copy pathuninstall.sh
File metadata and controls
165 lines (138 loc) ยท 5.91 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
#!/bin/bash
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
# ไธ็ๅ
ญ้จ ยท OpenClaw Multi-Agent System ไธ้ฎๅธ่ฝฝ่ๆฌ
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
set -e
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
OC_HOME="$HOME/.openclaw"
OC_CFG="$OC_HOME/openclaw.json"
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
banner() {
echo ""
echo -e "${BLUE}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo -e "${BLUE}โ ๐๏ธ ไธ็ๅ
ญ้จ ยท ๅธ่ฝฝๅๅฏผ โ${NC}"
echo -e "${BLUE}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo ""
}
log() { echo -e "${GREEN}โ
$1${NC}"; }
warn() { echo -e "${YELLOW}โ ๏ธ $1${NC}"; }
info() { echo -e "${BLUE}โน๏ธ $1${NC}"; }
# โโ Step 0: ็กฎ่ฎค โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
check_env() {
info "ๆฃๆฅ็ฏๅข..."
if ! command -v python3 &>/dev/null; then
warn "ๆชๆพๅฐ python3๏ผ่ทณ่ฟๆธ
็้
็ฝฎ้กน"
fi
echo ""
echo -e "${YELLOW}็กฎๅฎ่ฆๅธ่ฝฝใไธ็ๅ
ญ้จใ็ณป็ปๅนถๆธ
็็ธๅ
ณ Agent ๆฐๆฎๅ๏ผ${NC}"
read -p "(y/N) " -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
info "ๅทฒๅๆถๅธ่ฝฝ"
exit 0
fi
}
# โโ Step 1: ๅๆญขๆญฃๅจ่ฟ่ก็ๆๅก โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
stop_services() {
info "ๅฐ่ฏๅๆญข็ธๅ
ณ่ฟ็จ..."
if pgrep -f "scripts/run_loop.sh" > /dev/null 2>&1; then
pkill -f "scripts/run_loop.sh" || warn "ๆ ๆณ่ชๅจๅๆญข run_loop.sh"
log "ๅทฒๅฐ่ฏๅๆญข run_loop.sh"
fi
if pgrep -f "python.*dashboard/server.py" > /dev/null 2>&1; then
pkill -f "python.*dashboard/server.py" || warn "ๆ ๆณ่ชๅจๅๆญข dashboard/server.py"
log "ๅทฒๅฐ่ฏๅๆญข dashboard/server.py"
fi
}
# โโ Step 2: ๆธ
็ OpenClaw ๆณจๅ้
็ฝฎ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
unregister_agents() {
info "ไป OpenClaw ็งป้คไธ็ๅ
ญ้จ Agents ๆณจๅไฟกๆฏ..."
if [ ! -f "$OC_CFG" ]; then
warn "ๆชๆพๅฐ openclaw.json๏ผ่ทณ่ฟ้
็ฝฎๆธ
็"
return
fi
cp "$OC_CFG" "$OC_CFG.bak.pre-uninstall-$(date +%Y%m%d-%H%M%S)"
log "ๅทฒๅคไปฝๅฝๅ้
็ฝฎ"
python3 << 'PYEOF'
import json, pathlib
cfg_path = pathlib.Path.home() / '.openclaw' / 'openclaw.json'
if not cfg_path.exists():
print(" openclaw.json ไธๅญๅจใ")
exit(0)
try:
cfg = json.loads(cfg_path.read_text(encoding='utf-8'))
except Exception as e:
print(f" ่งฃๆ openclaw.json ๅคฑ่ดฅ: {e}")
exit(1)
AGENTS_TO_REMOVE = {
"taizi", "zhongshu", "menxia", "shangshu",
"hubu", "libu", "bingbu", "xingbu", "gongbu",
"libu_hr", "zaochao"
}
agents_list = cfg.get('agents', {}).get('list', [])
new_list = [a for a in agents_list if a.get('id') not in AGENTS_TO_REMOVE]
removed_count = len(agents_list) - len(new_list)
if 'agents' in cfg:
cfg['agents']['list'] = new_list
cfg_path.write_text(json.dumps(cfg, ensure_ascii=False, indent=2), encoding='utf-8')
print(f" ๆๅ็งป้คไบ {removed_count} ไธช Agent ็ๆณจๅไฟกๆฏ")
PYEOF
log "ๆณจๅไฟกๆฏๆธ
็ๅฎๆ"
}
# โโ Step 3: ๆธ
้ค Workspace ็ฎๅฝ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
remove_workspaces() {
info "ๆธ
้ค Agent Workspace ็ฎๅฝ..."
AGENTS=(taizi zhongshu menxia shangshu hubu libu bingbu xingbu gongbu libu_hr zaochao)
removed=0
for agent in "${AGENTS[@]}"; do
ws="$OC_HOME/workspace-$agent"
if [ -d "$ws" ]; then
rm -rf "$ws"
removed=$((removed+1))
fi
done
log "ๆๅๆธ
็ไบ $removed ไธช Workspace ็ฎๅฝ"
}
# โโ Step 4: ๆธ
้คๆฌๅฐๆฐๆฎ็ผๅญ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
remove_data() {
info "ๆธ
้คๆฌๅฐ data ็ผๅญ..."
echo -e "${YELLOW}ๆฏๅฆ้่ฆๅ ้ค้กน็ฎๅ
็ data ็ฎๅฝๅๅทฒ็ๆ็ๆฐๆฎ๏ผ${NC}"
read -p "(y/N) " -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ -d "$REPO_DIR/data" ]; then
rm -rf "$REPO_DIR/data"
log "ๅทฒๅ ้ค $REPO_DIR/data"
else
warn "$REPO_DIR/data ไธๅญๅจ"
fi
else
info "ไฟ็ๅๆ data ็ฎๅฝ"
fi
}
# โโ Step 5: ้ๅฏ Gateway โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
restart_gateway() {
info "้ๅฏ OpenClaw Gateway ไปฅๅบ็จ้
็ฝฎ..."
if command -v openclaw &>/dev/null; then
if openclaw gateway restart 2>/dev/null; then
log "Gateway ้ๅฏๆๅ"
else
warn "Gateway ้ๅฏๅคฑ่ดฅ๏ผ่ฏทๆๅจ้ๅฏ๏ผopenclaw gateway restart"
fi
else
warn "ๆชๆพๅฐ openclaw ๅฝไปค่กๅทฅๅ
ท๏ผ่ทณ่ฟ้ๅฏ Gateway"
fi
}
# โโ Main โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
banner
check_env
stop_services
unregister_agents
remove_workspaces
remove_data
restart_gateway
echo ""
echo -e "${GREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo -e "${GREEN}โ โ
ไธ็ๅ
ญ้จๅธ่ฝฝๅฎๆ๏ผ โ${NC}"
echo -e "${GREEN}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${NC}"
echo ""