Few updates

This commit is contained in:
Antoine Nguyen
2024-04-24 08:28:56 +02:00
parent 68ecf77045
commit 18369e238c
5 changed files with 25 additions and 27 deletions

View File

@@ -165,19 +165,17 @@ Certificate
Self-signed
-----------
It is the default way of the installer, it is however
not recommended for production use. We recommend using
letsencrypt for production. Using Letsencrypt imply that
you accept their Tos (see bellow)
It is the default type of certificate the installer will generate, it
is however not recommended for production use.
Letsencrypt
-----------
.. warning::
Please note that by using this option, you aggree to the `ToS
Please note that by using this option, you agree to the `ToS
<https://community.letsencrypt.org/tos>`_ of
letsencrypt and that your IP will be logged (see ToS)
letsencrypt and that your IP will be logged (see ToS).
Please also note this option requires the hostname you're using to be
valid (ie. it can be resolved with a DNS query) and to match the
server you're installing Modoboa on.
@@ -202,11 +200,13 @@ Manual
------
.. warning::
It is not possible to configure manual certs interactively.
To do so, please run ``run.py`` with `--stop-after-configfile-check`,
configure your file as desired and apply the configuration as
written bellow. Then run ``run.py`` without
`--stop-after-configfile-check` or `--interactive`.
It is not possible to configure manual certs interactively, so
you'll have to do it in 2 steps. Please run ``run.py`` with
`--stop-after-configfile-check` first, configure your file as
desired and apply the configuration as written bellow. Then run
``run.py`` again but without `--stop-after-configfile-check` or
`--interactive`.
If you want to use already generated certs, simply edit the
``installer.cfg`` file and modify the following settings::

View File

@@ -39,8 +39,8 @@ ConfigDictTemplate = [
"default": "self-signed",
"customizable": True,
"question": "Please choose your certificate type",
"value_return": ["manual"],
"values": ["self-signed", "letsencrypt", "manual"],
"non_interactive_values": ["manual"],
},
{
"option": "tls_cert_file_path",

View File

@@ -7,7 +7,7 @@ from . import package
from . import utils
class CertificateBackend(object):
class CertificateBackend:
"""Base class."""
def __init__(self, config):
@@ -29,7 +29,7 @@ class CertificateBackend(object):
pass
class ManualCertification(CertificateBackend):
class ManualCertificate(CertificateBackend):
"""Use certificate provided."""
def __init__(self, *args, **kwargs):
@@ -61,7 +61,7 @@ class SelfSignedCertificate(CertificateBackend):
def __init__(self, *args, **kwargs):
"""Sanity checks."""
super(SelfSignedCertificate, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
if self.config.has_option("general", "tls_key_file"):
# Compatibility
return
@@ -96,7 +96,7 @@ class LetsEncryptCertificate(CertificateBackend):
def __init__(self, *args, **kwargs):
"""Update config."""
super(LetsEncryptCertificate, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.hostname = self.config.get("general", "hostname")
self.config.set("general", "tls_cert_file", (
"/etc/letsencrypt/live/{}/fullchain.pem".format(self.hostname)))
@@ -158,5 +158,5 @@ def get_backend(config):
if cert_type == "letsencrypt":
return LetsEncryptCertificate(config)
if cert_type == "manual":
return ManualCertification(config)
return ManualCertificate(config)
return SelfSignedCertificate(config)

View File

@@ -317,16 +317,14 @@ def get_entry_value(entry, interactive):
if entry.get("values") and user_value != "":
user_value = values[int(user_value)]
condition = (
entry.get("value_return") and
user_value in entry.get("value_return")
non_interactive_values = entry.get("non_interactive_values", [])
if user_value in non_interactive_values:
error(
f"{user_value} cannot be set interactively. "
"Please configure installer.cfg manually by running "
"'python3 run.py --stop-after-configfile-check domain'. "
"Check modoboa-installer README for more information."
)
if condition:
error(f"{user_value} cannot be set interactively, "
"Please configure installer.cfg manually by running "
"'python3 run.py --stop-after-configfile-check domain'. "
"Check modoboa-installer Readme for more information."
)
sys.exit(1)
return user_value if user_value else default_value

2
run.py
View File

@@ -203,7 +203,7 @@ def main(input_args):
if not args.skip_checks:
utils.printcolor("Checking the installer...", utils.BLUE)
checks.handle()
utils.success("Checks complete")
utils.success("Checks complete\n")
is_config_file_available, outdate_config = utils.check_config_file(
args.configfile, args.interactive, args.upgrade, args.backup, is_restoring)