From caa6cb32801ea0875040877674084983049303ac Mon Sep 17 00:00:00 2001 From: Marc Barry <4965634+marc-barry@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:14:14 -0500 Subject: [PATCH] Exit and error if a domain lookup for TO_DOMAIN fails. --- docker-entrypoint.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 99da509..e8b1c2e 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -2,8 +2,23 @@ set -e +# Function to resolve domain to IP +resolve_domain_to_ip() { + local domain=$1 + local ip + + ip=$(dig +short "$domain" | head -n 1) + if [[ -z "$ip" ]]; then + echo "Error: Failed to resolve domain $domain" + exit 1 + fi + + echo "$ip" +} + +# If provided resolve TO_DOMAIN to IP and set it to TO_ADDR if [[ -n "$TO_DOMAIN" ]]; then - TO_ADDR=$(dig +short "$TO_DOMAIN" | head -n 1) + TO_ADDR=$(resolve_domain_to_ip "$TO_DOMAIN") fi # Default values for ACCEPT_UIDS and ACCEPT_GIDS