Skip to content

Commit e7353f7

Browse files
committed
Make sure the initial connection made to create the database doesn't try
to use the database that hasn't been created yet.
1 parent 94852d9 commit e7353f7

11 files changed

+11
-33
lines changed

9.2/alpine/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.2/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.3/alpine/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.3/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.4/alpine/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.4/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.5/alpine/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.5/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.6/alpine/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

9.6/docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

docker-entrypoint.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ "$1" = 'postgres' ]; then
8989
psql=( psql -v ON_ERROR_STOP=1 )
9090

9191
if [ "$PGDATABASE" != 'postgres' ]; then
92-
"${psql[@]}" --username postgres <<-EOSQL
92+
"${psql[@]}" --username postgres --dbname postgres <<-EOSQL
9393
CREATE DATABASE "$PGDATABASE" ;
9494
EOSQL
9595
echo
@@ -105,8 +105,6 @@ if [ "$1" = 'postgres' ]; then
105105
EOSQL
106106
echo
107107

108-
psql+=( --username "$PGUSER" --dbname "$PGDATABASE" )
109-
110108
echo
111109
# Taken from https://www.youtube.com/watch?v=JqMduJimzFQ
112110
cat <<EOF >> ${PGDATA}/postgresql.conf

0 commit comments

Comments
 (0)