Skip to content

Check that vol actually contains DB files, as opposed to a non-empty dir. #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions 9.0/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
set -e

if [ "$1" = 'postgres' ]; then
mkdir -p "$PGDATA"
chown -R postgres "$PGDATA"

chmod g+s /run/postgresql
chown -R postgres:postgres /run/postgresql

if [ -z "$(ls -A "$PGDATA")" ]; then

# look specifically for PG_VERSION, as it is expected in the DB dir
if [ -s "$PGDATA/PG_VERSION" ]; then
gosu postgres initdb

sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf
# check password first so we can ouptut the warning before postgres

# check password first so we can output the warning before postgres
# messes it up
if [ "$POSTGRES_PASSWORD" ]; then
pass="PASSWORD '$POSTGRES_PASSWORD'"
Expand All @@ -27,16 +29,16 @@ if [ "$1" = 'postgres' ]; then
Docker's default configuration, this is
effectively any other container on the same
system.

Use "-e POSTGRES_PASSWORD=password" to set
it in "docker run".
****************************************************
EOWARN

pass=
authMethod=trust
fi

: ${POSTGRES_USER:=postgres}
: ${POSTGRES_DB:=$POSTGRES_USER}

Expand All @@ -46,7 +48,7 @@ if [ "$1" = 'postgres' ]; then
EOSQL
echo
fi

if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
Expand All @@ -57,16 +59,16 @@ if [ "$1" = 'postgres' ]; then
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL
echo

{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA"/pg_hba.conf

if [ -d /docker-entrypoint-initdb.d ]; then
for f in /docker-entrypoint-initdb.d/*.sh; do
[ -f "$f" ] && . "$f"
done
fi
fi

exec gosu postgres "$@"
fi

Expand Down
28 changes: 15 additions & 13 deletions 9.1/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
set -e

if [ "$1" = 'postgres' ]; then
mkdir -p "$PGDATA"
chown -R postgres "$PGDATA"

chmod g+s /run/postgresql
chown -R postgres:postgres /run/postgresql

if [ -z "$(ls -A "$PGDATA")" ]; then

# look specifically for PG_VERSION, as it is expected in the DB dir
if [ -s "$PGDATA/PG_VERSION" ]; then
gosu postgres initdb

sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf
# check password first so we can ouptut the warning before postgres

# check password first so we can output the warning before postgres
# messes it up
if [ "$POSTGRES_PASSWORD" ]; then
pass="PASSWORD '$POSTGRES_PASSWORD'"
Expand All @@ -27,16 +29,16 @@ if [ "$1" = 'postgres' ]; then
Docker's default configuration, this is
effectively any other container on the same
system.

Use "-e POSTGRES_PASSWORD=password" to set
it in "docker run".
****************************************************
EOWARN

pass=
authMethod=trust
fi

: ${POSTGRES_USER:=postgres}
: ${POSTGRES_DB:=$POSTGRES_USER}

Expand All @@ -46,7 +48,7 @@ if [ "$1" = 'postgres' ]; then
EOSQL
echo
fi

if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
Expand All @@ -57,16 +59,16 @@ if [ "$1" = 'postgres' ]; then
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL
echo

{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA"/pg_hba.conf

if [ -d /docker-entrypoint-initdb.d ]; then
for f in /docker-entrypoint-initdb.d/*.sh; do
[ -f "$f" ] && . "$f"
done
fi
fi

exec gosu postgres "$@"
fi

Expand Down
28 changes: 15 additions & 13 deletions 9.2/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
set -e

if [ "$1" = 'postgres' ]; then
mkdir -p "$PGDATA"
chown -R postgres "$PGDATA"

chmod g+s /run/postgresql
chown -R postgres:postgres /run/postgresql

if [ -z "$(ls -A "$PGDATA")" ]; then

# look specifically for PG_VERSION, as it is expected in the DB dir
if [ -s "$PGDATA/PG_VERSION" ]; then
gosu postgres initdb

sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf
# check password first so we can ouptut the warning before postgres

# check password first so we can output the warning before postgres
# messes it up
if [ "$POSTGRES_PASSWORD" ]; then
pass="PASSWORD '$POSTGRES_PASSWORD'"
Expand All @@ -27,16 +29,16 @@ if [ "$1" = 'postgres' ]; then
Docker's default configuration, this is
effectively any other container on the same
system.

Use "-e POSTGRES_PASSWORD=password" to set
it in "docker run".
****************************************************
EOWARN

pass=
authMethod=trust
fi

: ${POSTGRES_USER:=postgres}
: ${POSTGRES_DB:=$POSTGRES_USER}

Expand All @@ -46,7 +48,7 @@ if [ "$1" = 'postgres' ]; then
EOSQL
echo
fi

if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
Expand All @@ -57,16 +59,16 @@ if [ "$1" = 'postgres' ]; then
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL
echo

{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA"/pg_hba.conf

if [ -d /docker-entrypoint-initdb.d ]; then
for f in /docker-entrypoint-initdb.d/*.sh; do
[ -f "$f" ] && . "$f"
done
fi
fi

exec gosu postgres "$@"
fi

Expand Down
28 changes: 15 additions & 13 deletions 9.3/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
set -e

if [ "$1" = 'postgres' ]; then
mkdir -p "$PGDATA"
chown -R postgres "$PGDATA"

chmod g+s /run/postgresql
chown -R postgres:postgres /run/postgresql

if [ -z "$(ls -A "$PGDATA")" ]; then

# look specifically for PG_VERSION, as it is expected in the DB dir
if [ -s "$PGDATA/PG_VERSION" ]; then
gosu postgres initdb

sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf
# check password first so we can ouptut the warning before postgres

# check password first so we can output the warning before postgres
# messes it up
if [ "$POSTGRES_PASSWORD" ]; then
pass="PASSWORD '$POSTGRES_PASSWORD'"
Expand All @@ -27,16 +29,16 @@ if [ "$1" = 'postgres' ]; then
Docker's default configuration, this is
effectively any other container on the same
system.

Use "-e POSTGRES_PASSWORD=password" to set
it in "docker run".
****************************************************
EOWARN

pass=
authMethod=trust
fi

: ${POSTGRES_USER:=postgres}
: ${POSTGRES_DB:=$POSTGRES_USER}

Expand All @@ -46,7 +48,7 @@ if [ "$1" = 'postgres' ]; then
EOSQL
echo
fi

if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
Expand All @@ -57,16 +59,16 @@ if [ "$1" = 'postgres' ]; then
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL
echo

{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA"/pg_hba.conf

if [ -d /docker-entrypoint-initdb.d ]; then
for f in /docker-entrypoint-initdb.d/*.sh; do
[ -f "$f" ] && . "$f"
done
fi
fi

exec gosu postgres "$@"
fi

Expand Down
28 changes: 15 additions & 13 deletions 9.4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
set -e

if [ "$1" = 'postgres' ]; then
mkdir -p "$PGDATA"
chown -R postgres "$PGDATA"

chmod g+s /run/postgresql
chown -R postgres:postgres /run/postgresql

if [ -z "$(ls -A "$PGDATA")" ]; then

# look specifically for PG_VERSION, as it is expected in the DB dir
if [ -s "$PGDATA/PG_VERSION" ]; then
gosu postgres initdb

sed -ri "s/^#(listen_addresses\s*=\s*)\S+/\1'*'/" "$PGDATA"/postgresql.conf
# check password first so we can ouptut the warning before postgres

# check password first so we can output the warning before postgres
# messes it up
if [ "$POSTGRES_PASSWORD" ]; then
pass="PASSWORD '$POSTGRES_PASSWORD'"
Expand All @@ -27,16 +29,16 @@ if [ "$1" = 'postgres' ]; then
Docker's default configuration, this is
effectively any other container on the same
system.

Use "-e POSTGRES_PASSWORD=password" to set
it in "docker run".
****************************************************
EOWARN

pass=
authMethod=trust
fi

: ${POSTGRES_USER:=postgres}
: ${POSTGRES_DB:=$POSTGRES_USER}

Expand All @@ -46,7 +48,7 @@ if [ "$1" = 'postgres' ]; then
EOSQL
echo
fi

if [ "$POSTGRES_USER" = 'postgres' ]; then
op='ALTER'
else
Expand All @@ -57,16 +59,16 @@ if [ "$1" = 'postgres' ]; then
$op USER "$POSTGRES_USER" WITH SUPERUSER $pass ;
EOSQL
echo

{ echo; echo "host all all 0.0.0.0/0 $authMethod"; } >> "$PGDATA"/pg_hba.conf

if [ -d /docker-entrypoint-initdb.d ]; then
for f in /docker-entrypoint-initdb.d/*.sh; do
[ -f "$f" ] && . "$f"
done
fi
fi

exec gosu postgres "$@"
fi

Expand Down
Loading