From e9d89bb830ce91a96a0bd0c6a23a4c494fb96800 Mon Sep 17 00:00:00 2001 From: Alexandru Marcencov Date: Thu, 16 Nov 2023 20:30:14 +0100 Subject: [PATCH] add script execution from docker-entrypoint.d folder (#3666) Co-authored-by: PePe Amengual --- docker-entrypoint.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index bdb00e4cf..18a8f6cea 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -29,4 +29,29 @@ if ! whoami > /dev/null 2>&1; then fi fi +# If we need to install some tools at entrypoint level, we can add shell scripts +# in folder /docker-entrypoint.d/ with extension .sh and this scripts will be executed +# at entrypount level. +if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then + echo "/docker-entrypoint.d/ is not empty, will attempt to perform script execition" + echo "Looking for shell scripts in /docker-entrypoint.d/" + find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do + case "$f" in + *.sh) + if [ -x "$f" ]; then + echo "Launching $f"; + "$f" + else + # warn on shell scripts without exec bit + echo "Ignoring $f, not executable"; + fi + ;; + *) echo "Ignoring $f";; + esac + done + echo "Configuration complete; ready for start up" +else + echo "No files found in /docker-entrypoint.d/, skipping" +fi + exec "$@"