diff --git a/8.4/docker-entrypoint.sh b/8.4/docker-entrypoint.sh index 7cfd7763e0..cd78dd8450 100755 --- a/8.4/docker-entrypoint.sh +++ b/8.4/docker-entrypoint.sh @@ -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 diff --git a/9.0/docker-entrypoint.sh b/9.0/docker-entrypoint.sh index 7cfd7763e0..cd78dd8450 100755 --- a/9.0/docker-entrypoint.sh +++ b/9.0/docker-entrypoint.sh @@ -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 diff --git a/9.1/docker-entrypoint.sh b/9.1/docker-entrypoint.sh index 7cfd7763e0..cd78dd8450 100755 --- a/9.1/docker-entrypoint.sh +++ b/9.1/docker-entrypoint.sh @@ -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 diff --git a/9.2/docker-entrypoint.sh b/9.2/docker-entrypoint.sh index 7cfd7763e0..cd78dd8450 100755 --- a/9.2/docker-entrypoint.sh +++ b/9.2/docker-entrypoint.sh @@ -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 diff --git a/9.3/docker-entrypoint.sh b/9.3/docker-entrypoint.sh index 7cfd7763e0..cd78dd8450 100755 --- a/9.3/docker-entrypoint.sh +++ b/9.3/docker-entrypoint.sh @@ -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 diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index 7cfd7763e0..cd78dd8450 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -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 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 7cfd7763e0..cd78dd8450 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -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