From df7fbe1211f6525b314af7a057939acc9ba4cbd5 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sat, 14 Sep 2024 15:51:22 +0200 Subject: [PATCH] [FIX] 20-postgres-wait: avoid assuming you have permission to list database --- entrypoint.d/20-postgres-wait | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/entrypoint.d/20-postgres-wait b/entrypoint.d/20-postgres-wait index 55ee402b..cca4d52d 100755 --- a/entrypoint.d/20-postgres-wait +++ b/entrypoint.d/20-postgres-wait @@ -6,6 +6,16 @@ fi log INFO Waiting until postgres is listening at $PGHOST... while true; do - psql --list > /dev/null 2>&1 && break + # If your postgres connection has minimal permissions, you should + # have at least an empty PGDATABASE and rights on this + # databases. The following will then succeed: + [ -n "$PGDATABASE" ] && echo "SELECT 1;" | psql "$PGDATABASE" > /dev/null 2>&1 && break + + # if previous check failed (if PGDATABASE is set, but not yet + # created), you are in a more common scenario where odoo is + # expected to manage databases, and it should have the permissions + # to create it and will attempt to do it. In that case, you'll + # probably also have the permissions to list the databases. + psql -l > /dev/null 2>&1 && break sleep 1 done