Skip to content

Commit

Permalink
Few updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioo committed Apr 24, 2024
1 parent 68ecf77 commit 18369e2
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 27 deletions.
22 changes: 11 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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::
Expand Down
2 changes: 1 addition & 1 deletion modoboa_installer/config_dict_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions modoboa_installer/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from . import utils


class CertificateBackend(object):
class CertificateBackend:
"""Base class."""

def __init__(self, config):
Expand All @@ -29,7 +29,7 @@ def generate_cert(self):
pass


class ManualCertification(CertificateBackend):
class ManualCertificate(CertificateBackend):
"""Use certificate provided."""

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -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)
16 changes: 7 additions & 9 deletions modoboa_installer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 18369e2

Please sign in to comment.