From 564a6a8eadc3bfdfcca987a0cf98ad93a616b185 Mon Sep 17 00:00:00 2001 From: Cameron Daniel Date: Mon, 31 Aug 2020 18:30:10 +0200 Subject: [PATCH] fix initdb check --- files/docker-initdb.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/files/docker-initdb.sh b/files/docker-initdb.sh index b5891b8..c6fdc6d 100755 --- a/files/docker-initdb.sh +++ b/files/docker-initdb.sh @@ -165,19 +165,20 @@ _main() { exec gosu postgres "$BASH_SOURCE" "$@" fi + declare -g DATABASE_ALREADY_EXISTS + # look specifically for PG_VERSION, as it is expected in the DB dir + if [ -s "$PGDATA/PG_VERSION" ]; then + DATABASE_ALREADY_EXISTS='true' + fi + # only run initialization on an empty data directory if [ -z "$DATABASE_ALREADY_EXISTS" ]; then # check dir permissions to reduce likelihood of half-initialized database ls /docker-entrypoint-initdb.d/ > /dev/null - echo "==> A" docker_init_database_dir - echo "==> B" docker_temp_server_start "$@" - echo "==> C" docker_process_init_files /docker-entrypoint-initdb.d/* - echo "==> D" docker_temp_server_stop - echo "==> E" echo echo 'PostgreSQL init process complete; ready for start up.'