From 47cbdec2520e88d0759c70ac86898e956e7bfe90 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Sun, 16 Nov 2025 09:54:03 +0100 Subject: [PATCH] Enhance healthchecks update process with backup and venv Added backup creation for existing healthchecks installation before updating. Enhanced the update process by recreating the Python virtual environment and installing requirements. --- ct/healthchecks.sh | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ct/healthchecks.sh b/ct/healthchecks.sh index a1912422b..7955c8ad1 100644 --- a/ct/healthchecks.sh +++ b/ct/healthchecks.sh @@ -28,26 +28,42 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + if check_for_gh_release "healthchecks" "healthchecks/healthchecks"; then msg_info "Stopping Services" systemctl stop healthchecks msg_ok "Stopped Services" - PYTHON_VERSION="3.13" setup_uv + msg_info "Backing up existing installation" + BACKUP="/opt/healthchecks-backup-$(date +%F-%H%M)" + cp -a /opt/healthchecks "$BACKUP" + msg_ok "Backup created at $BACKUP" + fetch_and_deploy_gh_release "healthchecks" "healthchecks/healthchecks" - msg_info "Updating healthchecks" cd /opt/healthchecks - mkdir -p /opt/healthchecks/static-collected/ - $STD uv pip install wheel gunicorn -r requirements.txt --system - $STD uv run -- python manage.py makemigrations - $STD uv run -- python manage.py migrate --noinput - $STD uv run -- python manage.py collectstatic --noinput - $STD uv run -- python manage.py compress - msg_ok "Updated healthchecks" + if [[ -d venv ]]; then + rm -rf venv + fi + msg_info "Recreating Python venv" + $STD python3 -m venv venv + $STD source venv/bin/activate + $STD pip install --upgrade pip wheel + msg_ok "Created venv" + + msg_info "Installing requirements" + $STD pip install gunicorn -r requirements.txt + msg_ok "Installed requirements" + + msg_info "Running Django migrations" + $STD python manage.py migrate --noinput + $STD python manage.py collectstatic --noinput + $STD python manage.py compress + msg_ok "Completed Django migrations and static build" + msg_info "Starting Services" systemctl start healthchecks - systemctl restart caddy + systemctl reload caddy msg_ok "Started Services" msg_ok "Updated successfully!" fi