Compare commits
15 Commits
e26c811b51
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 4dcf1d6b3c | |||
| ff9383f597 | |||
| 126b19dd7a | |||
| da477378a7 | |||
| 2007545b1d | |||
|
|
966f7e0ac8 | ||
|
|
1a84adb97b | ||
|
|
5e9d63ae1a | ||
|
|
cde26a8f7f | ||
|
|
40983ec0ee | ||
|
|
68c1bee826 | ||
|
|
0108f7fa2f | ||
|
|
25f31c596d | ||
|
|
d33688454b | ||
|
|
8385460172 |
451
README.md
451
README.md
@@ -1,430 +1,159 @@
|
|||||||
# <p align="center">2026年 OpenClaw 龙虾AI 一键部署教学,免费白嫖 MiniMax + Claude!</p>
|
# OpenClaw 一键安装脚本(macOS / Windows)
|
||||||
|
|
||||||
<p align="center">最近更新于:2026年2月13日</p>
|
这个仓库提供一组简化脚本,用于快速安装并初始化 OpenClaw。
|
||||||
|
|
||||||
<!-- TODO: Hero 图片(中文文件名) -->
|
- `install-macos.sh`:macOS 一键安装
|
||||||
<!--  -->
|
- `install-windows.ps1`:Windows 中文版一键安装
|
||||||
|
- `install-windows-en.ps1`:Windows 英文版一键安装
|
||||||
说实话,我之前一直想要一个能真正帮我做事的 AI 助手,后来发现了 OpenClaw(龙虾AI)。它不只是聊天工具,能直接帮你清理邮箱、管理日程、订机票,而且完全本地部署、数据不出本机。最重要的是,还能免费白嫖 MiniMax 大模型7天。配置过程也很简单,一行命令搞定,不用折腾环境。这篇教程把我踩过的坑都整理好了,照着做5分钟就能跑起来。
|
- `configure-aws-bedrock.sh/.ps1`:可选的 AWS Bedrock 配置脚本
|
||||||
|
- `uninstall-macos.sh` / `uninstall-windows.ps1`:卸载脚本
|
||||||
<blockquote>
|
|
||||||
|
|
||||||
### 🚀 一键安装 OpenClaw
|
|
||||||
|
|
||||||
* **macOS 用户**:复制粘贴一行命令,自动安装 Node.js + OpenClaw,5分钟搞定。查看:[macOS 安装](#一键安装)
|
|
||||||
* **Windows 用户**:管理员运行 PowerShell,一键安装 WSL2 + OpenClaw,重启后继续。查看:[Windows 安装](#一键安装)
|
|
||||||
|
|
||||||
### 💰 免费白嫖大模型方案
|
|
||||||
|
|
||||||
* **方法一:MiniMax 免费7天(推荐新手)**:注册即用,无需信用卡,国内直连。查看:[白嫖 MiniMax](#方法一免费白嫖-minimax7天试用)
|
|
||||||
|
|
||||||
* **方法二:AWS Bedrock $200(适合海外用户)**:新用户赠送 $200,免费用 Claude 3个月。查看:[AWS Bedrock](#方法二白嫖-aws-bedrock-claude)
|
|
||||||
|
|
||||||
* **方法三:合租拼车(长期使用,适合国内用户)**:Claude Pro/Code 合租,14元/月起。查看:[合租拼车](#方法三通过合租拼车降低-claude-价格)
|
|
||||||
|
|
||||||
</blockquote>
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## OpenClaw 龙虾AI 是什么?
|
## 与官方仓库对齐说明
|
||||||
|
|
||||||
[OpenClaw(龙虾AI / ClawsBot)](https://openclaw.ai)是一款**开源**的个人 AI 助手,由 PSPDFKit 创始人 Peter Steinberger 开发。它不只是聊天,而是真正能**帮你做事**的 AI:清理邮箱、发送消息、管理日程、订机票、监控市场……所有数据都在本地处理,完全隐私可控。
|
本仓库已按 `openclaw/openclaw` 最新安装建议做了对齐:
|
||||||
|
|
||||||
OpenClaw 通过你**已经在用的聊天工具**工作(WhatsApp、Telegram、Discord、Slack、微信、iMessage 等),也可以在终端和网页中使用。它支持接入多种大模型(MiniMax、Claude、GPT、Gemini 等),拥有 100+ 可扩展技能(AgentSkills),还有持久化记忆系统,能记住你的偏好和上下文。
|
1. 安装后统一进入 `openclaw onboard`
|
||||||
|
2. 向导阶段启用 `--install-daemon`,安装网关后台服务
|
||||||
|
3. 安装步骤改为“安装/更新”模式,避免机器上已有旧版本时不升级
|
||||||
|
4. 删除了与安装无关的营销内容,保留纯技术流程
|
||||||
|
|
||||||
### OpenClaw 龙虾AI 的核心优势
|
官方参考:
|
||||||
|
- GitHub: https://github.com/openclaw/openclaw
|
||||||
| 特性 | OpenClaw 龙虾AI | 传统 AI 助手 |
|
- Docs: https://docs.openclaw.ai/start/getting-started
|
||||||
|------|----------------|-------------|
|
|
||||||
| 价格 | **免费开源** | 大多需要付费订阅 |
|
|
||||||
| 使用方式 | **聊天工具(微信/WhatsApp/Telegram)+ 终端 + 网页** | 通常只有网页/App |
|
|
||||||
| 能力范围 | **真正执行任务**(发邮件、订机票、管理日程) | 大多只能回答问题 |
|
|
||||||
| 模型选择 | **多模型自由切换**(MiniMax、Claude、GPT、Gemini) | 通常绑定单一模型 |
|
|
||||||
| 数据隐私 | **数据不出本机** | 大多云端处理 |
|
|
||||||
| 国内可用 | **支持国内模型(MiniMax)** | 国外服务需要翻墙 |
|
|
||||||
| 可扩展性 | **100+ AgentSkills + 社区技能** | 功能固定 |
|
|
||||||
| 记忆系统 | **持久化记忆,跨会话保留上下文** | 大多仅限单次对话 |
|
|
||||||
|
|
||||||
### OpenClaw 能做什么?
|
|
||||||
|
|
||||||
OpenClaw 不只是聊天,而是真正能**帮你做事**的 AI 助手:
|
|
||||||
|
|
||||||
- **📧 邮件管理**:自动清理收件箱、发送邮件、回复消息
|
|
||||||
- **📅 日程管理**:管理日历、安排会议、设置提醒
|
|
||||||
- **✈️ 生活助手**:订机票、查航班、办理登机手续
|
|
||||||
- **🌐 网络自动化**:爬取网站数据、监控市场、研究信息
|
|
||||||
- **💻 代码开发**:写代码、Debug、重构、执行命令
|
|
||||||
- **📁 文件管理**:整理文件、批量处理、自动化脚本
|
|
||||||
- **🔗 跨平台协作**:通过你常用的聊天工具(微信、WhatsApp、Telegram)随时随地使用
|
|
||||||
|
|
||||||
<!-- TODO: 添加 OpenClaw 使用截图 -->
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 一键安装
|
## 统一入口(安装 / 卸载)
|
||||||
|
|
||||||
### 脚本做了什么?
|
> 运行脚本后会先弹出菜单,让用户选择:
|
||||||
|
> 1) 安装 / 更新
|
||||||
|
> 2) 卸载
|
||||||
|
|
||||||
完全透明 — 以下是脚本的具体操作:
|
|
||||||
|
### macOS
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/install-macos.sh | bash
|
||||||
|
```
|
||||||
|
|
||||||
|
### Windows(PowerShell)
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/install-windows.ps1 | iex
|
||||||
|
```
|
||||||
|
|
||||||
|
> 官方文档对 Windows 的推荐路径是 **WSL2**。如果你准备长期稳定使用,建议参考:
|
||||||
|
> https://docs.openclaw.ai/platforms/windows
|
||||||
|
|
||||||
|
### 当前默认配置(适合完全新手)
|
||||||
|
|
||||||
|
- Gateway 监听在本机回环地址(`127.0.0.1` / `loopback`)
|
||||||
|
- 默认跳过搜索提供商配置(`--skip-search`)
|
||||||
|
- 默认跳过渠道配置(`--skip-channels`)
|
||||||
|
- 默认跳过 Skills 配置(`--skip-skills`)
|
||||||
|
- OpenClaw 安装优先走 `npmmirror`,失败后回退 `npmjs`(更适合国内网络)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 安装脚本做了什么
|
||||||
|
|
||||||
| 步骤 | macOS | Windows |
|
| 步骤 | macOS | Windows |
|
||||||
|------|-------|---------|
|
|------|-------|---------|
|
||||||
| 1 | 检查/安装 Node.js 22+(通过 Homebrew) | 检查/安装 WSL2 + Ubuntu 24.04 |
|
| 1 | 检查/安装 Node.js 22+(Homebrew) | 检查/安装 Node.js 22+(winget/choco) |
|
||||||
| 2 | 安装 OpenClaw(静默安装) | 启用 systemd + 安装 Node.js 22+ |
|
| 2 | 安装或更新 OpenClaw | 安装或更新 OpenClaw |
|
||||||
| 3 | 启动配置向导 | 安装 OpenClaw + 网关守护进程 |
|
| 3 | 运行 onboarding 向导 | 运行 onboarding 向导 |
|
||||||
| 4 | — | 启动配置向导 |
|
| 4 | 安装 Gateway 后台服务 | 安装 Gateway 后台服务 |
|
||||||
|
|
||||||
脚本不会在 Homebrew (macOS) 或 WSL (Windows) 之外安装任何东西。
|
向导命令(脚本内部):
|
||||||
|
|
||||||
### macOS
|
|
||||||
|
|
||||||
打开终端,粘贴以下命令:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/install-macos.sh | bash
|
openclaw onboard --accept-risk --flow quickstart --install-daemon --gateway-bind loopback --node-manager npm --skip-search --skip-channels --skip-skills
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows
|
|
||||||
|
|
||||||
以**管理员身份**打开 PowerShell,运行:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
iwr -useb https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/install-windows.ps1 | iex
|
|
||||||
```
|
|
||||||
|
|
||||||
> **Windows 说明:** 脚本会自动安装 WSL2(Windows 子系统 Linux)。可能需要重启,重启后再次运行脚本即可。
|
|
||||||
|
|
||||||
### 配置流程
|
|
||||||
|
|
||||||
脚本运行后会自动进入配置向导,跟着以下步骤操作即可完成 OpenClaw 部署:
|
|
||||||
|
|
||||||
#### 1. 选择模型服务商
|
|
||||||
|
|
||||||
选择 **MiniMax**(默认 7 天免费试用,无需信用卡)
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 2. 选择认证方式
|
|
||||||
|
|
||||||
选择 **MiniMax OAuth**
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 3. 选择服务版本并授权
|
|
||||||
|
|
||||||
- **国内版**:国内访问更快(推荐国内用户)
|
|
||||||
- **国际版**:适合海外用户
|
|
||||||
|
|
||||||
选择后会自动打开浏览器进行 OAuth 授权,**新用户免费获得 7 天使用额度**,无需信用卡。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 4. 选择聊天频道(可选)
|
|
||||||
|
|
||||||
OpenClaw 可以通过多种聊天工具使用,选择你常用的:
|
|
||||||
|
|
||||||
- **Telegram**(推荐,国际用户首选,设置简单)
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
- **飞书**(推荐,国内用户首选)
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
- **其他频道**:WhatsApp、Discord、Slack、iMessage 等
|
|
||||||
|
|
||||||
> **提示:** 可以跳过频道配置,之后通过 `openclaw configure --section channels` 添加。
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 方法一:免费白嫖 MiniMax(7天试用)
|
## 安装完成后
|
||||||
|
|
||||||
MiniMax 是国内领先的 AI 大模型公司,他们的 MiniMax-M2.1 模型提供**7天免费试用**,无需信用卡,注册即可使用。
|
|
||||||
|
|
||||||
### 如何获取 MiniMax API Key
|
|
||||||
|
|
||||||
1. 前往 [platform.minimax.io](https://platform.minimax.io) 注册账号
|
|
||||||
2. 在控制台找到 **API Keys**
|
|
||||||
3. 点击 **创建新密钥**,复制保存
|
|
||||||
|
|
||||||
<!-- TODO: 添加 MiniMax 注册截图 -->
|
|
||||||
|
|
||||||
> **配置 OpenClaw 使用 MiniMax:** 运行安装脚本后,按照上方 [配置流程](#配置流程) 选择 MiniMax 并输入 API Key 即可。
|
|
||||||
|
|
||||||
### MiniMax vs Claude 能力对比
|
|
||||||
|
|
||||||
| 指标 | MiniMax-M2.1 | Claude Sonnet 4.5 |
|
|
||||||
|------|-------------|-------------------|
|
|
||||||
| 上下文窗口 | 20万 tokens | 20万 tokens |
|
|
||||||
| 最大输出 | 8,192 tokens | 8,192 tokens |
|
|
||||||
| 综合能力 | 强(支持代码、写作、分析等) | 非常强 |
|
|
||||||
| 价格 | **7天免费** | 按量付费 |
|
|
||||||
| 国内访问 | **直连,无需翻墙** | 需要翻墙 |
|
|
||||||
|
|
||||||
> **我的体验**:MiniMax-M2.1 的能力已经很不错了,日常写代码、处理邮件、分析数据、写文档都没问题。如果你是第一次用 OpenClaw,先白嫖7天体验一下,不满意再换其他模型。
|
|
||||||
|
|
||||||
<p align="center"><a href="https://platform.minimax.io">立即注册 MiniMax 免费账号</a></p>
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 方法二:白嫖 AWS Bedrock Claude
|
|
||||||
|
|
||||||
AWS Bedrock 为新用户提供**最高 $200 免费额度**(注册送 $100 + 完成任务送 $100),可以免费使用 Claude Opus / Sonnet 大约 3 个月。这个方法适合**人在海外**的用户(需要海外信用卡和地址)。
|
|
||||||
|
|
||||||
| 项目 | 额度 |
|
|
||||||
|------|-----|
|
|
||||||
| 注册赠送 | $100(立即可用)|
|
|
||||||
| 完成 5 个任务 | $100(额外奖励)|
|
|
||||||
| **总计** | **$200** |
|
|
||||||
| 有效期 | 3 个月 |
|
|
||||||
|
|
||||||
### AWS 注册和任务完成
|
|
||||||
|
|
||||||
**详细教程**:查看我们的 [Claude Code 安装 + AWS $200 白嫖完整指南](https://github.com/736773174/claude-code-free),包含:
|
|
||||||
- 注册 AWS 账号的完整步骤
|
|
||||||
- 5 个任务的详细操作教程(附截图)
|
|
||||||
- 如何获得 $200 免费额度
|
|
||||||
|
|
||||||
### 获取 AWS Access Key
|
|
||||||
|
|
||||||
配置脚本需要 AWS Access Key ID 和 Secret Access Key。按以下步骤创建:
|
|
||||||
|
|
||||||
#### 1. 创建 IAM 用户
|
|
||||||
|
|
||||||
进入 [IAM 控制台 → 用户](https://console.aws.amazon.com/iam/home#/users),点击右上角 **创建用户**。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 2. 输入用户名
|
|
||||||
|
|
||||||
输入用户名(如 `BedrockAPIKey`),**不勾选**控制台访问,点击下一步。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 3. 设置权限
|
|
||||||
|
|
||||||
选择 **直接附加策略**,搜索 `bedrock`,勾选 **AmazonBedrockFullAccess**,点击下一步并创建用户。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 4. 点击进入刚创建的用户
|
|
||||||
|
|
||||||
回到用户列表,点击刚创建的用户名。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 5. 创建访问密钥
|
|
||||||
|
|
||||||
在用户详情页,点击右上角的 **创建访问密钥**。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 6. 选择使用场景
|
|
||||||
|
|
||||||
选择 **在 AWS 之外运行的应用程序**,点击下一步。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### 7. 复制 Access Key
|
|
||||||
|
|
||||||
复制 **Access Key ID** 和 **Secret Access Key**,保存好(Secret Key 只显示一次)。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
> **重要**:还需要在 [AWS Bedrock 控制台](https://console.aws.amazon.com/bedrock/home#/modelaccess) 中**启用模型访问权限**,否则即使 IAM 权限正确也无法调用模型。
|
|
||||||
|
|
||||||
#### 8. 运行一键配置脚本
|
|
||||||
|
|
||||||
拿到 Access Key 后,在终端运行:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/configure-aws-bedrock.sh | bash
|
openclaw gateway status
|
||||||
|
openclaw dashboard
|
||||||
```
|
```
|
||||||
|
|
||||||
脚本会提示你输入上一步获取的 Access Key ID 和 Secret Access Key,然后自动完成配置、重启网关并测试连接。
|
如果服务未启动,可执行:
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### 可用模型一览
|
|
||||||
|
|
||||||
| 模型 | Bedrock Model ID | 推理能力 | 推荐用途 |
|
|
||||||
|------|-----------------|---------|---------|
|
|
||||||
| Claude Opus 4.6 | `global.anthropic.claude-opus-4-6-v1` | 有 | 最强推理,复杂架构决策 |
|
|
||||||
| Claude Opus 4.5 | `global.anthropic.claude-opus-4-5-20251001-v1:0` | 有 | 深度分析与研究 |
|
|
||||||
| **Claude Sonnet 4.5(默认)** | `global.anthropic.claude-sonnet-4-5-20250929-v1:0` | 有 | 日常开发,性价比最高 |
|
|
||||||
| Claude Haiku 4.5 | `global.anthropic.claude-haiku-4-5-20251001-v1:0` | 无 | 轻量任务,速度最快 |
|
|
||||||
|
|
||||||
> **配置参考**:完整配置示例请查看 [pahud 的 Gist](https://gist.github.com/pahud/8965bfeec441225009abfa96f4751f48)
|
|
||||||
|
|
||||||
> **注意**:AWS Bedrock 需要海外信用卡和地址,国内用户可能无法注册。国内用户建议选择方法一(MiniMax)或方法三(合租)。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 方法三:通过合租/拼车降低 Claude 价格(适合国内用户)
|
|
||||||
|
|
||||||
如果你需要长期使用 Claude,但觉得官方 API 太贵,可以通过第三方平台**合租 Claude Pro** 或 **Claude Code 订阅**,价格只有原价的 1/5 左右。
|
|
||||||
|
|
||||||
### 什么是 Claude 合租/拼车?
|
|
||||||
|
|
||||||
多个用户共享一个 Claude Pro 或 Claude Code 订阅账号,分摊费用。第三方平台负责管理账号和分配使用额度,每个用户都能正常使用 Claude,但价格大幅降低。
|
|
||||||
|
|
||||||
### 推荐平台
|
|
||||||
|
|
||||||
| 平台 | Claude Code 价格 | Claude Pro 价格 | 特点 |
|
|
||||||
|------|----------------|----------------|------|
|
|
||||||
| 星际放映厅 | 14元/月起 | 20元/月起 | 有备案,支持发票 |
|
|
||||||
| 其他平台 | 10-30元/月 | 15-40元/月 | 价格波动大 |
|
|
||||||
|
|
||||||
> **风险提示**:合租账号存在以下风险:
|
|
||||||
> - 可能被官方封号(虽然概率较低)
|
|
||||||
> - 平台跑路风险
|
|
||||||
> - 使用额度限制
|
|
||||||
> - 不适合企业/商业用途
|
|
||||||
|
|
||||||
### 如何在 OpenClaw 中使用合租账号?
|
|
||||||
|
|
||||||
合租平台通常提供 API Key 或 共享账号,你可以:
|
|
||||||
|
|
||||||
1. 如果提供 **API Key**:在 OpenClaw 配置向导中选择 **Anthropic**,填入平台提供的 API Key
|
|
||||||
2. 如果提供 **共享账号**:联系平台客服,询问是否支持 OpenClaw 接入
|
|
||||||
|
|
||||||
> **我的建议**:合租适合轻度使用,如果你是重度用户或企业用途,建议选择方法二(AWS Bedrock)或直接购买 Anthropic 官方 API。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 安装完成后怎么用?
|
|
||||||
|
|
||||||
### macOS
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd 你的项目目录
|
openclaw gateway start
|
||||||
openclaw
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 可选:配置 AWS Bedrock
|
||||||
|
|
||||||
|
### macOS / Linux
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -fsSL https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/configure-aws-bedrock.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
wsl
|
iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/configure-aws-bedrock.ps1 | iex
|
||||||
cd /mnt/c/Users/你的用户名/项目目录
|
|
||||||
openclaw
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 添加技能(可选)
|
脚本会提示输入:
|
||||||
|
- AWS Access Key ID
|
||||||
安装脚本跳过了技能配置,让你更快上手。后续添加技能:
|
- AWS Secret Access Key
|
||||||
|
- Region(默认 `us-east-1`)
|
||||||
```bash
|
|
||||||
openclaw configure --section skills
|
|
||||||
```
|
|
||||||
|
|
||||||
浏览可用技能:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openclaw skills
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 卸载 OpenClaw
|
## 卸载
|
||||||
|
|
||||||
|
> 推荐直接运行上面的“统一入口”脚本,然后选择 **2) 卸载**。
|
||||||
|
> 下面保留独立卸载命令,方便自动化或批量操作。
|
||||||
|
|
||||||
### macOS
|
### macOS
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
curl -fsSL https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/uninstall-macos.sh | bash
|
curl -fsSL https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-macos.sh | bash
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows(管理员 PowerShell)
|
### Windows
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
iwr -useb https://raw.githubusercontent.com/736773174/openclaw-setup-cn/main/uninstall-windows.ps1 | iex
|
iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-windows.ps1 | iex
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 常见问题
|
## 常见问题
|
||||||
|
|
||||||
### OpenClaw 龙虾AI 是什么?
|
### 1) `openclaw: command not found`
|
||||||
|
|
||||||
OpenClaw 是一款开源的个人 AI 助手,能真正帮你**执行任务**(发邮件、订机票、管理日程、处理文件等),不只是回答问题。它通过你已经在用的聊天工具(微信、WhatsApp、Telegram 等)工作,完全免费、开源,支持接入多种大模型(MiniMax、Claude、GPT、Gemini 等)。数据全部在本地处理,隐私性极好。
|
重新打开终端后再试,或手动加载 PATH。
|
||||||
|
|
||||||
### 国内能用吗?需要翻墙吗?
|
### 2) Node 版本过低
|
||||||
|
|
||||||
**选 MiniMax 或 MiniMax CN 就不需要翻墙**。如果选择 Claude 或 OpenAI 等国外模型,则需要科学上网。
|
确保 Node.js 主版本为 22 或更高:
|
||||||
|
|
||||||
### MiniMax 免费试用到期后怎么办?
|
|
||||||
|
|
||||||
到期后可以:
|
|
||||||
1. 继续付费使用 MiniMax
|
|
||||||
2. 切换到其他模型(在配置中修改):`openclaw onboard`
|
|
||||||
3. 使用 OpenRouter 等平台的免费额度
|
|
||||||
|
|
||||||
### "openclaw: command not found" 怎么解决?
|
|
||||||
|
|
||||||
Shell 可能没有加载新的 PATH:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# macOS
|
node -v
|
||||||
source ~/.zshrc
|
|
||||||
# 或者
|
|
||||||
export PATH="$HOME/.openclaw/bin:$PATH"
|
|
||||||
|
|
||||||
# Windows(在 WSL 中)
|
|
||||||
source ~/.bashrc
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Node.js 版本太旧怎么办?
|
### 3) 网关异常
|
||||||
|
|
||||||
|
执行:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# macOS
|
openclaw doctor
|
||||||
brew install node@22 && brew link --overwrite node@22
|
openclaw gateway status
|
||||||
|
|
||||||
# Windows(在 WSL 中)
|
|
||||||
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
||||||
sudo apt-get install -y nodejs
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### WSL2 安装失败怎么办?(Windows)
|
|
||||||
|
|
||||||
1. 确保以**管理员身份**运行 PowerShell
|
|
||||||
2. 在 BIOS 中检查虚拟化是否已启用
|
|
||||||
3. 运行 `wsl --update` 更新到最新版本
|
|
||||||
4. 手动安装:`wsl --install -d Ubuntu-24.04`
|
|
||||||
|
|
||||||
### 怎么重新选择模型/服务商?
|
|
||||||
|
|
||||||
```bash
|
|
||||||
openclaw onboard
|
|
||||||
```
|
|
||||||
|
|
||||||
### "openclaw doctor" 报错怎么办?
|
|
||||||
|
|
||||||
运行 `openclaw doctor` 查看具体哪项检查失败:
|
|
||||||
- **Node 版本**:升级到 Node 22+
|
|
||||||
- **API 连接**:检查网络连接和 API Key
|
|
||||||
- **网关**(Windows):在 WSL 中运行 `openclaw gateway install`
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 相关链接
|
|
||||||
|
|
||||||
- [OpenClaw 龙虾AI 官方文档](https://openclaw.ai/docs)
|
|
||||||
- [OpenClaw GitHub](https://github.com/anthropics/openclaw)
|
|
||||||
- [MiniMax 平台](https://platform.minimax.io)
|
|
||||||
- [MiniMax API 文档](https://platform.minimax.io/docs)
|
|
||||||
- [Anthropic Console](https://console.anthropic.com)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 关键词
|
|
||||||
|
|
||||||
OpenClaw, 龙虾AI, ClawsBot, MiniMax, Claude, 个人AI助手, 一键部署, 免费白嫖, 本地AI, AI自动化, MiniMax-M2.1, 开源AI助手, 自主AI代理, AI agent, 大模型助手, 国内AI, 免费AI工具, 聊天AI助手, WhatsApp AI, Telegram AI, Discord AI
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 免责声明
|
|
||||||
|
|
||||||
本教程仅供学习和参考使用。MiniMax 免费试用政策以官方为准,如有变动请以 [platform.minimax.io](https://platform.minimax.io) 最新信息为准。Claude API 按量计费,请注意控制用量。
|
|
||||||
|
|
||||||
## 许可证
|
## 许可证
|
||||||
|
|
||||||
MIT
|
MIT
|
||||||
|
|||||||
246
configure-aws-bedrock.ps1
Normal file
246
configure-aws-bedrock.ps1
Normal file
@@ -0,0 +1,246 @@
|
|||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# OpenClaw AWS Bedrock 配置脚本 (Windows)
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
||||||
|
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
||||||
|
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
||||||
|
function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; throw $msg }
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================" -ForegroundColor White
|
||||||
|
Write-Host " OpenClaw AWS Bedrock 配置器 (Windows)" -ForegroundColor White
|
||||||
|
Write-Host "========================================" -ForegroundColor White
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# 步骤 1: 检查 OpenClaw
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Info "正在检查 OpenClaw 安装..."
|
||||||
|
|
||||||
|
try {
|
||||||
|
$null = Get-Command openclaw -ErrorAction Stop
|
||||||
|
Write-Ok "已找到 OpenClaw。"
|
||||||
|
} catch {
|
||||||
|
Write-Err "未找到 OpenClaw。请先运行安装脚本:`niwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/install-windows.ps1 | iex"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# 步骤 2: 获取 AWS 凭证
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
$openclawDir = Join-Path $env:USERPROFILE ".openclaw"
|
||||||
|
$envFile = Join-Path $openclawDir ".env"
|
||||||
|
$configFile = Join-Path $openclawDir "openclaw.json"
|
||||||
|
|
||||||
|
$skipInput = $false
|
||||||
|
|
||||||
|
if (Test-Path $envFile) {
|
||||||
|
$envContent = Get-Content $envFile -Raw
|
||||||
|
if ($envContent -match "AWS_ACCESS_KEY_ID") {
|
||||||
|
Write-Warn "检测到已存在 AWS 凭证配置"
|
||||||
|
$useExisting = Read-Host "是否使用现有凭证? [Y/n]"
|
||||||
|
if ($useExisting -ne "n" -and $useExisting -ne "N") {
|
||||||
|
$skipInput = $true
|
||||||
|
# 加载现有凭证
|
||||||
|
foreach ($line in (Get-Content $envFile)) {
|
||||||
|
if ($line -match '^\s*export\s+(\w+)="?([^"]*)"?') {
|
||||||
|
[Environment]::SetEnvironmentVariable($Matches[1], $Matches[2], "Process")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Ok "使用现有凭证"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $skipInput) {
|
||||||
|
Write-Info "请输入你的 AWS Access Key ID:"
|
||||||
|
Write-Host "(从 IAM 控制台获取)" -ForegroundColor Yellow
|
||||||
|
$accessKey = Read-Host
|
||||||
|
|
||||||
|
if ([string]::IsNullOrWhiteSpace($accessKey)) {
|
||||||
|
Write-Err "AWS Access Key ID 不能为空"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Info "请输入你的 AWS Secret Access Key:"
|
||||||
|
$secretKey = Read-Host -AsSecureString
|
||||||
|
$secretKeyPlain = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
|
||||||
|
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($secretKey)
|
||||||
|
)
|
||||||
|
|
||||||
|
if ([string]::IsNullOrWhiteSpace($secretKeyPlain)) {
|
||||||
|
Write-Err "AWS Secret Access Key 不能为空"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Info "请输入 AWS 区域 (默认: us-west-2):"
|
||||||
|
$region = Read-Host
|
||||||
|
if ([string]::IsNullOrWhiteSpace($region)) {
|
||||||
|
$region = "us-west-2"
|
||||||
|
}
|
||||||
|
|
||||||
|
$env:AWS_ACCESS_KEY_ID = $accessKey
|
||||||
|
$env:AWS_SECRET_ACCESS_KEY = $secretKeyPlain
|
||||||
|
$env:AWS_REGION = $region
|
||||||
|
|
||||||
|
Write-Ok "已获取 AWS 凭证"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# 步骤 3: 创建环境变量文件
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
if (-not $skipInput) {
|
||||||
|
Write-Info "正在创建 $envFile..."
|
||||||
|
|
||||||
|
if (-not (Test-Path $openclawDir)) {
|
||||||
|
New-Item -ItemType Directory -Path $openclawDir -Force | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
# 备份
|
||||||
|
if (Test-Path $envFile) {
|
||||||
|
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
|
||||||
|
Copy-Item $envFile "$envFile.backup.$timestamp"
|
||||||
|
Write-Warn "已备份现有 .env 文件"
|
||||||
|
}
|
||||||
|
|
||||||
|
$envContent = @"
|
||||||
|
# AWS Bedrock Credentials
|
||||||
|
export AWS_ACCESS_KEY_ID="$($env:AWS_ACCESS_KEY_ID)"
|
||||||
|
export AWS_SECRET_ACCESS_KEY="$($env:AWS_SECRET_ACCESS_KEY)"
|
||||||
|
export AWS_REGION="$($env:AWS_REGION)"
|
||||||
|
"@
|
||||||
|
|
||||||
|
Set-Content -Path $envFile -Value $envContent -Encoding UTF8
|
||||||
|
Write-Ok "已创建环境变量文件"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# 步骤 4: 配置 openclaw.json
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Info "正在配置 $configFile..."
|
||||||
|
|
||||||
|
# 备份
|
||||||
|
if (Test-Path $configFile) {
|
||||||
|
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
|
||||||
|
Copy-Item $configFile "$configFile.backup.$timestamp"
|
||||||
|
Write-Warn "已备份现有 openclaw.json 文件"
|
||||||
|
}
|
||||||
|
|
||||||
|
$awsRegion = if ($env:AWS_REGION) { $env:AWS_REGION } else { "us-west-2" }
|
||||||
|
|
||||||
|
$configContent = @"
|
||||||
|
{
|
||||||
|
"gateway": {
|
||||||
|
"mode": "local"
|
||||||
|
},
|
||||||
|
"models": {
|
||||||
|
"providers": {
|
||||||
|
"amazon-bedrock": {
|
||||||
|
"baseUrl": "https://bedrock-runtime.$awsRegion.amazonaws.com",
|
||||||
|
"api": "bedrock-converse-stream",
|
||||||
|
"auth": "aws-sdk",
|
||||||
|
"models": [
|
||||||
|
{
|
||||||
|
"id": "global.anthropic.claude-opus-4-6-v1",
|
||||||
|
"name": "Claude Opus 4.6 (Bedrock)",
|
||||||
|
"reasoning": true,
|
||||||
|
"input": ["text", "image"],
|
||||||
|
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||||
|
"contextWindow": 200000,
|
||||||
|
"maxTokens": 8192
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "global.anthropic.claude-opus-4-5-20251001-v1:0",
|
||||||
|
"name": "Claude Opus 4.5 (Bedrock)",
|
||||||
|
"reasoning": true,
|
||||||
|
"input": ["text", "image"],
|
||||||
|
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||||
|
"contextWindow": 200000,
|
||||||
|
"maxTokens": 8192
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "global.anthropic.claude-sonnet-4-5-20250929-v1:0",
|
||||||
|
"name": "Claude Sonnet 4.5 (Bedrock)",
|
||||||
|
"reasoning": true,
|
||||||
|
"input": ["text", "image"],
|
||||||
|
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||||
|
"contextWindow": 200000,
|
||||||
|
"maxTokens": 8192
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "global.anthropic.claude-haiku-4-5-20251001-v1:0",
|
||||||
|
"name": "Claude Haiku 4.5 (Bedrock)",
|
||||||
|
"reasoning": false,
|
||||||
|
"input": ["text", "image"],
|
||||||
|
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 },
|
||||||
|
"contextWindow": 200000,
|
||||||
|
"maxTokens": 8192
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"agents": {
|
||||||
|
"defaults": {
|
||||||
|
"model": {
|
||||||
|
"primary": "amazon-bedrock/global.anthropic.claude-sonnet-4-5-20250929-v1:0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
|
||||||
|
Set-Content -Path $configFile -Value $configContent -Encoding UTF8
|
||||||
|
Write-Ok "已配置 openclaw.json"
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# 步骤 5: 设置环境变量到当前会话
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Info "正在设置环境变量..."
|
||||||
|
|
||||||
|
# 设置为用户级环境变量(持久化)
|
||||||
|
[Environment]::SetEnvironmentVariable("AWS_ACCESS_KEY_ID", $env:AWS_ACCESS_KEY_ID, "User")
|
||||||
|
[Environment]::SetEnvironmentVariable("AWS_SECRET_ACCESS_KEY", $env:AWS_SECRET_ACCESS_KEY, "User")
|
||||||
|
[Environment]::SetEnvironmentVariable("AWS_REGION", $env:AWS_REGION, "User")
|
||||||
|
|
||||||
|
Write-Ok "已设置用户环境变量(新 PowerShell 窗口自动生效)"
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# 步骤 6: 完成
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
|
Write-Host " 配置完成!" -ForegroundColor Green
|
||||||
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " 配置摘要:" -ForegroundColor White
|
||||||
|
Write-Host " Provider: AWS Bedrock" -ForegroundColor Cyan
|
||||||
|
Write-Host " Region: $awsRegion" -ForegroundColor Cyan
|
||||||
|
Write-Host " 默认模型: Claude Sonnet 4.5" -ForegroundColor Cyan
|
||||||
|
Write-Host " 已配置模型:" -ForegroundColor White
|
||||||
|
Write-Host " * Claude Opus 4.6" -ForegroundColor Cyan
|
||||||
|
Write-Host " * Claude Opus 4.5" -ForegroundColor Cyan
|
||||||
|
Write-Host " * Claude Sonnet 4.5" -ForegroundColor Cyan
|
||||||
|
Write-Host " * Claude Haiku 4.5" -ForegroundColor Cyan
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " 使用方法:" -ForegroundColor White
|
||||||
|
Write-Host " cd 你的项目路径" -ForegroundColor Gray
|
||||||
|
Write-Host " openclaw" -ForegroundColor Cyan
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " 测试连接:" -ForegroundColor White
|
||||||
|
Write-Host " openclaw agent --session-id test --message `"Say OK`" --local" -ForegroundColor Cyan
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " 所需 IAM 权限:" -ForegroundColor White
|
||||||
|
Write-Host " * bedrock:InvokeModel" -ForegroundColor Yellow
|
||||||
|
Write-Host " * bedrock:InvokeModelWithResponseStream" -ForegroundColor Yellow
|
||||||
|
Write-Host " 或使用托管策略:AmazonBedrockFullAccess" -ForegroundColor Yellow
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "[错误] 脚本执行失败: $_" -ForegroundColor Red
|
||||||
|
Write-Host ""
|
||||||
|
} finally {
|
||||||
|
Write-Host ""
|
||||||
|
Read-Host "按 Enter 键关闭此窗口"
|
||||||
|
}
|
||||||
BIN
images/hero-banner.png
Normal file
BIN
images/hero-banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 MiB |
BIN
images/my-group-wechat.JPG
Normal file
BIN
images/my-group-wechat.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 284 KiB |
BIN
images/my-wechat-qr.JPG
Normal file
BIN
images/my-wechat-qr.JPG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 242 KiB |
BIN
images/pinche.png
Normal file
BIN
images/pinche.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.3 MiB |
@@ -28,6 +28,24 @@ header() {
|
|||||||
|
|
||||||
header
|
header
|
||||||
|
|
||||||
|
echo -e "${BOLD}请选择操作:${NC}"
|
||||||
|
echo " 1) 安装 / 更新 OpenClaw"
|
||||||
|
echo " 2) 卸载 OpenClaw"
|
||||||
|
read -r -p "请输入选项 [1/2](默认 1): " ACTION
|
||||||
|
ACTION=${ACTION:-1}
|
||||||
|
|
||||||
|
if [[ "$ACTION" == "2" ]]; then
|
||||||
|
info "你选择了:卸载 OpenClaw"
|
||||||
|
if command -v openclaw &>/dev/null; then
|
||||||
|
openclaw uninstall --all --yes --non-interactive
|
||||||
|
else
|
||||||
|
warn "在 PATH 中未找到 openclaw,尝试使用 npx 卸载..."
|
||||||
|
npx -y openclaw uninstall --all --yes --non-interactive
|
||||||
|
fi
|
||||||
|
success "OpenClaw 已卸载。"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 1: 检查 / 安装 Node 22+
|
# 步骤 1: 检查 / 安装 Node 22+
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
@@ -70,19 +88,32 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 2: 安装 OpenClaw
|
# 步骤 2: 安装 / 更新 OpenClaw
|
||||||
|
# 国内网络优先:npmmirror → npmjs(必要时)
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
info "正在安装 OpenClaw..."
|
info "正在安装 / 更新 OpenClaw..."
|
||||||
|
|
||||||
if command -v openclaw &>/dev/null; then
|
install_openclaw_with_registry() {
|
||||||
success "OpenClaw 已安装。"
|
local registry="$1"
|
||||||
|
info "尝试通过 npm 安装 OpenClaw($registry)..."
|
||||||
|
npm install -g openclaw@latest --registry="$registry"
|
||||||
|
}
|
||||||
|
|
||||||
|
if install_openclaw_with_registry "https://registry.npmmirror.com"; then
|
||||||
|
success "已通过 npmmirror 安装 / 更新 OpenClaw。"
|
||||||
|
elif install_openclaw_with_registry "https://registry.npmjs.org"; then
|
||||||
|
success "已通过 npm 官方源安装 / 更新 OpenClaw。"
|
||||||
else
|
else
|
||||||
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard
|
error "OpenClaw 安装失败:npmmirror 与 npm 官方源均不可用。"
|
||||||
success "OpenClaw 安装完成。"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 确保 openclaw 在 PATH 中
|
# 确保 openclaw 在 PATH 中
|
||||||
export PATH="$HOME/.openclaw/bin:$PATH"
|
NPM_PREFIX=$(npm config get prefix 2>/dev/null || true)
|
||||||
|
if [[ -n "$NPM_PREFIX" ]]; then
|
||||||
|
export PATH="$NPM_PREFIX/bin:$HOME/.openclaw/bin:$PATH"
|
||||||
|
else
|
||||||
|
export PATH="$HOME/.openclaw/bin:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
if ! command -v openclaw &>/dev/null; then
|
if ! command -v openclaw &>/dev/null; then
|
||||||
error "OpenClaw 安装失败 — 在 PATH 中找不到 'openclaw'。请尝试重启终端后再次运行此脚本。"
|
error "OpenClaw 安装失败 — 在 PATH 中找不到 'openclaw'。请尝试重启终端后再次运行此脚本。"
|
||||||
@@ -96,12 +127,8 @@ echo -e "${GREEN}${BOLD}========================================${NC}"
|
|||||||
echo -e "${GREEN}${BOLD} OpenClaw 安装完成!开始配置...${NC}"
|
echo -e "${GREEN}${BOLD} OpenClaw 安装完成!开始配置...${NC}"
|
||||||
echo -e "${GREEN}${BOLD}========================================${NC}"
|
echo -e "${GREEN}${BOLD}========================================${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e " ${BOLD}提示:${NC}当配置向导要求选择服务商时,"
|
|
||||||
echo -e " 选择 ${BOLD}MiniMax${NC} 可获得 ${BOLD}7天免费试用${NC} — 无需信用卡。"
|
|
||||||
echo -e " 注册地址:${BLUE}https://platform.minimax.io${NC}"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
openclaw onboard --accept-risk --flow quickstart --node-manager npm --skip-skills < /dev/tty
|
openclaw onboard --accept-risk --flow quickstart --install-daemon --gateway-bind loopback --node-manager npm --skip-search --skip-channels --skip-skills < /dev/tty
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "${GREEN}${BOLD}========================================${NC}"
|
echo -e "${GREEN}${BOLD}========================================${NC}"
|
||||||
@@ -110,6 +137,6 @@ echo -e "${GREEN}${BOLD}========================================${NC}"
|
|||||||
echo ""
|
echo ""
|
||||||
echo -e " ${BOLD}接下来:${NC}"
|
echo -e " ${BOLD}接下来:${NC}"
|
||||||
echo -e " 1. 开始使用 OpenClaw:${BLUE}openclaw${NC}"
|
echo -e " 1. 开始使用 OpenClaw:${BLUE}openclaw${NC}"
|
||||||
echo -e " 2. 添加技能(可选):${BLUE}openclaw configure --section skills${NC}"
|
echo -e " 2. 查看网关状态:${BLUE}openclaw gateway status${NC}"
|
||||||
echo -e " 3. 浏览可用技能:${BLUE}openclaw skills${NC}"
|
echo -e " 3. 如需卸载:${BLUE}curl -fsSL https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-macos.sh | bash${NC}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
258
install-windows-en.ps1
Normal file
258
install-windows-en.ps1
Normal file
@@ -0,0 +1,258 @@
|
|||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# OpenClaw One-Click Installer (Windows)
|
||||||
|
# Installs Node.js + OpenClaw, runs natively
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
function Write-Info($msg) { Write-Host "[INFO] $msg" -ForegroundColor Cyan }
|
||||||
|
function Write-Ok($msg) { Write-Host "[DONE] $msg" -ForegroundColor Green }
|
||||||
|
function Write-Warn($msg) { Write-Host "[WARN] $msg" -ForegroundColor Yellow }
|
||||||
|
function Write-Err($msg) { Write-Host "[ERROR] $msg" -ForegroundColor Red; throw $msg }
|
||||||
|
|
||||||
|
function Write-Header {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================" -ForegroundColor White
|
||||||
|
Write-Host " OpenClaw One-Click Installer (Windows)" -ForegroundColor White
|
||||||
|
Write-Host "========================================" -ForegroundColor White
|
||||||
|
Write-Host ""
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Write-Header
|
||||||
|
|
||||||
|
Write-Host "Choose an action:" -ForegroundColor White
|
||||||
|
Write-Host " 1) Install / Update OpenClaw" -ForegroundColor Gray
|
||||||
|
Write-Host " 2) Uninstall OpenClaw" -ForegroundColor Gray
|
||||||
|
$action = Read-Host "Enter [1/2] (default: 1)"
|
||||||
|
if ([string]::IsNullOrWhiteSpace($action)) { $action = "1" }
|
||||||
|
|
||||||
|
if ($action -eq "2") {
|
||||||
|
Write-Info "You chose: uninstall OpenClaw"
|
||||||
|
|
||||||
|
$uninstalled = $false
|
||||||
|
|
||||||
|
if (Get-Command openclaw -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
} catch {
|
||||||
|
Write-Warn "openclaw uninstall failed, trying npx..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $uninstalled -and (Get-Command npx -ErrorAction SilentlyContinue)) {
|
||||||
|
try {
|
||||||
|
npx -y openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
} catch {
|
||||||
|
Write-Warn "npx uninstall failed."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
||||||
|
try { npm uninstall -g openclaw 2>$null | Out-Null } catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($uninstalled) {
|
||||||
|
Write-Ok "OpenClaw uninstalled."
|
||||||
|
} else {
|
||||||
|
Write-Err "Failed to uninstall OpenClaw. Please ensure Node.js/npm is available and retry."
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# Step 1: Check / Install Node.js 22+
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Info "Checking Node.js..."
|
||||||
|
|
||||||
|
$needsNode = $true
|
||||||
|
|
||||||
|
try {
|
||||||
|
$nodeVersion = (node -v 2>$null)
|
||||||
|
if ($nodeVersion -match "v(\d+)") {
|
||||||
|
$major = [int]$Matches[1]
|
||||||
|
if ($major -ge 22) {
|
||||||
|
Write-Ok "Found Node.js $nodeVersion"
|
||||||
|
$needsNode = $false
|
||||||
|
} else {
|
||||||
|
Write-Warn "Found Node.js $nodeVersion, but v22+ is required. Upgrading..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Warn "Node.js not found."
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($needsNode) {
|
||||||
|
Write-Info "Installing Node.js 22..."
|
||||||
|
|
||||||
|
$installed = $false
|
||||||
|
|
||||||
|
# Method 1: winget (built into Windows 11 / Windows 10)
|
||||||
|
if (-not $installed -and (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Info "Installing via winget..."
|
||||||
|
winget install OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
$installed = $true
|
||||||
|
Write-Ok "Node.js installed via winget"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Method 2: Chocolatey
|
||||||
|
if (-not $installed -and (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Info "Installing via Chocolatey..."
|
||||||
|
choco install nodejs-lts -y 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
$installed = $true
|
||||||
|
Write-Ok "Node.js installed via Chocolatey"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Method 3: Manual download prompt
|
||||||
|
if (-not $installed) {
|
||||||
|
Write-Err "Could not install Node.js automatically. Please install manually and re-run this script:`n`n Download: https://nodejs.org/en/download/`n`n After installing, reopen PowerShell and run this script again."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Refresh PATH
|
||||||
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
|
||||||
|
# Verify installation
|
||||||
|
try {
|
||||||
|
$nodeVersion = (node -v 2>$null)
|
||||||
|
Write-Ok "Node.js $nodeVersion installed successfully"
|
||||||
|
} catch {
|
||||||
|
Write-Err "Node.js verification failed after install. Please close and reopen PowerShell, then try again."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# Step 2: Check / Install Git
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Info "Checking Git..."
|
||||||
|
|
||||||
|
if (Get-Command git -ErrorAction SilentlyContinue) {
|
||||||
|
Write-Ok "Found Git."
|
||||||
|
} else {
|
||||||
|
Write-Info "Installing Git (required by OpenClaw dependencies)..."
|
||||||
|
|
||||||
|
$gitInstalled = $false
|
||||||
|
|
||||||
|
if (-not $gitInstalled -and (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Info "Installing Git via winget..."
|
||||||
|
winget install Git.Git --accept-package-agreements --accept-source-agreements 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
$gitInstalled = $true
|
||||||
|
Write-Ok "Git installed via winget"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $gitInstalled -and (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Info "Installing Git via Chocolatey..."
|
||||||
|
choco install git -y 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
$gitInstalled = $true
|
||||||
|
Write-Ok "Git installed via Chocolatey"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Method 3: Direct download and silent install
|
||||||
|
if (-not $gitInstalled) {
|
||||||
|
Write-Info "Downloading Git installer directly..."
|
||||||
|
$gitInstaller = Join-Path $env:TEMP "git-installer.exe"
|
||||||
|
try {
|
||||||
|
$releases = Invoke-RestMethod "https://api.github.com/repos/git-for-windows/git/releases/latest" -ErrorAction Stop
|
||||||
|
$asset = $releases.assets | Where-Object { $_.name -match "Git-.*-64-bit\.exe$" } | Select-Object -First 1
|
||||||
|
if ($asset) {
|
||||||
|
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $gitInstaller -ErrorAction Stop
|
||||||
|
Write-Info "Installing Git silently..."
|
||||||
|
Start-Process -FilePath $gitInstaller -ArgumentList "/VERYSILENT", "/NORESTART", "/NOCANCEL", "/SP-", "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS" -Wait
|
||||||
|
Remove-Item $gitInstaller -Force -ErrorAction SilentlyContinue
|
||||||
|
$gitInstalled = $true
|
||||||
|
Write-Ok "Git installed via direct download"
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Warn "Direct download failed: $_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $gitInstalled) {
|
||||||
|
Write-Err "Could not install Git automatically. Please install manually and re-run this script:`n`n Download: https://git-scm.com/download/win`n`n After installing, reopen PowerShell and run this script again."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Refresh PATH
|
||||||
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
}
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# Step 3: Install / Update OpenClaw
|
||||||
|
# China-first path: npmmirror → npmjs (if needed)
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Info "Installing / updating OpenClaw..."
|
||||||
|
|
||||||
|
function Install-OpenClawByRegistry($registry) {
|
||||||
|
Write-Info "Trying npm install via $registry ..."
|
||||||
|
npm install -g openclaw@latest --registry=$registry 2>&1 | Write-Host
|
||||||
|
return ($LASTEXITCODE -eq 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
$installedOpenClaw = $false
|
||||||
|
if (Install-OpenClawByRegistry "https://registry.npmmirror.com") {
|
||||||
|
Write-Ok "OpenClaw installed / updated via npmmirror."
|
||||||
|
$installedOpenClaw = $true
|
||||||
|
} elseif (Install-OpenClawByRegistry "https://registry.npmjs.org") {
|
||||||
|
Write-Ok "OpenClaw installed / updated via npm registry."
|
||||||
|
$installedOpenClaw = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $installedOpenClaw) {
|
||||||
|
Write-Err "OpenClaw installation failed: both npmmirror and npm registry are unavailable."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Refresh PATH
|
||||||
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
|
||||||
|
# Add npm global bin to PATH
|
||||||
|
try {
|
||||||
|
$npmPrefix = (npm config get prefix 2>$null).Trim()
|
||||||
|
if ($npmPrefix) {
|
||||||
|
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
if (-not ($userPath -split ";" | Where-Object { $_ -ieq $npmPrefix })) {
|
||||||
|
[Environment]::SetEnvironmentVariable("Path", "$userPath;$npmPrefix", "User")
|
||||||
|
$env:Path += ";$npmPrefix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
Write-Ok "OpenClaw installed / updated."
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# Step 3: Launch interactive setup
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
|
Write-Host " OpenClaw installed! Starting setup..." -ForegroundColor Green
|
||||||
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
openclaw onboard --accept-risk --flow quickstart --install-daemon --gateway-bind loopback --node-manager npm --skip-search --skip-channels --skip-skills
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
|
Write-Host " Setup complete!" -ForegroundColor Green
|
||||||
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host " Next steps:" -ForegroundColor White
|
||||||
|
Write-Host " 1. Start OpenClaw: openclaw" -ForegroundColor Gray
|
||||||
|
Write-Host " 2. Check gateway status: openclaw gateway status" -ForegroundColor Gray
|
||||||
|
Write-Host " 3. Uninstall (if needed): iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-windows.ps1 | iex" -ForegroundColor Gray
|
||||||
|
Write-Host ""
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "[ERROR] Script failed: $_" -ForegroundColor Red
|
||||||
|
Write-Host ""
|
||||||
|
} finally {
|
||||||
|
Write-Host ""
|
||||||
|
Read-Host "Press Enter to close this window"
|
||||||
|
}
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# OpenClaw 一键部署安装脚本 (Windows)
|
# OpenClaw 一键部署安装脚本 (Windows)
|
||||||
# 安装 WSL2 + Ubuntu,然后在 WSL 中设置 OpenClaw
|
# 安装 Node.js + OpenClaw,原生 Windows 运行
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
|
|
||||||
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
||||||
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
||||||
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
||||||
function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; exit 1 }
|
function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; throw $msg }
|
||||||
|
|
||||||
function Write-Header {
|
function Write-Header {
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
@@ -18,166 +16,227 @@ function Write-Header {
|
|||||||
Write-Host ""
|
Write-Host ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
Write-Header
|
Write-Header
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
Write-Host "请选择操作:" -ForegroundColor White
|
||||||
# 步骤 1: 检查 / 安装 WSL2
|
Write-Host " 1) 安装 / 更新 OpenClaw" -ForegroundColor Gray
|
||||||
# ─────────────────────────────────────────────
|
Write-Host " 2) 卸载 OpenClaw" -ForegroundColor Gray
|
||||||
Write-Info "正在检查 WSL2 安装..."
|
$action = Read-Host "请输入选项 [1/2](默认 1)"
|
||||||
|
if ([string]::IsNullOrWhiteSpace($action)) { $action = "1" }
|
||||||
|
|
||||||
$wslInstalled = $false
|
if ($action -eq "2") {
|
||||||
try {
|
Write-Info "你选择了:卸载 OpenClaw"
|
||||||
$wslOutput = wsl --status 2>&1
|
|
||||||
if ($LASTEXITCODE -eq 0) {
|
|
||||||
$wslInstalled = $true
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
$wslInstalled = $false
|
|
||||||
}
|
|
||||||
|
|
||||||
# 检查 WSL 中是否有 Ubuntu
|
$uninstalled = $false
|
||||||
$ubuntuAvailable = $false
|
|
||||||
if ($wslInstalled) {
|
|
||||||
$distros = wsl --list --quiet 2>&1
|
|
||||||
if ($distros -match "Ubuntu") {
|
|
||||||
$ubuntuAvailable = $true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (-not $wslInstalled -or -not $ubuntuAvailable) {
|
if (Get-Command openclaw -ErrorAction SilentlyContinue) {
|
||||||
Write-Info "正在安装 WSL2 和 Ubuntu 24.04..."
|
try {
|
||||||
Write-Warn "可能需要重启。重启后请再次运行此脚本。"
|
openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
wsl --install -d Ubuntu-24.04
|
} catch {
|
||||||
if ($LASTEXITCODE -ne 0) {
|
Write-Warn "openclaw 卸载失败,尝试 npx 方式..."
|
||||||
Write-Err "WSL2 安装失败。请手动安装:wsl --install -d Ubuntu-24.04"
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-Ok "WSL2 + Ubuntu 24.04 安装完成。"
|
if (-not $uninstalled -and (Get-Command npx -ErrorAction SilentlyContinue)) {
|
||||||
Write-Warn "如果提示重启,请重启计算机后再次运行此脚本。"
|
try {
|
||||||
|
npx -y openclaw uninstall --all --yes --non-interactive
|
||||||
# 检查是否需要重启
|
$uninstalled = $true
|
||||||
$restartNeeded = $false
|
} catch {
|
||||||
try {
|
Write-Warn "npx 卸载失败。"
|
||||||
wsl --status 2>&1 | Out-Null
|
}
|
||||||
if ($LASTEXITCODE -ne 0) { $restartNeeded = $true }
|
|
||||||
} catch {
|
|
||||||
$restartNeeded = $true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($restartNeeded) {
|
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
||||||
Write-Host ""
|
try { npm uninstall -g openclaw 2>$null | Out-Null } catch {}
|
||||||
Write-Warn "需要重启才能完成 WSL2 安装。"
|
|
||||||
Write-Host "重启后,请再次运行此脚本。" -ForegroundColor Yellow
|
|
||||||
Write-Host ""
|
|
||||||
Read-Host "按 Enter 键退出"
|
|
||||||
exit 0
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Write-Ok "已找到 WSL2 和 Ubuntu。"
|
if ($uninstalled) {
|
||||||
|
Write-Ok "OpenClaw 已卸载。"
|
||||||
|
} else {
|
||||||
|
Write-Err "未能完成 OpenClaw 卸载。请确认 Node.js/npm 可用后重试。"
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 2: 在 WSL 中启用 systemd
|
# 步骤 1: 检查 / 安装 Node.js 22+
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
Write-Info "正在配置 WSL 中的 systemd..."
|
Write-Info "正在检查 Node.js..."
|
||||||
|
|
||||||
$checkSystemd = wsl -d Ubuntu-24.04 -- bash -c "cat /etc/wsl.conf 2>/dev/null || echo ''"
|
|
||||||
if ($checkSystemd -notmatch "systemd=true") {
|
|
||||||
wsl -d Ubuntu-24.04 -- bash -c "echo '[boot]' | sudo tee /etc/wsl.conf > /dev/null && echo 'systemd=true' | sudo tee -a /etc/wsl.conf > /dev/null"
|
|
||||||
Write-Ok "已在 /etc/wsl.conf 中启用 systemd"
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────
|
|
||||||
# 步骤 3: 重启 WSL
|
|
||||||
# ─────────────────────────────────────────
|
|
||||||
Write-Info "正在重启 WSL 以应用 systemd..."
|
|
||||||
wsl --shutdown
|
|
||||||
Start-Sleep -Seconds 3
|
|
||||||
Write-Ok "WSL 已重启。"
|
|
||||||
} else {
|
|
||||||
Write-Ok "systemd 已启用。"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
|
||||||
# 步骤 4: 在 WSL 中安装 Node 22+
|
|
||||||
# ─────────────────────────────────────────────
|
|
||||||
Write-Info "正在检查 WSL 中的 Node.js..."
|
|
||||||
|
|
||||||
$nodeCheck = wsl -d Ubuntu-24.04 -- bash -c "command -v node && node -v || echo 'NOT_FOUND'" 2>&1
|
|
||||||
$needsNode = $true
|
$needsNode = $true
|
||||||
|
|
||||||
if ($nodeCheck -notmatch "NOT_FOUND" -and $nodeCheck -match "v(\d+)") {
|
try {
|
||||||
$nodeVersion = [int]$Matches[1]
|
$nodeVersion = (node -v 2>$null)
|
||||||
if ($nodeVersion -ge 22) {
|
if ($nodeVersion -match "v(\d+)") {
|
||||||
Write-Ok "WSL 中已找到 Node.js v$nodeVersion (>= 22)。"
|
$major = [int]$Matches[1]
|
||||||
$needsNode = $false
|
if ($major -ge 22) {
|
||||||
} else {
|
Write-Ok "已找到 Node.js $nodeVersion"
|
||||||
Write-Warn "WSL 中已找到 Node.js v$nodeVersion,但需要 >= 22。正在升级..."
|
$needsNode = $false
|
||||||
|
} else {
|
||||||
|
Write-Warn "已找到 Node.js $nodeVersion,但需要 v22+,正在升级..."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} catch {
|
||||||
Write-Warn "WSL 中未找到 Node.js。"
|
Write-Warn "未找到 Node.js。"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($needsNode) {
|
if ($needsNode) {
|
||||||
Write-Info "正在通过 NodeSource 在 WSL 中安装 Node.js 22..."
|
Write-Info "正在安装 Node.js 22..."
|
||||||
|
|
||||||
$installNodeScript = @'
|
$installed = $false
|
||||||
set -e
|
|
||||||
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
|
|
||||||
sudo apt-get install -y nodejs
|
|
||||||
node -v
|
|
||||||
'@
|
|
||||||
|
|
||||||
wsl -d Ubuntu-24.04 -- bash -c $installNodeScript
|
# 方式 1: winget(Windows 11 / Windows 10 自带)
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if (-not $installed -and (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||||
Write-Err "WSL 中 Node.js 安装失败。"
|
Write-Info "使用 winget 安装..."
|
||||||
|
winget install OpenJS.NodeJS.LTS --accept-package-agreements --accept-source-agreements 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
$installed = $true
|
||||||
|
Write-Ok "Node.js 已通过 winget 安装"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Write-Ok "WSL 中 Node.js 22 安装完成。"
|
|
||||||
}
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# 方式 2: Chocolatey
|
||||||
# 步骤 5: 在 WSL 中安装 OpenClaw
|
if (-not $installed -and (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||||
# ─────────────────────────────────────────────
|
Write-Info "使用 Chocolatey 安装..."
|
||||||
Write-Info "正在在 WSL 中安装 OpenClaw..."
|
choco install nodejs-lts -y 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
$openclawCheck = wsl -d Ubuntu-24.04 -- bash -c "command -v openclaw || echo 'NOT_FOUND'" 2>&1
|
$installed = $true
|
||||||
|
Write-Ok "Node.js 已通过 Chocolatey 安装"
|
||||||
if ($openclawCheck -match "NOT_FOUND") {
|
}
|
||||||
wsl -d Ubuntu-24.04 -- bash -c "curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard"
|
}
|
||||||
if ($LASTEXITCODE -ne 0) {
|
|
||||||
Write-Err "WSL 中 OpenClaw 安装失败。"
|
# 方式 3: 手动下载提示
|
||||||
|
if (-not $installed) {
|
||||||
|
Write-Err "无法自动安装 Node.js。请手动下载安装:`n`n 下载地址:https://nodejs.cn/download/`n 或:https://nodejs.org/en/download/`n`n 安装完成后重新打开 PowerShell 运行此脚本。"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 刷新 PATH
|
||||||
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
|
||||||
|
# 验证安装
|
||||||
|
try {
|
||||||
|
$nodeVersion = (node -v 2>$null)
|
||||||
|
Write-Ok "Node.js $nodeVersion 安装成功"
|
||||||
|
} catch {
|
||||||
|
Write-Err "Node.js 安装后验证失败。请关闭 PowerShell 重新打开后再试。"
|
||||||
}
|
}
|
||||||
Write-Ok "WSL 中 OpenClaw 安装完成。"
|
|
||||||
} else {
|
|
||||||
Write-Ok "WSL 中已安装 OpenClaw。"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 6: 安装 OpenClaw 网关守护进程
|
# 步骤 2: 检查 / 安装 Git
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
Write-Info "正在安装 OpenClaw 网关守护进程..."
|
Write-Info "正在检查 Git..."
|
||||||
|
|
||||||
wsl -d Ubuntu-24.04 -- bash -c 'export PATH="$HOME/.openclaw/bin:$PATH" && openclaw gateway install'
|
if (Get-Command git -ErrorAction SilentlyContinue) {
|
||||||
if ($LASTEXITCODE -ne 0) {
|
Write-Ok "已找到 Git。"
|
||||||
Write-Warn "网关守护进程安装遇到问题。您可以稍后使用以下命令安装:openclaw gateway install"
|
|
||||||
} else {
|
} else {
|
||||||
Write-Ok "网关守护进程安装完成。"
|
Write-Info "正在安装 Git(OpenClaw 依赖需要)..."
|
||||||
|
|
||||||
|
$gitInstalled = $false
|
||||||
|
|
||||||
|
if (-not $gitInstalled -and (Get-Command winget -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Info "使用 winget 安装 Git..."
|
||||||
|
winget install Git.Git --accept-package-agreements --accept-source-agreements 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
$gitInstalled = $true
|
||||||
|
Write-Ok "Git 已通过 winget 安装"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $gitInstalled -and (Get-Command choco -ErrorAction SilentlyContinue)) {
|
||||||
|
Write-Info "使用 Chocolatey 安装 Git..."
|
||||||
|
choco install git -y 2>$null
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
$gitInstalled = $true
|
||||||
|
Write-Ok "Git 已通过 Chocolatey 安装"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 方式 3: 直接下载安装
|
||||||
|
if (-not $gitInstalled) {
|
||||||
|
Write-Info "正在直接下载 Git 安装包..."
|
||||||
|
$gitInstaller = Join-Path $env:TEMP "git-installer.exe"
|
||||||
|
try {
|
||||||
|
# 从 GitHub 获取最新 64-bit 安装包 URL
|
||||||
|
$releases = Invoke-RestMethod "https://api.github.com/repos/git-for-windows/git/releases/latest" -ErrorAction Stop
|
||||||
|
$asset = $releases.assets | Where-Object { $_.name -match "Git-.*-64-bit\.exe$" } | Select-Object -First 1
|
||||||
|
if ($asset) {
|
||||||
|
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $gitInstaller -ErrorAction Stop
|
||||||
|
Write-Info "正在静默安装 Git..."
|
||||||
|
Start-Process -FilePath $gitInstaller -ArgumentList "/VERYSILENT", "/NORESTART", "/NOCANCEL", "/SP-", "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS" -Wait
|
||||||
|
Remove-Item $gitInstaller -Force -ErrorAction SilentlyContinue
|
||||||
|
$gitInstalled = $true
|
||||||
|
Write-Ok "Git 已通过直接下载安装"
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Warn "直接下载安装失败: $_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $gitInstalled) {
|
||||||
|
Write-Err "无法自动安装 Git。请手动下载安装:`n`n 下载地址:https://git-scm.com/download/win`n`n 安装完成后重新打开 PowerShell 运行此脚本。"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 刷新 PATH
|
||||||
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
}
|
}
|
||||||
|
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# 步骤 7: 启动交互式配置
|
# 步骤 3: 安装 / 更新 OpenClaw
|
||||||
|
# 国内网络优先:npmmirror → npmjs(必要时)
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
Write-Info "正在安装 / 更新 OpenClaw..."
|
||||||
|
|
||||||
|
function Install-OpenClawByRegistry($registry) {
|
||||||
|
Write-Info "尝试通过 npm 安装 OpenClaw($registry)..."
|
||||||
|
npm install -g openclaw@latest --registry=$registry 2>&1 | Write-Host
|
||||||
|
return ($LASTEXITCODE -eq 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
$installedOpenClaw = $false
|
||||||
|
if (Install-OpenClawByRegistry "https://registry.npmmirror.com") {
|
||||||
|
Write-Ok "已通过 npmmirror 安装 / 更新 OpenClaw。"
|
||||||
|
$installedOpenClaw = $true
|
||||||
|
} elseif (Install-OpenClawByRegistry "https://registry.npmjs.org") {
|
||||||
|
Write-Ok "已通过 npm 官方源安装 / 更新 OpenClaw。"
|
||||||
|
$installedOpenClaw = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $installedOpenClaw) {
|
||||||
|
Write-Err "OpenClaw 安装失败:npmmirror 与 npm 官方源均不可用。"
|
||||||
|
}
|
||||||
|
|
||||||
|
# 刷新 PATH
|
||||||
|
$env:Path = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
|
||||||
|
# 把 npm global bin 加到 PATH
|
||||||
|
try {
|
||||||
|
$npmPrefix = (npm config get prefix 2>$null).Trim()
|
||||||
|
if ($npmPrefix) {
|
||||||
|
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
||||||
|
if (-not ($userPath -split ";" | Where-Object { $_ -ieq $npmPrefix })) {
|
||||||
|
[Environment]::SetEnvironmentVariable("Path", "$userPath;$npmPrefix", "User")
|
||||||
|
$env:Path += ";$npmPrefix"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
|
Write-Ok "OpenClaw 安装 / 更新完成。"
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# 步骤 3: 启动交互式配置
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "========================================" -ForegroundColor Green
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
Write-Host " OpenClaw 安装完成!开始配置..." -ForegroundColor Green
|
Write-Host " OpenClaw 安装完成!开始配置..." -ForegroundColor Green
|
||||||
Write-Host "========================================" -ForegroundColor Green
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " 提示:当配置向导要求选择服务商时," -ForegroundColor White
|
|
||||||
Write-Host " 选择 MiniMax 可获得 7天免费试用 - 无需信用卡。" -ForegroundColor White
|
|
||||||
Write-Host " 注册地址:https://platform.minimax.io" -ForegroundColor Cyan
|
|
||||||
Write-Host ""
|
|
||||||
|
|
||||||
wsl -d Ubuntu-24.04 -- bash -c 'export PATH="$HOME/.openclaw/bin:$PATH" && openclaw onboard --accept-risk --flow quickstart --node-manager npm --skip-skills < /dev/tty'
|
openclaw onboard --accept-risk --flow quickstart --install-daemon --gateway-bind loopback --node-manager npm --skip-search --skip-channels --skip-skills
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "========================================" -ForegroundColor Green
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
@@ -185,7 +244,16 @@ Write-Host " 配置完成!" -ForegroundColor Green
|
|||||||
Write-Host "========================================" -ForegroundColor Green
|
Write-Host "========================================" -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host " 接下来:" -ForegroundColor White
|
Write-Host " 接下来:" -ForegroundColor White
|
||||||
Write-Host " 1. 开始使用 OpenClaw:openclaw(在 WSL 中)" -ForegroundColor Gray
|
Write-Host " 1. 开始使用 OpenClaw:openclaw" -ForegroundColor Gray
|
||||||
Write-Host " 2. 添加技能(可选):openclaw configure --section skills" -ForegroundColor Gray
|
Write-Host " 2. 查看网关状态:openclaw gateway status" -ForegroundColor Gray
|
||||||
Write-Host " 3. 浏览可用技能:openclaw skills" -ForegroundColor Gray
|
Write-Host " 3. 如需卸载:iwr -useb https://github.carrydelahaye.work/openclaw/openclaw-setup-cn/raw/branch/main/uninstall-windows.ps1 | iex" -ForegroundColor Gray
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
|
} catch {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "[错误] 脚本执行失败: $_" -ForegroundColor Red
|
||||||
|
Write-Host ""
|
||||||
|
} finally {
|
||||||
|
Write-Host ""
|
||||||
|
Read-Host "按 Enter 键关闭此窗口"
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
# OpenClaw 卸载脚本 (Windows / WSL)
|
# OpenClaw 卸载脚本 (Windows)
|
||||||
|
# 与当前“原生 Windows 安装”流程对齐
|
||||||
# ─────────────────────────────────────────────
|
# ─────────────────────────────────────────────
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
@@ -7,6 +8,7 @@ $ErrorActionPreference = "Stop"
|
|||||||
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
function Write-Info($msg) { Write-Host "[信息] $msg" -ForegroundColor Cyan }
|
||||||
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
function Write-Ok($msg) { Write-Host "[完成] $msg" -ForegroundColor Green }
|
||||||
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
function Write-Warn($msg) { Write-Host "[警告] $msg" -ForegroundColor Yellow }
|
||||||
|
function Write-Err($msg) { Write-Host "[错误] $msg" -ForegroundColor Red; throw $msg }
|
||||||
|
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "========================================" -ForegroundColor White
|
Write-Host "========================================" -ForegroundColor White
|
||||||
@@ -14,20 +16,51 @@ Write-Host " OpenClaw 卸载器 (Windows)" -ForegroundColor White
|
|||||||
Write-Host "========================================" -ForegroundColor White
|
Write-Host "========================================" -ForegroundColor White
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|
||||||
$uninstallScript = @'
|
$uninstalled = $false
|
||||||
set -e
|
|
||||||
export PATH="$HOME/.openclaw/bin:$PATH"
|
|
||||||
if command -v openclaw &>/dev/null; then
|
|
||||||
echo "[信息] 已找到 openclaw,正在运行卸载..."
|
|
||||||
openclaw uninstall --all --yes --non-interactive
|
|
||||||
else
|
|
||||||
echo "[警告] 在 PATH 中未找到 openclaw,使用 npx..."
|
|
||||||
npx -y openclaw uninstall --all --yes --non-interactive
|
|
||||||
fi
|
|
||||||
'@
|
|
||||||
|
|
||||||
Write-Info "正在卸载 WSL 中的 OpenClaw..."
|
# 1) 优先使用已安装的 openclaw 命令
|
||||||
wsl -d Ubuntu-24.04 -- bash -c $uninstallScript
|
if (Get-Command openclaw -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
Write-Info "已找到 openclaw,正在卸载(--all)..."
|
||||||
|
openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
Write-Ok "OpenClaw 卸载命令执行完成。"
|
||||||
|
} catch {
|
||||||
|
Write-Warn "openclaw 卸载失败,尝试 npx 方式..."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 2) 回退:npx 直接调用
|
||||||
|
if (-not $uninstalled) {
|
||||||
|
if (Get-Command npx -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
Write-Info "使用 npx 执行卸载..."
|
||||||
|
npx -y openclaw uninstall --all --yes --non-interactive
|
||||||
|
$uninstalled = $true
|
||||||
|
Write-Ok "OpenClaw 卸载命令执行完成(npx)。"
|
||||||
|
} catch {
|
||||||
|
Write-Warn "npx 卸载失败。"
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Warn "未找到 npx,跳过 npx 卸载。"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# 3) 清理全局 npm 包(幂等,失败不终止)
|
||||||
|
if (Get-Command npm -ErrorAction SilentlyContinue) {
|
||||||
|
try {
|
||||||
|
Write-Info "尝试移除全局 npm 包 openclaw(如存在)..."
|
||||||
|
npm uninstall -g openclaw 2>$null | Out-Null
|
||||||
|
Write-Ok "全局 npm 包清理完成。"
|
||||||
|
} catch {
|
||||||
|
Write-Warn "全局 npm 包清理跳过:$_"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not $uninstalled) {
|
||||||
|
Write-Err "未能完成 OpenClaw 卸载。请确认 Node.js/npm 可用后重试。"
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
Write-Ok "OpenClaw 已卸载。"
|
Write-Ok "OpenClaw 已卸载。"
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
|
|||||||
Reference in New Issue
Block a user