From 12c6cd39b1e91fe0f87fdf507eba1f8beddda88e Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Mon, 2 Jan 2023 09:48:58 -0800 Subject: [PATCH] automatically restart services if needed --- bin/vmail-domains-imp.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/vmail-domains-imp.sh b/bin/vmail-domains-imp.sh index c2d83c0..706ae93 100755 --- a/bin/vmail-domains-imp.sh +++ b/bin/vmail-domains-imp.sh @@ -62,15 +62,19 @@ elif [[ -z $domains_id ]] ; then # /etc/ configs if [[ -d /var/vmail/$domain/.exp/etc ]]; 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 + fi fi echo echo "Vmail import complete. If it's no longer need you can remove the data dir:" echo "/var/vmail/$domain/.exp/" - echo - echo "Assuming /etc/ configs were imported you should now reload services with:" - echo "systemctl reload apache2.service dovecot.service" - echo else @@ -81,14 +85,14 @@ elif [[ -z $domains_id ]] ; then else - echo "Vmail dir for $domain exists, but there is no .exp data dir." + echo "ERROR: Vmail dir for $domain exists, but there is no .exp data dir." exit 1 fi else - echo "$domain exists in vmail db, but /var/vmail/$domain dir does not exist." + echo "ERROR: $domain exists in vmail db, but /var/vmail/$domain dir does not exist." echo "This script excepts a sync of the /var/vmail/$domain dir and no records in the db." exit 1