| 1 | # Ubuntu Lighthouse bootstrap |
| 2 | |
| 3 | Choose the trusted networks that may reach SSH before running the bootstrap: |
| 4 | |
| 5 | ```bash |
| 6 | sudo SSH_ALLOWED_CIDRS='203.0.113.4/32,2001:db8::/64' \ |
| 7 | bash scripts/tencent-lighthouse/bootstrap-ubuntu.sh |
| 8 | ``` |
| 9 | |
| 10 | Replace the example networks with your own. Every IPv4 /8–/32 or IPv6 /16–/128 |
| 11 | CIDR is validated before packages, users, files, or firewall rules change. |
| 12 | The script adds the narrow rules before removing the broad OpenSSH rule. |
| 13 | Keep the Lighthouse console firewall consistent with this policy. |
| 14 | |
| 15 | If a public SSH endpoint is deliberately required, explicitly pass |
| 16 | `SSH_ALLOW_ANY_SOURCE=1` instead. Omitting both settings stops the bootstrap. |
| 17 | The final instructions install the unified CLI, which includes the TUI and |
| 18 | runtime server, using Rust 1.89 or newer. |
| 19 | |
| 20 | ## Upgrading from an earlier release: reinstall the runtime unit and rotate the token |
| 21 | |
| 22 | The runtime unit now reads `CODEWHALE_RUNTIME_TOKEN` from |
| 23 | `/etc/codewhale/runtime.env` and carries no token on its command line. Earlier |
| 24 | releases of `deploy/tencent-lighthouse/systemd/codewhale-runtime.service` and of |
| 25 | the unit written by `codewhale remote-setup` passed the token as `--auth-token`, |
| 26 | which other users on the machine could read in the process list. Upgrading the |
| 27 | `codewhale` binary does not change a unit that is already installed, so on every |
| 28 | host that has one: |
| 29 | |
| 30 | 1. Reinstall the unit from an updated checkout, or from a freshly generated |
| 31 | `codewhale remote-setup` bundle: |
| 32 | |
| 33 | ```bash |
| 34 | sudo install -m 0644 deploy/tencent-lighthouse/systemd/codewhale-runtime.service \ |
| 35 | /etc/systemd/system/codewhale-runtime.service |
| 36 | sudo systemctl daemon-reload |
| 37 | ``` |
| 38 | |
| 39 | A `codewhale remote-setup` bundle carries the same unit as |
| 40 | `codewhale-runtime.service`; install that file instead of the repository path. |
| 41 | |
| 42 | 2. Set a new token. Put the same new value in `/etc/codewhale/runtime.env` and in |
| 43 | the bridge's env file, because the old one was readable while the unit ran: |
| 44 | |
| 45 | ```bash |
| 46 | openssl rand -hex 32 |
| 47 | ``` |
| 48 | |
| 49 | 3. Restart the runtime and the bridge, then check that the unit no longer |
| 50 | carries a token argument (the command prints `0`): |
| 51 | |
| 52 | ```bash |
| 53 | sudo systemctl restart codewhale-runtime |
| 54 | sudo systemctl restart codewhale-feishu-bridge # or codewhale-telegram-bridge |
| 55 | systemctl cat codewhale-runtime | grep -c -- '--auth-token' |
| 56 | ``` |
| 57 | |
| 58 | 4. Delete any old `codewhale remote-setup` output directory (it holds the old |
| 59 | token in plain files), or keep it only after replacing the token in it. |
| 60 | |
| 61 | ## 简体中文 |
| 62 | |
| 63 | 运行上面的命令前,请把示例网段替换为允许访问 SSH 的可信来源。脚本接受逗号或 |
| 64 | 空格分隔的 IPv4 /8–/32 和 IPv6 /16–/128 CIDR,并在安装软件包、创建用户、修改 |
| 65 | 文件或防火墙规则之前验证整个列表。它先添加受限规则,再删除对所有来源开放的 |
| 66 | OpenSSH 规则。Lighthouse 控制台防火墙也应采用一致的策略。 |
| 67 | |
| 68 | 确实需要公开 SSH 时,必须显式设置 `SSH_ALLOW_ANY_SOURCE=1`。两个设置都未 |
| 69 | 提供时,脚本会停止。最后的安装步骤使用 Rust 1.89 或更新版本,安装包含 TUI 和 |
| 70 | 运行时服务的统一 CLI。 |
| 71 | |
| 72 | ### 从早期版本升级:重新安装运行时单元并更换令牌 |
| 73 | |
| 74 | 运行时单元现在从 `/etc/codewhale/runtime.env` 读取 `CODEWHALE_RUNTIME_TOKEN`, |
| 75 | 命令行中不再带令牌。早期版本的 |
| 76 | `deploy/tencent-lighthouse/systemd/codewhale-runtime.service`,以及 |
| 77 | `codewhale remote-setup` 生成的单元,都用 `--auth-token` 传递令牌,机器上的其他 |
| 78 | 用户可以在进程列表中看到它。升级 `codewhale` 二进制不会修改已经安装的单元,所以 |
| 79 | 每台已安装单元的主机都需要: |
| 80 | |
| 81 | 1. 从更新后的代码库,或新生成的 `codewhale remote-setup` 输出中的 |
| 82 | `codewhale-runtime.service` 重新安装单元, |
| 83 | 然后运行 `sudo systemctl daemon-reload`。 |
| 84 | 2. 设置新的令牌:用 `openssl rand -hex 32` 生成,并把同一个新值写入 |
| 85 | `/etc/codewhale/runtime.env` 和桥接服务的环境文件。旧令牌在单元运行期间是可见的。 |
| 86 | 3. 重启运行时和桥接服务,再运行 |
| 87 | `systemctl cat codewhale-runtime | grep -c -- '--auth-token'`,应输出 `0`。 |
| 88 | 4. 删除旧的 `codewhale remote-setup` 输出目录(其中以明文文件保存旧令牌),或先替换其中的令牌。 |
| 89 |