install_update_dovecot-2.4.sh: another intermediate version.

This commit is contained in:
2025-07-23 01:57:24 +02:00
parent 195e3f65ee
commit bbc3cf87f1

View File

@ -115,7 +115,7 @@ echo_failed(){
echo -e "\033[71G[ \033[1;31mfailed\033[m ]"
}
echo_skipped() {
echo -e "\033[71G[ \033[33m\033[1mskipped\033[m ]"
echo -e "\033[71G[ \033[37m\033[1mskipped\033[m ]"
}
detect_os_1 () {
@ -264,7 +264,7 @@ replace_or_append_code_block() {
echo "" >> "$file"
cat _new_block_to_append.tmp >> "$file"
rm -f "$tmp_file" _new_block_to_append.tmp
echo "Block '$block_name' wurde nicht gefunden und deshalb am Ende der Datei angehängt."
#echo "Block '$block_name' wurde nicht gefunden und deshalb am Ende der Datei angehängt."
return 0
fi
@ -3000,6 +3000,101 @@ EOF
echo -e "$rc_skipped"
fi
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf"
echononl " Create empty file '$(basename "${_conf_file}")'.."
if [[ ! -f "${_conf_file}" ]] ; then
_failed=false
cat <<'EOF' > "${_conf_file}" 2> "${log_file}"
##
## Log destination.
##
EOF
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Creating file '${_conf_file}' failed!"
fi
else
echo -e "$rc_skipped"
fi
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf"
echononl " Create empty file '$(basename "${_conf_file}")'.."
if [[ ! -f "${_conf_file}" ]] ; then
_failed=false
cat <<'EOF' > "${_conf_file}" 2> "${log_file}"
##
## LDA specific settings (also used by LMTP)
##
EOF
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Creating file '${_conf_file}' failed!"
fi
else
echo -e "$rc_skipped"
fi
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-lmtp.conf"
echononl " Create empty file '$(basename "${_conf_file}")'.."
if [[ ! -f "${_conf_file}" ]] ; then
_failed=false
cat <<'EOF' > "${_conf_file}" 2> "${log_file}"
##
## LMTP specific settings
##
EOF
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Creating file '${_conf_file}' failed!"
fi
else
echo -e "$rc_skipped"
fi
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf"
echononl " Create empty file '$(basename "${_conf_file}")'.."
if [[ ! -f "${_conf_file}" ]] ; then
_failed=false
cat <<'EOF' > "${_conf_file}" 2> "${log_file}"
##
## IMAP specific settings
##
EOF
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Creating file '${_conf_file}' failed!"
fi
else
echo -e "$rc_skipped"
fi
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf"
echononl " Create empty file '$(basename "${_conf_file}")'.."
if [[ ! -f "${_conf_file}" ]] ; then
_failed=false
cat <<'EOF' > "${_conf_file}" 2> "${log_file}"
##
## POP3 specific settings
##
EOF
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Creating file '${_conf_file}' failed!"
fi
else
echo -e "$rc_skipped"
fi
blank_line
@ -5923,7 +6018,7 @@ EOF
if grep -qE "^\s*\!include\s+" "${_conf_file}"; then
replace_variable '!include' "auth-sql.conf.ext" "${_conf_file}" || _failed=true
sed -i "s|^!include[[:space:]]\+.*$|!include auth-sql.conf.ext|" "${_conf_file}"
else
cat <<'EOF' >> "${_conf_file}" || _failed=true
@ -6438,8 +6533,122 @@ _conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf"
if [[ $dovecot_major_version -gt 2 ]] \
|| ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
# edit /usr/local/dovecot/etc/dovecot/conf.d/10-logging.conf
#
# log_path =syslog
# syslog_facility = local1
# auth_verbose = yes
# auth_verbose_passwords = plain
#
#
# in conjunction with the the following entries in /etc/rsyslog.conf
#
# local1.* -/var/log/dovecot.log
# local1.info -/var/log/dovecot.info
# local1.warn -/var/log/dovecot.warn
# local1.err -/var/log/dovecot.err
# :msg,contains,"stored mail into mailbox"\
# -/var/log/dovecot.lmtp
echononl " Adjusting file '$(basename "${_conf_file}")'.."
echo -e "$rc_not_yet_implemented"
if grep -qE "^\s*log_path\s*=" "${_conf_file}"; then
replace_variable "log_path" "syslog" "${_conf_file}" || _failed=true
else
cat <<'EOF' >> "${_conf_file}" || _failed=true
# Specify the log file to use for error messages.
#
# Options:
#
# - syslog: Log to syslog
# - /dev/stderr: Log to stderr
#
# If you don't want to use syslog, or if you just can't find the Dovecot's error logs,
# you can make Dovecot log elsewhere as well:
#
# log_path = /var/log/dovecot.log
#
# If you don't want errors, info, and debug logs all in one file, specify
# info_log_path or debug_log_path as well:
#
# log_path = /var/log/dovecot.log
# info_log_path = /var/log/dovecot-info.log
#
log_path =syslog
EOF
fi
if grep -qE "^\s*syslog_facility\s*=" "${_conf_file}"; then
replace_variable "syslog_facility" "local1" "${_conf_file}" || _failed=true
else
cat <<'EOF' >> "${_conf_file}" || _failed=true
# The syslog facility used if you're logging to syslog
syslog_facility = local1
EOF
fi
if grep -qE "^\s*auth_verbose\s*=" "${_conf_file}"; then
replace_variable "auth_verbose" "yes" "${_conf_file}" || _failed=true
else
cat <<'EOF' >> "${_conf_file}" || _failed=true
# If yes, log unsuccessful authentication attempts and why they failed.
auth_verbose = yes
EOF
fi
if grep -qE "^\s*auth_verbose_passwords\s*=" "${_conf_file}"; then
replace_variable "auth_verbose_passwords" "yes" "${_conf_file}" || _failed=true
else
cat <<'EOF' >> "${_conf_file}" || _failed=true
# In case of password mismatches, log the attempted password. You can also truncate
# the logged password to n chars by appending :n (e.g. sha1:6).
#
#Available transformations:
#
# plain, yes: Output cleartext password (NOT RECOMMENDED)
# sha1: Output SHA1 hashed password
auth_verbose_passwords = plain
EOF
fi
if ! $_failed ; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Adjusting Adjusting file ${_conf_file} failed"
error "$(cat "${log_file}")"
echo ""
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interupted by user"
fi
else
@ -6568,8 +6777,105 @@ _conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf"
if [[ $dovecot_major_version -gt 2 ]] \
|| ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
# edit /usr/local/dovecot/etc/dovecot/conf.d/15-lda.conf
#
# postmaster_address = $postmaster_address
# hostname = $hostname
# sendmail_path = /usr/sbin/sendmail
# lda_mailbox_autocreate = no
#
# protocol lda {
# mail_plugins = $mail_plugins sieve
# }
#
echononl " Adjusting file '$(basename "${_conf_file}")'.."
echo -e "$rc_not_yet_implemented"
if grep -qE "^\s*postmaster_address\s*=" "${_conf_file}"; then
replace_variable "postmaster_address" "${postmaster_address}" "${_conf_file}" || _failed=true
else
cat <<EOF >> "${_conf_file}" || _failed=true
# The From address from which email rejection messages (bounces) are sent.
#
# Default postmaster@%{user|domain|default(hostname)}
#
# As used here, %{user | domain} expands to the domain of the local user. Other Mail user
# variables can be used as well.
# see: https://doc.dovecot.org/2.4.1/core/settings/variables.html#mail-user-variables
postmaster_address = ${postmaster_address}
EOF
fi
if grep -qE "^\s*hostname\s*=" "${_conf_file}"; then
replace_variable "hostname" "${hostname}" "${_conf_file}" || _failed=true
else
cat <<EOF >> "${_conf_file}" || _failed=true
# The hostname to be used in email messages sent out by the local delivery agent
# (such as the Message-ID: header), in LMTP replies, and as the hostname advertised
# by submission SMTP service.
#
# Default: <system's real hostname@domain.tld>
hostname = ${hostname}
EOF
fi
if grep -qE "^\s*sendmail_path\s*=" "${_conf_file}"; then
replace_variable "sendmail_path" "/usr/sbin/sendmail" "${_conf_file}" || _failed=true
else
cat <<EOF >> "${_conf_file}" || _failed=true
# The binary to use for sending email.
#
#Used only if submission_host is not set.
sendmail_path = /usr/sbin/sendmail
EOF
fi
read -r -d '' NEW_BLOCK <<'EOF'
protocol lda {
# A list of mail plugins to load.
#
# The boolean list can be configured as a space or comma-separated list, which replaces
# the previous boolean list entirely.
mail_plugins = ${mail_plugins} sieve
}
EOF
replace_or_append_code_block "protocol lda" "${NEW_BLOCK}" "${_conf_file}" || _failed=true
if ! $_failed ; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Adjusting Adjusting file ${_conf_file} failed"
error "$(cat "${log_file}")"
echo ""
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interupted by user"
fi
else
@ -6610,8 +6916,63 @@ _conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-lmtp.conf"
if [[ $dovecot_major_version -gt 2 ]] \
|| ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
# edit /usr/local/dovecot/etc/dovecot/conf.d/20-lmtp
#
# lmtp_save_to_detail_mailbox = no
#
# protocol lmtp {
# mail_plugins = $mail_plugins sieve
# }
#
echononl " Adjusting file '$(basename "${_conf_file}")'.."
echo -e "$rc_not_yet_implemented"
if grep -qE "^\s*lmtp_save_to_detail_mailbox\s*=" "${_conf_file}"; then
replace_variable "lmtp_save_to_detail_mailbox" "no" "${_conf_file}" || _failed=true
else
cat <<EOF >> "${_conf_file}" || _failed=true
# If the recipient address includes a detail element / role (as in user+detail format),
# save the message to the detail mailbox.
lmtp_save_to_detail_mailbox = no
EOF
fi
read -r -d '' NEW_BLOCK <<'EOF'
protocol lmtp {
# A list of mail plugins to load.
#
# The boolean list can be configured as a space or comma-separated list, which replaces
# the previous boolean list entirely.
mail_plugins = ${mail_plugins} sieve
}
EOF
replace_or_append_code_block "protocol lda" "${NEW_BLOCK}" "${_conf_file}" || _failed=true
if ! $_failed ; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Adjusting Adjusting file ${_conf_file} failed"
error "$(cat "${log_file}")"
echo ""
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interupted by user"
fi
else
@ -6633,7 +6994,7 @@ else
fatal "Adjusting '${_conf_file}' failed"
fi
fi # edit /usr/local/dovecot/etc/dovecot/conf.d/20-lmtp
fi # edit /usr/local/dovecot/etc/dovecot/conf.d/20-lmtp.conf
# edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf
@ -7522,55 +7883,69 @@ echo
echo -e "\033[1mConfigure quota support for dovecot\033[m"
## - take care quota plugins (quota,imap_quota) will
## - be loaded:
## -
## - there are two quota related plugins:
## -
## - * quota: implements the actual quota handling and includes also all the quota backends.
## - * imap_quota: for reporting quota information via imap.
## -
## - enable them in configuration files, e.g.:
## -
## - conf.d/10-mail.conf:
## -
## - # space separated list of plugins to load for all services. plugins specific to
## - # imap, lda, etc. are added to this list in their own .conf files.
## - mail_plugins = $mail_plugins quota
## -
## - conf.d/20-imap.conf:
## -
## - protocol imap {
## - # space separated list of plugins to load (default is global mail_plugins).
## - mail_plugins = $mail_plugins imap_quota
## - }
## -
## - we have done it befor, at the basic configuration
## -
## - configure dict service
## -
## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf
## -
## - add:
## -
## - service dict {
## - unix_listener dict {
## - mode = 0600
## - user = vmail
## - }
## - }
## -
# edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf
#
# add service dict
#
_failed=false
echononl " Configure dict service (10-master.conf)"
perl -i -n -p -e "s#^([ ]*)(unix_listener\ +dict.*)#\1\2\n\1 mode = 0600\n\1 user = vmail#g" \
/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true
if ! $_failed ; then
echo -e "$rc_done"
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf"
if [[ $dovecot_major_version -gt 2 ]] \
|| ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
echononl " Configure dict service ($(basename "${_conf_file}"))"
echo -e "$rc_not_yet_implemented"
else
echo -e "$rc_failed"
fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf failed"
fi
## - take care quota plugins (quota,imap_quota) will
## - be loaded:
## -
## - there are two quota related plugins:
## -
## - * quota: implements the actual quota handling and includes also all the quota backends.
## - * imap_quota: for reporting quota information via imap.
## -
## - enable them in configuration files, e.g.:
## -
## - conf.d/10-mail.conf:
## -
## - # space separated list of plugins to load for all services. plugins specific to
## - # imap, lda, etc. are added to this list in their own .conf files.
## - mail_plugins = $mail_plugins quota
## -
## - conf.d/20-imap.conf:
## -
## - protocol imap {
## - # space separated list of plugins to load (default is global mail_plugins).
## - mail_plugins = $mail_plugins imap_quota
## - }
## -
## - we have done it befor, at the basic configuration
## -
## - configure dict service
## -
## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf
## -
## - add:
## -
## - service dict {
## - unix_listener dict {
## - mode = 0600
## - user = vmail
## - }
## - }
## -
_failed=false
echononl " Configure dict service ($(basename "${_conf_file}"))"
perl -i -n -p -e "s#^([ ]*)(unix_listener\ +dict.*)#\1\2\n\1 mode = 0600\n\1 user = vmail#g" \
"${_conf_file}" || _failed=true
if ! $_failed ; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf failed"
fi
fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf
## - edit /usr/local/dovecot/etc/dovecot/dovecot.conf
@ -7581,14 +7956,23 @@ fi
## - quota = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext
## - }
_failed=false
echononl " Adjust file dovecot.conf for (dict) quota service"
perl -i -n -p -e "s#^([ ]*)(dict\ +{.*)#\1\2\n\1 quota = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext#g" \
/usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true
if ! $_failed ; then
echo -e "$rc_done"
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf"
if [[ $dovecot_major_version -gt 2 ]] \
|| ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
echononl " Adjust file $(basename "${_conf_file}") for (dict) quota service"
echo -e "$rc_not_yet_implemented"
else
echo -e "$rc_failed"
fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf failed"
echononl " Adjust file dovecot.conf for (dict) quota service"
perl -i -n -p -e "s#^([ ]*)(dict\ +{.*)#\1\2\n\1 quota = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext#g" \
"${_conf_file}" || _failed=true
if ! $_failed ; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf failed"
fi
fi