Remove rspamd from recommends, replace with a global setting similar to pop3 to enable/disable antispam

This commit is contained in:
Alexandre Aubin 2024-01-14 17:12:42 +01:00
parent 1cbc30e0d5
commit 0dcecf5f47
4 changed files with 40 additions and 7 deletions

1
debian/control vendored
View file

@ -35,7 +35,6 @@ Recommends: yunohost-admin, yunohost-portal (>= 12.0)
, bash-completion, rsyslog
, unattended-upgrades
, libdbd-ldap-perl, libnet-dns-perl
, rspamd
Conflicts: iptables-persistent
, apache2
, bind9

View file

@ -447,7 +447,9 @@
"global_settings_setting_nginx_redirect_to_https_help": "Redirect HTTP requests to HTTPs by default (DO NOT TURN OFF unless you really know what you're doing!)",
"global_settings_setting_passwordless_sudo": "Allow admins to use 'sudo' without re-typing their passwords",
"global_settings_setting_pop3_enabled": "Enable POP3",
"global_settings_setting_pop3_enabled_help": "Enable the POP3 protocol for the mail server",
"global_settings_setting_pop3_enabled_help": "Enable the POP3 protocol for the mail server. POP3 is an older protocol to access mailboxes from email clients and is more lightweight, but has less features than IMAP (enabled by default)",
"global_settings_setting_antispam_enabled": "Enable antispam",
"global_settings_setting_antispam_enabled_help": "Install and configure rspamd, a spam filtering system",
"global_settings_setting_portal_theme": "Portal theme",
"global_settings_setting_portal_theme_help": "More info regarding creating custom portal themes at https://yunohost.org/theming",
"global_settings_setting_postfix_compatibility": "Postfix Compatibility",

View file

@ -108,6 +108,12 @@ name = "Email"
type = "boolean"
default = false
[email.antispam]
name = "Antispam"
[email.antispam.antispam_enabled]
type = "boolean"
default = false
[email.smtp]
name = "SMTP"
[email.smtp.smtp_allow_ipv6]

View file

@ -367,7 +367,6 @@ def reconfigure_postfix(setting_name, old_value, new_value):
@post_change_hook("pop3_enabled")
def reconfigure_dovecot(setting_name, old_value, new_value):
dovecot_package = "dovecot-pop3d"
environment = os.environ.copy()
environment.update({"DEBIAN_FRONTEND": "noninteractive"})
@ -381,7 +380,7 @@ def reconfigure_dovecot(setting_name, old_value, new_value):
"-o Dpkg::Options::=--force-confdef",
"-o Dpkg::Options::=--force-confold",
"install",
dovecot_package,
"dovecot-pop3d",
]
subprocess.call(command, env=environment)
if old_value != new_value:
@ -389,5 +388,32 @@ def reconfigure_dovecot(setting_name, old_value, new_value):
else:
if old_value != new_value:
regen_conf(names=["dovecot"])
command = ["apt-get", "-y", "remove", dovecot_package]
command = ["apt-get", "-y", "remove", "dovecot-pop3d"]
subprocess.call(command, env=environment)
@post_change_hook("antispam_enabled")
def reconfigure_rspamd(setting_name, old_value, new_value):
environment = os.environ.copy()
environment.update({"DEBIAN_FRONTEND": "noninteractive"})
# Depending on how consistent the config panel is, it may spit 1 or True or ..? ...
if new_value:
command = [
"apt-get",
"-y",
"--no-remove",
"-o Dpkg::Options::=--force-confdef",
"-o Dpkg::Options::=--force-confold",
"install",
"rspamd",
]
subprocess.call(command, env=environment)
if old_value != new_value:
regen_conf(names=["rspamd"])
else:
if old_value != new_value:
regen_conf(names=["rspamd"])
command = ["apt-get", "-y", "remove", "rspamd"]
subprocess.call(command, env=environment)