From 5950846753f33a321d09b408686d4e99973f6210 Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Fri, 13 Feb 2015 23:30:13 -0800 Subject: [PATCH] Fixed checks for USER/DB combinations :ok_hand::squirrel: --- 8.4/docker-entrypoint.sh | 12 ++++++++---- 9.0/docker-entrypoint.sh | 12 ++++++++---- 9.1/docker-entrypoint.sh | 12 ++++++++---- 9.2/docker-entrypoint.sh | 12 ++++++++---- 9.3/docker-entrypoint.sh | 12 ++++++++---- 9.4/docker-entrypoint.sh | 12 ++++++++---- docker-entrypoint.sh | 12 ++++++++---- 7 files changed, 56 insertions(+), 28 deletions(-) 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