1
0
mirror of https://github.com/docker-library/postgres.git synced 2025-07-28 10:42:06 +03:00

Fixed checks for USER/DB combinations 👌:squirrel:

This commit is contained in:
Justin Garrison
2015-02-13 23:30:13 -08:00
parent 1438bacac6
commit 5950846753
7 changed files with 56 additions and 28 deletions

View File

@ -30,16 +30,20 @@ if [ "$1" = 'postgres' ]; then
: ${POSTGRES_USER:=postgres}
: ${POSTGRES_DB:=$POSTGRES_USER}
if [ "$POSTGRES_DB" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
if [ ! "$POSTGRES_DB" = 'postgres' ]; then
gosu postgres postgres --single -jE <<-EOSQL
CREATE DATABASE "$POSTGRES_DB" ;
EOSQL
echo
fi
if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
fi
gosu postgres postgres --single -jE <<-EOSQL
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL