#!/usr/bin/env bash # ADPanel privileged job: prepare the pgAdmin Apache backend (localhost:5050). # Invoked via adpanel-priv: adpanel-priv job pgadmin-prepare # stdin: base64-encoded Apache VirtualHost configuration for pgAdmin4. set -u CONF_B64="$(cat)" [ -n "$CONF_B64" ] || { echo "pgadmin-prepare: missing config payload" >&2; exit 2; } systemctl daemon-reload 2>/dev/null || true systemctl start postgresql 2>/dev/null || true mkdir -p /etc/apache2/sites-available /etc/apache2/sites-enabled printf %s "$CONF_B64" | base64 -d > /etc/apache2/sites-available/pgadmin4.conf chmod 0644 /etc/apache2/sites-available/pgadmin4.conf ln -sf /etc/apache2/sites-available/pgadmin4.conf /etc/apache2/sites-enabled/pgadmin4.conf rm -f /etc/apache2/sites-enabled/000-default.conf 2>/dev/null || true rm -f /etc/apache2/sites-enabled/default-ssl.conf 2>/dev/null || true rm -f /etc/apache2/conf-enabled/phpmyadmin.conf 2>/dev/null || true rm -f /etc/apache2/conf-enabled/pgadmin4.conf 2>/dev/null || true cat > /etc/apache2/ports.conf <<'EOF' # Apache ports configuration - managed by ADPanel Listen 127.0.0.1:5050 EOF a2enmod wsgi >/dev/null 2>&1 || true a2enmod headers >/dev/null 2>&1 || true apache2ctl -t >/dev/null 2>&1 || true systemctl restart apache2 2>/dev/null || systemctl start apache2 2>/dev/null || true