安装器内部原理
OpenClaw 提供三个安装脚本,覆盖所有主流平台。本文档面向需要了解脚本内部行为的高级用户和 CI/CD 集成。
三个安装脚本
| 脚本 | 平台 | 说明 |
|---|---|---|
install.sh | macOS / Linux / WSL2 | 主安装脚本,安装 Gateway + CLI + 系统服务 |
install-cli.sh | macOS / Linux / WSL2 | 仅安装 CLI 工具(不含 Gateway 服务) |
install.ps1 | Windows PowerShell | Windows 平台安装脚本 |
install.sh 工作流程
开始
│
├── 检测操作系统 & 架构
├── 检测 Node.js 版本(>= 22)
│ └── 未找到 → 提示安装 Node.js 并退出
├── 检测已有安装
│ └── 已安装 → 询问是否升级
├── 下载最新版本包
│ ├── 优先使用 GitHub Releases CDN
│ └── 回退到 npm registry
├── 解压到 ~/.openclaw/
├── 安装原生依赖(sharp 等)
├── 创建 symlink → /usr/local/bin/openclaw
├── 注册系统服务
│ ├── macOS → launchd plist
│ └── Linux → systemd user service
├── 运行 openclaw doctor
└── 输出安装完成信息标志位(Flags)
| Flag | 说明 |
|---|---|
--version <ver> | 安装指定版本(默认 latest) |
--channel <ch> | 安装通道:stable / beta / dev |
--hackable | 从源码安装,保留 .git 目录 |
--no-service | 不注册系统服务 |
--prefix <path> | 自定义安装路径(默认 ~/.openclaw) |
--skip-doctor | 跳过安装后健康检查 |
--yes / -y | 非交互模式,自动确认所有提示 |
示例:
bash
# 安装 beta 通道的 v2.0.0-beta.1 版本
curl -fsSL https://openclaw.ai/install.sh | bash -s -- \
--channel beta --version 2.0.0-beta.1
# CI 环境:非交互式安装,不注册服务
curl -fsSL https://openclaw.ai/install.sh | bash -s -- \
--yes --no-service --skip-doctor环境变量
| 变量 | 说明 |
|---|---|
OPENCLAW_INSTALL_DIR | 覆盖安装目录(等同 --prefix) |
OPENCLAW_VERSION | 覆盖安装版本(等同 --version) |
OPENCLAW_CHANNEL | 覆盖安装通道(等同 --channel) |
OPENCLAW_MIRROR | 自定义下载镜像 URL |
OPENCLAW_NO_SERVICE | 设为 1 跳过服务注册 |
CI | 设为 true 时自动启用非交互模式 |
install-cli.sh 工作流程
install-cli.sh 是精简版脚本,仅安装 openclaw CLI 二进制:
bash
curl -fsSL https://openclaw.ai/install-cli.sh | bash- 不安装 Gateway 服务
- 不注册 launchd / systemd 服务
- 适用于只需要 CLI 工具的场景(如远程管理)
install.ps1 工作流程
Windows PowerShell 安装脚本:
开始
│
├── 检测 PowerShell 版本(>= 5.1)
├── 检测 Node.js 版本
├── 下载最新版本 zip
├── 解压到 %USERPROFILE%\.openclaw\
├── 添加到用户 PATH
├── (可选)注册 Windows 服务
├── 运行 openclaw doctor
└── 输出安装完成信息PowerShell 标志位
powershell
# 指定版本
irm https://openclaw.ai/install.ps1 | iex -Args "--version", "1.2.3"
# 非交互模式
$env:OPENCLAW_YES = "1"
irm https://openclaw.ai/install.ps1 | iexCI / CD 自动化集成
GitHub Actions
yaml
- name: Install OpenClaw
run: |
curl -fsSL https://openclaw.ai/install.sh | bash -s -- \
--yes --no-service --skip-doctor
openclaw --versionGitLab CI
yaml
install_openclaw:
script:
- curl -fsSL https://openclaw.ai/install.sh | bash -s -- -y --no-service
- openclaw --versionDocker
dockerfile
RUN curl -fsSL https://openclaw.ai/install-cli.sh | bash🇨🇳 中国用户须知
在 CI 环境中使用镜像加速:
bash
export OPENCLAW_MIRROR="https://cdn.jsdelivr.net/gh/openclaw/dist@main"
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --yes或直接使用中文社区分发的安装脚本:
bash
curl -fsSL https://openclaw.ai/install.sh | bash