Few updates
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user