Skip to content

Commit

Permalink
Merge pull request #533 from modoboa/fix-prevent-old-ext-install
Browse files Browse the repository at this point in the history
Prevent installation of incompatible extensions
  • Loading branch information
tonioo authored Apr 24, 2024
2 parents 3a498b7 + c069f7e commit ea26a6d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
9 changes: 4 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ 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::

``/tmp`` partition must be mounted without the ``noexec`` option.

.. note::
Expand Down Expand Up @@ -92,8 +91,8 @@ You can activate it as follows::

It will automatically install latest versions of modoboa and its plugins.

Backup mode
------------
Backup mode
-----------

An experimental backup mode is available.

Expand Down
11 changes: 6 additions & 5 deletions modoboa_installer/compatibility_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
"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"
}
21 changes: 16 additions & 5 deletions modoboa_installer/scripts/modoboa.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ def __init__(self, *args, **kwargs):

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."""
Expand All @@ -80,6 +84,13 @@ def _setup_venv(self):
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))
Expand Down
8 changes: 7 additions & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
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 "
Expand All @@ -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:",
Expand Down

0 comments on commit ea26a6d

Please sign in to comment.