57 lines
1.5 KiB
Bash
57 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
||
# 代码已更新(git pull)后执行:刷新 venv、重建 web-console、重启控制面与 Caddy 边缘。
|
||
# 不需要也不应代替首次装机;不等价于 install-hub / install-business / install-all。
|
||
set -euo pipefail
|
||
|
||
SELF_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||
INSTALL_TAG="upgrade"
|
||
. "$SELF_DIR/lib/common.sh"
|
||
|
||
ensure_root "$@"
|
||
load_env
|
||
|
||
# git pull 若以 root 执行,避免 live 用户无法写 venv / node_modules
|
||
chown -R live:live "$ROOT_DIR" || true
|
||
|
||
log "Refreshing Python venv + requirements"
|
||
prepare_python_runtime
|
||
|
||
log "Rebuilding web-console (npm)"
|
||
prepare_web_console
|
||
|
||
log "Restarting live-console.service"
|
||
systemctl daemon-reload
|
||
systemctl restart live-console.service
|
||
|
||
if [ "${ENABLE_LIVE_EDGE_PROXY:-1}" = "1" ]; then
|
||
log "Regenerating Caddyfile and restarting live-edge.service"
|
||
install_live_edge_proxy
|
||
else
|
||
log "ENABLE_LIVE_EDGE_PROXY is not 1 — skipping live-edge (direct :${PORT})"
|
||
fi
|
||
|
||
ok=0
|
||
for _ in 1 2 3 4 5 6; do
|
||
if curl -sf -m 6 "http://127.0.0.1:${PORT}/health" >/dev/null; then
|
||
ok=1
|
||
break
|
||
fi
|
||
sleep 2
|
||
done
|
||
if [ "$ok" = 1 ]; then
|
||
log "Health check OK on http://127.0.0.1:${PORT}/health"
|
||
else
|
||
log "WARN: health check failed — see: journalctl -u live-console.service -n 80 --no-pager"
|
||
exit 1
|
||
fi
|
||
|
||
cat <<EOF
|
||
|
||
Upgrade done. Open:
|
||
http://${HOSTNAME_ALIAS}.local/ (port 80, if live-edge active)
|
||
http://${HOSTNAME_ALIAS}.local:${PORT}/ (direct)
|
||
|
||
Next time after git pull, run: sudo bash upgrade-live.sh
|
||
(No need for install-all.sh unless you change OS-level stack or first install.)
|
||
EOF
|