change to try-reload-or-restart

try-reload-or-restart has this logic:
  Reload service if it supports it.
  If not, stop and then start instead.
  Does nothing if the service is not running.
This commit is contained in:
Matthew Saunders Brown 2023-12-20 10:11:36 -08:00
parent 800ffbff8a
commit b1ea2ee09e
5 changed files with 4 additions and 9 deletions

View File

@ -64,12 +64,9 @@ elif [[ -z $domains_id ]] ; then
cp -a /var/vmail/$domain/.exp/etc/* /etc/
# reload dovecot
if [[ -f /etc/dovecot/sites.d/mail.$domain.conf ]]; then
systemctl --quiet reload dovecot.service
fi
# reload apache (webmail)
if [[ -L /etc/apache2/sites-enabled/mail.$domain.conf ]]; then
systemctl --quiet reload apache2.service
systemctl --quiet try-reload-or-restart dovecot.service
fi
# apache reload (webmail) handled by vhost-reload-apache.path
fi
echo

View File

@ -31,5 +31,5 @@ fi
# disable dovecot for domain
if [ -f "/etc/dovecot/sites.d/mail.$domain.conf" ]; then
rm /etc/dovecot/sites.d/mail.$domain.conf
/usr/bin/systemctl --quiet is-active dovecot && systemctl --quiet reload dovecot
systemctl --quiet try-reload-or-restart dovecot
fi

View File

@ -48,5 +48,5 @@ if [ ! -f "/etc/dovecot/sites.d/$confile" ]; then
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
systemctl --quiet try-reload-or-restart dovecot
fi

View File

@ -31,7 +31,6 @@ fi
# disable webmail vhost & restart apache
if [ -h "/etc/apache2/sites-enabled/mail.$domain.conf" ]; then
/usr/sbin/a2dissite --quiet mail.$domain
/usr/bin/systemctl --quiet reload apache2
fi
if [ -f "/etc/apache2/sites-available/mail.$domain.conf" ]; then

View File

@ -44,5 +44,4 @@ fi
if [ ! -h "/etc/apache2/sites-enabled/mail.$domain.conf" ]; then
/usr/sbin/a2ensite --quiet mail.$domain
/usr/bin/systemctl --quiet is-active apache2 && systemctl --quiet reload apache2
fi