From 34b9c447ed2e7afcf9e0709a874fba1b62589f5e Mon Sep 17 00:00:00 2001 From: MickLesk <47820557+MickLesk@users.noreply.github.com> Date: Fri, 18 Sep 2026 07:56:42 +0200 Subject: [PATCH] scanopy: make the rollback restore the whole old setup The health check put the previous binary back but nothing else, and the source tree it needs was already gone by then: the update deleted /opt/scanopy/ui before starting the new server, and removed SCANOPY_WEB_EXTERNAL_PATH from the env at the same time. A failed health check therefore left the old binary running without the UI it serves from disk, so the rollback produced an API-only server. Back up the env file and the unit alongside the binary, restore all three when the check fails, and delete the source tree only once the new server has answered. Nothing the old version needs is removed before the new one has proven itself. --- ct/scanopy.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/ct/scanopy.sh b/ct/scanopy.sh index eb79ec4d7..1ce28ad44 100644 --- a/ct/scanopy.sh +++ b/ct/scanopy.sh @@ -38,6 +38,10 @@ function update_script() { [[ -f /etc/systemd/system/scanopy-daemon.service ]] && systemctl stop scanopy-daemon msg_ok "Stopped services" + cp -f /usr/bin/scanopy-server /usr/bin/scanopy-server.bak 2>/dev/null || true + cp -f /opt/scanopy/.env /opt/scanopy/.env.bak + cp -f /etc/systemd/system/scanopy-server.service /etc/systemd/system/scanopy-server.service.bak + if ! grep -q "PUBLIC_URL" /opt/scanopy/.env; then sed -i "\|_PATH=|a\\SCANOPY_PUBLIC_URL=http://${LOCAL_IP}:60072" /opt/scanopy/.env fi @@ -46,11 +50,8 @@ function update_script() { sed -i 's|^WorkingDirectory=/opt/scanopy/backend$|WorkingDirectory=/opt/scanopy|' /etc/systemd/system/scanopy-server.service systemctl daemon-reload - cp -f /usr/bin/scanopy-server /usr/bin/scanopy-server.bak 2>/dev/null || true - fetch_and_deploy_gh_release "Scanopy" "scanopy/scanopy" "singlefile" "latest" "/usr/bin" "scanopy-server-linux-$(arch_resolve)" - - rm -rf /opt/scanopy/backend /opt/scanopy/ui + mv -f /usr/bin/Scanopy /usr/bin/scanopy-server if [[ -f /etc/systemd/system/scanopy-daemon.service ]]; then fetch_and_deploy_gh_release "Scanopy Daemon" "scanopy/scanopy" "singlefile" "latest" "/usr/local/bin" "scanopy-daemon-linux-$(arch_resolve)" @@ -76,11 +77,15 @@ function update_script() { if [[ "$healthy" -ne 1 ]]; then systemctl stop scanopy-server [[ -f /usr/bin/scanopy-server.bak ]] && mv -f /usr/bin/scanopy-server.bak /usr/bin/scanopy-server + mv -f /opt/scanopy/.env.bak /opt/scanopy/.env + mv -f /etc/systemd/system/scanopy-server.service.bak /etc/systemd/system/scanopy-server.service + systemctl daemon-reload systemctl start scanopy-server - msg_error "New server did not answer /api/health, restored the previous binary" + msg_error "New server did not answer /api/health, restored the previous version" exit 1 fi - rm -f /usr/bin/scanopy-server.bak + rm -rf /opt/scanopy/backend /opt/scanopy/ui + rm -f /usr/bin/scanopy-server.bak /opt/scanopy/.env.bak /etc/systemd/system/scanopy-server.service.bak [[ -f /etc/systemd/system/scanopy-daemon.service ]] && systemctl start scanopy-daemon msg_ok "Updated successfully!" fi