Skip to content

Commit 533f140

Browse files
Merge pull request #621 from 0k/avoid-assume-db-list-perm
[FIX] 20-postgres-wait: avoid assuming you have permission to list database
2 parents 312a923 + df7fbe1 commit 533f140

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

entrypoint.d/20-postgres-wait

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ fi
66

77
log INFO Waiting until postgres is listening at $PGHOST...
88
while true; do
9-
psql --list > /dev/null 2>&1 && break
9+
# If your postgres connection has minimal permissions, you should
10+
# have at least an empty PGDATABASE and rights on this
11+
# databases. The following will then succeed:
12+
[ -n "$PGDATABASE" ] && echo "SELECT 1;" | psql "$PGDATABASE" > /dev/null 2>&1 && break
13+
14+
# if previous check failed (if PGDATABASE is set, but not yet
15+
# created), you are in a more common scenario where odoo is
16+
# expected to manage databases, and it should have the permissions
17+
# to create it and will attempt to do it. In that case, you'll
18+
# probably also have the permissions to list the databases.
19+
psql -l > /dev/null 2>&1 && break
1020
sleep 1
1121
done

0 commit comments

Comments
 (0)