From 7491ec840cb5d73df435f9bee46ad61e1561d068 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 14 Apr 2024 12:05:58 +0200 Subject: [PATCH] bundles/dovecot: add full text indexing --- bundles/dovecot/files/dovecot-sql.conf | 1 + bundles/dovecot/files/dovecot.conf | 34 +++++++++++++++++++++----- bundles/dovecot/items.py | 7 ++++++ bundles/dovecot/metadata.py | 11 +++++++++ 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/bundles/dovecot/files/dovecot-sql.conf b/bundles/dovecot/files/dovecot-sql.conf index 86cb8db..75c06ae 100644 --- a/bundles/dovecot/files/dovecot-sql.conf +++ b/bundles/dovecot/files/dovecot-sql.conf @@ -3,3 +3,4 @@ driver = pgsql default_pass_scheme = MD5-CRYPT password_query = SELECT username as user, password FROM mailbox WHERE username = '%u' AND active = true user_query = SELECT '/var/mail/vmail/' || maildir as home, 65534 as uid, 65534 as gid FROM mailbox WHERE username = '%u' AND active = true +iterate_query = SELECT username as user FROM mailbox WHERE active = true diff --git a/bundles/dovecot/files/dovecot.conf b/bundles/dovecot/files/dovecot.conf index 9a294aa..19dea4f 100644 --- a/bundles/dovecot/files/dovecot.conf +++ b/bundles/dovecot/files/dovecot.conf @@ -40,7 +40,7 @@ login_greeting = IMAPd ready auth_mechanisms = plain login first_valid_uid = 65534 disable_plaintext_auth = yes -mail_plugins = $mail_plugins zlib old_stats +mail_plugins = $mail_plugins zlib old_stats fts fts_xapian plugin { zlib_save_level = 6 @@ -56,6 +56,15 @@ plugin { old_stats_refresh = 30 secs old_stats_track_cmds = yes + fts = xapian + fts_xapian = partial=3 full=20 + + fts_autoindex = yes + fts_enforced = yes + + # Index attachements + fts_decoder = decode2text + % if node.has_bundle('rspamd'): sieve_before = /var/mail/vmail/sieve/global/spam-global.sieve @@ -86,14 +95,19 @@ service auth { } } -service lmtp { - unix_listener /var/spool/postfix/private/dovecot-lmtp { - group = postfix - mode = 0600 - user = postfix +service decode2text { + executable = script /usr/lib/dovecot/decode2text.sh + user = dovecot + unix_listener decode2text { + mode = 0666 } } +service indexer-worker { + vsz_limit = 0 + process_limit = 0 +} + service imap { executable = imap } @@ -104,6 +118,14 @@ service imap-login { vsz_limit = 64M } +service lmtp { + unix_listener /var/spool/postfix/private/dovecot-lmtp { + group = postfix + mode = 0600 + user = postfix + } +} + service managesieve-login { inet_listener sieve { port = 4190 diff --git a/bundles/dovecot/items.py b/bundles/dovecot/items.py index 627a203..6c14a79 100644 --- a/bundles/dovecot/items.py +++ b/bundles/dovecot/items.py @@ -49,6 +49,13 @@ files = { }, } +symlinks['/usr/lib/dovecot/decode2text.sh'] = { + 'target': '/usr/share/doc/dovecot-core/examples/decode2text.sh', + 'before': { + 'svc_systemd:dovecot', + }, +} + actions = { 'dovecot_generate_dhparam': { 'command': 'openssl dhparam -out /etc/dovecot/ssl/dhparam.pem 2048', diff --git a/bundles/dovecot/metadata.py b/bundles/dovecot/metadata.py index 00ee5a4..6d126a1 100644 --- a/bundles/dovecot/metadata.py +++ b/bundles/dovecot/metadata.py @@ -3,6 +3,7 @@ from bundlewrap.metadata import atomic defaults = { 'apt': { 'packages': { + 'dovecot-fts-xapian': {}, 'dovecot-imapd': {}, 'dovecot-lmtpd': {}, 'dovecot-managesieved': {}, @@ -35,6 +36,16 @@ defaults = { 'dovecot', }, }, + 'systemd-timers': { + 'timers': { + 'dovecot_fts_optimize': { + 'command': [ + '/usr/bin/doveadm fts optimize -A', + ], + 'when': '02:{}:00'.format(node.magic_number % 60), + }, + }, + }, } if node.has_bundle('postfixadmin'):