1
0
mirror of https://github.com/docker-library/postgres.git synced 2025-07-28 10:42:06 +03:00

Merge pull request #49 from rothgar/postgres_db_var

Added POSTGRES_DB variable to optionally specify DB name
This commit is contained in:
yosifkit
2015-02-23 15:32:21 -08:00
7 changed files with 70 additions and 35 deletions

View File

@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then
fi fi
: ${POSTGRES_USER:=postgres} : ${POSTGRES_USER:=postgres}
if [ "$POSTGRES_USER" = 'postgres' ]; then : ${POSTGRES_DB:=$POSTGRES_USER}
op='ALTER'
else if [ "$POSTGRES_DB" != 'postgres' ]; then
op='CREATE'
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
CREATE DATABASE "$POSTGRES_USER" ; CREATE DATABASE "$POSTGRES_DB" ;
EOSQL EOSQL
echo echo
fi fi
if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
fi
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ; $op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL EOSQL

View File

@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then
fi fi
: ${POSTGRES_USER:=postgres} : ${POSTGRES_USER:=postgres}
if [ "$POSTGRES_USER" = 'postgres' ]; then : ${POSTGRES_DB:=$POSTGRES_USER}
op='ALTER'
else if [ "$POSTGRES_DB" != 'postgres' ]; then
op='CREATE'
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
CREATE DATABASE "$POSTGRES_USER" ; CREATE DATABASE "$POSTGRES_DB" ;
EOSQL EOSQL
echo echo
fi fi
if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
fi
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ; $op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL EOSQL

View File

@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then
fi fi
: ${POSTGRES_USER:=postgres} : ${POSTGRES_USER:=postgres}
if [ "$POSTGRES_USER" = 'postgres' ]; then : ${POSTGRES_DB:=$POSTGRES_USER}
op='ALTER'
else if [ "$POSTGRES_DB" != 'postgres' ]; then
op='CREATE'
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
CREATE DATABASE "$POSTGRES_USER" ; CREATE DATABASE "$POSTGRES_DB" ;
EOSQL EOSQL
echo echo
fi fi
if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
fi
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ; $op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL EOSQL

View File

@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then
fi fi
: ${POSTGRES_USER:=postgres} : ${POSTGRES_USER:=postgres}
if [ "$POSTGRES_USER" = 'postgres' ]; then : ${POSTGRES_DB:=$POSTGRES_USER}
op='ALTER'
else if [ "$POSTGRES_DB" != 'postgres' ]; then
op='CREATE'
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
CREATE DATABASE "$POSTGRES_USER" ; CREATE DATABASE "$POSTGRES_DB" ;
EOSQL EOSQL
echo echo
fi fi
if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
fi
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ; $op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL EOSQL

View File

@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then
fi fi
: ${POSTGRES_USER:=postgres} : ${POSTGRES_USER:=postgres}
if [ "$POSTGRES_USER" = 'postgres' ]; then : ${POSTGRES_DB:=$POSTGRES_USER}
op='ALTER'
else if [ "$POSTGRES_DB" != 'postgres' ]; then
op='CREATE'
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
CREATE DATABASE "$POSTGRES_USER" ; CREATE DATABASE "$POSTGRES_DB" ;
EOSQL EOSQL
echo echo
fi fi
if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
fi
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ; $op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL EOSQL

View File

@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then
fi fi
: ${POSTGRES_USER:=postgres} : ${POSTGRES_USER:=postgres}
if [ "$POSTGRES_USER" = 'postgres' ]; then : ${POSTGRES_DB:=$POSTGRES_USER}
op='ALTER'
else if [ "$POSTGRES_DB" != 'postgres' ]; then
op='CREATE'
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
CREATE DATABASE "$POSTGRES_USER" ; CREATE DATABASE "$POSTGRES_DB" ;
EOSQL EOSQL
echo echo
fi fi
if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
fi
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ; $op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL EOSQL

View File

@ -35,16 +35,21 @@ if [ "$1" = 'postgres' ]; then
fi fi
: ${POSTGRES_USER:=postgres} : ${POSTGRES_USER:=postgres}
if [ "$POSTGRES_USER" = 'postgres' ]; then : ${POSTGRES_DB:=$POSTGRES_USER}
op='ALTER'
else if [ "$POSTGRES_DB" != 'postgres' ]; then
op='CREATE'
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
CREATE DATABASE "$POSTGRES_USER" ; CREATE DATABASE "$POSTGRES_DB" ;
EOSQL EOSQL
echo echo
fi fi
if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
op='CREATE'
fi
gosu postgres postgres --single -jE <<-EOSQL gosu postgres postgres --single -jE <<-EOSQL
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ; $op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL EOSQL