Merge pull request #533 from modoboa/fix-prevent-old-ext-install
Prevent installation of incompatible extensions
This commit is contained in:
@@ -9,9 +9,8 @@ An installer which deploy a complete mail server based on Modoboa.
|
||||
|
||||
This tool is still in beta stage, it has been tested on:
|
||||
|
||||
* Debian Buster (10) / Bullseye (11)
|
||||
* Debian 10 and upper
|
||||
* Ubuntu Bionic Beaver (18.04) and upper
|
||||
* CentOS 7
|
||||
|
||||
.. warning::
|
||||
|
||||
@@ -93,7 +92,7 @@ You can activate it as follows::
|
||||
It will automatically install latest versions of modoboa and its plugins.
|
||||
|
||||
Backup mode
|
||||
------------
|
||||
-----------
|
||||
|
||||
An experimental backup mode is available.
|
||||
|
||||
|
||||
@@ -21,13 +21,14 @@ COMPATIBILITY_MATRIX = {
|
||||
"modoboa-sievefilters": ">=1.1.1",
|
||||
"modoboa-webmail": ">=1.2.0",
|
||||
},
|
||||
"2.1.0": {
|
||||
"modoboa-pdfcredentials": None,
|
||||
"modoboa-dmarc": None,
|
||||
"modoboa-imap-migration": None,
|
||||
},
|
||||
}
|
||||
|
||||
EXTENSIONS_AVAILABILITY = {
|
||||
"modoboa-contacts": "1.7.4",
|
||||
}
|
||||
|
||||
REMOVED_EXTENSIONS = {
|
||||
"modoboa-pdfcredentials": "2.1.0",
|
||||
"modoboa-dmarc": "2.1.0",
|
||||
"modoboa-imap-migration": "2.1.0"
|
||||
}
|
||||
|
||||
@@ -65,12 +65,16 @@ class Modoboa(base.Installer):
|
||||
|
||||
def is_extension_ok_for_version(self, extension, version):
|
||||
"""Check if extension can be installed with this modo version."""
|
||||
if extension not in compatibility_matrix.EXTENSIONS_AVAILABILITY:
|
||||
return True
|
||||
version = utils.convert_version_to_int(version)
|
||||
min_version = compatibility_matrix.EXTENSIONS_AVAILABILITY[extension]
|
||||
min_version = utils.convert_version_to_int(min_version)
|
||||
return version >= min_version
|
||||
if extension in compatibility_matrix.EXTENSIONS_AVAILABILITY:
|
||||
min_version = compatibility_matrix.EXTENSIONS_AVAILABILITY[extension]
|
||||
min_version = utils.convert_version_to_int(min_version)
|
||||
return version >= min_version
|
||||
if extension in compatibility_matrix.REMOVED_EXTENSIONS:
|
||||
max_version = compatibility_matrix.REMOVED_EXTENSIONS[extension]
|
||||
max_version = utils.convert_version_to_int(max_version)
|
||||
return version < max_version
|
||||
return True
|
||||
|
||||
def _setup_venv(self):
|
||||
"""Prepare a dedicated virtualenv."""
|
||||
@@ -80,6 +84,13 @@ class Modoboa(base.Installer):
|
||||
version = self.config.get("modoboa", "version")
|
||||
if version == "latest":
|
||||
packages += ["modoboa"] + self.extensions
|
||||
for extension in list(self.extensions):
|
||||
if extension in compatibility_matrix.REMOVED_EXTENSIONS.keys():
|
||||
self.extensions.remove(extension)
|
||||
self.extensions = [
|
||||
extension for extension in self.extensions
|
||||
if extension not in compatibility_matrix.REMOVED_EXTENSIONS
|
||||
]
|
||||
else:
|
||||
matrix = compatibility_matrix.COMPATIBILITY_MATRIX[version]
|
||||
packages.append("modoboa=={}".format(version))
|
||||
|
||||
8
run.py
8
run.py
@@ -38,6 +38,12 @@ PRIMARY_APPS = [
|
||||
def installation_disclaimer(args, config):
|
||||
"""Display installation disclaimer."""
|
||||
hostname = config.get("general", "hostname")
|
||||
utils.printcolor(
|
||||
"Notice:\n"
|
||||
"It is recommanded to run this installer on a FRESHLY installed server.\n"
|
||||
"(ie. with nothing special already installed on it)\n",
|
||||
utils.CYAN
|
||||
)
|
||||
utils.printcolor(
|
||||
"Warning:\n"
|
||||
"Before you start the installation, please make sure the following "
|
||||
@@ -48,7 +54,7 @@ def installation_disclaimer(args, config):
|
||||
hostname.replace(".{}".format(args.domain), ""),
|
||||
hostname
|
||||
),
|
||||
utils.CYAN
|
||||
utils.YELLOW
|
||||
)
|
||||
utils.printcolor(
|
||||
"Your mail server will be installed with the following components:",
|
||||
|
||||
Reference in New Issue
Block a user