From 1ebfb5ef34f38c06114246f5636eb39b66bc2bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Mon, 16 Nov 2026 10:59:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20make=20update-box=E2=80=94=E2=80=94?= =?UTF-8?q?=E5=BE=9E=E5=91=BD=E4=BB=A4=E5=88=97=E9=87=8D=E5=BB=BA=E3=80=8C?= =?UTF-8?q?Bot=20=E7=9A=84=E9=9B=BB=E8=85=A6=E3=80=8D=E6=98=A0=E5=83=8F?= =?UTF-8?q?=E4=B8=A6=E6=8F=9B=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 設定 › 電腦 › 更新 Bot 的電腦的命令列版:照 box/Dockerfile 重建映像、把舊電腦 停掉,大腦在 Bot 下次用電腦時自動用新映像開機。資料碟 anybot-box-home 不動: 檔案和瀏覽器登入都留著。支援 ANYBOT_BOX_NAME/ANYBOT_BOX_IMAGE(一部大腦一台 電腦的情境)。和按鈕的分別是它不跑更新前快照和進度顯示,help 裡寫清楚了:有 視窗的大腦請優先按按鈕。git pull 沒成功就停,不會半更新。 Co-Authored-By: Claude Opus 5.5 --- Makefile | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8156da2..8a44027 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ RELAY := $(if $(CARGO_TARGET_DIR),$(CARGO_TARGET_DIR),relay/target)/release/an # make update PULL=0: install this checkout as it is, without pulling the newest first. PULL ?= 1 -.PHONY: all build app relay run serve setup relay-run test deps doctor install uninstall update update-app update-hands update-server server-logs hands server dist clean help check-rust lint-sh sign-setup +.PHONY: all build app relay run serve setup relay-run test deps doctor install uninstall update update-app update-hands update-server update-box server-logs hands server dist clean help check-rust lint-sh sign-setup all: build @@ -43,6 +43,8 @@ help: @echo " make update-hands 只更新 Linux 手腳(換新程式、重新啟動背景服務)" @echo " make update-server 只更新伺服器(帳號伺服器 + 大腦,Docker)" @echo " 加 PULL=0:不拉新版,裝現在這份原始碼" + @echo " make update-box 重建「Bot 的電腦」映像並換上新電腦(檔案和登入保留)" + @echo " 有視窗的大腦請優先用設定 › 電腦 › 更新 Bot 的電腦(會先存快照)" @echo "" @echo " make deps 裝好建置需要的東西:系統套件和 Rust(Linux 會問 sudo 密碼)" @echo " make doctor 檢查這台缺什麼" @@ -152,6 +154,22 @@ update-hands: update-server: @PULL=$(PULL) MAKE="$(MAKE)" sh deploy/update.sh server +# The box (Bot 的電腦): rebuild the image from box/ and take the container down, so the running +# brain opens a new computer from the new image the next time a bot uses one (create_container +# on demand). The home volume (anybot-box-home) is untouched: files and browser logins stay. +# Same effect as 設定 › 電腦 › 更新 Bot 的電腦, minus its snapshot and progress display — on a +# brain with a window, prefer the settings page. A box renamed per brain (ANYBOT_BOX_NAME) and a +# box image of its own (ANYBOT_BOX_IMAGE) are respected. +update-box: + @if [ "$(PULL)" = "1" ]; then git pull --ff-only || { echo " ✗ git pull 沒成功(有未送出的修改?),先處理好再更新"; exit 1; }; fi + @command -v docker >/dev/null 2>&1 || { echo " ✗ 這台沒有 docker,建不了 Bot 的電腦"; exit 1; } + @V=$$(sed -n 's/^LABEL anybot.box.version="\([0-9]*\)"/\1/p' box/Dockerfile); \ + echo "建立 Bot 的電腦映像(box 第 $$V 版,第一次要幾分鐘)…"; \ + docker build -q -t $${ANYBOT_BOX_IMAGE:-anybot-box:1} box/ >/dev/null || { echo " ✗ 建立映像檔失敗"; exit 1; }; \ + echo "映像檔完成。" + @docker rm -f $${ANYBOT_BOX_NAME:-anybot-box} >/dev/null 2>&1 && echo "舊電腦已停。" || true + @echo "Bot 下次用電腦時會用新映像開機(檔案和登入保留)。" + # The author, once: sign every commit so installs can check where an update came from. sign-setup: @sh deploy/sign-setup.sh