diff options
author | Luke Smith <luke@lukesmith.xyz> | 2024-01-25 12:41:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-25 12:41:03 +0000 |
commit | 42993e8ba80bc4b067a086b8b741cf511d806175 (patch) | |
tree | 7089d8a4c74964fd13c43275490f33f3b3567292 /emailwiz.sh | |
parent | 9861a6af1ee3ae33a6722a7956761b84a2ab3d04 (diff) | |
parent | e58b2bf426fe102211a5af6a41178923c73bc120 (diff) |
Merge pull request #308 from tfasano1/master
Add safeguards to script
Diffstat (limited to 'emailwiz.sh')
-rw-r--r-- | emailwiz.sh | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/emailwiz.sh b/emailwiz.sh index ce8e1f5..b525e59 100644 --- a/emailwiz.sh +++ b/emailwiz.sh @@ -23,6 +23,12 @@ subdom=${MAIL_SUBDOM:-mail} maildomain="$subdom.$domain" certdir="/etc/letsencrypt/live/$maildomain" +# Preliminary record checks +ipv4=$(host "$domain" | grep -m1 -Eo '([0-9]+\.){3}[0-9]+') +[ -z "$ipv4" ] && echo "\033[0;31mPlease point your domain ("$domain") to your server's ipv4 address." && exit 1 +ipv6=$(host "$domain" | grep "IPv6" | awk '{print $NF}') +[ -z "$ipv6" ] && echo "\033[0;31mPlease point your domain ("$domain") to your server's ipv6 address." && exit 1 + # Open required mail ports, and 80, for Certbot. for port in 80 993 465 25 587; do ufw allow "$port" 2>/dev/null @@ -350,7 +356,7 @@ done pval="$(tr -d '\n' <"/etc/postfix/dkim/$domain/$subdom.txt" | sed "s/k=rsa.* \"p=/k=rsa; p=/;s/\"\s*\"//;s/\"\s*).*//" | grep -o 'p=.*')" dkimentry="$subdom._domainkey.$domain TXT v=DKIM1; k=rsa; $pval" dmarcentry="_dmarc.$domain TXT v=DMARC1; p=reject; rua=mailto:dmarc@$domain; fo=1" -spfentry="$domain TXT v=spf1 mx a:$maildomain -all" +spfentry="$domain TXT v=spf1 mx a:$maildomain ip4:$ipv4 ip6:$ipv6 -all" mxentry="$domain MX 10 $maildomain 300" useradd -m -G mail dmarc |