From eff90effc6b5578be90bef93d96b3fceb1082a7c Mon Sep 17 00:00:00 2001 From: Tianon Gravi Date: Wed, 30 May 2018 09:26:04 -0700 Subject: [PATCH] Allow "initdb.d" scripts to be executed instead of sourced --- 10/alpine/docker-entrypoint.sh | 12 +++++++++++- 10/docker-entrypoint.sh | 12 +++++++++++- 11/alpine/docker-entrypoint.sh | 12 +++++++++++- 11/docker-entrypoint.sh | 12 +++++++++++- 9.3/alpine/docker-entrypoint.sh | 12 +++++++++++- 9.3/docker-entrypoint.sh | 12 +++++++++++- 9.4/alpine/docker-entrypoint.sh | 12 +++++++++++- 9.4/docker-entrypoint.sh | 12 +++++++++++- 9.5/alpine/docker-entrypoint.sh | 12 +++++++++++- 9.5/docker-entrypoint.sh | 12 +++++++++++- 9.6/alpine/docker-entrypoint.sh | 12 +++++++++++- 9.6/docker-entrypoint.sh | 12 +++++++++++- docker-entrypoint.sh | 12 +++++++++++- 13 files changed, 143 insertions(+), 13 deletions(-) diff --git a/10/alpine/docker-entrypoint.sh b/10/alpine/docker-entrypoint.sh index 0b0daf8604..33d48430fc 100755 --- a/10/alpine/docker-entrypoint.sh +++ b/10/alpine/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/10/docker-entrypoint.sh b/10/docker-entrypoint.sh index ecd7458d58..dafe66000f 100755 --- a/10/docker-entrypoint.sh +++ b/10/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/11/alpine/docker-entrypoint.sh b/11/alpine/docker-entrypoint.sh index 0b0daf8604..33d48430fc 100755 --- a/11/alpine/docker-entrypoint.sh +++ b/11/alpine/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/11/docker-entrypoint.sh b/11/docker-entrypoint.sh index ecd7458d58..dafe66000f 100755 --- a/11/docker-entrypoint.sh +++ b/11/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/9.3/alpine/docker-entrypoint.sh b/9.3/alpine/docker-entrypoint.sh index 547adfbd87..4ab34909c7 100755 --- a/9.3/alpine/docker-entrypoint.sh +++ b/9.3/alpine/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/9.3/docker-entrypoint.sh b/9.3/docker-entrypoint.sh index fbac223fc0..41802e82c2 100755 --- a/9.3/docker-entrypoint.sh +++ b/9.3/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/9.4/alpine/docker-entrypoint.sh b/9.4/alpine/docker-entrypoint.sh index 547adfbd87..4ab34909c7 100755 --- a/9.4/alpine/docker-entrypoint.sh +++ b/9.4/alpine/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/9.4/docker-entrypoint.sh b/9.4/docker-entrypoint.sh index fbac223fc0..41802e82c2 100755 --- a/9.4/docker-entrypoint.sh +++ b/9.4/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/9.5/alpine/docker-entrypoint.sh b/9.5/alpine/docker-entrypoint.sh index 547adfbd87..4ab34909c7 100755 --- a/9.5/alpine/docker-entrypoint.sh +++ b/9.5/alpine/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/9.5/docker-entrypoint.sh b/9.5/docker-entrypoint.sh index fbac223fc0..41802e82c2 100755 --- a/9.5/docker-entrypoint.sh +++ b/9.5/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/9.6/alpine/docker-entrypoint.sh b/9.6/alpine/docker-entrypoint.sh index 547adfbd87..4ab34909c7 100755 --- a/9.6/alpine/docker-entrypoint.sh +++ b/9.6/alpine/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/9.6/docker-entrypoint.sh b/9.6/docker-entrypoint.sh index fbac223fc0..41802e82c2 100755 --- a/9.6/docker-entrypoint.sh +++ b/9.6/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;; diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index ecd7458d58..dafe66000f 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then echo for f in /docker-entrypoint-initdb.d/*; do case "$f" in - *.sh) echo "$0: running $f"; . "$f" ;; + *.sh) + # https://github.com/docker-library/postgres/issues/450#issuecomment-393167936 + # https://github.com/docker-library/postgres/pull/452 + if [ -x "$f" ]; then + echo "$0: running $f" + "$f" + else + echo "$0: sourcing $f" + . "$f" + fi + ;; *.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;; *.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;; *) echo "$0: ignoring $f" ;;