Skip to content

Commit de19732

Browse files
committed
Update POSTGRES_USER's password
1 parent 6bebca2 commit de19732

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

docker-entrypoint.d/10-fix-pg_hba.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ else
88
authMethod=trust
99
fi
1010

11+
# Fix pg_hba.conf
1112
if grep -q "^host all all 0.0.0.0/0 " "$PGDATA/pg_hba.conf"; then
1213
if grep -q "^host all all 0.0.0.0/0 $authMethod$" "$PGDATA/pg_hba.conf"; then
1314
echo "pg_hba.conf already valid"
@@ -18,3 +19,11 @@ else
1819
{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA/pg_hba.conf"
1920
fi
2021

22+
# Fix user password
23+
if psql -U postgres -c "SELECT COUNT(*) AS count FROM pg_catalog.pg_user WHERE usename = '$POSTGRES_USER'" | grep -q 1; then
24+
op="ALTER"
25+
else
26+
op="CREATE"
27+
fi
28+
29+
psql -Upostgres -c "$op USER \"$POSTGRES_USER\" WITH SUPERUSER $pass ;"

0 commit comments

Comments
 (0)