Skip to content

Commit 5950846

Browse files
committed
Fixed checks for USER/DB combinations 👌:squirrel:
1 parent 1438bac commit 5950846

7 files changed

+56
-28
lines changed

8.4/docker-entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ if [ "$1" = 'postgres' ]; then
3030

3131
: ${POSTGRES_USER:=postgres}
3232
: ${POSTGRES_DB:=$POSTGRES_USER}
33-
if [ "$POSTGRES_DB" = 'postgres' ]; then
34-
op='ALTER'
35-
else
36-
op='CREATE'
33+
34+
if [ ! "$POSTGRES_DB" = 'postgres' ]; then
3735
gosu postgres postgres --single -jE <<-EOSQL
3836
CREATE DATABASE "$POSTGRES_DB" ;
3937
EOSQL
4038
echo
4139
fi
4240

41+
if [ "$POSTGRES_USER" = 'postgres' ]; then
42+
op='ALTER'
43+
else
44+
op='CREATE'
45+
fi
46+
4347
gosu postgres postgres --single -jE <<-EOSQL
4448
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
4549
EOSQL

9.0/docker-entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ if [ "$1" = 'postgres' ]; then
3030

3131
: ${POSTGRES_USER:=postgres}
3232
: ${POSTGRES_DB:=$POSTGRES_USER}
33-
if [ "$POSTGRES_DB" = 'postgres' ]; then
34-
op='ALTER'
35-
else
36-
op='CREATE'
33+
34+
if [ ! "$POSTGRES_DB" = 'postgres' ]; then
3735
gosu postgres postgres --single -jE <<-EOSQL
3836
CREATE DATABASE "$POSTGRES_DB" ;
3937
EOSQL
4038
echo
4139
fi
4240

41+
if [ "$POSTGRES_USER" = 'postgres' ]; then
42+
op='ALTER'
43+
else
44+
op='CREATE'
45+
fi
46+
4347
gosu postgres postgres --single -jE <<-EOSQL
4448
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
4549
EOSQL

9.1/docker-entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ if [ "$1" = 'postgres' ]; then
3030

3131
: ${POSTGRES_USER:=postgres}
3232
: ${POSTGRES_DB:=$POSTGRES_USER}
33-
if [ "$POSTGRES_DB" = 'postgres' ]; then
34-
op='ALTER'
35-
else
36-
op='CREATE'
33+
34+
if [ ! "$POSTGRES_DB" = 'postgres' ]; then
3735
gosu postgres postgres --single -jE <<-EOSQL
3836
CREATE DATABASE "$POSTGRES_DB" ;
3937
EOSQL
4038
echo
4139
fi
4240

41+
if [ "$POSTGRES_USER" = 'postgres' ]; then
42+
op='ALTER'
43+
else
44+
op='CREATE'
45+
fi
46+
4347
gosu postgres postgres --single -jE <<-EOSQL
4448
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
4549
EOSQL

9.2/docker-entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ if [ "$1" = 'postgres' ]; then
3030

3131
: ${POSTGRES_USER:=postgres}
3232
: ${POSTGRES_DB:=$POSTGRES_USER}
33-
if [ "$POSTGRES_DB" = 'postgres' ]; then
34-
op='ALTER'
35-
else
36-
op='CREATE'
33+
34+
if [ ! "$POSTGRES_DB" = 'postgres' ]; then
3735
gosu postgres postgres --single -jE <<-EOSQL
3836
CREATE DATABASE "$POSTGRES_DB" ;
3937
EOSQL
4038
echo
4139
fi
4240

41+
if [ "$POSTGRES_USER" = 'postgres' ]; then
42+
op='ALTER'
43+
else
44+
op='CREATE'
45+
fi
46+
4347
gosu postgres postgres --single -jE <<-EOSQL
4448
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
4549
EOSQL

9.3/docker-entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ if [ "$1" = 'postgres' ]; then
3030

3131
: ${POSTGRES_USER:=postgres}
3232
: ${POSTGRES_DB:=$POSTGRES_USER}
33-
if [ "$POSTGRES_DB" = 'postgres' ]; then
34-
op='ALTER'
35-
else
36-
op='CREATE'
33+
34+
if [ ! "$POSTGRES_DB" = 'postgres' ]; then
3735
gosu postgres postgres --single -jE <<-EOSQL
3836
CREATE DATABASE "$POSTGRES_DB" ;
3937
EOSQL
4038
echo
4139
fi
4240

41+
if [ "$POSTGRES_USER" = 'postgres' ]; then
42+
op='ALTER'
43+
else
44+
op='CREATE'
45+
fi
46+
4347
gosu postgres postgres --single -jE <<-EOSQL
4448
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
4549
EOSQL

9.4/docker-entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ if [ "$1" = 'postgres' ]; then
3030

3131
: ${POSTGRES_USER:=postgres}
3232
: ${POSTGRES_DB:=$POSTGRES_USER}
33-
if [ "$POSTGRES_DB" = 'postgres' ]; then
34-
op='ALTER'
35-
else
36-
op='CREATE'
33+
34+
if [ ! "$POSTGRES_DB" = 'postgres' ]; then
3735
gosu postgres postgres --single -jE <<-EOSQL
3836
CREATE DATABASE "$POSTGRES_DB" ;
3937
EOSQL
4038
echo
4139
fi
4240

41+
if [ "$POSTGRES_USER" = 'postgres' ]; then
42+
op='ALTER'
43+
else
44+
op='CREATE'
45+
fi
46+
4347
gosu postgres postgres --single -jE <<-EOSQL
4448
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
4549
EOSQL

docker-entrypoint.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,20 @@ if [ "$1" = 'postgres' ]; then
3030

3131
: ${POSTGRES_USER:=postgres}
3232
: ${POSTGRES_DB:=$POSTGRES_USER}
33-
if [ "$POSTGRES_DB" = 'postgres' ]; then
34-
op='ALTER'
35-
else
36-
op='CREATE'
33+
34+
if [ ! "$POSTGRES_DB" = 'postgres' ]; then
3735
gosu postgres postgres --single -jE <<-EOSQL
3836
CREATE DATABASE "$POSTGRES_DB" ;
3937
EOSQL
4038
echo
4139
fi
4240

41+
if [ "$POSTGRES_USER" = 'postgres' ]; then
42+
op='ALTER'
43+
else
44+
op='CREATE'
45+
fi
46+
4347
gosu postgres postgres --single -jE <<-EOSQL
4448
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
4549
EOSQL

0 commit comments

Comments
 (0)