openclawsetup 1.0.9 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.sh +237 -11
- package/package.json +1 -1
- package//344/275/277/347/224/250/350/257/264/346/230/216.md +31 -21
package/install.sh
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# OpenClaw 一键安装脚本
|
|
3
|
-
# 用法: curl -fsSL https://
|
|
3
|
+
# 用法: curl -fsSL https://unpkg.com/openclawsetup/install.sh | bash
|
|
4
4
|
|
|
5
5
|
set -e
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ RED='\033[0;31m'
|
|
|
9
9
|
GREEN='\033[0;32m'
|
|
10
10
|
YELLOW='\033[0;33m'
|
|
11
11
|
CYAN='\033[0;36m'
|
|
12
|
-
NC='\033[0m'
|
|
12
|
+
NC='\033[0m'
|
|
13
13
|
|
|
14
14
|
log_info() { echo -e "${CYAN}$1${NC}"; }
|
|
15
15
|
log_success() { echo -e "${GREEN}✓ $1${NC}"; }
|
|
@@ -69,7 +69,6 @@ install_node() {
|
|
|
69
69
|
log_info "正在安装 Node.js 22..."
|
|
70
70
|
|
|
71
71
|
if [ "$OS" == "macos" ]; then
|
|
72
|
-
# macOS - 使用 Homebrew 或 nvm
|
|
73
72
|
if command -v brew &> /dev/null; then
|
|
74
73
|
brew install node@22
|
|
75
74
|
brew link --overwrite --force node@22
|
|
@@ -82,7 +81,6 @@ install_node() {
|
|
|
82
81
|
nvm alias default 22
|
|
83
82
|
fi
|
|
84
83
|
elif [ "$OS" == "linux" ]; then
|
|
85
|
-
# Linux - 根据包管理器安装
|
|
86
84
|
case "$PM" in
|
|
87
85
|
apt)
|
|
88
86
|
log_info "使用 NodeSource 安装..."
|
|
@@ -145,6 +143,216 @@ check_npm() {
|
|
|
145
143
|
fi
|
|
146
144
|
}
|
|
147
145
|
|
|
146
|
+
# 检测 OpenClaw 安装状态
|
|
147
|
+
check_openclaw() {
|
|
148
|
+
if [ -d "$HOME/.openclaw" ] || [ -d "$HOME/.clawdbot" ]; then
|
|
149
|
+
return 0
|
|
150
|
+
fi
|
|
151
|
+
if command -v openclaw &> /dev/null || command -v clawdbot &> /dev/null; then
|
|
152
|
+
return 0
|
|
153
|
+
fi
|
|
154
|
+
return 1
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
# 获取 CLI 名称
|
|
158
|
+
get_cli_name() {
|
|
159
|
+
if command -v openclaw &> /dev/null; then
|
|
160
|
+
echo "openclaw"
|
|
161
|
+
elif command -v clawdbot &> /dev/null; then
|
|
162
|
+
echo "clawdbot"
|
|
163
|
+
else
|
|
164
|
+
echo "openclaw"
|
|
165
|
+
fi
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
# 读取配置信息
|
|
169
|
+
read_config() {
|
|
170
|
+
local config_dir=""
|
|
171
|
+
local config_file=""
|
|
172
|
+
|
|
173
|
+
if [ -d "$HOME/.openclaw" ]; then
|
|
174
|
+
config_dir="$HOME/.openclaw"
|
|
175
|
+
config_file="$config_dir/openclaw.json"
|
|
176
|
+
elif [ -d "$HOME/.clawdbot" ]; then
|
|
177
|
+
config_dir="$HOME/.clawdbot"
|
|
178
|
+
config_file="$config_dir/clawdbot.json"
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
if [ -f "$config_file" ]; then
|
|
182
|
+
TOKEN=$(grep -o '"token"[[:space:]]*:[[:space:]]*"[^"]*"' "$config_file" | head -1 | sed 's/.*"token"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/')
|
|
183
|
+
PORT=$(grep -o '"port"[[:space:]]*:[[:space:]]*[0-9]*' "$config_file" | head -1 | sed 's/.*"port"[[:space:]]*:[[:space:]]*\([0-9]*\).*/\1/')
|
|
184
|
+
PORT=${PORT:-18789}
|
|
185
|
+
fi
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
# 显示已安装信息
|
|
189
|
+
show_installed_info() {
|
|
190
|
+
local cli_name=$(get_cli_name)
|
|
191
|
+
read_config
|
|
192
|
+
|
|
193
|
+
echo ""
|
|
194
|
+
echo -e "${GREEN}========================================"
|
|
195
|
+
echo -e "✅ OpenClaw 已安装"
|
|
196
|
+
echo -e "========================================${NC}"
|
|
197
|
+
|
|
198
|
+
echo -e "${CYAN}\n配置信息:${NC}"
|
|
199
|
+
if [ -d "$HOME/.openclaw" ]; then
|
|
200
|
+
echo " 配置目录: $HOME/.openclaw"
|
|
201
|
+
elif [ -d "$HOME/.clawdbot" ]; then
|
|
202
|
+
echo " 配置目录: $HOME/.clawdbot"
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
if command -v $cli_name &> /dev/null; then
|
|
206
|
+
echo " 版本: $($cli_name --version 2>/dev/null || echo '未知')"
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
echo " Gateway 端口: ${PORT:-18789}"
|
|
210
|
+
if [ -n "$TOKEN" ]; then
|
|
211
|
+
echo " Gateway Token: $TOKEN"
|
|
212
|
+
fi
|
|
213
|
+
|
|
214
|
+
# 检测是否在 VPS 上
|
|
215
|
+
IS_VPS=false
|
|
216
|
+
if [ -d "/etc/cloud" ] || [ -d "/var/lib/cloud" ] || [ -d "/sys/hypervisor" ]; then
|
|
217
|
+
IS_VPS=true
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
if [ "$IS_VPS" = true ]; then
|
|
221
|
+
echo -e "${CYAN}\n📡 Dashboard 访问 (云服务器):${NC}"
|
|
222
|
+
echo -e "\033[90m Gateway 默认绑定 127.0.0.1,外部无法直接访问(安全设计)\033[0m"
|
|
223
|
+
echo ""
|
|
224
|
+
echo -e "${YELLOW} 方式一:SSH 隧道(推荐,安全)${NC}"
|
|
225
|
+
echo -e "\033[90m 在本地电脑执行以下命令,保持终端窗口打开:\033[0m"
|
|
226
|
+
echo " ssh -N -L ${PORT:-18789}:127.0.0.1:${PORT:-18789} root@<服务器IP>"
|
|
227
|
+
echo -e "\033[90m 然后在本地浏览器访问:\033[0m"
|
|
228
|
+
echo -e " ${GREEN}http://127.0.0.1:${PORT:-18789}/?token=${TOKEN:-<你的token>}${NC}"
|
|
229
|
+
echo ""
|
|
230
|
+
echo -e "${YELLOW} 方式二:直接暴露端口(不推荐,有安全风险)${NC}"
|
|
231
|
+
echo -e "\033[90m 1. 修改配置文件 ~/.openclaw/openclaw.json\033[0m"
|
|
232
|
+
echo -e "\033[90m 将 \"bind\": \"loopback\" 改为 \"bind\": \"all\"\033[0m"
|
|
233
|
+
echo -e "\033[90m 2. 在云服务器控制台开放端口 ${PORT:-18789}\033[0m"
|
|
234
|
+
echo -e "\033[90m - 腾讯云:安全组 → 入站规则 → 添加 TCP ${PORT:-18789}\033[0m"
|
|
235
|
+
echo -e "\033[90m - 阿里云:安全组 → 配置规则 → 添加 TCP ${PORT:-18789}\033[0m"
|
|
236
|
+
echo -e "\033[90m 3. 重启 Gateway:$cli_name gateway restart\033[0m"
|
|
237
|
+
echo -e "\033[90m 4. 访问:http://<服务器IP>:${PORT:-18789}/?token=...\033[0m"
|
|
238
|
+
else
|
|
239
|
+
echo -e "${CYAN}\nDashboard 访问:${NC}"
|
|
240
|
+
echo -e " ${YELLOW}http://127.0.0.1:${PORT:-18789}/?token=${TOKEN:-<你的token>}${NC}"
|
|
241
|
+
fi
|
|
242
|
+
|
|
243
|
+
echo -e "${CYAN}\n常用命令:${NC}"
|
|
244
|
+
echo " 查看状态: $cli_name status"
|
|
245
|
+
echo " 查看日志: $cli_name gateway logs"
|
|
246
|
+
echo " 重启服务: $cli_name gateway restart"
|
|
247
|
+
echo " 诊断问题: $cli_name doctor"
|
|
248
|
+
|
|
249
|
+
echo -e "${CYAN}\n配置 AI 模型:${NC}"
|
|
250
|
+
echo " npx openclawapi@latest preset-claude"
|
|
251
|
+
|
|
252
|
+
echo -e "${CYAN}\n配置聊天渠道:${NC}"
|
|
253
|
+
echo " Discord: npx openclawdc"
|
|
254
|
+
echo " 飞书: npx openclawfs"
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
# 显示菜单并获取选择
|
|
258
|
+
show_menu() {
|
|
259
|
+
echo -e "${CYAN}\n请选择操作:${NC}"
|
|
260
|
+
echo -e " ${YELLOW}1${NC}. 检查并更新 OpenClaw"
|
|
261
|
+
echo -e " ${YELLOW}2${NC}. 卸载后重新安装(会清除配置)"
|
|
262
|
+
echo -e " ${YELLOW}0${NC}. 退出"
|
|
263
|
+
echo ""
|
|
264
|
+
read -p "请输入选项编号: " choice
|
|
265
|
+
echo "$choice"
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
# 更新 OpenClaw
|
|
269
|
+
update_openclaw() {
|
|
270
|
+
local cli_name=$(get_cli_name)
|
|
271
|
+
|
|
272
|
+
echo -e "${CYAN}\n检查更新中...${NC}"
|
|
273
|
+
|
|
274
|
+
local current_version=$($cli_name --version 2>/dev/null || echo "未知")
|
|
275
|
+
echo " 当前版本: $current_version"
|
|
276
|
+
|
|
277
|
+
log_info "正在更新到最新版本..."
|
|
278
|
+
npm install -g ${cli_name}@latest
|
|
279
|
+
|
|
280
|
+
local new_version=$($cli_name --version 2>/dev/null || echo "未知")
|
|
281
|
+
if [ "$new_version" != "$current_version" ]; then
|
|
282
|
+
log_success "更新完成: $current_version → $new_version"
|
|
283
|
+
else
|
|
284
|
+
log_success "已是最新版本: $new_version"
|
|
285
|
+
fi
|
|
286
|
+
|
|
287
|
+
echo -e "${CYAN}\n重启 Gateway 服务...${NC}"
|
|
288
|
+
if $cli_name gateway restart 2>/dev/null; then
|
|
289
|
+
log_success "Gateway 已重启"
|
|
290
|
+
else
|
|
291
|
+
log_warn "Gateway 重启失败,请手动重启: $cli_name gateway restart"
|
|
292
|
+
fi
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
# 卸载 OpenClaw
|
|
296
|
+
uninstall_openclaw() {
|
|
297
|
+
local cli_name=$(get_cli_name)
|
|
298
|
+
|
|
299
|
+
echo -e "${CYAN}\n开始卸载...${NC}"
|
|
300
|
+
|
|
301
|
+
# 停止服务
|
|
302
|
+
log_info "停止 Gateway 服务..."
|
|
303
|
+
$cli_name gateway stop 2>/dev/null || true
|
|
304
|
+
|
|
305
|
+
# 卸载 npm 包
|
|
306
|
+
log_info "卸载 npm 包..."
|
|
307
|
+
npm uninstall -g $cli_name 2>/dev/null || true
|
|
308
|
+
log_success "npm 包已卸载"
|
|
309
|
+
|
|
310
|
+
# 删除配置目录
|
|
311
|
+
if [ -d "$HOME/.openclaw" ]; then
|
|
312
|
+
log_info "删除配置目录..."
|
|
313
|
+
rm -rf "$HOME/.openclaw"
|
|
314
|
+
log_success "配置目录已删除"
|
|
315
|
+
fi
|
|
316
|
+
if [ -d "$HOME/.clawdbot" ]; then
|
|
317
|
+
rm -rf "$HOME/.clawdbot"
|
|
318
|
+
fi
|
|
319
|
+
|
|
320
|
+
# 删除服务持久化配置
|
|
321
|
+
if [ "$OS" == "macos" ]; then
|
|
322
|
+
local plist="$HOME/Library/LaunchAgents/com.openclaw.gateway.plist"
|
|
323
|
+
if [ -f "$plist" ]; then
|
|
324
|
+
launchctl unload "$plist" 2>/dev/null || true
|
|
325
|
+
rm -f "$plist"
|
|
326
|
+
log_success "macOS 服务配置已删除"
|
|
327
|
+
fi
|
|
328
|
+
elif [ "$OS" == "linux" ]; then
|
|
329
|
+
systemctl --user stop openclaw 2>/dev/null || true
|
|
330
|
+
systemctl --user disable openclaw 2>/dev/null || true
|
|
331
|
+
local service="$HOME/.config/systemd/user/openclaw.service"
|
|
332
|
+
if [ -f "$service" ]; then
|
|
333
|
+
rm -f "$service"
|
|
334
|
+
systemctl --user daemon-reload 2>/dev/null || true
|
|
335
|
+
log_success "Linux 服务配置已删除"
|
|
336
|
+
fi
|
|
337
|
+
fi
|
|
338
|
+
|
|
339
|
+
log_success "卸载完成"
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
# 安装 OpenClaw
|
|
343
|
+
install_openclaw() {
|
|
344
|
+
echo ""
|
|
345
|
+
log_info "开始安装 OpenClaw..."
|
|
346
|
+
echo ""
|
|
347
|
+
|
|
348
|
+
# 清除 npm 缓存确保获取最新版本
|
|
349
|
+
log_info "清除 npm 缓存..."
|
|
350
|
+
npm cache clean --force 2>/dev/null || true
|
|
351
|
+
|
|
352
|
+
# 运行安装
|
|
353
|
+
npx --yes openclawsetup@latest
|
|
354
|
+
}
|
|
355
|
+
|
|
148
356
|
# 主流程
|
|
149
357
|
main() {
|
|
150
358
|
# 1. 检查/安装 Node.js
|
|
@@ -162,15 +370,33 @@ main() {
|
|
|
162
370
|
exit 1
|
|
163
371
|
fi
|
|
164
372
|
|
|
165
|
-
# 3.
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
373
|
+
# 3. 检测 OpenClaw 安装状态
|
|
374
|
+
if check_openclaw; then
|
|
375
|
+
# 已安装:显示信息和菜单
|
|
376
|
+
show_installed_info
|
|
169
377
|
|
|
170
|
-
|
|
171
|
-
npm cache clean --force openclawsetup 2>/dev/null || true
|
|
378
|
+
choice=$(show_menu)
|
|
172
379
|
|
|
173
|
-
|
|
380
|
+
case "$choice" in
|
|
381
|
+
1)
|
|
382
|
+
update_openclaw
|
|
383
|
+
;;
|
|
384
|
+
2)
|
|
385
|
+
uninstall_openclaw
|
|
386
|
+
echo ""
|
|
387
|
+
echo -e "${GREEN}✓ 卸载完成,开始重新安装...${NC}"
|
|
388
|
+
echo ""
|
|
389
|
+
install_openclaw
|
|
390
|
+
;;
|
|
391
|
+
*)
|
|
392
|
+
echo -e "\033[90m\n已退出\033[0m"
|
|
393
|
+
exit 0
|
|
394
|
+
;;
|
|
395
|
+
esac
|
|
396
|
+
else
|
|
397
|
+
# 未安装:直接安装
|
|
398
|
+
install_openclaw
|
|
399
|
+
fi
|
|
174
400
|
}
|
|
175
401
|
|
|
176
402
|
main "$@"
|
package/package.json
CHANGED
|
@@ -2,16 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
## 快速开始
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### 方式一:npx 直接安装(推荐)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
已安装 Node.js 18+ 的用户,直接运行:
|
|
8
8
|
|
|
9
|
-
**Linux (Debian/Ubuntu/CentOS 等):**
|
|
10
9
|
```bash
|
|
11
|
-
|
|
10
|
+
npx --yes openclawsetup@latest
|
|
12
11
|
```
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
### 方式二:一键脚本
|
|
14
|
+
|
|
15
|
+
自动检测并安装 Node.js,无需任何前置条件。
|
|
16
|
+
|
|
17
|
+
**Linux / macOS:**
|
|
15
18
|
```bash
|
|
16
19
|
curl -fsSL https://unpkg.com/openclawsetup/install.sh | bash
|
|
17
20
|
```
|
|
@@ -21,24 +24,26 @@ curl -fsSL https://unpkg.com/openclawsetup/install.sh | bash
|
|
|
21
24
|
irm https://unpkg.com/openclawsetup/install.ps1 | iex
|
|
22
25
|
```
|
|
23
26
|
|
|
24
|
-
### 方式二:npx(需要已安装 Node.js)
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npx openclawsetup
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
⚠️ 如果提示 `npx: command not found`,说明未安装 Node.js,请使用方式一。
|
|
31
|
-
|
|
32
27
|
### 方式三:指定端口
|
|
33
28
|
```bash
|
|
34
29
|
# macOS/Linux
|
|
35
|
-
OPENCLAW_PORT=8080 npx openclawsetup
|
|
30
|
+
OPENCLAW_PORT=8080 npx --yes openclawsetup@latest
|
|
36
31
|
|
|
37
32
|
# Windows PowerShell
|
|
38
|
-
$env:OPENCLAW_PORT=8080; npx openclawsetup
|
|
33
|
+
$env:OPENCLAW_PORT=8080; npx --yes openclawsetup@latest
|
|
39
34
|
|
|
40
35
|
# Windows CMD
|
|
41
|
-
set OPENCLAW_PORT=8080 && npx openclawsetup
|
|
36
|
+
set OPENCLAW_PORT=8080 && npx --yes openclawsetup@latest
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 已安装用户:更新或重装
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# 检查并更新
|
|
43
|
+
npx --yes openclawsetup@latest --update
|
|
44
|
+
|
|
45
|
+
# 卸载后重新安装(会清除配置)
|
|
46
|
+
npx --yes openclawsetup@latest --reinstall
|
|
42
47
|
```
|
|
43
48
|
|
|
44
49
|
## 安装完成后
|
|
@@ -115,18 +120,23 @@ apk add curl
|
|
|
115
120
|
---
|
|
116
121
|
|
|
117
122
|
### 错误:npm 安装失败
|
|
118
|
-
**现象**:提示 "npm 安装失败"
|
|
123
|
+
**现象**:提示 "npm 安装失败" 或 "No matching version found"
|
|
119
124
|
**解决**:
|
|
120
|
-
1.
|
|
121
|
-
|
|
125
|
+
1. 清除 npm 缓存后重试:
|
|
126
|
+
```bash
|
|
127
|
+
npm cache clean --force
|
|
128
|
+
npx --yes openclawsetup@latest
|
|
129
|
+
```
|
|
130
|
+
2. 检查网络连接
|
|
131
|
+
3. 尝试使用代理:
|
|
122
132
|
```bash
|
|
123
133
|
npm config set proxy http://proxy:port
|
|
124
134
|
```
|
|
125
|
-
|
|
135
|
+
4. 手动安装:
|
|
126
136
|
```bash
|
|
127
137
|
npm install -g openclaw@latest
|
|
128
138
|
```
|
|
129
|
-
|
|
139
|
+
5. Linux/macOS 可能需要 sudo:
|
|
130
140
|
```bash
|
|
131
141
|
sudo npm install -g openclaw@latest
|
|
132
142
|
```
|