Skip to content

Commit fcc68c8

Browse files
authored
Merge pull request #656 from infosiftr/sourced
Allow "initdb.d" scripts to be executed instead of sourced
2 parents f7ba980 + b1c48f6 commit fcc68c8

File tree

4 files changed

+44
-4
lines changed

4 files changed

+44
-4
lines changed

.template.Debian/docker-entrypoint.sh

+11-1
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 ;;

5.6/docker-entrypoint.sh

+11-1
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 ;;

5.7/docker-entrypoint.sh

+11-1
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 ;;

8.0/docker-entrypoint.sh

+11-1
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)