自动化部署openclaw
#.SYNOPSISOpenClaw 一键安装脚本 (Windows PowerShell).DESCRIPTION自动检查环境、安装 OpenClaw、运行配置向导。.NOTES版本: 1.0 | 日期: 2026-03-27#Write-Host -ForegroundColor CyanWrite-Host OpenClaw 一键安装脚本 -ForegroundColor CyanWrite-Host -ForegroundColor CyanWrite-Host # 1. 检查 Node.jsWrite-Host [1/4] 检查 Node.js... -ForegroundColor Yellow$nodeVersion $nulltry { $nodeVersion node -v 2$null } catch {}if ($nodeVersion) {$major [int]($nodeVersion -replace ^v(\d).*, $1)if ($major -ge 22) {Write-Host [OK] Node.js $nodeVersion (满足要求) -ForegroundColor Green} else {Write-Host [WARN] Node.js $nodeVersion (需要 v22.14) -ForegroundColor RedWrite-Host 请访问 https://nodejs.org 下载安装 Node.js v24 LTS -ForegroundColor YellowRead-Host 安装完成后按回车继续}} else {Write-Host [FAIL] 未检测到 Node.js -ForegroundColor RedWrite-Host 正在通过 winget 安装 Node.js LTS... -ForegroundColor Yellowwinget install OpenJS.NodeJS.LTSWrite-Host 请重新打开终端后重新运行此脚本 -ForegroundColor Yellowexit 1}# 2. 安装 OpenClawWrite-Host Write-Host [2/4] 安装 OpenClaw... -ForegroundColor Yellowtry {npm install -g openclawlatestWrite-Host [OK] OpenClaw 安装成功 -ForegroundColor Green} catch {Write-Host [FAIL] 安装失败: $_ -ForegroundColor Redexit 1}# 3. 验证安装Write-Host Write-Host [3/4] 验证安装... -ForegroundColor Yellow$version openclaw --version 2$nullif ($version) {Write-Host [OK] OpenClaw $version -ForegroundColor Green} else {Write-Host [WARN] 命令不可用可能需要重启终端 -ForegroundColor DarkYellow}# 4. 运行配置向导Write-Host Write-Host [4/4] 启动配置向导... -ForegroundColor YellowWrite-Host 即将运行 openclaw onboard 引导你完成初始配置 -ForegroundColor WhiteWrite-Host 你需要准备至少一个 AI 模型的 API Key (Anthropic/OpenAI/DeepSeek 等) -ForegroundColor WhiteWrite-Host $runOnboard Read-Host 是否现在开始配置? (Y/n)if ($runOnboard -ne n) {openclaw onboard --install-daemon}Write-Host Write-Host -ForegroundColor CyanWrite-Host 安装完成! -ForegroundColor GreenWrite-Host 常用命令: -ForegroundColor WhiteWrite-Host openclaw gateway status # 查看状态 -ForegroundColor DarkGrayWrite-Host openclaw dashboard # 打开控制面板 -ForegroundColor DarkGrayWrite-Host openclaw doctor # 运行诊断 -ForegroundColor DarkGrayWrite-Host openclaw logs --follow # 查看日志 -ForegroundColor DarkGrayWrite-Host -ForegroundColor Cyan