Skip to content

Commit 48ee774

Browse files
committed
Allow "initdb.d" scripts to be executed instead of sourced
1 parent 61057cc commit 48ee774

6 files changed

+66
-6
lines changed

10.1/docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ docker_process_init_files() {
5858
local f
5959
for f; do
6060
case "$f" in
61-
*.sh) mysql_note "$0: running $f"; . "$f" ;;
61+
*.sh)
62+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
63+
# https://github.com/docker-library/postgres/pull/452
64+
if [ -x "$f" ]; then
65+
mysql_note "$0: running $f"
66+
"$f"
67+
else
68+
mysql_note "$0: sourcing $f"
69+
. "$f"
70+
fi
71+
;;
6272
*.sql) mysql_note "$0: running $f"; docker_process_sql < "$f"; echo ;;
6373
*.sql.gz) mysql_note "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;;
6474
*.sql.xz) mysql_note "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;;

10.2/docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ docker_process_init_files() {
5858
local f
5959
for f; do
6060
case "$f" in
61-
*.sh) mysql_note "$0: running $f"; . "$f" ;;
61+
*.sh)
62+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
63+
# https://github.com/docker-library/postgres/pull/452
64+
if [ -x "$f" ]; then
65+
mysql_note "$0: running $f"
66+
"$f"
67+
else
68+
mysql_note "$0: sourcing $f"
69+
. "$f"
70+
fi
71+
;;
6272
*.sql) mysql_note "$0: running $f"; docker_process_sql < "$f"; echo ;;
6373
*.sql.gz) mysql_note "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;;
6474
*.sql.xz) mysql_note "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;;

10.3/docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ docker_process_init_files() {
5858
local f
5959
for f; do
6060
case "$f" in
61-
*.sh) mysql_note "$0: running $f"; . "$f" ;;
61+
*.sh)
62+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
63+
# https://github.com/docker-library/postgres/pull/452
64+
if [ -x "$f" ]; then
65+
mysql_note "$0: running $f"
66+
"$f"
67+
else
68+
mysql_note "$0: sourcing $f"
69+
. "$f"
70+
fi
71+
;;
6272
*.sql) mysql_note "$0: running $f"; docker_process_sql < "$f"; echo ;;
6373
*.sql.gz) mysql_note "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;;
6474
*.sql.xz) mysql_note "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;;

10.4/docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ docker_process_init_files() {
5858
local f
5959
for f; do
6060
case "$f" in
61-
*.sh) mysql_note "$0: running $f"; . "$f" ;;
61+
*.sh)
62+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
63+
# https://github.com/docker-library/postgres/pull/452
64+
if [ -x "$f" ]; then
65+
mysql_note "$0: running $f"
66+
"$f"
67+
else
68+
mysql_note "$0: sourcing $f"
69+
. "$f"
70+
fi
71+
;;
6272
*.sql) mysql_note "$0: running $f"; docker_process_sql < "$f"; echo ;;
6373
*.sql.gz) mysql_note "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;;
6474
*.sql.xz) mysql_note "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;;

10.5/docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ docker_process_init_files() {
5858
local f
5959
for f; do
6060
case "$f" in
61-
*.sh) mysql_note "$0: running $f"; . "$f" ;;
61+
*.sh)
62+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
63+
# https://github.com/docker-library/postgres/pull/452
64+
if [ -x "$f" ]; then
65+
mysql_note "$0: running $f"
66+
"$f"
67+
else
68+
mysql_note "$0: sourcing $f"
69+
. "$f"
70+
fi
71+
;;
6272
*.sql) mysql_note "$0: running $f"; docker_process_sql < "$f"; echo ;;
6373
*.sql.gz) mysql_note "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;;
6474
*.sql.xz) mysql_note "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;;

docker-entrypoint.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,17 @@ docker_process_init_files() {
5858
local f
5959
for f; do
6060
case "$f" in
61-
*.sh) mysql_note "$0: running $f"; . "$f" ;;
61+
*.sh)
62+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
63+
# https://github.com/docker-library/postgres/pull/452
64+
if [ -x "$f" ]; then
65+
mysql_note "$0: running $f"
66+
"$f"
67+
else
68+
mysql_note "$0: sourcing $f"
69+
. "$f"
70+
fi
71+
;;
6272
*.sql) mysql_note "$0: running $f"; docker_process_sql < "$f"; echo ;;
6373
*.sql.gz) mysql_note "$0: running $f"; gunzip -c "$f" | docker_process_sql; echo ;;
6474
*.sql.xz) mysql_note "$0: running $f"; xzcat "$f" | docker_process_sql; echo ;;

0 commit comments

Comments
 (0)