From 2e6d7561a3cc5d50577f94f8b3e5a824d9b1c6b4 Mon Sep 17 00:00:00 2001 From: polarathene <5098581+polarathene@users.noreply.github.com> Date: Tue, 28 Sep 2021 11:11:49 +1300 Subject: [PATCH] chore: 2/6 - Handle CMD check early, wrap init logic into a function --- docker-entrypoint.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 95e1fad..aa7ed96 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -32,6 +32,7 @@ function _setup_dhparam() { fi } +function _init() { # Warn if the DOCKER_HOST socket does not exist if [[ $DOCKER_HOST = unix://* ]]; then socket_file=${DOCKER_HOST#unix://} @@ -41,11 +42,9 @@ if [[ $DOCKER_HOST = unix://* ]]; then Typically you should run your nginxproxy/nginx-proxy with: \`-v /var/run/docker.sock:$socket_file:ro\` See the documentation at http://git.io/vZaGJ EOT - - # If the user has run the default command and the socket doesn't exist, fail - if [ "$1" = forego ] && [ "$2" = start ] && [ "$3" = '-r' ]; then - exit 1 - fi + + exit 1 + fi fi @@ -64,5 +63,11 @@ elif [[ $RESOLVERS =~ $SCOPED_IPV6_REGEX ]]; then echo "$RESOLVERS" | grep -Eo "$SCOPED_IPV6_REGEX" | paste -s -d ' ' >&2 RESOLVERS=$(echo "$RESOLVERS" | sed -r "s/$SCOPED_IPV6_REGEX//g" | xargs echo -n); export RESOLVERS fi +} + +# Run the init logic if the default CMD was provided +if [[ $* == 'forego start -r' ]]; then + _init +fi exec "$@"