Made 90-sieve a template
This commit is contained in:
committed by
Antoine Nguyen
parent
38eae741bf
commit
e73d318e14
@@ -4,7 +4,6 @@ import glob
|
|||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
import shutil
|
import shutil
|
||||||
import uuid
|
|
||||||
|
|
||||||
from .. import database
|
from .. import database
|
||||||
from .. import package
|
from .. import package
|
||||||
@@ -15,6 +14,7 @@ from . import base
|
|||||||
|
|
||||||
|
|
||||||
class Dovecot(base.Installer):
|
class Dovecot(base.Installer):
|
||||||
|
|
||||||
"""Dovecot installer."""
|
"""Dovecot installer."""
|
||||||
|
|
||||||
appname = "dovecot"
|
appname = "dovecot"
|
||||||
@@ -27,9 +27,8 @@ class Dovecot(base.Installer):
|
|||||||
}
|
}
|
||||||
config_files = [
|
config_files = [
|
||||||
"dovecot.conf", "dovecot-dict-sql.conf.ext", "conf.d/10-ssl.conf",
|
"dovecot.conf", "dovecot-dict-sql.conf.ext", "conf.d/10-ssl.conf",
|
||||||
"conf.d/10-master.conf", "conf.d/20-lmtp.conf", "conf.d/10-ssl-keys.try",
|
"conf.d/10-master.conf", "conf.d/20-lmtp.conf",
|
||||||
"conf.d/dovecot-oauth2.conf.ext"
|
"conf.d/10-ssl-keys.try", "conf.d/90-sieve.conf"]
|
||||||
]
|
|
||||||
with_user = True
|
with_user = True
|
||||||
|
|
||||||
def setup_user(self):
|
def setup_user(self):
|
||||||
@@ -43,8 +42,7 @@ class Dovecot(base.Installer):
|
|||||||
_config_files = self.config_files
|
_config_files = self.config_files
|
||||||
|
|
||||||
if self.app_config["move_spam_to_junk"]:
|
if self.app_config["move_spam_to_junk"]:
|
||||||
_config_files += ["conf.d/90-sieve.conf",
|
_config_files += ["conf.d/custom_after_sieve/spam-to-junk.sieve"]
|
||||||
"conf.d/custom_after_sieve/spam-to-junk.sieve"]
|
|
||||||
|
|
||||||
return _config_files + [
|
return _config_files + [
|
||||||
"dovecot-sql-{}.conf.ext=dovecot-sql.conf.ext"
|
"dovecot-sql-{}.conf.ext=dovecot-sql.conf.ext"
|
||||||
@@ -80,7 +78,7 @@ class Dovecot(base.Installer):
|
|||||||
|
|
||||||
def get_template_context(self):
|
def get_template_context(self):
|
||||||
"""Additional variables."""
|
"""Additional variables."""
|
||||||
context = super().get_template_context()
|
context = super(Dovecot, self).get_template_context()
|
||||||
pw_mailbox = pwd.getpwnam(self.mailboxes_owner)
|
pw_mailbox = pwd.getpwnam(self.mailboxes_owner)
|
||||||
dovecot_package = {"deb": "dovecot-core", "rpm": "dovecot"}
|
dovecot_package = {"deb": "dovecot-core", "rpm": "dovecot"}
|
||||||
ssl_protocol_parameter = "ssl_protocols"
|
ssl_protocol_parameter = "ssl_protocols"
|
||||||
@@ -122,8 +120,7 @@ class Dovecot(base.Installer):
|
|||||||
"ssl_protocols": ssl_protocols,
|
"ssl_protocols": ssl_protocols,
|
||||||
"ssl_protocol_parameter": ssl_protocol_parameter,
|
"ssl_protocol_parameter": ssl_protocol_parameter,
|
||||||
"modoboa_2_2_or_greater": "" if self.modoboa_2_2_or_greater else "#",
|
"modoboa_2_2_or_greater": "" if self.modoboa_2_2_or_greater else "#",
|
||||||
"not_modoboa_2_2_or_greater": "" if not self.modoboa_2_2_or_greater else "#",
|
"not_modoboa_2_2_or_greater": "" if not self.modoboa_2_2_or_greater else "#"
|
||||||
"oauth2_introspection_url": oauth2_introspection_url
|
|
||||||
})
|
})
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@@ -153,7 +150,7 @@ class Dovecot(base.Installer):
|
|||||||
# See https://github.com/modoboa/modoboa/issues/2157.
|
# See https://github.com/modoboa/modoboa/issues/2157.
|
||||||
if self.app_config["move_spam_to_junk"]:
|
if self.app_config["move_spam_to_junk"]:
|
||||||
# Compile sieve script
|
# Compile sieve script
|
||||||
sieve_file = "/etc/dovecot/conf.d/custom_after_sieve/spam-to-junk.sieve"
|
sieve_file = f"{self.config_dir}/conf.d/custom_after_sieve/spam-to-junk.sieve"
|
||||||
utils.exec_cmd(f"/usr/bin/sievec {sieve_file}")
|
utils.exec_cmd(f"/usr/bin/sievec {sieve_file}")
|
||||||
system.add_user_to_group(self.mailboxes_owner, 'dovecot')
|
system.add_user_to_group(self.mailboxes_owner, 'dovecot')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user