From 4d165fbb9bd2c3e19b521cc9b1760e3ecb5323bf Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 25 Dec 2017 03:52:49 +0100 Subject: [PATCH] - Stop dovecot service befor installing it - Reload systemd daemon - Only create init script if systemd is not supported --- install_update_dovecot.sh | 49 ++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/install_update_dovecot.sh b/install_update_dovecot.sh index 3aff2c3..91df580 100755 --- a/install_update_dovecot.sh +++ b/install_update_dovecot.sh @@ -465,6 +465,27 @@ if $_new ; then fi +## ----------------- +## --- Stop dovecot if running +echo +echononl "\tStop dovecot service.." +if ps ax 2> /dev/null | grep -q -E "/usr/local/dovecot[0-9.-]*/sbin/dovecot" > /dev/null 2>&1 + if $systemd_support ; then + systemctl stop dovecot > /dev/null 2>&1 + else + /etc/init.d/dovecot stop > /dev/null 2>&1 + fi + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "Stopping dovecot service failed" + fi +else + echo -e "$rc_failed" +fi + + ## ----------------- ## --- Install Base System @@ -1470,7 +1491,7 @@ EOF echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Restarting rsyslog failed" + error "Restarting rsyslog failed" fi @@ -1711,7 +1732,7 @@ fi chown -R vmail:vmail /usr/local/dovecot-${_version}/etc/dovecot/sieve -if $_new ; then +if $_new && ! $systemd_support; then _create_init="" echo @@ -1925,6 +1946,7 @@ EOF ## - Make dovecot start at boot time ## - + echononl "\tMake dovecot start at boottime.." if $systemd_support ; then systemctl enable dovecot > /dev/null 2>&1 @@ -2022,6 +2044,21 @@ EOF fi +# - Reload systemd +# - +echononl "\tReload systemd.." +if $systemd_support ; then + systemctl daemon-reload + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "Reloading systemd failed" + fi +else + echo -e "$rc_skipped" +fi + echo echo -e "Change (from lda) to lmtp-service" @@ -3214,20 +3251,20 @@ fi _restart="" echo -echo -e -n "Restart services (dovecot/postfix)? [y/n]: " +echo -e -n "Start/Restart services (dovecot/postfix)? [y/n]: " read _restart if [ "y" = "$_restart" -o "Y" = "$_restart" -o "Yes" = "$_restart" -o "yes" = "$_restart" ];then - echononl "\tRestart dovecot.." + echononl "\tStart dovecot service.." if $systemd_support ; then systemctl start dovecot else - /etc/init.d/dovecot restart > /dev/null 2>&1 + /etc/init.d/dovecot start > /dev/null 2>&1 fi if [ "$?" = 0 ]; then echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Restarting dovecot failed" + error "Starting dovecot service failed" fi echononl "\tRestart postfix.." if $SYSTEMD_EXISTS ; then