diff --git a/bin/vmail-dovecot-enable.sh b/bin/vmail-dovecot-enable.sh index 9189fab..a047f02 100755 --- a/bin/vmail-dovecot-enable.sh +++ b/bin/vmail-dovecot-enable.sh @@ -29,19 +29,24 @@ vmail:getoptions "$@" if [[ -z $domain ]]; then echo "ERROR: domain name is required" exit 1 +else + # set vars + maildomain="mail.$domain" + pemfile="$maildomain.pem" + confile="$maildomain.conf" fi # check that letsencrypt cert exists -if [ ! -f /etc/ssl/letsencrypt/mail.$domain.pem ]; then - echo "Let's Encrypt cert for mail.$domain does not exist, create that first:" +if [ ! -f /etc/ssl/letsencrypt/$pemfile ]; then + echo "Let's Encrypt cert for $maildomain does not exist, create that first:" exit 1 fi # create dovecot config & restart -if [ ! -f "/etc/dovecot/sites.d/mail.$domain.conf" ]; then - echo "local_name mail.pawderosa.com {" > /etc/dovecot/sites.d/mail.$domain.conf - echo " ssl_cert = > /etc/dovecot/sites.d/mail.$domain.conf - echo " ssl_key = > /etc/dovecot/sites.d/mail.$domain.conf - echo "}" >> /etc/dovecot/sites.d/mail.$domain.conf +if [ ! -f "/etc/dovecot/sites.d/$confile" ]; then + echo "local_name $maildomain {" > /etc/dovecot/sites.d/$confile + echo " ssl_cert = > /etc/dovecot/sites.d/$confile + echo " ssl_key = > /etc/dovecot/sites.d/$confile + echo "}" >> /etc/dovecot/sites.d/$confile /usr/bin/systemctl --quiet is-active dovecot && systemctl --quiet reload dovecot fi