certbot-route53 icon indicating copy to clipboard operation
certbot-route53 copied to clipboard

Problem when strip out the hostname part to leave only the domain

Open duke-count opened this issue 6 years ago • 1 comments

Thanks for this script. I realized that the internal sed command does not work when the host name is made up of more than three levels, for example: mail.external.example.com should return DOMAIN "example.com" but the value is "external.example. com "

# CERTBOT_DOMAIN is a hostname, not a domain (zone)
# We strip out the hostname part to leave only the domain
DOMAIN="$(sed -r 's/^[^.]+.(.*)$/\1/' <<< "${CERTBOT_DOMAIN}")"

duke-count avatar Mar 12 '18 15:03 duke-count

echo something.very.long.example.com | sed -r 's/^([^.]+.)+.(com|net|org)$/\1.\2/' will return example.com

for me it did the trick as we own few domains outside of .com it was quick to adapt.

noonespecial2 avatar Jul 03 '18 01:07 noonespecial2