From 7946a9cc96210509ed368e066c49705a1205fc92 Mon Sep 17 00:00:00 2001 From: Ben Peachey Date: Tue, 27 Aug 2024 17:42:55 +0200 Subject: [PATCH] Add logic to entrypoint to show `assets/` content when mounted. --- entrypoint.sh | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index cb1cddf..3d1590b 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -57,13 +57,25 @@ defaultCommand() { } entrypoint() { - local -r subject="${1-}" + local url subject + readonly subject="${1-}" # If the first argument is a command that exists, run it if [ -n "${subject}" ] && [ -n "$(command -v "${subject}" 2> /dev/null)" ]; then exec "${@}" else runChecks + + if [ -d /var/www/html/assets ]; then + url="$(guessUrl)" + readonly url + + printf "An assets folder has been found and is available at %s\nAvailable assets:\n%s\n%s\n\n" \ + "$(tput setaf 7)${url}/assets/$(tput sgr 0)" \ + "$(find /var/www/html/assets -maxdepth 1 -type d -exec echo -e "\t{}/" \; | sort)" \ + "$(find /var/www/html/assets -maxdepth 1 -type f -exec echo -e "\t{}" \; | sort)" + fi + defaultCommand "${@}" fi }