- Stop dovecot service befor installing it

- Reload systemd daemon
- Only create init script if systemd is not supported
This commit is contained in:
Christoph 2017-12-25 03:52:49 +01:00
parent f9029628b8
commit 4d165fbb9b

View File

@ -465,6 +465,27 @@ if $_new ; then
fi 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 ## --- Install Base System
@ -1470,7 +1491,7 @@ EOF
echo -e "$rc_done" echo -e "$rc_done"
else else
echo -e "$rc_failed" echo -e "$rc_failed"
fatal "Restarting rsyslog failed" error "Restarting rsyslog failed"
fi fi
@ -1711,7 +1732,7 @@ fi
chown -R vmail:vmail /usr/local/dovecot-${_version}/etc/dovecot/sieve chown -R vmail:vmail /usr/local/dovecot-${_version}/etc/dovecot/sieve
if $_new ; then if $_new && ! $systemd_support; then
_create_init="" _create_init=""
echo echo
@ -1925,6 +1946,7 @@ EOF
## - Make dovecot start at boot time ## - Make dovecot start at boot time
## - ## -
echononl "\tMake dovecot start at boottime.." echononl "\tMake dovecot start at boottime.."
if $systemd_support ; then if $systemd_support ; then
systemctl enable dovecot > /dev/null 2>&1 systemctl enable dovecot > /dev/null 2>&1
@ -2022,6 +2044,21 @@ EOF
fi 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
echo -e "Change (from lda) to lmtp-service" echo -e "Change (from lda) to lmtp-service"
@ -3214,20 +3251,20 @@ fi
_restart="" _restart=""
echo echo
echo -e -n "Restart services (dovecot/postfix)? [y/n]: " echo -e -n "Start/Restart services (dovecot/postfix)? [y/n]: "
read _restart read _restart
if [ "y" = "$_restart" -o "Y" = "$_restart" -o "Yes" = "$_restart" -o "yes" = "$_restart" ];then if [ "y" = "$_restart" -o "Y" = "$_restart" -o "Yes" = "$_restart" -o "yes" = "$_restart" ];then
echononl "\tRestart dovecot.." echononl "\tStart dovecot service.."
if $systemd_support ; then if $systemd_support ; then
systemctl start dovecot systemctl start dovecot
else else
/etc/init.d/dovecot restart > /dev/null 2>&1 /etc/init.d/dovecot start > /dev/null 2>&1
fi fi
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
echo -e "$rc_failed" echo -e "$rc_failed"
fatal "Restarting dovecot failed" error "Starting dovecot service failed"
fi fi
echononl "\tRestart postfix.." echononl "\tRestart postfix.."
if $SYSTEMD_EXISTS ; then if $SYSTEMD_EXISTS ; then