Skip to content

Commit

Permalink
Merge pull request #6 from qpoint-io/marc-barry/fail-on-domain-lookup
Browse files Browse the repository at this point in the history
Exit and error if a domain lookup for TO_DOMAIN fails.
  • Loading branch information
marc-barry authored Nov 10, 2023
2 parents a533bf3 + caa6cb3 commit 22837bb
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 22837bb

Please sign in to comment.