From 3ac3ee2b7599ffd8a69bdfcd3bdfe7621b9156dc Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Thu, 18 May 2023 15:59:54 -0700 Subject: [PATCH] create new vars, remove placeholder domain --- bin/vmail-dovecot-enable.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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