11#! /usr/bin/env bash
2-
32# Copyright (c) 2021-2025 community-scripts ORG
43# Author: MickLesk (Canbiz)
54# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
@@ -16,43 +15,44 @@ update_os
1615msg_info " Installing Dependencies"
1716$STD apt install -y \
1817 gcc \
18+ python3 \
19+ python3-dev \
20+ python3-venv \
1921 libpq-dev \
2022 libcurl4-openssl-dev \
2123 libssl-dev \
2224 caddy
25+
26+ mkdir -p ~ /.config/pip
27+ cat > ~ /.config/pip/pip.conf << EOF
28+ [global]
29+ break-system-packages = true
30+ EOF
2331msg_ok " Installed Dependencies"
2432
25- PYTHON_VERSION=" 3.13" setup_uv
2633PG_VERSION=16 setup_postgresql
34+ PG_DB_NAME=" healthchecks_db" PG_DB_USER=" hc_user" PG_DB_PASS=$( openssl rand -base64 18 | tr -dc ' a-zA-Z0-9' | cut -c1-13) setup_postgresql_db
2735
28- msg_info " Setup Database"
29- DB_NAME=healthchecks_db
30- DB_USER=hc_user
31- DB_PASS=$( openssl rand -base64 18 | tr -dc ' a-zA-Z0-9' | cut -c1-13)
36+ msg_info " Setup Keys (Admin / Secret)"
3237SECRET_KEY=" $( openssl rand -base64 32 | tr -dc ' a-zA-Z0-9' | cut -c1-32) "
33383439ADMIN_PASSWORD=" $DB_PASS "
35- $STD sudo -u postgres psql -c " CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS ';"
36- $STD sudo -u postgres psql -c " CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
37- $STD sudo -u postgres psql -c " ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
38- $STD sudo -u postgres psql -c " ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
39- $STD sudo -u postgres psql -c " ALTER ROLE $DB_USER SET timezone TO 'UTC'"
4040{
41- echo " healthchecks-Credentials"
42- echo " healthchecks Database User: $DB_USER "
43- echo " healthchecks Database Password: $DB_PASS "
44- echo " healthchecks Database Name: $DB_NAME "
4541 echo " healthchecks Admin Email: $ADMIN_EMAIL "
4642 echo " healthchecks Admin Password: $ADMIN_PASSWORD "
4743} >> ~/healthchecks.creds
48- msg_ok " Set up Database "
44+ msg_ok " Set up Keys "
4945
5046fetch_and_deploy_gh_release " healthchecks" " healthchecks/healthchecks"
5147
52- msg_info " Setup healthchecks "
48+ msg_info " Installing Healthchecks (venv) "
5349cd /opt/healthchecks
54- mkdir -p /opt/healthchecks/static-collected/
55- $STD uv pip install wheel gunicorn -r requirements.txt --system
50+ python3 -m venv venv
51+ source venv/bin/activate
52+
53+ $STD pip install --upgrade pip wheel
54+ $STD pip install gunicorn -r requirements.txt
55+ msg_ok " Installed Python packages"
5656
5757LOCAL_IP=$( hostname -I | awk ' {print $1}' )
5858cat << EOF >/opt/healthchecks/hc/local_settings.py
@@ -83,18 +83,19 @@ DATABASES = {
8383}
8484EOF
8585
86- $STD uv run -- python manage.py makemigrations
87- $STD uv run -- python manage.py migrate --noinput
88- $STD uv run -- python manage.py collectstatic --noinput
89- $STD uv run -- python manage.py compress
86+ msg_info " Running Django setup"
87+ $STD python manage.py makemigrations
88+ $STD python manage.py migrate --noinput
89+ $STD python manage.py collectstatic --noinput
90+ $STD python manage.py compress
9091
91- cat << EOF | $STD uv run -- python manage.py shell
92+ python << EOF
9293from django.contrib.auth import get_user_model
9394User = get_user_model()
9495if not User.objects.filter(email="${ADMIN_EMAIL} ").exists():
9596 User.objects.create_superuser("${ADMIN_EMAIL} ", "${ADMIN_EMAIL} ", "${ADMIN_PASSWORD} ")
9697EOF
97- msg_ok " Installed healthchecks "
98+ msg_ok " Configured Django "
9899
99100msg_info " Configuring Caddy"
100101cat << EOF >/etc/caddy/Caddyfile
@@ -108,20 +109,21 @@ ${LOCAL_IP} {
108109EOF
109110msg_ok " Configured Caddy"
110111
111- msg_info " Creating Service "
112+ msg_info " Creating systemd service "
112113cat << EOF >/etc/systemd/system/healthchecks.service
113114[Unit]
114115Description=Healthchecks Service
115116After=network.target postgresql.service
116117
117118[Service]
118119WorkingDirectory=/opt/healthchecks/
119- ExecStart=/usr/local/ bin/uv run -- gunicorn hc.wsgi:application --bind 127.0.0.1:8000
120+ ExecStart=/opt/healthchecks/venv/ bin/gunicorn hc.wsgi:application --bind 127.0.0.1:8000
120121Restart=always
121122
122123[Install]
123124WantedBy=multi-user.target
124125EOF
126+
125127systemctl enable -q --now healthchecks caddy
126128systemctl reload caddy
127129msg_ok " Created Service"
0 commit comments