Skip to content
广告 · 本站推荐广告

安装器内部原理

OpenClaw 提供三个安装脚本,覆盖所有主流平台。本文档面向需要了解脚本内部行为的高级用户和 CI/CD 集成。


三个安装脚本

脚本平台说明
install.shmacOS / Linux / WSL2主安装脚本,安装 Gateway + CLI + 系统服务
install-cli.shmacOS / Linux / WSL2仅安装 CLI 工具(不含 Gateway 服务)
install.ps1Windows PowerShellWindows 平台安装脚本

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 | iex

CI / CD 自动化集成

GitHub Actions

yaml
- name: Install OpenClaw
  run: |
    curl -fsSL https://openclaw.ai/install.sh | bash -s -- \
      --yes --no-service --skip-doctor
    openclaw --version

GitLab CI

yaml
install_openclaw:
  script:
    - curl -fsSL https://openclaw.ai/install.sh | bash -s -- -y --no-service
    - openclaw --version

Docker

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

基于MIT协议开源 | 内容翻译自 官方文档,同步更新