diff --git a/8.4/docker-entrypoint.sh b/8.4/docker-entrypoint.sh index ed1f2c7292..6d546b4816 100755 --- a/8.4/docker-entrypoint.sh +++ b/8.4/docker-entrypoint.sh @@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then - op='ALTER' - else - op='CREATE' + : ${POSTGRES_DB:=$POSTGRES_USER} + + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + 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 diff --git a/9.0/docker-entrypoint.sh b/9.0/docker-entrypoint.sh index ed1f2c7292..6d546b4816 100755 --- a/9.0/docker-entrypoint.sh +++ b/9.0/docker-entrypoint.sh @@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then - op='ALTER' - else - op='CREATE' + : ${POSTGRES_DB:=$POSTGRES_USER} + + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + 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 diff --git a/9.1/docker-entrypoint.sh b/9.1/docker-entrypoint.sh index ed1f2c7292..6d546b4816 100755 --- a/9.1/docker-entrypoint.sh +++ b/9.1/docker-entrypoint.sh @@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then - op='ALTER' - else - op='CREATE' + : ${POSTGRES_DB:=$POSTGRES_USER} + + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + 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 diff --git a/9.2/docker-entrypoint.sh b/9.2/docker-entrypoint.sh index ed1f2c7292..6d546b4816 100755 --- a/9.2/docker-entrypoint.sh +++ b/9.2/docker-entrypoint.sh @@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then - op='ALTER' - else - op='CREATE' + : ${POSTGRES_DB:=$POSTGRES_USER} + + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + 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 diff --git a/9.3/docker-entrypoint.sh b/9.3/docker-entrypoint.sh index ed1f2c7292..6d546b4816 100755 --- a/9.3/docker-entrypoint.sh +++ b/9.3/docker-entrypoint.sh @@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then - op='ALTER' - else - op='CREATE' + : ${POSTGRES_DB:=$POSTGRES_USER} + + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + 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 diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index ed1f2c7292..6d546b4816 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then - op='ALTER' - else - op='CREATE' + : ${POSTGRES_DB:=$POSTGRES_USER} + + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + 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 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index ed1f2c7292..6d546b4816 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then - op='ALTER' - else - op='CREATE' + : ${POSTGRES_DB:=$POSTGRES_USER} + + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + 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