Files
Kelx/privileged/jobs/pgadmin-setup-recover.sh
2026-11-30 16:32:37 +00:00

22 lines
856 B
Bash

#!/usr/bin/env bash
# ADPanel privileged job: re-run pgAdmin setup-web.sh to (re)create the
# initial admin account, then restart Apache.
# Invoked via adpanel-priv: adpanel-priv job pgadmin-setup-recover
# Environment: PGADMIN_SETUP_EMAIL, PGADMIN_SETUP_PASSWORD
set -u
SETUP_SCRIPT=""
if [ -x /usr/pgadmin4/bin/setup-web.sh ]; then
SETUP_SCRIPT="/usr/pgadmin4/bin/setup-web.sh"
elif [ -x /usr/share/pgadmin4/bin/setup-web.sh ]; then
SETUP_SCRIPT="/usr/share/pgadmin4/bin/setup-web.sh"
fi
if [ -n "$SETUP_SCRIPT" ]; then
: "${PGADMIN_SETUP_EMAIL:?PGADMIN_SETUP_EMAIL not set}"
: "${PGADMIN_SETUP_PASSWORD:?PGADMIN_SETUP_PASSWORD not set}"
"$SETUP_SCRIPT" --yes >/dev/null 2>&1 || true
rm -f /etc/apache2/conf-enabled/pgadmin4.conf 2>/dev/null || true
systemctl restart apache2 2>/dev/null || systemctl start apache2 2>/dev/null || true
fi