Skip to content

Commit 01ec8a1

Browse files
committed
pgadmin: fix entrypoint replace-servers EMAIL guard and external-DB double-init
Signed-off-by: Ricardo Dias <ricardo.dias@percona.com>
1 parent ef122ab commit 01ec8a1

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • root/ppg/devel/pgadmin/containers/percona-pgadmin4/obs

root/ppg/devel/pgadmin/containers/percona-pgadmin4/obs/entrypoint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,26 @@ if [ ! -e "${SQLITE_PATH}" ] && [ "${external_config_db_exists}" = "False" ]; th
9494
/usr/bin/pgadmin4-cli set-prefs "${PGADMIN_DEFAULT_EMAIL}" --input-file "${prefs_json}"
9595
fi
9696
elif [ "${PGADMIN_REPLACE_SERVERS_ON_STARTUP:-}" = "True" ]; then
97+
if [ -z "${PGADMIN_DEFAULT_EMAIL:-}" ]; then
98+
echo 'PGADMIN_REPLACE_SERVERS_ON_STARTUP=True requires PGADMIN_DEFAULT_EMAIL to be set.' >&2
99+
exit 1
100+
fi
97101
server_json="${PGADMIN_SERVER_JSON_FILE:-/pgadmin4/servers.json}"
98102
if [ -f "${server_json}" ]; then
99103
/usr/bin/pgadmin4-cli load-servers "${server_json}" --user "${PGADMIN_DEFAULT_EMAIL}" --replace
100104
fi
101105
fi
102106

107+
# --- External-config-DB mode: prevent launcher double-init -----------------
108+
# The launcher's own first-run branch fires whenever its sqlite path is
109+
# absent and DEFAULT_EMAIL/DEFAULT_PASSWORD are set, with no knowledge of an
110+
# external config DB. We already decided above (external_config_db_exists)
111+
# that setup must not run; clear these so the launcher can't re-decide to
112+
# run setup-db against the external DB.
113+
if [ "${external_config_db_exists}" = "True" ]; then
114+
unset PGADMIN_DEFAULT_EMAIL PGADMIN_DEFAULT_PASSWORD
115+
fi
116+
103117
# --- TLS pre-flight ---------------------------------------------------------
104118
# The launcher wires the certs; fail early and clearly when they are missing.
105119
if [ "${PGADMIN_ENABLE_TLS:-}" = "true" ]; then

0 commit comments

Comments
 (0)