openclawsetup 1.0.4 → 1.0.5
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/bin/cli.mjs +43 -2
- package/package.json +1 -1
package/bin/cli.mjs
CHANGED
|
@@ -519,6 +519,23 @@ function startService(cliName) {
|
|
|
519
519
|
return false;
|
|
520
520
|
}
|
|
521
521
|
|
|
522
|
+
// 检测是否在云服务器/VPS 上运行
|
|
523
|
+
function detectVPS() {
|
|
524
|
+
// 检查常见的云服务器特征
|
|
525
|
+
const indicators = [
|
|
526
|
+
existsSync('/etc/cloud'), // cloud-init
|
|
527
|
+
existsSync('/var/lib/cloud'), // cloud-init data
|
|
528
|
+
existsSync('/sys/hypervisor'), // 虚拟化
|
|
529
|
+
process.env.CLOUD_SHELL === 'true', // Google Cloud Shell
|
|
530
|
+
];
|
|
531
|
+
|
|
532
|
+
// 检查是否有公网 IP(简单检测)
|
|
533
|
+
const result = safeExec('hostname -I 2>/dev/null || hostname -i 2>/dev/null');
|
|
534
|
+
const hasPublicIP = result.ok && result.output && !result.output.startsWith('127.');
|
|
535
|
+
|
|
536
|
+
return indicators.some(Boolean) || hasPublicIP;
|
|
537
|
+
}
|
|
538
|
+
|
|
522
539
|
// 主函数
|
|
523
540
|
async function main() {
|
|
524
541
|
const options = parseArgs();
|
|
@@ -567,6 +584,9 @@ async function main() {
|
|
|
567
584
|
log.info('跳过服务启动 (--skip-start)');
|
|
568
585
|
}
|
|
569
586
|
|
|
587
|
+
// 检测是否在 VPS 上
|
|
588
|
+
const isVPS = detectVPS();
|
|
589
|
+
|
|
570
590
|
// 完成
|
|
571
591
|
console.log(colors.bold(colors.green('\n========================================')));
|
|
572
592
|
console.log(colors.bold(colors.green('✅ OpenClaw 安装完成!')));
|
|
@@ -577,8 +597,29 @@ async function main() {
|
|
|
577
597
|
console.log(` Gateway 端口: ${colors.yellow(config.port)}`);
|
|
578
598
|
console.log(` Gateway Token: ${colors.yellow(config.token)}`);
|
|
579
599
|
|
|
580
|
-
|
|
581
|
-
|
|
600
|
+
// 根据环境显示不同的访问说明
|
|
601
|
+
if (isVPS) {
|
|
602
|
+
console.log(colors.cyan('\n📡 Dashboard 访问 (云服务器):'));
|
|
603
|
+
console.log(colors.gray(' Gateway 默认绑定 127.0.0.1,外部无法直接访问(安全设计)'));
|
|
604
|
+
console.log('');
|
|
605
|
+
console.log(colors.yellow(' 方式一:SSH 隧道(推荐,安全)'));
|
|
606
|
+
console.log(colors.gray(' 在本地电脑执行以下命令,保持终端窗口打开:'));
|
|
607
|
+
console.log(` ssh -N -L ${config.port}:127.0.0.1:${config.port} root@<服务器IP>`);
|
|
608
|
+
console.log(colors.gray(' 然后在本地浏览器访问:'));
|
|
609
|
+
console.log(` ${colors.green(`http://127.0.0.1:${config.port}/?token=${config.token}`)}`);
|
|
610
|
+
console.log('');
|
|
611
|
+
console.log(colors.yellow(' 方式二:直接暴露端口(不推荐,有安全风险)'));
|
|
612
|
+
console.log(colors.gray(' 1. 修改配置文件 ~/.openclaw/openclaw.json'));
|
|
613
|
+
console.log(colors.gray(' 将 "bind": "loopback" 改为 "bind": "all"'));
|
|
614
|
+
console.log(colors.gray(' 2. 在云服务器控制台开放端口 ' + config.port));
|
|
615
|
+
console.log(colors.gray(' - 腾讯云:安全组 → 入站规则 → 添加 TCP ' + config.port));
|
|
616
|
+
console.log(colors.gray(' - 阿里云:安全组 → 配置规则 → 添加 TCP ' + config.port));
|
|
617
|
+
console.log(colors.gray(' 3. 重启 Gateway:' + cliName + ' gateway restart'));
|
|
618
|
+
console.log(colors.gray(' 4. 访问:http://<服务器IP>:' + config.port + '/?token=...'));
|
|
619
|
+
} else {
|
|
620
|
+
console.log(colors.cyan('\nDashboard 访问:'));
|
|
621
|
+
console.log(` ${colors.yellow(`http://127.0.0.1:${config.port}/?token=${config.token}`)}`);
|
|
622
|
+
}
|
|
582
623
|
|
|
583
624
|
console.log(colors.cyan('\n下一步 - 配置 AI 模型:'));
|
|
584
625
|
console.log(` ${colors.yellow('npx openclawapi@latest preset-claude')}`);
|