From 8e226012531443024caa6cf2497e7be6aade1fc2 Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Thu, 12 Feb 2015 16:07:53 -0800 Subject: [PATCH 1/7] Added POSTGRES_DB variable to optionally specify DB name --- 8.4/docker-entrypoint.sh | 5 +++-- 9.0/docker-entrypoint.sh | 5 +++-- 9.1/docker-entrypoint.sh | 3 ++- 9.2/docker-entrypoint.sh | 5 +++-- 9.3/docker-entrypoint.sh | 5 +++-- 9.4/docker-entrypoint.sh | 5 +++-- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/8.4/docker-entrypoint.sh b/8.4/docker-entrypoint.sh index 28f8354f70..7cfd7763e0 100755 --- a/8.4/docker-entrypoint.sh +++ b/8.4/docker-entrypoint.sh @@ -29,12 +29,13 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then + : ${POSTGRES_DB:=$POSTGRES_USER} + if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else op='CREATE' gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + CREATE DATABASE "$POSTGRES_DB" ; EOSQL echo fi diff --git a/9.0/docker-entrypoint.sh b/9.0/docker-entrypoint.sh index 28f8354f70..201bae2e4c 100755 --- a/9.0/docker-entrypoint.sh +++ b/9.0/docker-entrypoint.sh @@ -29,12 +29,13 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then + : ${POSTGRES_DB:=$POSTGRES_USER} + if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else op='CREATE' gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + CREATE DATABASE "$POSTGRES_DB" ; EOSQL echo fi diff --git a/9.1/docker-entrypoint.sh b/9.1/docker-entrypoint.sh index 28f8354f70..4cbb7fec4a 100755 --- a/9.1/docker-entrypoint.sh +++ b/9.1/docker-entrypoint.sh @@ -29,12 +29,13 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} + : ${POSTGRES_DB:=$POSTGRES_USER} if [ "$POSTGRES_USER" = 'postgres' ]; then op='ALTER' else op='CREATE' gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + CREATE DATABASE "$POSTGRES_DB" ; EOSQL echo fi diff --git a/9.2/docker-entrypoint.sh b/9.2/docker-entrypoint.sh index 28f8354f70..201bae2e4c 100755 --- a/9.2/docker-entrypoint.sh +++ b/9.2/docker-entrypoint.sh @@ -29,12 +29,13 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then + : ${POSTGRES_DB:=$POSTGRES_USER} + if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else op='CREATE' gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + CREATE DATABASE "$POSTGRES_DB" ; EOSQL echo fi diff --git a/9.3/docker-entrypoint.sh b/9.3/docker-entrypoint.sh index 28f8354f70..201bae2e4c 100755 --- a/9.3/docker-entrypoint.sh +++ b/9.3/docker-entrypoint.sh @@ -29,12 +29,13 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then + : ${POSTGRES_DB:=$POSTGRES_USER} + if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else op='CREATE' gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + CREATE DATABASE "$POSTGRES_DB" ; EOSQL echo fi diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index 28f8354f70..201bae2e4c 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -29,12 +29,13 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then + : ${POSTGRES_DB:=$POSTGRES_USER} + if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else op='CREATE' gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + CREATE DATABASE "$POSTGRES_DB" ; EOSQL echo fi From 80fa6827894b0ff10037a56c077da166ca37661b Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Thu, 12 Feb 2015 16:32:07 -0800 Subject: [PATCH 2/7] retabed files --- 9.0/docker-entrypoint.sh | 2 +- 9.1/docker-entrypoint.sh | 2 +- 9.2/docker-entrypoint.sh | 2 +- 9.3/docker-entrypoint.sh | 2 +- 9.4/docker-entrypoint.sh | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/9.0/docker-entrypoint.sh b/9.0/docker-entrypoint.sh index 201bae2e4c..7cfd7763e0 100755 --- a/9.0/docker-entrypoint.sh +++ b/9.0/docker-entrypoint.sh @@ -29,7 +29,7 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - : ${POSTGRES_DB:=$POSTGRES_USER} + : ${POSTGRES_DB:=$POSTGRES_USER} if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else diff --git a/9.1/docker-entrypoint.sh b/9.1/docker-entrypoint.sh index 4cbb7fec4a..34708b0f4c 100755 --- a/9.1/docker-entrypoint.sh +++ b/9.1/docker-entrypoint.sh @@ -29,7 +29,7 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - : ${POSTGRES_DB:=$POSTGRES_USER} + : ${POSTGRES_DB:=$POSTGRES_USER} if [ "$POSTGRES_USER" = 'postgres' ]; then op='ALTER' else diff --git a/9.2/docker-entrypoint.sh b/9.2/docker-entrypoint.sh index 201bae2e4c..7cfd7763e0 100755 --- a/9.2/docker-entrypoint.sh +++ b/9.2/docker-entrypoint.sh @@ -29,7 +29,7 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - : ${POSTGRES_DB:=$POSTGRES_USER} + : ${POSTGRES_DB:=$POSTGRES_USER} if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else diff --git a/9.3/docker-entrypoint.sh b/9.3/docker-entrypoint.sh index 201bae2e4c..7cfd7763e0 100755 --- a/9.3/docker-entrypoint.sh +++ b/9.3/docker-entrypoint.sh @@ -29,7 +29,7 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - : ${POSTGRES_DB:=$POSTGRES_USER} + : ${POSTGRES_DB:=$POSTGRES_USER} if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index 201bae2e4c..7cfd7763e0 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -29,7 +29,7 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - : ${POSTGRES_DB:=$POSTGRES_USER} + : ${POSTGRES_DB:=$POSTGRES_USER} if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else From 167c2ae96307923f4eded82b62a5997514d664aa Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Fri, 13 Feb 2015 09:44:07 -0800 Subject: [PATCH 3/7] missed variable in 9.1 entrypoint.sh --- 9.1/docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/9.1/docker-entrypoint.sh b/9.1/docker-entrypoint.sh index 34708b0f4c..7cfd7763e0 100755 --- a/9.1/docker-entrypoint.sh +++ b/9.1/docker-entrypoint.sh @@ -30,7 +30,7 @@ if [ "$1" = 'postgres' ]; then : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} - if [ "$POSTGRES_USER" = 'postgres' ]; then + if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else op='CREATE' From c863eb347143c15223d58d619c316f8ec3cb8556 Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Fri, 13 Feb 2015 09:54:07 -0800 Subject: [PATCH 4/7] updated template docker-entrypoint --- docker-entrypoint.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 28f8354f70..74a4e356fc 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -29,7 +29,8 @@ if [ "$1" = 'postgres' ]; then fi : ${POSTGRES_USER:=postgres} - if [ "$POSTGRES_USER" = 'postgres' ]; then + : ${POSTGRES_DB:=$POSTGRES_USER} + if [ "$POSTGRES_DB" = 'postgres' ]; then op='ALTER' else op='CREATE' From 1438bacac69b4f72efc6a943011e8cb5ce45e991 Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Fri, 13 Feb 2015 11:17:55 -0800 Subject: [PATCH 5/7] Forgot CREATE DATABASE variable --- docker-entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 74a4e356fc..7cfd7763e0 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -35,7 +35,7 @@ if [ "$1" = 'postgres' ]; then else op='CREATE' gosu postgres postgres --single -jE <<-EOSQL - CREATE DATABASE "$POSTGRES_USER" ; + CREATE DATABASE "$POSTGRES_DB" ; EOSQL echo fi From 5950846753f33a321d09b408686d4e99973f6210 Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Fri, 13 Feb 2015 23:30:13 -0800 Subject: [PATCH 6/7] 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 From 796f3f151eb0817c541b357df024678088efd9cb Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Thu, 19 Feb 2015 22:37:53 -0800 Subject: [PATCH 7/7] "!...=" != "!=" :exclamation: --- 8.4/docker-entrypoint.sh | 2 +- 9.0/docker-entrypoint.sh | 2 +- 9.1/docker-entrypoint.sh | 2 +- 9.2/docker-entrypoint.sh | 2 +- 9.3/docker-entrypoint.sh | 2 +- 9.4/docker-entrypoint.sh | 2 +- docker-entrypoint.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/8.4/docker-entrypoint.sh b/8.4/docker-entrypoint.sh index cd78dd8450..da128fc38f 100755 --- a/8.4/docker-entrypoint.sh +++ b/8.4/docker-entrypoint.sh @@ -31,7 +31,7 @@ if [ "$1" = 'postgres' ]; then : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} - if [ ! "$POSTGRES_DB" = 'postgres' ]; then + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL CREATE DATABASE "$POSTGRES_DB" ; EOSQL diff --git a/9.0/docker-entrypoint.sh b/9.0/docker-entrypoint.sh index cd78dd8450..da128fc38f 100755 --- a/9.0/docker-entrypoint.sh +++ b/9.0/docker-entrypoint.sh @@ -31,7 +31,7 @@ if [ "$1" = 'postgres' ]; then : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} - if [ ! "$POSTGRES_DB" = 'postgres' ]; then + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL CREATE DATABASE "$POSTGRES_DB" ; EOSQL diff --git a/9.1/docker-entrypoint.sh b/9.1/docker-entrypoint.sh index cd78dd8450..da128fc38f 100755 --- a/9.1/docker-entrypoint.sh +++ b/9.1/docker-entrypoint.sh @@ -31,7 +31,7 @@ if [ "$1" = 'postgres' ]; then : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} - if [ ! "$POSTGRES_DB" = 'postgres' ]; then + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL CREATE DATABASE "$POSTGRES_DB" ; EOSQL diff --git a/9.2/docker-entrypoint.sh b/9.2/docker-entrypoint.sh index cd78dd8450..da128fc38f 100755 --- a/9.2/docker-entrypoint.sh +++ b/9.2/docker-entrypoint.sh @@ -31,7 +31,7 @@ if [ "$1" = 'postgres' ]; then : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} - if [ ! "$POSTGRES_DB" = 'postgres' ]; then + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL CREATE DATABASE "$POSTGRES_DB" ; EOSQL diff --git a/9.3/docker-entrypoint.sh b/9.3/docker-entrypoint.sh index cd78dd8450..da128fc38f 100755 --- a/9.3/docker-entrypoint.sh +++ b/9.3/docker-entrypoint.sh @@ -31,7 +31,7 @@ if [ "$1" = 'postgres' ]; then : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} - if [ ! "$POSTGRES_DB" = 'postgres' ]; then + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL CREATE DATABASE "$POSTGRES_DB" ; EOSQL diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index cd78dd8450..da128fc38f 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -31,7 +31,7 @@ if [ "$1" = 'postgres' ]; then : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} - if [ ! "$POSTGRES_DB" = 'postgres' ]; then + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL CREATE DATABASE "$POSTGRES_DB" ; EOSQL diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index cd78dd8450..da128fc38f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -31,7 +31,7 @@ if [ "$1" = 'postgres' ]; then : ${POSTGRES_USER:=postgres} : ${POSTGRES_DB:=$POSTGRES_USER} - if [ ! "$POSTGRES_DB" = 'postgres' ]; then + if [ "$POSTGRES_DB" != 'postgres' ]; then gosu postgres postgres --single -jE <<-EOSQL CREATE DATABASE "$POSTGRES_DB" ; EOSQL