add script execution from docker-entrypoint.d folder (#3666)

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
This commit is contained in:
Alexandru Marcencov
2023-11-16 20:30:14 +01:00
committed by GitHub
parent 488a1ac92e
commit e9d89bb830

View File

@@ -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 "$@"