From 5f62cbe095cf05417235701cab0b83f59c13bf8f Mon Sep 17 00:00:00 2001 From: UX0l0l Date: Wed, 19 Jun 2024 18:15:19 +0300 Subject: [PATCH] Added IPv6 support prompt and domain input incase /etc/mailname is empty --- emailwiz.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/emailwiz.sh b/emailwiz.sh index ddfbc13..5cb3a28 100644 --- a/emailwiz.sh +++ b/emailwiz.sh @@ -17,20 +17,28 @@ umask 0022 -apt-get install -y postfix postfix-pcre dovecot-imapd dovecot-pop3d dovecot-sieve opendkim opendkim-tools spamassassin spamc net-tools fail2ban bind9-host -domain="$(cat /etc/mailname)" +apt install -y postfix postfix-pcre dovecot-imapd dovecot-pop3d dovecot-sieve opendkim opendkim-tools spamassassin spamc net-tools fail2ban bind9-host +domain="$(< /etc/mailname || read -p 'Domain: ' domain && printf $domain)" subdom=${MAIL_SUBDOM:-mail} maildomain="$subdom.$domain" certdir="/etc/letsencrypt/live/$maildomain" +read -p 'Enable IPv6 support? (Y/n) ' v6choice + # 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 +case "$v6choice" in + [nN]) ;; + *) + ipv6=$(host "$domain" | grep "IPv6" | awk '{print $NF}') + [ -z "$ipv6" ] && { printf "\033[0;31mPlease point your domain (%s) to your server's IPv6 address.\033[0m\n" "$domain"; exit 1; } + ;; +esac # Open required mail ports, and 80, for Certbot. -for port in 80 993 465 25 587 110 995; do +for port in 80 993 465 25 587 110 995 +do ufw allow "$port" 2>/dev/null done @@ -213,7 +221,7 @@ service auth { mode = 0660 user = postfix group = postfix -} + } } protocol lda {