Move settings away from mailinabox.conf

This commit is contained in:
David Duque 2020-04-16 22:52:48 +01:00
parent 5e080bedb6
commit 9b6781685a
No known key found for this signature in database
GPG Key ID: 2F327738A3C0AE3A
3 changed files with 7 additions and 13 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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