From 9b6781685a854937e4f61907e06740d44daed9f6 Mon Sep 17 00:00:00 2001 From: David Duque Date: Thu, 16 Apr 2020 22:52:48 +0100 Subject: [PATCH] Move settings away from mailinabox.conf --- management/daemon.py | 11 ++++++----- management/utils.py | 2 +- setup/mail-postfix.sh | 7 ------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/management/daemon.py b/management/daemon.py index 94a16ecc..99276427 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -523,11 +523,12 @@ def privacy_status_set(): @app.route('/system/smtp/relay', methods=["GET"]) @authorized_personnel_only def smtp_relay_get(): + config = utils.load_settings(env) return { - "enabled": (env["SMTP_RELAY_ENABLED"] == "true"), - "host": env["SMTP_RELAY_HOST"], - "auth_enabled": (env["SMTP_RELAY_AUTH"] == "true"), - "user": env["SMTP_RELAY_USER"] + "enabled": (config.get("SMTP_RELAY_ENABLED", "true") == "true"), + "host": config.get("SMTP_RELAY_HOST", ""), + "auth_enabled": (config.get("SMTP_RELAY_AUTH", "false") == "true"), + "user": config.get("SMTP_RELAY_USER", "") } @app.route('/system/smtp/relay', methods=["POST"]) @@ -544,7 +545,7 @@ def smtp_relay_set(): config["SMTP_RELAY_USER"] = newconf.get("user") utils.write_settings(config, env) # Restart Postfix - return "OK" + return utils.shell("check_output", ["/usr/bin/systemctl", "restart", "postfix"], capture_stderr=True) except Exception as e: return (str(e), 500) diff --git a/management/utils.py b/management/utils.py index 652b48f6..f198286c 100644 --- a/management/utils.py +++ b/management/utils.py @@ -92,7 +92,7 @@ def sort_domains(domain_names, env): # Then in right-to-left lexicographic order of the .-separated parts of the name. list(reversed(d.split("."))), )) - + return domain_names def sort_email_addresses(email_addresses, env): diff --git a/setup/mail-postfix.sh b/setup/mail-postfix.sh index c76e8580..a9f8a426 100755 --- a/setup/mail-postfix.sh +++ b/setup/mail-postfix.sh @@ -273,13 +273,6 @@ touch /etc/postfix/sasl_passwd chmod 600 /etc/postfix/sasl_passwd postmap /etc/postfix/sasl_passwd -# Store those configurations in the mailinabox.conf file -tools/editconf.py /etc/mailinabox.conf \ - SMTP_RELAY_ENABLED=false \ - SMTP_RELAY_HOST="" \ - SMTP_RELAY_AUTH=false \ - SMTP_RELAY_USER="" - # Allow the two SMTP ports in the firewall. ufw_allow smtp