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.
This commit is contained in:
CanbiZ
2025-11-16 09:54:03 +01:00
committed by GitHub
parent 7f28f12989
commit 47cbdec252

View File

@@ -28,26 +28,42 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
if check_for_gh_release "healthchecks" "healthchecks/healthchecks"; then if check_for_gh_release "healthchecks" "healthchecks/healthchecks"; then
msg_info "Stopping Services" msg_info "Stopping Services"
systemctl stop healthchecks systemctl stop healthchecks
msg_ok "Stopped Services" 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" fetch_and_deploy_gh_release "healthchecks" "healthchecks/healthchecks"
msg_info "Updating healthchecks"
cd /opt/healthchecks cd /opt/healthchecks
mkdir -p /opt/healthchecks/static-collected/ if [[ -d venv ]]; then
$STD uv pip install wheel gunicorn -r requirements.txt --system rm -rf venv
$STD uv run -- python manage.py makemigrations fi
$STD uv run -- python manage.py migrate --noinput msg_info "Recreating Python venv"
$STD uv run -- python manage.py collectstatic --noinput $STD python3 -m venv venv
$STD uv run -- python manage.py compress $STD source venv/bin/activate
msg_ok "Updated healthchecks" $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" msg_info "Starting Services"
systemctl start healthchecks systemctl start healthchecks
systemctl restart caddy systemctl reload caddy
msg_ok "Started Services" msg_ok "Started Services"
msg_ok "Updated successfully!" msg_ok "Updated successfully!"
fi fi