install_update_dovecot.sh: fix error in case of update: aervice file was not newed.

This commit is contained in:
Christoph 2021-11-06 16:30:27 +01:00
parent 6868898142
commit 3dbea534e6

View File

@ -866,6 +866,32 @@ else
echo -e "$rc_skipped"
fi
echononl "\tRemove dovecot service file if exists.."
if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then
rm -f "/etc/systemd/system/dovecot.service" > /dev/null 2>&1
if [[ "$?" -gt 0 ]]; then
echo -e "$rc_failed"
error "Removing file '/etc/systemd/system/dovecot.service' failed."
else
echo -e "$rc_done"
fi
else
echo -e "$rc_skipped"
fi
echononl "\tRemove dovecot systemd's socket file if exists.."
if [[ -f "/etc/systemd/system/dovecot.socket" ]] ; then
rm -f "/etc/systemd/system/dovecot.socket" > /dev/null 2>&1
if [[ "$?" -gt 0 ]]; then
echo -e "$rc_failed"
error "Removing systemd's socket file '/etc/systemd/system/dovecot.socket' failed."
else
echo -e "$rc_done"
fi
else
echo -e "$rc_skipped"
fi
## - Install dovecot
## -
echononl "\tInstall Dovecot into Folder /usr/local/dovecot-${_version}"
@ -2337,6 +2363,98 @@ fi
## -
chown -R vmail:vmail /usr/local/dovecot-${_version}/etc/dovecot/sieve
if $systemd_support; then
## - # - At time, we don't use private tmp directory for divecot.
## - # -
## - echononl "\tAdjust Systemd service file, set PrivateTmp=false.."
## - if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then
## -
## - if $(grep -o -E "PrivateTmp\s*=\s*[^[:blank:]]+" /etc/systemd/system/dovecot.service | grep -q true 2> /dev/null ) ; then
## - perl -i -n -p -e "s/(PrivateTmp\s*=\s*)true/\1false/" /etc/systemd/system/dovecot.service
## - if [[ $? -eq 0 ]]; then
## - echo -e "$rc_done"
## - else
## - echo -e "$rc_failed"
## - fi
## - else
## - echo -e "$rc_skipped"
## - fi
## - else
## - echo -e "$rc_skipped"
## - fi
## - Increase LimitNOFILE to fit dovecots setting for 'default_client_limit'.
## -
## - here:
## - LimitNOFILE=32768
## -
echononl "\tAdjust 'LimitNOFILE' at file 'dovecot.service'.."
if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then
if $(grep -q -o -E "LimitNOFILE\s*=\s*[^[:blank:]]+" /etc/systemd/system/dovecot.service 2> /dev/null ) ; then
perl -i -n -p -e "s/(LimitNOFILE\s*=\s*.*)/LimitNOFILE=32768/" /etc/systemd/system/dovecot.service
if [[ $? -eq 0 ]]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fi
else
echo -e "$rc_skipped"
fi
else
echo -e "$rc_skipped"
fi
echononl "Adjust 'PIDFile' at file 'dovecot.service'.."
if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then
if $(grep -q -o -E "^\s*PIDFile\s*=\s*/run/" /etc/systemd/system/dovecot.service 2> /dev/null ) ; then
perl -i -n -p -e "s/^(PIDFile\s*=\/var(\/run\/.+))/#\1\nPIDFile=\2/" /etc/systemd/system/dovecot.service
if [[ $? -eq 0 ]]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fi
else
echo -e "$rc_skipped"
fi
else
echo -e "$rc_skipped"
fi
echononl "\tReload systemd .."
systemctl daemon-reload > /dev/null 2>&1
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fi
## - Make dovecot start at boot time
## -
echononl "\tMake dovecot start at boottime.."
systemctl enable dovecot > /dev/null 2>&1
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fatal "Make dovecot start at boottime (systend service) failed"
fi
else
## - Make dovecot start at boot time
## -
echononl "\tMake dovecot start at boottime.."
update-rc.d dovecot defaults > /dev/null 2>&1
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fatal "Make dovecot start at boottime (init script) failed"
fi
fi
if $_new ; then
@ -2551,63 +2669,6 @@ EOF
echo -e "$rc_skipped"
fi
else
## - # - At time, we don't use private tmp directory for divecot.
## - # -
## - echononl "\tAdjust Systemd service file, set PrivateTmp=false.."
## - if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then
## -
## - if $(grep -o -E "PrivateTmp\s*=\s*[^[:blank:]]+" /etc/systemd/system/dovecot.service | grep -q true 2> /dev/null ) ; then
## - perl -i -n -p -e "s/(PrivateTmp\s*=\s*)true/\1false/" /etc/systemd/system/dovecot.service
## - if [[ $? -eq 0 ]]; then
## - echo -e "$rc_done"
## - else
## - echo -e "$rc_failed"
## - fi
## - else
## - echo -e "$rc_skipped"
## - fi
## - else
## - echo -e "$rc_skipped"
## - fi
## - Increase LimitNOFILE to fit dovecots setting for 'default_client_limit'.
## -
## - here:
## - LimitNOFILE=32768
## -
echononl "\tAdjust 'LimitNOFILE' at file 'dovecot.service'.."
if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then
if $(grep -q -o -E "LimitNOFILE\s*=\s*[^[:blank:]]+" /etc/systemd/system/dovecot.service 2> /dev/null ) ; then
perl -i -n -p -e "s/(LimitNOFILE\s*=\s*.*)/LimitNOFILE=32768/" /etc/systemd/system/dovecot.service
if [[ $? -eq 0 ]]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fi
else
echo -e "$rc_skipped"
fi
else
echo -e "$rc_skipped"
fi
echononl "Adjust 'PIDFile' at file 'dovecot.service'.."
if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then
if $(grep -q -o -E "^\s*PIDFile\s*=\s*/run/" /etc/systemd/system/dovecot.service 2> /dev/null ) ; then
perl -i -n -p -e "s/^(PIDFile\s*=\/var(\/run\/.+))/#\1\nPIDFile=\2/" /etc/systemd/system/dovecot.service
if [[ $? -eq 0 ]]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fi
else
echo -e "$rc_skipped"
fi
else
echo -e "$rc_skipped"
fi
fi
## - Add a cronjob to restart dovecot after booting the system.
@ -2637,33 +2698,6 @@ EOF
echo -e "$rc_skipped"
fi
rm -f $_crontab_tmp_file
## - Make dovecot start at boot time
## -
if $systemd_support ; then
echononl "\tReload systemd .."
systemctl daemon-reload > /dev/null 2>&1
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fi
fi
echononl "\tMake dovecot start at boottime.."
if $systemd_support ; then
systemctl enable dovecot > /dev/null 2>&1
else
update-rc.d dovecot defaults > /dev/null 2>&1
fi
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fatal "Make dovecot start at boottime failed"
fi
## - update postfix configuration to play with dovecot lda
@ -2751,23 +2785,6 @@ EOF
fi
rm -f $_crontab_tmp_file
else
# - 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
fi # if $_new