Skip to content

Commit

Permalink
Merge pull request #621 from 0k/avoid-assume-db-list-perm
Browse files Browse the repository at this point in the history
[FIX] 20-postgres-wait: avoid assuming you have permission to list database
  • Loading branch information
josep-tecnativa authored Oct 1, 2024
2 parents 312a923 + df7fbe1 commit 533f140
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion entrypoint.d/20-postgres-wait
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 533f140

Please sign in to comment.