This commit is contained in:
CanbiZ 2025-08-21 11:53:07 +02:00
parent 8faecd1f7d
commit 1514caac11
2 changed files with 9 additions and 7 deletions

View File

@ -49,20 +49,22 @@ msg_info "Setup healthchecks"
cd /opt/healthchecks
mkdir -p /opt/healthchecks/static-collected/
$STD uv pip install wheel gunicorn -r requirements.txt --system
LOCAL_IP=$(hostname -I | awk '{print $1}')
cat <<EOF >/opt/healthchecks/hc/local_settings.py
DEBUG = False
ALLOWED_HOSTS = ["${LOCAL_IP}", "127.0.0.1", "localhost"]
CSRF_TRUSTED_ORIGINS = ["https://${LOCAL_IP}"]
CSRF_TRUSTED_ORIGINS = ["http://${LOCAL_IP}", "https://${LOCAL_IP}"]
SECRET_KEY = "${SECRET_KEY}"
SITE_ROOT = "https://${LOCAL_IP}"
SITE_ROOT = "http://${LOCAL_IP}:8000"
SITE_NAME = "MyChecks"
DEFAULT_FROM_EMAIL = "healthchecks@${LOCAL_IP}"
STATIC_ROOT = "/opt/healthchecks/static-collected"
COMPRESS_OFFLINE = True
DATABASES = {
'default': {
@ -76,9 +78,11 @@ DATABASES = {
}
}
EOF
$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
ADMIN_EMAIL="admin@helper-scripts.local"
ADMIN_PASSWORD="$DB_PASS"
@ -98,9 +102,7 @@ After=network.target postgresql.service
[Service]
WorkingDirectory=/opt/healthchecks/
EnvironmentFile=/opt/healthchecks/.env
ExecStart=/usr/local/bin/uv run -- gunicorn hc.wsgi:application --bind 127.0.0.1:8000
Restart=always
[Install]

View File

@ -163,7 +163,7 @@ function setup_postgresql() {
if [[ "$CURRENT_PG_VERSION" == "$PG_VERSION" ]]; then
: # PostgreSQL is already at the desired version no action needed
else
msg_info "Detected PostgreSQL $CURRENT_PG_VERSION, preparing upgrade to $PG_VERSION"
$STD msg_info "Detected PostgreSQL $CURRENT_PG_VERSION, preparing upgrade to $PG_VERSION"
NEED_PG_INSTALL=true
fi
else
@ -173,9 +173,9 @@ function setup_postgresql() {
if [[ "$NEED_PG_INSTALL" == true ]]; then
if [[ -n "$CURRENT_PG_VERSION" ]]; then
msg_info "Dumping PostgreSQL $CURRENT_PG_VERSION data"
$STD msg_info "Dumping PostgreSQL $CURRENT_PG_VERSION data"
su - postgres -c "pg_dumpall > /var/lib/postgresql/backup_$(date +%F)_v${CURRENT_PG_VERSION}.sql"
msg_ok "Data dump completed"
$STD msg_ok "Data dump completed"
systemctl stop postgresql
fi