App incompatibility detection, updated for 2.2.0
This commit is contained in:
@@ -37,3 +37,10 @@ REMOVED_EXTENSIONS = {
|
||||
"modoboa-radicale": "2.4.0",
|
||||
"modoboa-webmail": "2.4.0",
|
||||
}
|
||||
|
||||
APP_INCOMPATIBILITY = {
|
||||
"opendkim": ["rspamd"],
|
||||
"amavis": ["rspamd"],
|
||||
"postwhite": ["rspamd"],
|
||||
"spamassassin": ["rspamd"]
|
||||
}
|
||||
|
||||
@@ -244,11 +244,11 @@ ConfigDictTemplate = [
|
||||
"default": "/var/lib/dkim"
|
||||
},
|
||||
{
|
||||
"option": "keys_path_map",
|
||||
"option": "key_map_path",
|
||||
"default": "/var/lib/dkim/keys.path.map"
|
||||
},
|
||||
{
|
||||
"option": "selectors_path_map",
|
||||
"option": "selector_map_path",
|
||||
"default": "/var/lib/dkim/selectors.path.map"
|
||||
},
|
||||
{
|
||||
@@ -392,7 +392,7 @@ ConfigDictTemplate = [
|
||||
"values": [
|
||||
{
|
||||
"option": "enabled",
|
||||
"default": "true",
|
||||
"default": "false",
|
||||
},
|
||||
{
|
||||
"option": "config_dir",
|
||||
|
||||
@@ -3,7 +3,7 @@ autostart=true
|
||||
autorestart=true
|
||||
command=%{venv_path}/bin/python %{home_dir}/instance/manage.py rqworker dkim
|
||||
directory=%{home_dir}
|
||||
user=%{opendkim_user}
|
||||
user=%{dkim_user}
|
||||
redirect_stderr=true
|
||||
numprocs=1
|
||||
stopsignal=TERM
|
||||
|
||||
@@ -248,6 +248,7 @@ class Modoboa(base.Installer):
|
||||
"dovecot_mailboxes_owner": (
|
||||
self.config.get("dovecot", "mailboxes_owner")),
|
||||
"opendkim_user": self.config.get("opendkim", "user"),
|
||||
"dkim_user": "_rspamd" if self.config.getboolean("rspamd", "enabled") else self.config.get("opendkim", "user")
|
||||
"minutes": random.randint(1, 59),
|
||||
"hours": f"{random_hour},{random_hour+12}",
|
||||
"modoboa_2_2_or_greater": "" if self.modoboa_2_2_or_greater else "#",
|
||||
@@ -291,6 +292,15 @@ class Modoboa(base.Installer):
|
||||
if self.config.getboolean("opendkim", "enabled"):
|
||||
settings["admin"]["dkim_keys_storage_dir"] = (
|
||||
self.config.get("opendkim", "keys_storage_dir"))
|
||||
|
||||
if self.config.getboolean("rspamd", "enabled"):
|
||||
settings["admin"]["dkim_keys_storage_dir"] = (
|
||||
self.config.get("rspamd", "dkim_keys_storage_dir"))
|
||||
settings["modoboa_rspamd"]["key_map_path"] = (
|
||||
self.config.get("rspamd", "key_map_path"))
|
||||
settings["modoboa_rspamd"]["selector_map_path"] = (
|
||||
self.config.get("rspamd", "selector_map_path"))
|
||||
|
||||
settings = json.dumps(settings)
|
||||
query = (
|
||||
"UPDATE core_localconfig SET _parameters='{}'"
|
||||
|
||||
@@ -60,8 +60,7 @@ class Rspamd(base.Installer):
|
||||
|
||||
def install_config_files(self):
|
||||
"""Make sure config directory exists."""
|
||||
user = self.config.get("modoboa", "user")
|
||||
pw = pwd.getpwnam(user)
|
||||
pw = pwd.getpwnam("_rspamd")
|
||||
targets = [
|
||||
[self.app_config["dkim_keys_storage_dir"], pw[2], pw[3]]
|
||||
]
|
||||
|
||||
@@ -19,6 +19,7 @@ except ImportError:
|
||||
import ConfigParser as configparser
|
||||
|
||||
from . import config_dict_template
|
||||
from . import compatibility_matrix.APP_INCOMPATIBILITY
|
||||
|
||||
|
||||
ENV = {}
|
||||
@@ -504,3 +505,15 @@ def create_oauth2_app(app_name: str, client_id: str, config) -> tuple[str, str]:
|
||||
)
|
||||
exec_cmd(cmd)
|
||||
return client_id, client_secret
|
||||
|
||||
|
||||
def check_app_compatibility(section, config):
|
||||
"""Check that the app can be installed in regards to other enabled apps."""
|
||||
incompatible_app = []
|
||||
if section in APP_INCOMPATIBILITY.keys():
|
||||
for app in APP_INCOMPATIBILITY[section]:
|
||||
if config.getboolean(app, "enabled"):
|
||||
error(f"{section} cannont be installed if {app} is enabled. "
|
||||
"Please disable one of them.")
|
||||
incompatible_app.append(app)
|
||||
return len(incompatible_app) == 0
|
||||
|
||||
7
run.py
7
run.py
@@ -22,14 +22,13 @@ from modoboa_installer import utils
|
||||
|
||||
|
||||
PRIMARY_APPS = [
|
||||
"amavis",
|
||||
"fail2ban",
|
||||
"modoboa",
|
||||
"automx",
|
||||
"radicale",
|
||||
"uwsgi",
|
||||
"nginx",
|
||||
"opendkim",
|
||||
"rspamd",
|
||||
"postfix",
|
||||
"dovecot"
|
||||
]
|
||||
@@ -261,6 +260,7 @@ def main(input_args):
|
||||
|
||||
# Show concerned components
|
||||
components = []
|
||||
incompatible_app_detected = False
|
||||
for section in config.sections():
|
||||
if section in ["general", "database", "mysql", "postgres",
|
||||
"certificate", "letsencrypt", "backup"]:
|
||||
@@ -268,7 +268,10 @@ def main(input_args):
|
||||
if (config.has_option(section, "enabled") and
|
||||
not config.getboolean(section, "enabled")):
|
||||
continue
|
||||
incompatible_app_detected = utils.check_app_compatibility(section, config)
|
||||
components.append(section)
|
||||
if incompatible_app_detected:
|
||||
sys.exit(0)
|
||||
utils.printcolor(" ".join(components), utils.YELLOW)
|
||||
if not args.force:
|
||||
answer = utils.user_input("Do you confirm? (Y/n) ")
|
||||
|
||||
Reference in New Issue
Block a user