feat: make update-box——從命令列重建「Bot 的電腦」映像並換新
設定 › 電腦 › 更新 Bot 的電腦的命令列版:照 box/Dockerfile 重建映像、把舊電腦 停掉,大腦在 Bot 下次用電腦時自動用新映像開機。資料碟 anybot-box-home 不動: 檔案和瀏覽器登入都留著。支援 ANYBOT_BOX_NAME/ANYBOT_BOX_IMAGE(一部大腦一台 電腦的情境)。和按鈕的分別是它不跑更新前快照和進度顯示,help 裡寫清楚了:有 視窗的大腦請優先按按鈕。git pull 沒成功就停,不會半更新。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5912ec6886
commit
1ebfb5ef34
20
Makefile
20
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue