From 19fc7e41dfa659176e41652a5637cdb8d78fbec6 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Fri, 16 Jun 2023 09:08:17 -0700 Subject: [PATCH] check for common mail subdomains --- bin/letsencrypt-certonly.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bin/letsencrypt-certonly.sh b/bin/letsencrypt-certonly.sh index 3027e97..7659a5f 100755 --- a/bin/letsencrypt-certonly.sh +++ b/bin/letsencrypt-certonly.sh @@ -99,6 +99,28 @@ fi # copy above www subdomain section and modify as desired to # automatically check for and add additional subdomains to cert +# check common additional mail subdomains +if [[ $domain = mail.* ]]; then + # check for imap subdomain + dns=`host -t A ${domain/mail./imap.}|grep 'has address'|awk '{ print $4 }'` + if [[ " ${ips[@]} " =~ " ${dns} " ]]; then + command="$command -d ${domain/mail./imap.}" + dnscheck=true + fi + # check for smtp subdomain + dns=`host -t A ${domain/mail./smtp.}|grep 'has address'|awk '{ print $4 }'` + if [[ " ${ips[@]} " =~ " ${dns} " ]]; then + command="$command -d ${domain/mail./smtp.}" + dnscheck=true + fi + # check for pop subdomain + dns=`host -t A ${domain/mail./pop.}|grep 'has address'|awk '{ print $4 }'` + if [[ " ${ips[@]} " =~ " ${dns} " ]]; then + command="$command -d ${domain/mail./pop.}" + dnscheck=true + fi +fi + # check if any of the dns lookups passed if [[ "$dnscheck" = "false" ]]; then echo "All dns checks failed, can't create cert."