diff --git a/README.rst b/README.rst index 173d382..c9b0917 100644 --- a/README.rst +++ b/README.rst @@ -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 `_ 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:: diff --git a/modoboa_installer/config_dict_template.py b/modoboa_installer/config_dict_template.py index a7fc685..bb7325d 100644 --- a/modoboa_installer/config_dict_template.py +++ b/modoboa_installer/config_dict_template.py @@ -39,8 +39,8 @@ def is_email(user_input): "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", diff --git a/modoboa_installer/ssl.py b/modoboa_installer/ssl.py index 0b161c4..4dd7357 100644 --- a/modoboa_installer/ssl.py +++ b/modoboa_installer/ssl.py @@ -7,7 +7,7 @@ from . import utils -class CertificateBackend(object): +class CertificateBackend: """Base class.""" def __init__(self, config): @@ -29,7 +29,7 @@ def generate_cert(self): 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) diff --git a/modoboa_installer/utils.py b/modoboa_installer/utils.py index a70637b..18725c1 100644 --- a/modoboa_installer/utils.py +++ b/modoboa_installer/utils.py @@ -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 diff --git a/run.py b/run.py index bdc7b5a..78b9877 100755 --- a/run.py +++ b/run.py @@ -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)