From 6ef68eeb34d09c755448f54e3919bb2a04252955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Thu, 19 Nov 2026 17:13:01 +0800 Subject: [PATCH] =?UTF-8?q?migrate=EF=BC=9A=E9=9D=9E=E4=BA=92=E5=8B=95=20S?= =?UTF-8?q?SH=20=E4=B8=8D=E8=AE=80=20.bashrc=E2=80=94=E2=80=94cargo=20?= =?UTF-8?q?=E6=AA=A2=E6=9F=A5=E8=88=87=E7=B7=A8=E8=AD=AF=E9=83=BD=E8=A3=9C?= =?UTF-8?q?=20~/.cargo/bin=20=E9=80=B2=20PATH?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/migrate-relay.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/deploy/migrate-relay.sh b/deploy/migrate-relay.sh index 231676c..322792b 100755 --- a/deploy/migrate-relay.sh +++ b/deploy/migrate-relay.sh @@ -41,7 +41,8 @@ read -r SSH_TARGET ssh -o BatchMode=yes -o ConnectTimeout=10 "$SSH_TARGET" true 2>/dev/null && ok "SSH 連線正常" || { bad "SSH 連不上(${SSH_TARGET})。先設好免密登入(ssh-copy-id)再來。"; exit 1; } SRV_OS=$(ssh -o BatchMode=yes "$SSH_TARGET" 'uname -s; uname -m' | tr '\n' ' ') ok "那台系統:$SRV_OS" -ssh -o BatchMode=yes "$SSH_TARGET" 'command -v cargo' >/dev/null 2>&1 && ok "那台有 Rust 工具鏈(編譯 relay 用)" || { bad "那台沒有 cargo。先裝 Rust:curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"; exit 1; } +# 非互動 SSH 不讀 .bashrc:rustup 裝在 ~/.cargo/bin,手動補進 PATH。 +ssh -o BatchMode=yes "$SSH_TARGET" 'export PATH="$HOME/.cargo/bin:$PATH"; command -v cargo' >/dev/null 2>&1 && ok "那台有 Rust 工具鏈(編譯 relay 用)" || { bad "那台沒有 cargo。先裝 Rust:ssh 進去後跑 curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y"; exit 1; } ssh -o BatchMode=yes "$SSH_TARGET" 'command -v tailscale' >/dev/null 2>&1 && ok "那台有 Tailscale" || { bad "那台沒有 Tailscale(要它給 relay 一個 https 網址)。"; exit 1; } # ---------- 2. 服务器上编译并启动 relay ---------- @@ -49,7 +50,7 @@ say "2/7 在那台編譯帳號伺服器(第一次約 3–10 分鐘)" ssh -o BatchMode=yes "$SSH_TARGET" 'mkdir -p ~/anybot-relay' rsync -a --delete --exclude target relay/ "$SSH_TARGET:~/anybot-relay/" 2>/dev/null || { bad "rsync 源码失败"; exit 1; } ok "源码已同步" -ssh -o BatchMode=yes "$SSH_TARGET" 'cd ~/anybot-relay && cargo build --release --quiet 2>&1 | tail -3' +ssh -o BatchMode=yes "$SSH_TARGET" 'export PATH="$HOME/.cargo/bin:$PATH"; cd ~/anybot-relay && cargo build --release --quiet 2>&1 | tail -3' ok "編譯完成" say " 启动 relay(127.0.0.1:8780,开机自启)"