create new vars, remove placeholder domain
This commit is contained in:
parent
c68120d55e
commit
3ac3ee2b75
|
@ -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/ssl/letsencrypt/mail.pawderosa.com.pem" >> /etc/dovecot/sites.d/mail.$domain.conf
|
||||
echo " ssl_key = </etc/ssl/letsencrypt/mail.pawderosa.com.pem" >> /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/ssl/letsencrypt/$pemfile" >> /etc/dovecot/sites.d/$confile
|
||||
echo " ssl_key = </etc/ssl/letsencrypt/$pemfile" >> /etc/dovecot/sites.d/$confile
|
||||
echo "}" >> /etc/dovecot/sites.d/$confile
|
||||
/usr/bin/systemctl --quiet is-active dovecot && systemctl --quiet reload dovecot
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue
Block a user