Compare commits

..
13 Commits
Author SHA1 Message Date
chrisandClaude Opus 5.5 b2c55d57b8 install_update_dovecot-2.4.sh: always write pop3 service blocks
Write 'service pop3-login' and 'service pop3' (also post-login) again
regardless of the selected mail services - like for imap and sieve.
Dovecot only starts services of enabled protocols, so a protocol can
be switched on/off simply via 'yes'/'no' in the 'protocols' block of
dovecot.conf followed by a restart.

Only dovecot's submission service blocks are still removed
(submission is provided by postfix).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 15:43:46 +01:00
chrisandClaude Opus 5.5 29fe6d0e0d install_update_dovecot-2.4.sh: use '2>&1' instead of '2<&1' for stderr redirection
'2<&1' duplicates fd 1 as an input descriptor. In bash it happens to
behave like '2>&1', but it is unusual and misleading. Use the common
form '2>&1' (cp, grep, pigeonhole configure/make/make install).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 15:13:37 +01:00
chrisandClaude Opus 5.5 38c7ce8f6a install_update_dovecot-2.4.sh: make provided mail services selectable
- New config parameter 'mail_protocols' (blank separated list of
  imap, pop3, sieve; defaults to "imap pop3 sieve"). lmtp is always
  enabled.
- New selection menu at install/update time:
    [1] all common mail services (imap pop3 sieve)
    [2] all common except pop3   (imap sieve)
    [3] other (follow-up input, preset with an individual list
        from the configuration file)
  The line matching the configuration file is highlighted.
- 'protocols' block is built from the selection; not selected
  protocols and dovecot's submission service are set to 'no'.
- Dovecot's submission service is no longer configured: submission
  (587/465) is provided by postfix. 'service submission-login' and
  'service submission' blocks are removed from 10-master.conf.
- 'service pop3-login' / 'service pop3' are only written if pop3 is
  selected, otherwise removed.
- Summary lists each protocol with its state; listener addresses are
  only shown for enabled protocols. 'mail_protocols' is written to the
  environment file.
- Helper functions call 'gawk' explicitly (they need GNU awk
  extensions like '\s'; mawk silently fails). gawk is installed for
  update and new installation, abort if that fails.
- Fix apt-get calls: '2&>1' -> '2>&1', add '-y', append to log.
- conf/install_update_dovecot.conf.sample: document 'mail_protocols'.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 15:12:45 +01:00
chrisandClaude Opus 5.5 1278bfcfd0 install_amavis.sh: disable clamav-freshclam-once timer/service.
Since Debian 13 the package clamav-freshclam also ships and enables
clamav-freshclam-once.timer and clamav-freshclam-once.service. Together
with the freshclam daemon (clamav-freshclam.service) both try to lock
/var/log/clamav/freshclam.log at boot and one of them fails.

Disable the 'once' units right after stopping the daemon and before the
initial freshclam run, so only the daemon keeps the databases current.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 01:47:20 +01:00
chris f0e6ff2506 fix: update systemd support check to use logical OR 2026-11-19 11:17:03 +01:00
chrisandClaude Opus 5.5 5429768e28 install_amavis.sh: open amavis port 10026 whenever submission/smtps use it
master.cf submission/smtps are always rewritten to
content_filter=amavisfeed:[127.0.0.1]:10026, but amavis only listened on
10026 if Cyrus SASL was enabled. Hosts authenticating via Dovecot SASL
(answer 'no') got [10024, 10029], so submitted mail was deferred with
"connect to 127.0.0.1:10026: Connection refused".

Now 10026 (ORIGINATING) is opened if SASL is enabled or master.cf contains
submission/smtps; 10029 (VIRUSONLY) is opened as before if 10026 is not
needed, or if main.cf content_filter points to 10029 (relay/sympa hosts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 00:45:13 +01:00
chris 787749f4d6 update delivery-main.cf.in: adjust size limits and alias maps for consistency with Postfix instance 2026-11-11 16:34:13 +01:00
chrisandClaude Opus 5.5 fa96599077 install_update_dovecot-2.4: enable mail_log only for imap, pop3 and lmtp
With mail_log loaded globally, doveadm also logs every action to stderr,
so cron jobs like "doveadm expunge -A mailbox Spam* savedbefore 30d"
produced one output line (and thus cron mail) per expunged message.

Scope the plugin to protocol imap/pop3/lmtp blocks in 95-mail-log.conf;
client actions and sieve filing are still logged, doveadm stays quiet
and only reports real errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 11:01:51 +01:00
chris 686f291b68 install_update_dovecot: add mail_log plugin configuration and logging options 2026-11-11 01:19:34 +01:00
chrisandClaude Opus 5.5 564a5254ad srs delivery template: do not set config_directory in main.cf
The instance gets MAIL_CONFIG=/etc/postfix-srs/delivery from
postfix@srs-delivery.service; setting it again makes postconf warn.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 15:35:48 +01:00
chris 877e8996b0 install_roundcube.sh: add support for roundcubemail 1.7.x 2026-11-09 18:07:05 +01:00
chris 4b1af1419e Merge branch 'master' of https://git.oopen.de/install/mailsystem 2026-11-09 15:14:08 +01:00
chris 3bd732b5b2 install_roundcube.sh: fix errors in installimg aspell pakcages. 2026-11-09 15:13:38 +01:00
6 changed files with 822 additions and 118 deletions

No files matched your search

+57
View File
@@ -69,6 +69,42 @@ ipv6=""
#postfix_main_cf="/etc/postfix/main.cf" #postfix_main_cf="/etc/postfix/main.cf"
# ---
# - Mail services (dovecot protocols)
# ---
# - mail_protocols
# -
# - Blank separated list of the mail services (dovecot protocols) to provide.
# -
# - Possible values:
# -
# - imap - IMAP (port 143) and IMAPS (port 993)
# - pop3 - POP3 (port 110) and POP3S (port 995)
# - sieve - ManageSieve (port 4190), e.g. used by the roundcube
# - 'managesieve' plugin (filter rules, vacation, ..)
# -
# - Note:
# - 'lmtp' is not part of this list. LMTP is required for delivering mail
# - from postfix into the mailboxes and is therefore always enabled.
# -
# - 'submission' is not part of this list either. In this mailsystem
# - submission (587) and submissions (465) are provided by postfix, so
# - dovecot's submission service is always disabled.
# -
# - The value given here determines which line is highlighted (and taken by
# - pressing <RETURN>) in the selection menu of the install script:
# -
# - "imap pop3 sieve" --> [1] all common mail services
# - "imap sieve" --> [2] all common mail services except pop3
# - anything else --> [3] other (the value is offered as default for
# - the following input)
# -
# - Defaults to "imap pop3 sieve"
# -
#mail_protocols="imap pop3 sieve"
# --- # ---
# - Listener configuration # - Listener configuration
# --- # ---
@@ -166,6 +202,27 @@ max_userip_connections=24
auth_mechanisms="plain login" auth_mechanisms="plain login"
# ---
# - Logging of mail actions (mail_log plugin, Dovecot 2.4+)
# ---
#
# - Logs copy/move, save, expunge, delete and folder create/delete/rename
# - into the dovecot log (file conf.d/95-mail-log.conf).
# -
# - Note: with fields 'from' and 'subject' personal data are written
# - to the log files.
# -
# - mail_log defaults to: true
# - mail_log_events defaults to:
# - "copy save expunge delete undelete mailbox_create mailbox_delete mailbox_rename"
# - mail_log_fields defaults to:
# - "uid box msgid from subject"
# -
#mail_log=true
#mail_log_events="copy save expunge delete undelete mailbox_create mailbox_delete mailbox_rename"
#mail_log_fields="uid box msgid from subject"
# --- # ---
# - Settings for quota warning sript # - Settings for quota warning sript
# --- # ---
+29 -4
View File
@@ -34,8 +34,14 @@ mynetworks = 127.0.0.0/8
# itself the final destination for. # itself the final destination for.
mydestination = @MYDESTINATION@ mydestination = @MYDESTINATION@
# Maximum size of a user mailbox # Size limits: taken from the regular Postfix instance. ALL mail that is
mailbox_size_limit = 51200000 # not delivered locally (outgoing mail of own users AND external alias
# forwards) passes this instance (default_transport = srs-forward), so the
# limits must match - otherwise the reinjection is rejected with
# "552 5.3.4 Message size exceeds fixed limit".
message_size_limit = @MESSAGE_SIZE_LIMIT@
mailbox_size_limit = @MAILBOX_SIZE_LIMIT@
virtual_mailbox_limit = @VIRTUAL_MAILBOX_LIMIT@
# Optional external command to use instead of mailbox delivery. If set, # Optional external command to use instead of mailbox delivery. If set,
# you must set up an alias to forward root mail to a real user. # you must set up an alias to forward root mail to a real user.
@@ -45,7 +51,10 @@ mailbox_command =
# List of alias maps to use to lookup local addresses. # List of alias maps to use to lookup local addresses.
# Per Debian Policy it should be /etc/aliases. # Per Debian Policy it should be /etc/aliases.
alias_maps = $alias_database, nis:mail.aliases # Taken from the regular instance (the Debian default
# "$alias_database, nis:mail.aliases" logs "NIS domain name not set"
# on every smtpd recipient lookup).
alias_maps = @ALIAS_MAPS@
# List of alias maps to make indexes on, when running newaliases. # List of alias maps to make indexes on, when running newaliases.
alias_database = hash:/etc/aliases alias_database = hash:/etc/aliases
@@ -105,4 +114,20 @@ smtp_tls_CAfile = @SMTP_TLS_CAFILE@
smtp_tls_mandatory_protocols = @SMTP_TLS_MANDATORY_PROTOCOLS@ smtp_tls_mandatory_protocols = @SMTP_TLS_MANDATORY_PROTOCOLS@
smtp_tls_protocols = @SMTP_TLS_PROTOCOLS@ smtp_tls_protocols = @SMTP_TLS_PROTOCOLS@
smtp_tls_security_level = @SMTP_TLS_SECURITY_LEVEL@ smtp_tls_security_level = @SMTP_TLS_SECURITY_LEVEL@
config_directory = /etc/postfix-srs/delivery
# Further settings taken from the regular Postfix instance: this instance
# does the actual SMTP delivery to the outside, so queue lifetimes, delay
# warnings, TLS policy, TLS logging/session cache and smtp_generic_maps
# must behave like the regular instance.
maximal_queue_lifetime = @MAXIMAL_QUEUE_LIFETIME@
bounce_queue_lifetime = @BOUNCE_QUEUE_LIFETIME@
delay_warning_time = @DELAY_WARNING_TIME@
smtp_tls_policy_maps = @SMTP_TLS_POLICY_MAPS@
smtp_tls_loglevel = @SMTP_TLS_LOGLEVEL@
smtp_tls_session_cache_database = @SMTP_TLS_SESSION_CACHE_DATABASE@
smtp_generic_maps = @SMTP_GENERIC_MAPS@
# config_directory is intentionally NOT set here: the instance is started by
# postfix@srs-delivery.service with MAIL_CONFIG=/etc/postfix-srs/delivery
# (systemd turns the '-' in the instance name into '/'). Setting it again in
# main.cf makes postconf warn "overriding earlier entry: config_directory=...".
+58 -9
View File
@@ -3082,6 +3082,26 @@ else
fi fi
fi fi
# - Since Debian 13 the package clamav-freshclam also ships (and enables)
# - clamav-freshclam-once.timer / clamav-freshclam-once.service. Together
# - with the freshclam daemon (clamav-freshclam.service) both try to lock
# - /var/log/clamav/freshclam.log at the same time and one of them fails.
# - Keep only the daemon.
# -
echononl " Disable clamav-freshclam-once (timer/service).."
if $systemd_exists && systemctl cat clamav-freshclam-once.service > /dev/null 2>&1 ; then
systemctl disable --now clamav-freshclam-once.timer clamav-freshclam-once.service > /dev/null 2> $tmp_err_msg
if [[ $? -eq 0 ]] ; then
systemctl reset-failed clamav-freshclam-once.service > /dev/null 2>&1
echo_ok
else
echo_failed
error "$(cat $tmp_err_msg)"
fi
else
echo_skipped
fi
echononl " Initial run of freshclam.." echononl " Initial run of freshclam.."
freshclam > /dev/null 2> $tmp_err_msg freshclam > /dev/null 2> $tmp_err_msg
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then
@@ -4268,11 +4288,43 @@ use strict;
# #
EOF EOF
if ${SASL_AUTH_ENABLED} ; then # - Port 10026 (policy bank ORIGINATING)
# -
# - Needed whenever master.cf contains submission or smtps: further below
# - both are rewritten to 'content_filter=amavisfeed:[127.0.0.1]:10026'.
# - install_postfix_advanced.sh creates submission/smtps on every host that
# - is not a relay host - independent of Cyrus SASL (most hosts authenticate
# - via Dovecot SASL and answer the Cyrus SASL question with 'no').
# -
# - Port 10029 (policy bank VIRUSONLY)
# -
# - Target of 'content_filter' in main.cf on relay hosts and sympa list
# - servers (see install_postfix_advanced.sh).
# -
if ${SASL_AUTH_ENABLED} \
|| grep -qiE "^(submission|smtps)\s+" /etc/postfix/master.cf 2> /dev/null ; then
amavis_originating_port=true
else
amavis_originating_port=false
fi
if ! ${amavis_originating_port} \
|| postconf -h content_filter 2> /dev/null | grep -q ':10029' ; then
amavis_virusonly_port=true
else
amavis_virusonly_port=false
fi
amavis_listen_ports="10024"
${amavis_originating_port} && amavis_listen_ports="${amavis_listen_ports}, 10026"
${amavis_virusonly_port} && amavis_listen_ports="${amavis_listen_ports}, 10029"
cat << EOF >> "${_config_file}"
\$inet_socket_port = [${amavis_listen_ports}];
EOF
if ${amavis_originating_port} ; then
cat << EOF >> "${_config_file}" cat << EOF >> "${_config_file}"
\$inet_socket_port = [10024, 10026];
#\$inet_socket_port = [10024, 10029];
#\$inet_socket_port = [10024, 10026, 10029];
\$interface_policy{'10026'} = 'ORIGINATING'; \$interface_policy{'10026'} = 'ORIGINATING';
\$policy_bank{'ORIGINATING'} = { \$policy_bank{'ORIGINATING'} = {
@@ -4282,13 +4334,10 @@ if ${SASL_AUTH_ENABLED} ; then
remove_existing_spam_headers => 1, remove_existing_spam_headers => 1,
}; };
EOF EOF
fi
else if ${amavis_virusonly_port} ; then
cat << EOF >> "${_config_file}" cat << EOF >> "${_config_file}"
#\$inet_socket_port = [10024, 10026];
\$inet_socket_port = [10024, 10029];
#\$inet_socket_port = [10024, 10026, 10029];
\$interface_policy{'10024'} = 'INBOUND'; \$interface_policy{'10024'} = 'INBOUND';
\$interface_policy{'10029'} = 'VIRUSONLY'; \$interface_policy{'10029'} = 'VIRUSONLY';
+73 -25
View File
@@ -181,7 +181,7 @@ systemd_supported=false
systemd=$(which systemd) systemd=$(which systemd)
systemctl=$(which systemctl) systemctl=$(which systemctl)
if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then if [[ -n "$systemd" ]] || [[ -n "$systemctl" ]] ; then
systemd_supported=true systemd_supported=true
fi fi
@@ -295,6 +295,10 @@ do
echo -e "\n\t\033[33m\033[1mA version number is required!\033[m\n" echo -e "\n\t\033[33m\033[1mA version number is required!\033[m\n"
fi fi
done done
# Hauptversionsnummer extrahieren (1.6 oder 1.7)
RC_MAIN_VERSION=$(echo "$ROUNDCUBE_VERSION" | cut -d. -f1-2)
echo "" echo ""
echo -e "\033[32m--\033[m" echo -e "\033[32m--\033[m"
echo "" echo ""
@@ -973,13 +977,24 @@ else
error "$(cat $log_file)" error "$(cat $log_file)"
fi fi
echononl "\tRename the composer.json-dist file into composer.json" #echononl "\tRename the composer.json-dist file into composer.json"
cp -a "composer.json-dist" "composer.json" > $log_file 2>&1 echononl "\tProvide the 'composer.json' file .."
if [[ $? -eq 0 ]]; then if [[ ! -e "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/composer.json" ]] ; then
echo_ok if [[ ! -e "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/composer.json-dist" ]] ; then
echo_failed
error "Neither the 'composer.json-dist' file nor the 'composer.json' file' exist"
else
cp -a "composer.json-dist" "composer.json" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
fi
else else
echo_failed echo_skipped
error "$(cat $log_file)"
fi fi
echononl "\tInstall composer to ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" echononl "\tInstall composer to ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}"
@@ -1084,18 +1099,27 @@ if [[ -h "${WEBSITE_BASEDIR}/htdocs" ]]; then
else else
echo_skipped echo_skipped
fi fi
_failed=false
echononl "\tCreate Symlink for DocumentRoot Directory 'htdocs'.." echononl "\tCreate Symlink for DocumentRoot Directory 'htdocs'.."
if [[ ! -h "${WEBSITE_BASEDIR}/htdocs" ]]; then if [ "$RC_MAIN_VERSION" == "1.6" ]; then
ln -s roundcubemail-${ROUNDCUBE_VERSION} ${WEBSITE_BASEDIR}/htdocs > $log_file 2>&1 ln -s "roundcubemail-${ROUNDCUBE_VERSION}" "${WEBSITE_BASEDIR}/htdocs" >> $log_file 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -ne 0 ]]; then
echo_ok _failed=true
else
echo_failed
error "$(cat $log_file)"
fi fi
else else
echo_skipped ln -s "roundcubemail-${ROUNDCUBE_VERSION}/public_html/" "${WEBSITE_BASEDIR}/htdocs" >> $log_file 2>&1
if [[ $? -ne 0 ]]; then
_failed=true
fi
fi fi
if $_failed ; then
echo_failed
error "$(cat $log_file)"
else
echo_ok
fi
if $SKIN_LOGO_PRESENT ; then if $SKIN_LOGO_PRESENT ; then
_failed=false _failed=false
@@ -1768,7 +1792,6 @@ echononl "\tRestart Apache Webservice.."
if [[ -n "$APACHE_SERVICE_FILE" ]] || [[ -n "$APACHE_INIT_SCRIPT" ]] ; then if [[ -n "$APACHE_SERVICE_FILE" ]] || [[ -n "$APACHE_INIT_SCRIPT" ]] ; then
if [[ -n "$APACHE_SERVICE_FILE" ]] ; then if [[ -n "$APACHE_SERVICE_FILE" ]] ; then
systemctl restart $APACHE_SERVICE_FILE > $log_file 2>&1 systemctl restart $APACHE_SERVICE_FILE > $log_file 2>&1
echo "systemctl restart $APACHE_SERVICE_FILE > $log_file 2>&1"
else else
$APACHE_INIT_SCRIPT restart > $log_file 2>&1 $APACHE_INIT_SCRIPT restart > $log_file 2>&1
fi fi
@@ -1935,10 +1958,15 @@ else
echo_skipped echo_skipped
fi fi
if [ "$RC_MAIN_VERSION" == "1.6" ]; then
INSTALLER_URL="https://${WEBSITE_NAME}/installer"
else
INSTALLER_URL="https://${WEBSITE_NAME}/installer.php"
fi
info "Now browse to the intaller site and continue installation.\n$(cat <<EOF info "Now browse to the intaller site and continue installation.\n$(cat <<EOF
Browse to site: \033[1mhttps://${WEBSITE_NAME}/installer\033[m Browse to site: \033[1m${INSTALLER_URL}\033[m
Maybe you want to change some values as follows Maybe you want to change some values as follows
@@ -1971,7 +1999,14 @@ info "Now browse to the intaller site and continue installation.\n$(cat <<EOF
Display settings & user prefs: Display settings & user prefs:
language...............: de_DE language...............: de_DE
skin...................: larry skin...................: elastic
After you've adjusted the values, save the configuration file created by the installer
to the /tmp directory, and then copy it to the configuration directory of the Roundube
installation:
\033[1;33mDcp /tmp/config.inc.php ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/config/\033[0m
EOF EOF
)" )"
@@ -2151,7 +2186,8 @@ fi
echononl "\tInstall needed debian packages.." echononl "\tInstall needed debian packages.."
needed_packages_spell="" declare -a needed_packages_spell_arr=()
_failed=false
_needed_packages_spell=" _needed_packages_spell="
aspell-en aspell-en
aspell-de aspell-de
@@ -2164,21 +2200,33 @@ for _pkg in $_needed_packages_spell ; do
if aptitude search "$_pkg" | grep " $_pkg " | grep -e "^i" > /dev/null 2>&1 ; then if aptitude search "$_pkg" | grep " $_pkg " | grep -e "^i" > /dev/null 2>&1 ; then
continue continue
else else
needed_packages_spell="$needed_packages_spell $_pkg" needed_packages_spell_arr+=("$_pkg")
fi fi
done done
if [[ -n "$needed_packages_spell" ]]; then > "$log_file"
DEBIAN_FRONTEND=noninteractive apt-get -y install $needed_packages_spell > /dev/null 2> "$log_file" if [[ ${#needed_packages_spell_arr[@]} -gt 0 ]]; then
if [[ $? -eq 0 ]] ; then for _pkg in ${needed_packages_spell_arr[@]} ; do
echo_ok
else DEBIAN_FRONTEND=noninteractive apt-get -y install "$_pkg" >> "$log_file" 2>&1
if [[ $? -gt 0 ]] ; then
_failed=true
fi
done
if $_failed ; then
echo_failed echo_failed
error "$(cat $log_file)" error "$(cat $log_file)"
else
echo_ok
fi fi
else else
echo_skipped echo_skipped
fi fi
echononl "\tAdjust Roundcube Configuration for specclchecking" echononl "\tAdjust Roundcube Configuration for specclchecking"
cat <<EOF >>$WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/config/config.inc.php 2> $log_file cat <<EOF >>$WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/config/config.inc.php 2> $log_file
+604 -79
View File
@@ -149,6 +149,24 @@ detect_os_1 () {
} }
# ---
# - Helper functions to edit dovecot's configuration files
# ---
# -
# - !! These functions require GNU awk (gawk) !!
# -
# - They use GNU awk extensions (e.g. '\s' in regular expressions). Therefore
# - 'gawk' is called explicitly - not 'awk'. On Debian 'awk' is usually 'mawk',
# - which does NOT support these extensions: blocks would silently not be
# - found, so nothing gets replaced/deleted, or blocks are appended a second
# - time instead of being replaced.
# -
# - gawk is installed (if missing) before dovecot is configured - see
# - "Check / install GNU awk (gawk)".
# -
# - Simple awk calls elsewhere (e.g. "awk '{print $1}'") only use POSIX awk
# - features and keep using 'awk'.
# -
replace_code_block() { replace_code_block() {
local block_name="$1" local block_name="$1"
local new_block="$2" local new_block="$2"
@@ -168,7 +186,7 @@ replace_code_block() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" -v new_block="$new_block" ' gawk -v block_name="$block_name" -v new_block="$new_block" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
for (i = 1; i <= length(str); i++) { for (i = 1; i <= length(str); i++) {
@@ -222,7 +240,7 @@ replace_or_append_code_block() {
local block_found=0 local block_found=0
awk -v block_name="$block_name" -v new_block="$new_block" ' gawk -v block_name="$block_name" -v new_block="$new_block" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
for (i = 1; i <= length(str); i++) { for (i = 1; i <= length(str); i++) {
@@ -333,7 +351,7 @@ replace_or_append_code_block_if_keyval() {
local block_found=0 local block_found=0
awk -v block_name="$block_name" -v new_block="$new_block" \ gawk -v block_name="$block_name" -v new_block="$new_block" \
-v req_key="$required_key" -v req_val="$required_value" ' -v req_key="$required_key" -v req_val="$required_value" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
@@ -450,7 +468,7 @@ replace_code_block_if_keyval() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" -v new_block="$new_block" \ gawk -v block_name="$block_name" -v new_block="$new_block" \
-v req_key="$required_key" -v req_val="$required_value" ' -v req_key="$required_key" -v req_val="$required_value" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
@@ -555,7 +573,7 @@ replace_or_append_code_block_if_keyval_strict() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" -v new_block="$new_block" \ gawk -v block_name="$block_name" -v new_block="$new_block" \
-v req_key="$required_key" -v req_val="$required_value" ' -v req_key="$required_key" -v req_val="$required_value" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
@@ -660,7 +678,7 @@ delete_code_block() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" ' gawk -v block_name="$block_name" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
for (i = 1; i <= length(str); i++) { for (i = 1; i <= length(str); i++) {
@@ -710,7 +728,7 @@ delete_code_block_with_comments() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" ' gawk -v block_name="$block_name" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
for (i = 1; i <= length(str); i++) { for (i = 1; i <= length(str); i++) {
@@ -782,7 +800,7 @@ replace_variable() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v var_name="$var_name" -v new_value="$new_value" ' gawk -v var_name="$var_name" -v new_value="$new_value" '
BEGIN { BEGIN {
replaced = 0 replaced = 0
} }
@@ -840,7 +858,7 @@ replace_or_append_variable() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v var_name="$var_name" -v new_value="$new_value" ' gawk -v var_name="$var_name" -v new_value="$new_value" '
BEGIN { replaced = 0 } BEGIN { replaced = 0 }
{ {
@@ -894,7 +912,7 @@ delete_variable() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v var_name="$var_name" ' gawk -v var_name="$var_name" '
# match: key = val, key=val, key val # match: key = val, key=val, key val
!($0 ~ "^[[:space:]]*" var_name "[[:space:]]*(=|[^[:alnum:]#])") { !($0 ~ "^[[:space:]]*" var_name "[[:space:]]*(=|[^[:alnum:]#])") {
print print
@@ -923,7 +941,7 @@ delete_variable_with_comments() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v var_name="$var_name" ' gawk -v var_name="$var_name" '
{ {
lines[NR] = $0 lines[NR] = $0
@@ -961,6 +979,132 @@ delete_variable_with_comments() {
} }
# ---
# - Mail services (dovecot protocols)
# ---
# - Known (selectable) mail services - in canonical order.
# -
# - imap - IMAP (143) and IMAPS (993)
# - pop3 - POP3 (110) and POP3S (995)
# - sieve - ManageSieve (4190)
# -
# - Note:
# - 'lmtp' is NOT part of this list. LMTP is needed for delivering mail from
# - postfix into the mailboxes and is therefore always enabled.
# -
KNOWN_MAIL_PROTOCOLS="imap pop3 sieve"
# - Mail services (dovecot protocols), which are ALWAYS disabled.
# -
# - submission - Dovecot's SMTP submission service (587 / 465)
# -
# - In this mailsystem submission (587) and submissions (465)
# - are provided by postfix. Dovecot's submission service would
# - collide with postfix (same ports) and also would need a
# - relay configuration (submission_relay_host, ..), which is
# - not done by this script.
# -
# - These protocols are explicitly set to 'no' in the 'protocols' block of
# - dovecot.conf and the corresponding 'service' blocks are removed from
# - 10-master.conf.
# -
DISABLED_MAIL_PROTOCOLS="submission"
# - Predefined selections of the menu entries [1] and [2]
# -
MAIL_PROTOCOLS_ALL="imap pop3 sieve"
MAIL_PROTOCOLS_ALL_BUT_POP3="imap sieve"
# - normalize_mail_protocols <list of mail services>
# -
# - Normalizes a blank (or comma) separated list of mail services and prints
# - the result to stdout:
# -
# - - all lowercase
# - - 'lmtp' is removed (always enabled anyway)
# - - unknown entries are removed (see unknown_mail_protocols())
# - - duplicates are removed
# - - sorted in canonical order (see KNOWN_MAIL_PROTOCOLS)
# -
# - Example:
# - normalize_mail_protocols "Sieve,IMAP lmtp imap" --> "imap sieve"
# -
normalize_mail_protocols() {
local _list="${1,,}"
local _known
local _entry
local _result=""
# - Commas are allowed as separator as well
# -
_list="${_list//,/ }"
# - Walk through the known services (canonical order) and take each one,
# - which is part of the given list. So duplicates and unknown entries
# - vanish automatically.
# -
for _known in ${KNOWN_MAIL_PROTOCOLS} ; do
for _entry in ${_list} ; do
if [[ "${_entry}" = "${_known}" ]] ; then
_result="${_result} ${_known}"
break
fi
done
done
# - Remove leading blank
# -
echo "${_result# }"
}
# - unknown_mail_protocols <list of mail services>
# -
# - Prints all entries of the given (blank or comma separated) list, which are
# - neither part of KNOWN_MAIL_PROTOCOLS nor 'lmtp'. Prints nothing if all
# - entries are known.
# -
unknown_mail_protocols() {
local _list="${1,,}"
local _entry
local _result=""
_list="${_list//,/ }"
for _entry in ${_list} ; do
# - 'lmtp' is always enabled - so its ok to be listed here
# -
[[ "${_entry}" = "lmtp" ]] && continue
if [[ ! " ${KNOWN_MAIL_PROTOCOLS} " =~ " ${_entry} " ]] ; then
_result="${_result} ${_entry}"
fi
done
echo "${_result# }"
}
# - mail_protocol_enabled <service>
# -
# - Returns 0 (true) if the given service is part of the (normalized) list
# - in variable 'mail_protocols', otherwise 1 (false).
# -
# - Example:
# - if mail_protocol_enabled pop3 ; then
# - ...
# - fi
# -
mail_protocol_enabled() {
[[ " ${mail_protocols} " =~ " ${1,,} " ]]
}
# - Support systemd ? # - Support systemd ?
# - # -
@@ -1093,8 +1237,31 @@ fi
[[ -n "$max_userip_connections" ]] || max_userip_connections=24 [[ -n "$max_userip_connections" ]] || max_userip_connections=24
[[ -n "$auth_mechanisms" ]] || auth_mechanisms="plain login" [[ -n "$auth_mechanisms" ]] || auth_mechanisms="plain login"
[[ -n "$mail_log" ]] || mail_log=true
[[ -n "$mail_log_events" ]] || mail_log_events="copy save expunge delete undelete mailbox_create mailbox_delete mailbox_rename"
[[ -n "$mail_log_fields" ]] || mail_log_fields="uid box msgid from subject"
[[ -n "$service_limit_nofile" ]] || service_limit_nofile=524280 [[ -n "$service_limit_nofile" ]] || service_limit_nofile=524280
# - Mail services (dovecot protocols) to provide
# -
# - Parameter 'mail_protocols' (configuration file) defaults to
# - "imap pop3 sieve" (= menu entry [1]).
# -
# - The (normalized) value determines, which line of the selection menu
# - will be highlighted (see below "Mail services (dovecot protocols)").
# -
[[ -n "$mail_protocols" ]] || mail_protocols="${MAIL_PROTOCOLS_ALL}"
_unknown="$(unknown_mail_protocols "${mail_protocols}")"
if [[ -n "${_unknown}" ]] ; then
fatal "Wrong value(s) for parameter 'mail_protocols' (${_unknown}). Only '${KNOWN_MAIL_PROTOCOLS}' is allowed."
fi
mail_protocols="$(normalize_mail_protocols "${mail_protocols}")"
if [[ -z "${mail_protocols}" ]] ; then
fatal "Parameter 'mail_protocols' contains no mail service. At least one of '${KNOWN_MAIL_PROTOCOLS}' is required."
fi
[[ -n "${vmail_uid}" ]] || vmail_uid=${DEFAULT_VMAIL_UID} [[ -n "${vmail_uid}" ]] || vmail_uid=${DEFAULT_VMAIL_UID}
[[ -n "${vmail_gid}" ]] || vmail_gid=${DEFAULT_VMAIL_GID} [[ -n "${vmail_gid}" ]] || vmail_gid=${DEFAULT_VMAIL_GID}
@@ -1239,6 +1406,152 @@ while [[ "$update" != "true" && "$update" != "false" ]] ; do
done done
# -------------
# - Mail services (dovecot protocols)
# -------------
# - Which line of the menu is highlighted (default for <RETURN>)?
# -
# - mail_protocols (configuration file) highlighted menu entry
# - ----------------------------------- ----------------------
# - "imap pop3 sieve" (or not set) [1] all common mail services
# - "imap sieve" [2] all except pop3
# - anything else [3] other
# -
# - Note:
# - 'mail_protocols' is already normalized here (see "Some defaults if
# - missing"), so the order of the entries in the configuration file
# - doesn't matter.
# -
if [[ "${mail_protocols}" = "${MAIL_PROTOCOLS_ALL}" ]] ; then
_default_mail_protocols_choice=1
elif [[ "${mail_protocols}" = "${MAIL_PROTOCOLS_ALL_BUT_POP3}" ]] ; then
_default_mail_protocols_choice=2
else
_default_mail_protocols_choice=3
fi
# - Value offered as default for the follow-up input of menu entry [3]
# -
# - Only if the configuration file contains an individual list (not the one
# - of [1] or [2]), this list is offered. Otherwise an explicit input is
# - required.
# -
if [[ ${_default_mail_protocols_choice} -eq 3 ]] ; then
_preset_mail_protocols="${mail_protocols}"
else
_preset_mail_protocols=""
fi
# - The menu lines
# -
_mail_protocols_menu[1]="[1] All common mail services ........: ${MAIL_PROTOCOLS_ALL}"
_mail_protocols_menu[2]="[2] All common except pop3 ..........: ${MAIL_PROTOCOLS_ALL_BUT_POP3}"
if [[ -n "${_preset_mail_protocols}" ]] ; then
_mail_protocols_menu[3]="[3] Other ...........................: ${_preset_mail_protocols}"
else
_mail_protocols_menu[3]="[3] Other (explicit input)"
fi
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Which mail services (dovecot protocols) should be provided?"
echo ""
echo -e " \033[33mNote\033[m: LMTP (delivery postfix --> mailboxes) is always enabled."
echo ""
echo ""
for _i in 1 2 3 ; do
if [[ ${_i} -eq ${_default_mail_protocols_choice} ]] ; then
echo -e "\033[37m\033[1m${_mail_protocols_menu[${_i}]}\033[m"
else
echo "${_mail_protocols_menu[${_i}]}"
fi
done
echo ""
echononl "Choose a number or press <RETURN> for highlighted value: "
_mail_protocols_choice=""
while [[ -z "${_mail_protocols_choice}" ]] ; do
read OPTION
case $OPTION in
1|2|3) _mail_protocols_choice=$OPTION
;;
'') _mail_protocols_choice=${_default_mail_protocols_choice}
;;
*) echo ""
echo -e "\tWrong entry! [ 1 = all common ; 2 = all except pop3 ; 3 = other ] or type <RETURN>"
echo ""
echononl "Reentry: "
;;
esac
done
case ${_mail_protocols_choice} in
1) mail_protocols="${MAIL_PROTOCOLS_ALL}"
;;
2) mail_protocols="${MAIL_PROTOCOLS_ALL_BUT_POP3}"
;;
3) # - Follow-up input: list of mail services
# -
# - - preset with the value from the configuration file, if that value
# - is an individual list --> <RETURN> takes the preset
# - - otherwise an explicit input is required
# -
echo ""
echo " Enter a blank separated list of mail services to provide."
echo ""
echo -e " Possible values: \033[1m${KNOWN_MAIL_PROTOCOLS}\033[m"
echo ""
echo -e " \033[33mNote\033[m: 'submission' (587/465) is provided by postfix - not by dovecot."
echo ""
_new_mail_protocols=""
while [[ -z "${_new_mail_protocols}" ]] ; do
if [[ -n "${_preset_mail_protocols}" ]] ; then
echononl "Mail services [${_preset_mail_protocols}]: "
else
echononl "Mail services: "
fi
read _input
# - <RETURN> (or only blanks) --> take preset (if any)
# -
if [[ -z "${_input//[[:space:]]/}" ]] ; then
if [[ -n "${_preset_mail_protocols}" ]] ; then
_new_mail_protocols="${_preset_mail_protocols}"
else
echo -e "\n\t\033[33m\033[1mAt least one mail service is required!\033[m\n"
fi
continue
fi
# - Unknown entries?
# -
_unknown="$(unknown_mail_protocols "${_input}")"
if [[ -n "${_unknown}" ]] ; then
echo -e "\n\t\033[33m\033[1mUnknown mail service(s): ${_unknown}\033[m"
echo -e "\t\033[33m\033[1mPossible values: ${KNOWN_MAIL_PROTOCOLS}\033[m\n"
continue
fi
# - Normalize (sort, remove duplicates and 'lmtp')
# -
_new_mail_protocols="$(normalize_mail_protocols "${_input}")"
if [[ -z "${_new_mail_protocols}" ]] ; then
echo -e "\n\t\033[33m\033[1mAt least one mail service (besides lmtp) is required!\033[m\n"
fi
done
mail_protocols="${_new_mail_protocols}"
;;
esac
# ------------- # -------------
@@ -1268,12 +1581,48 @@ echo ""
echo -e "\tIPv4 address..................: $ipv4" echo -e "\tIPv4 address..................: $ipv4"
echo -e "\tIPv6 address..................: $ipv6" echo -e "\tIPv6 address..................: $ipv6"
echo "" echo ""
echo -e "\tIMAP listener addresses.......: $imap_listener_adresses"
echo -e "\tIMAPS listener addresses......: $imaps_listener_adresses" # - Mail services (dovecot protocols) to activate
echo "" # -
echo -e "\tPOP3 listener addresses.......: $pop_listener_adresses" # - Each protocol is listed with its state. Enabled protocols are highlighted.
echo -e "\tPOP3S listener addresses......: $pops_listener_adresses" # -
# - 'lmtp' is always enabled, the protocols of DISABLED_MAIL_PROTOCOLS
# - (submission) are always disabled.
# -
echo -e "\tMail services (protocols) to activate:"
echo -e "\t lmtp.......................: \033[1myes\033[m (always - delivery postfix --> mailboxes)"
for _protocol in ${KNOWN_MAIL_PROTOCOLS} ; do
# - Fill up the protocol name with dots (column width as used above)
# -
_label="${_protocol}..........................."
_label="${_label:0:27}"
if mail_protocol_enabled "${_protocol}" ; then
echo -e "\t ${_label}: \033[1myes\033[m"
else
echo -e "\t ${_label}: no"
fi
done
for _protocol in ${DISABLED_MAIL_PROTOCOLS} ; do
_label="${_protocol}..........................."
_label="${_label:0:27}"
echo -e "\t ${_label}: no (provided by postfix)"
done
echo "" echo ""
# - Listener addresses only for the enabled protocols
# -
if mail_protocol_enabled imap ; then
echo -e "\tIMAP listener addresses.......: $imap_listener_adresses"
echo -e "\tIMAPS listener addresses......: $imaps_listener_adresses"
echo ""
fi
if mail_protocol_enabled pop3 ; then
echo -e "\tPOP3 listener addresses.......: $pop_listener_adresses"
echo -e "\tPOP3S listener addresses......: $pops_listener_adresses"
echo ""
fi
echo -e "\tPostfix Configuration File....: $postfix_main_cf" echo -e "\tPostfix Configuration File....: $postfix_main_cf"
echo "" echo ""
echo -e "\tDatenbank.....................: $database" echo -e "\tDatenbank.....................: $database"
@@ -1303,6 +1652,12 @@ echo ""
echo -e "\tSpan folder...................: $spam_folder" echo -e "\tSpan folder...................: $spam_folder"
echo -e "\tMax user connections per ip...: $max_userip_connections" echo -e "\tMax user connections per ip...: $max_userip_connections"
echo "" echo ""
echo -e "\tLog mail actions (mail_log)...: $mail_log"
if $mail_log ; then
echo -e "\t mail_log_events............: $mail_log_events"
echo -e "\t mail_log_fields............: $mail_log_fields"
fi
echo ""
echo -e "\tAuth Listener (Jabber)........: $xmpp_listener" echo -e "\tAuth Listener (Jabber)........: $xmpp_listener"
if $xmpp_listener ; then if $xmpp_listener ; then
echo -e "\t Auth Listener Addresses....: $xmpp_listener_addresses" echo -e "\t Auth Listener Addresses....: $xmpp_listener_addresses"
@@ -1443,6 +1798,24 @@ detect_os_1 () {
} }
# ---
# - Helper functions to edit dovecot's configuration files
# ---
# -
# - !! These functions require GNU awk (gawk) !!
# -
# - They use GNU awk extensions (e.g. '\s' in regular expressions). Therefore
# - 'gawk' is called explicitly - not 'awk'. On Debian 'awk' is usually 'mawk',
# - which does NOT support these extensions: blocks would silently not be
# - found, so nothing gets replaced/deleted, or blocks are appended a second
# - time instead of being replaced.
# -
# - gawk is installed (if missing) before dovecot is configured - see
# - "Check / install GNU awk (gawk)".
# -
# - Simple awk calls elsewhere (e.g. "awk '{print $1}'") only use POSIX awk
# - features and keep using 'awk'.
# -
replace_code_block() { replace_code_block() {
local block_name="$1" local block_name="$1"
local new_block="$2" local new_block="$2"
@@ -1462,7 +1835,7 @@ replace_code_block() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" -v new_block="$new_block" ' gawk -v block_name="$block_name" -v new_block="$new_block" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
for (i = 1; i <= length(str); i++) { for (i = 1; i <= length(str); i++) {
@@ -1516,7 +1889,7 @@ replace_or_append_code_block() {
local block_found=0 local block_found=0
awk -v block_name="$block_name" -v new_block="$new_block" ' gawk -v block_name="$block_name" -v new_block="$new_block" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
for (i = 1; i <= length(str); i++) { for (i = 1; i <= length(str); i++) {
@@ -1627,7 +2000,7 @@ replace_or_append_code_block_if_keyval() {
local block_found=0 local block_found=0
awk -v block_name="$block_name" -v new_block="$new_block" \ gawk -v block_name="$block_name" -v new_block="$new_block" \
-v req_key="$required_key" -v req_val="$required_value" ' -v req_key="$required_key" -v req_val="$required_value" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
@@ -1744,7 +2117,7 @@ replace_code_block_if_keyval() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" -v new_block="$new_block" \ gawk -v block_name="$block_name" -v new_block="$new_block" \
-v req_key="$required_key" -v req_val="$required_value" ' -v req_key="$required_key" -v req_val="$required_value" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
@@ -1849,7 +2222,7 @@ replace_or_append_code_block_if_keyval_strict() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" -v new_block="$new_block" \ gawk -v block_name="$block_name" -v new_block="$new_block" \
-v req_key="$required_key" -v req_val="$required_value" ' -v req_key="$required_key" -v req_val="$required_value" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
@@ -1954,7 +2327,7 @@ delete_code_block() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" ' gawk -v block_name="$block_name" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
for (i = 1; i <= length(str); i++) { for (i = 1; i <= length(str); i++) {
@@ -2004,7 +2377,7 @@ delete_code_block_with_comments() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v block_name="$block_name" ' gawk -v block_name="$block_name" '
function count_char(str, c) { function count_char(str, c) {
n = 0 n = 0
for (i = 1; i <= length(str); i++) { for (i = 1; i <= length(str); i++) {
@@ -2076,7 +2449,7 @@ replace_variable() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v var_name="$var_name" -v new_value="$new_value" ' gawk -v var_name="$var_name" -v new_value="$new_value" '
BEGIN { BEGIN {
replaced = 0 replaced = 0
} }
@@ -2134,7 +2507,7 @@ replace_or_append_variable() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v var_name="$var_name" -v new_value="$new_value" ' gawk -v var_name="$var_name" -v new_value="$new_value" '
BEGIN { replaced = 0 } BEGIN { replaced = 0 }
{ {
@@ -2188,7 +2561,7 @@ delete_variable() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v var_name="$var_name" ' gawk -v var_name="$var_name" '
# match: key = val, key=val, key val # match: key = val, key=val, key val
!($0 ~ "^[[:space:]]*" var_name "[[:space:]]*(=|[^[:alnum:]#])") { !($0 ~ "^[[:space:]]*" var_name "[[:space:]]*(=|[^[:alnum:]#])") {
print print
@@ -2217,7 +2590,7 @@ delete_variable_with_comments() {
local tmp_file local tmp_file
tmp_file=$(mktemp) tmp_file=$(mktemp)
awk -v var_name="$var_name" ' gawk -v var_name="$var_name" '
{ {
lines[NR] = $0 lines[NR] = $0
@@ -2293,6 +2666,10 @@ echo "pops_listener_adresses=\"${pops_listener_adresses}\"" >> ${INSTALL_UPDATE_
echo "" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} echo "" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "mail_protocols=\"${mail_protocols}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "xmpp_listener=${xmpp_listener}" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} echo "xmpp_listener=${xmpp_listener}" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
if $xmpp_listener ; then if $xmpp_listener ; then
echo "xmpp_listener_addresses=\"${xmpp_listener_addresses}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} echo "xmpp_listener_addresses=\"${xmpp_listener_addresses}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
@@ -2337,6 +2714,10 @@ echo "" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "spam_folder=\"${spam_folder}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} echo "spam_folder=\"${spam_folder}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "max_userip_connections"=${max_userip_connections} >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} echo "max_userip_connections"=${max_userip_connections} >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "mail_log=${mail_log}" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "mail_log_events=\"${mail_log_events}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "mail_log_fields=\"${mail_log_fields}\"" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
echo "plugin_expire=${plugin_expire}" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} echo "plugin_expire=${plugin_expire}" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
#echo "" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE} #echo "" >> ${INSTALL_UPDATE_ENVIRONMENT_FILE}
@@ -2613,31 +2994,66 @@ dovecot_pigeonhole_archiv_prefix="${dovecot_pigeonhole_archiv%.tar.gz}"
dovecot_pigeonhole_archiv_dir="${dovecot_pigeonhole_archiv%.tar.gz}" dovecot_pigeonhole_archiv_dir="${dovecot_pigeonhole_archiv%.tar.gz}"
## - Check / install GNU awk (gawk)
## -
## - Required for update AND new installation: the helper functions which
## - edit dovecot's configuration files (replace_code_block,
## - delete_code_block_with_comments, replace_variable, ..) call 'gawk'
## - explicitly (see "Helper functions to edit dovecot's configuration files").
## -
## - Without gawk these functions would empty the configuration files
## - (command not found --> empty output). So abort here, if gawk cannot be
## - installed.
## -
echo ""
echo -e "\033[1mCheck required tools\033[m.."
echononl " Installing gawk (GNU awk).."
if ! command -v gawk > /dev/null 2>&1 ; then
apt-get install -y gawk > "${log_file}" 2>&1
if [[ $? -eq 0 ]] && command -v gawk > /dev/null 2>&1 ; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "$(cat "${log_file}")"
fatal "Installing debian package 'gawk' failed - but gawk is required!"
fi
else
echo -e "$rc_skipped"
fi
if $_new ; then if $_new ; then
## - Install reqired debian packages ## - Install reqired debian packages
## - ## -
echo "" echo ""
echo -e "\033[1mInstalling required debian packages\033[m.." echo -e "\033[1mInstalling required debian packages\033[m.."
# - Note:
# - - '-y' : no interactive confirmation (output goes into the
# - log file, so a prompt would not be visible)
# - - '>> .. 2>&1' : stdout AND stderr into the log file
# - - 'dpkg -l .. 2>/dev/null' : suppress "no packages found .." message
# - if the package is not installed
# -
echononl " Installing libpq5 libpq-dev .." echononl " Installing libpq5 libpq-dev .."
if ! dpkg -l libpq-dev | grep -e "^ii" | grep libpq-dev > /dev/null ; then if ! dpkg -l libpq-dev 2>/dev/null | grep -e "^ii" | grep libpq-dev > /dev/null ; then
apt-get install libpq5 libpq-dev > ${_log_dir}/debian-install.log 2&>1 apt-get install -y libpq5 libpq-dev >> "${_log_dir}/debian-install.log" 2>&1
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 "installing debian package(s) failed" fatal "installing debian package(s) failed - see '${_log_dir}/debian-install.log'"
fi fi
else else
echo -e "$rc_skipped" echo -e "$rc_skipped"
fi fi
echononl " Installing libkrb5-dev .." echononl " Installing libkrb5-dev .."
if ! dpkg -l libkrb5-dev | grep -e "^ii" | grep libkrb5-dev > /dev/null ; then if ! dpkg -l libkrb5-dev 2>/dev/null | grep -e "^ii" | grep libkrb5-dev > /dev/null ; then
apt-get install libkrb5-dev >> ${_log_dir}/debian-install.log 2&>1 apt-get install -y libkrb5-dev >> "${_log_dir}/debian-install.log" 2>&1
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 "installing debian package(s) failed" fatal "installing debian package(s) failed - see '${_log_dir}/debian-install.log'"
fi fi
else else
echo -e "$rc_skipped" echo -e "$rc_skipped"
@@ -3410,7 +3826,7 @@ echononl " Add /usr/local/dovecot/bin to PATH variable.."
if grep -Eq '^\s*checkdir="?/usr/local/dovecot/bin"?$' "${_file}"; then if grep -Eq '^\s*checkdir="?/usr/local/dovecot/bin"?$' "${_file}"; then
echo -e "$rc_skipped" echo -e "$rc_skipped"
else else
cp "${_file}" "/tmp/etc_profile.${backup_date}" > "${log_file}" 2<&1 cp "${_file}" "/tmp/etc_profile.${backup_date}" > "${log_file}" 2>&1
if [[ $? -gt 0 ]] ; then if [[ $? -gt 0 ]] ; then
echo -e "$rc_failed" echo -e "$rc_failed"
error "$(cat $log_file)" error "$(cat $log_file)"
@@ -3447,7 +3863,7 @@ fi
echononl " Copy Manpages if not exists.." echononl " Copy Manpages if not exists.."
## - Manpages ## - Manpages
## - ## -
if ! grep /usr/local/dovecot/share/man /etc/manpath.config > /dev/null 2<&1 ; then if ! grep /usr/local/dovecot/share/man /etc/manpath.config > /dev/null 2>&1 ; then
echo >> /etc/manpath.config echo >> /etc/manpath.config
echo "MANDATORY_MANPATH /usr/local/dovecot/share/man /var/cache/man" >> /etc/manpath.config echo "MANDATORY_MANPATH /usr/local/dovecot/share/man /var/cache/man" >> /etc/manpath.config
echo "MANPATH_MAP /usr/local/dovecot/bin /usr/local/dovecot/share/man" >> /etc/manpath.config echo "MANPATH_MAP /usr/local/dovecot/bin /usr/local/dovecot/share/man" >> /etc/manpath.config
@@ -3477,7 +3893,7 @@ cd ${dovecot_pigeonhole_archiv_dir}
echononl " Configure Pigeonhole ManageSieve.." echononl " Configure Pigeonhole ManageSieve.."
./configure \ ./configure \
--prefix=/usr/local/dovecot-${_version} \ --prefix=/usr/local/dovecot-${_version} \
--with-dovecot=/usr/local/dovecot-${_version}/lib/dovecot > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-configure.log 2<&1 --with-dovecot=/usr/local/dovecot-${_version}/lib/dovecot > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-configure.log 2>&1
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
@@ -3486,7 +3902,7 @@ else
fi fi
echononl " Compile Pigeonhole ManageSieve.." echononl " Compile Pigeonhole ManageSieve.."
make > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-make.log 2<&1 make > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-make.log 2>&1
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
@@ -3495,7 +3911,7 @@ else
fi fi
echononl " Install Pigeonhole ManageSieve.." echononl " Install Pigeonhole ManageSieve.."
make install > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-install.log 2<&1 make install > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-install.log 2>&1
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
@@ -3618,7 +4034,42 @@ if [[ $dovecot_major_version -gt 2 ]] \
echo -e "$rc_skipped" echo -e "$rc_skipped"
fi fi
_protocols_block="protocols {\n imap = yes\n lmtp = yes\n pop3 = yes\n sieve = yes\n}" # - Build 'protocols' block from the selected mail services (mail_protocols)
# -
# - - lmtp is always enabled (delivery postfix --> mailboxes)
# - - every known but NOT selected service is explicitly set to 'no'. So it
# - is guaranteed, that no protocol is enabled via dovecot's built-in
# - defaults (boolean lists are merged with the defaults).
# - - the always disabled services (DISABLED_MAIL_PROTOCOLS, e.g.
# - submission) are set to 'no' as well.
# -
# - The 'service' blocks (10-master.conf) of imap, pop3 and sieve are always
# - written. So a protocol can later be switched on/off simply by changing
# - 'yes'/'no' here and restarting dovecot.
# -
# - Example (mail_protocols="imap sieve"):
# -
# - protocols {
# - lmtp = yes
# - imap = yes
# - pop3 = no
# - sieve = yes
# - submission = no
# - }
# -
_protocols_block="protocols {\n lmtp = yes"
for _protocol in ${KNOWN_MAIL_PROTOCOLS} ; do
if mail_protocol_enabled "${_protocol}" ; then
_protocols_block="${_protocols_block}\n ${_protocol} = yes"
else
_protocols_block="${_protocols_block}\n ${_protocol} = no"
fi
done
for _protocol in ${DISABLED_MAIL_PROTOCOLS} ; do
_protocols_block="${_protocols_block}\n ${_protocol} = no"
done
_protocols_block="${_protocols_block}\n}"
if [[ -n "$ipv6" ]]; then if [[ -n "$ipv6" ]]; then
_listen="$ipv4 $ipv6" _listen="$ipv4 $ipv6"
else else
@@ -3862,7 +4313,10 @@ else
perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(listen\ ?=.*)#\1\#\# \2\n\1listen = $ipv4#g" \ perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(listen\ ?=.*)#\1\#\# \2\n\1listen = $ipv4#g" \
/usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true
fi fi
perl -i -n -p -e "s#^([ ]*)\#?\ ?(protocols\ ?=.*)#\1\#\# \2\n\1protocols = imap pop3 sieve#g" \ # - protocols: the selected mail services (mail_protocols) - lmtp is
# - enabled later on (see "Change (from lda) to lmtp-service")
# -
perl -i -n -p -e "s#^([ ]*)\#?\ ?(protocols\ ?=.*)#\1\#\# \2\n\1protocols = ${mail_protocols}#g" \
/usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true
perl -i -n -p -e "s#^([ ]*)\#?\ ?(base_dir\ ?=.*)#\1\#\# \2\n\1base_dir = /run/dovecot/\n\nstate_dir = /run/dovecot#g" \ perl -i -n -p -e "s#^([ ]*)\#?\ ?(base_dir\ ?=.*)#\1\#\# \2\n\1base_dir = /run/dovecot/\n\nstate_dir = /run/dovecot#g" \
/usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true
@@ -4270,6 +4724,7 @@ if [[ $dovecot_major_version -gt 2 ]] \
# process_min_avail = 16 # process_min_avail = 16
# } # }
# #
# # always written - pop3 is switched on/off in 'protocols' (dovecot.conf)
# service pop3-login { # service pop3-login {
# inet_listener pop3 { # inet_listener pop3 {
# address = $pop_listener_adresses # address = $pop_listener_adresses
@@ -4281,16 +4736,8 @@ if [[ $dovecot_major_version -gt 2 ]] \
# } # }
# } # }
# #
# service submission-login { # # 'service submission-login' and 'service submission' are removed:
# # # submission (587/465) is provided by postfix in this mailsystem.
# inet_listener submission {
# #port = 587
# }
#
# inet_listener submissions {
# #port = 465
# }
# }
# #
# service lmtp { # service lmtp {
# #
@@ -4321,6 +4768,7 @@ if [[ $dovecot_major_version -gt 2 ]] \
# #process_limit = 1024 # #process_limit = 1024
# } # }
# #
# # always written - pop3 is switched on/off in 'protocols' (dovecot.conf)
# service pop3 { # service pop3 {
# #
# # tell imap to do post-login lookup using a socket called "imap-postlogin" # # tell imap to do post-login lookup using a socket called "imap-postlogin"
@@ -4330,12 +4778,6 @@ if [[ $dovecot_major_version -gt 2 ]] \
# #process_limit = 1024 # #process_limit = 1024
# } # }
# #
# service submission {
#
# # Max. number of SMTP Submission processes (connections)
# #process_limit = 1024
# }
#
# service auth { # service auth {
# #
# # Auth Listener (XMPP - Jabber) # # Auth Listener (XMPP - Jabber)
@@ -4439,6 +4881,13 @@ EOF
_failed=true _failed=true
fi fi
# - service pop3-login
# -
# - Always written - also if mail service 'pop3' is not selected. Dovecot
# - only starts the services of enabled protocols (see 'protocols' block in
# - dovecot.conf). So pop3 can be switched on/off simply by setting
# - 'pop3 = yes|no' there - the service configuration is already in place.
# -
read -r -d '' NEW_BLOCK <<EOF read -r -d '' NEW_BLOCK <<EOF
service pop3-login { service pop3-login {
@@ -4459,20 +4908,14 @@ EOF
_failed=true _failed=true
fi fi
read -r -d '' NEW_BLOCK <<EOF # - service submission-login
service submission-login { # -
# - Dovecot's submission service is NOT used in this mailsystem (submission
inet_listener submission { # - is provided by postfix - see DISABLED_MAIL_PROTOCOLS). So remove an
#port = 587 # - existing block (e.g. from the shipped example configuration).
} # -
delete_code_block_with_comments "service submission-login" "${_conf_file}" >> "${log_file}" 2>&1
inet_listener submissions { if [[ $? -gt 1 ]]; then
#port = 465
}
}
EOF
replace_or_append_code_block "service submission-login" "${NEW_BLOCK}" "${_conf_file}" >> "${log_file}" 2>&1
if [[ $? -gt 0 ]]; then
_failed=true _failed=true
fi fi
@@ -4517,6 +4960,10 @@ EOF
_failed=true _failed=true
fi fi
# - service pop3
# -
# - Always written (see 'service pop3-login' above)
# -
read -r -d '' NEW_BLOCK <<EOF read -r -d '' NEW_BLOCK <<EOF
service pop3 { service pop3 {
@@ -4532,15 +4979,13 @@ EOF
_failed=true _failed=true
fi fi
read -r -d '' NEW_BLOCK <<EOF # - service submission
service submission { # -
# - Not used in this mailsystem (see DISABLED_MAIL_PROTOCOLS) - remove an
# Max. number of SMTP Submission processes (connections) # - existing block.
#process_limit = 1024 # -
} delete_code_block_with_comments "service submission" "${_conf_file}" >> "${log_file}" 2>&1
EOF if [[ $? -gt 1 ]]; then
replace_or_append_code_block "service submission" "${NEW_BLOCK}" "${_conf_file}" >> "${log_file}" 2>&1
if [[ $? -gt 0 ]]; then
_failed=true _failed=true
fi fi
@@ -9723,6 +10168,86 @@ PYEOF
fi # Dovecot 2.4+ quota_clone fi # Dovecot 2.4+ quota_clone
## -----------------------------------------------------------------
## --- mail_log plugin (Dovecot 2.4+)
## ---
## --- Logs mailbox actions (copy/move, save, expunge, delete, folder
## --- create/delete/rename). Helps to answer "where did my mail go?"
## --- (e.g. client rules moving mails into the spam folder).
## ---
## --- Every line carries the prefix imap(<user>)<pid><session>; the
## --- session id links it to the imap-login line (rip=, login time).
## ---
## --- Enabled for imap, pop3 and lmtp only - not for doveadm, otherwise
## --- cron jobs running "doveadm expunge" print a line per message.
## -----------------------------------------------------------------
if [[ $dovecot_major_version -gt 2 ]] \
|| ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then
_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/95-mail-log.conf"
if $mail_log ; then
echononl " Create '$(basename "${_conf_file}")' (mail_log plugin).."
cat <<EOF > "${_conf_file}" 2> "${log_file}"
##
## Logging of mail actions (mail_log plugin)
##
## Generated by $(basename "$0") - change settings in
## conf/$(basename "${conf_file}") (mail_log, mail_log_events,
## mail_log_fields) and rerun the script.
##
## Every line carries the prefix imap(<user>)<pid><session>
## -> the session=<...> of the matching imap-login line gives
## client IP (rip=) and login time.
##
## Only enabled for imap, pop3 and lmtp (client actions and sieve
## filing). NOT for doveadm: doveadm writes log lines to stderr, so
## cron jobs like "doveadm expunge ..." would produce output (mail)
## for every expunged message.
##
## see also: https://doc.dovecot.org/${_version}/core/plugins/mail_log.html
##
mail_log_events = ${mail_log_events}
mail_log_fields = ${mail_log_fields}
protocol imap {
mail_plugins {
notify = yes
mail_log = yes
}
}
protocol pop3 {
mail_plugins {
notify = yes
mail_log = yes
}
}
protocol lmtp {
mail_plugins {
notify = yes
mail_log = yes
}
}
EOF
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Creating file '${_conf_file}' failed!\n$(cat "${log_file}")"
fi
else
echononl " Create '$(basename "${_conf_file}")' (mail_log plugin).."
rm -f "${_conf_file}"
echo -e "$rc_skipped"
fi
fi # Dovecot 2.4+ mail_log
# In order to support extra variable "quota_rule", also userdb's and # In order to support extra variable "quota_rule", also userdb's and
# passdb's SQL query have to update # passdb's SQL query have to update
# #
+1 -1
View File
@@ -179,7 +179,7 @@ systemd_supported=false
systemd=$(which systemd) systemd=$(which systemd)
systemctl=$(which systemctl) systemctl=$(which systemctl)
if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then if [[ -n "$systemd" ]] || [[ -n "$systemctl" ]] ; then
systemd_supported=true systemd_supported=true
fi fi