From 8e226012531443024caa6cf2497e7be6aade1fc2 Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Thu, 12 Feb 2015 16:07:53 -0800 Subject: [PATCH] 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