Skip to content

Commit eff90ef

Browse files
committed
Allow "initdb.d" scripts to be executed instead of sourced
1 parent 3f8d33c commit eff90ef

13 files changed

+143
-13
lines changed

10/alpine/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

10/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

11/alpine/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

11/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

9.3/alpine/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

9.3/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

9.4/alpine/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

9.4/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

9.5/alpine/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

9.5/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

9.6/alpine/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

9.6/docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

docker-entrypoint.sh

+11-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,17 @@ if [ "$1" = 'postgres' ]; then
142142
echo
143143
for f in /docker-entrypoint-initdb.d/*; do
144144
case "$f" in
145-
*.sh) echo "$0: running $f"; . "$f" ;;
145+
*.sh)
146+
# https://github.com/docker-library/postgres/issues/450#issuecomment-393167936
147+
# https://github.com/docker-library/postgres/pull/452
148+
if [ -x "$f" ]; then
149+
echo "$0: running $f"
150+
"$f"
151+
else
152+
echo "$0: sourcing $f"
153+
. "$f"
154+
fi
155+
;;
146156
*.sql) echo "$0: running $f"; "${psql[@]}" -f "$f"; echo ;;
147157
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${psql[@]}"; echo ;;
148158
*) echo "$0: ignoring $f" ;;

0 commit comments

Comments
 (0)