From 86908a5b6652a264898363cb5caf986d3cd4f326 Mon Sep 17 00:00:00 2001 From: shazhou-ww Date: Mon, 30 Mar 2026 14:50:30 +0000 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=96=B0=E5=A2=9E=20Bootstrap=20?= =?UTF-8?q?=E6=96=B0=E8=AE=BE=E5=A4=87=E6=96=B9=E6=B3=95=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 记录一行命令 bootstrap 新设备的完整方法论: - 理念:人类只做最少特权操作,buddy agent 接管后续 - 技术方案:cloudflared Quick Tunnel + SSH 隧道 - bash <(curl ...) vs curl | bash 的区别 - 踩坑记录:curl|bash stdin 问题、tcp:// 协议、VPN bypass 等 脚本仓库:https://github.com/shazhou-ww/oc-bootstrap --- docs/shared/bootstrap-onboarding.md | 177 ++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 178 insertions(+) create mode 100644 docs/shared/bootstrap-onboarding.md diff --git a/docs/shared/bootstrap-onboarding.md b/docs/shared/bootstrap-onboarding.md new file mode 100644 index 0000000..22b91f9 --- /dev/null +++ b/docs/shared/bootstrap-onboarding.md @@ -0,0 +1,177 @@ +# 一行命令 Bootstrap 新设备 + +> **理念**:人类只做最少特权操作,buddy agent 接管后续。 + +## 概述 + +这套方法论解决了一个经典问题:如何让一台全新的设备快速接入 Agent 生态,同时把人类需要手动操作的步骤压缩到最低? + +核心思路: + +1. 人类在新设备上执行一条 bootstrap 命令 +2. 脚本自动安装必要组件,建立公网 SSH 隧道 +3. 客户端 buddy agent 通过隧道 SSH 进入新设备 +4. buddy agent 完成剩余所有配置 + +**人类只需要:** 运行一行命令,然后把隧道地址告诉 agent。 + +脚本仓库:[https://github.com/shazhou-ww/oc-bootstrap](https://github.com/shazhou-ww/oc-bootstrap) + +--- + +## 流程图 + +```mermaid +sequenceDiagram + participant H as 人类(新设备) + participant S as Bootstrap 脚本 + participant CF as Cloudflare Quick Tunnel + participant A as Buddy Agent(客户端) + + H->>S: bash <(curl -fsSL ) + S->>S: 安装依赖(cloudflared、OpenClaw 等) + S->>CF: cloudflared tunnel --url tcp://localhost:22 + CF-->>S: 返回隧道域名 xxx.trycloudflare.com + S->>H: 显示隧道地址,等待 agent 接管 + H->>A: 把隧道地址发给 agent + A->>CF: cloudflared access tcp --hostname xxx.trycloudflare.com --url localhost:2222 + A->>A: ssh -p 2222 user@localhost + A->>A: 执行剩余配置(复制公钥、配置 OpenClaw 等) +``` + +--- + +## 技术方案 + +### Bootstrap 脚本执行方式 + +```bash +bash <(curl -fsSL https://raw.githubusercontent.com/shazhou-ww/oc-bootstrap/main/bootstrap.sh) +``` + +!!! warning "为什么不用 `curl | bash`" + `curl | bash` 会把 curl 的 stdout 接到 bash 的 stdin,导致脚本内的 `read` 命令无法从终端读取用户输入。即使加 `