From 48abccbbd603e33409ae3e59114996b8899ed882 Mon Sep 17 00:00:00 2001 From: Ana Custura Date: Mon, 30 Mar 2026 15:15:22 +0100 Subject: [PATCH] Add initial madmail installer step --- app/routes.py | 3 +- change_manager.py | 2 +- install_madmail.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 install_madmail.py diff --git a/app/routes.py b/app/routes.py index 335050b..3bd03bb 100644 --- a/app/routes.py +++ b/app/routes.py @@ -17,6 +17,7 @@ import glob import time import qrcode from flask_babel import lazy_gettext as _l +from install_madmail import run_madmail_installer CHANGES_REQUIRING_RESTART = ['wifi_password', 'ssid', 'enable_access_point', 'enable_chat', 'enable_delta_chat', 'butterbox_hostname', 'ssh_access_settings', 'root_account_settings', 'root_password'] RASPAP_INSTALLED = os.path.exists("/var/www/html/raspap") @@ -231,7 +232,6 @@ def step3(): return render_template('step3.html', raspap_installed=RASPAP_INSTALLED, form=form, get_setting=get_setting) return redirect(url_for('admin')) - @app.route('/step4', methods=['GET', 'POST']) def step4(): form = Step4Form() @@ -252,6 +252,7 @@ def step4(): setting_value = getattr(form, s).data set_setting(s, setting_value) set_setting('first_setup', "false") + run_madmail_installer() db.session.commit() return redirect(url_for('setup_complete')) if get_setting("first_setup") == "true": diff --git a/change_manager.py b/change_manager.py index 7864fa6..52f1b66 100644 --- a/change_manager.py +++ b/change_manager.py @@ -157,7 +157,7 @@ def check_settings(raspap_installed: bool): if s == "enable_access_point" and raspap_installed: needs_restart = change_service_status("enable_access_point", "raspapd") or needs_restart if s == "enable_deltachat": - needs_restart = change_service_status("enable_deltachat", "madmail") or needs_restart + needs_restart = change_service_status("enable_deltachat", "maddy") or needs_restart if s == "butterbox_hostname": # change in /etc/hostname print("Writing new hostname to /etc/hostname") diff --git a/install_madmail.py b/install_madmail.py new file mode 100644 index 0000000..f4f9442 --- /dev/null +++ b/install_madmail.py @@ -0,0 +1,69 @@ +import pexpect +import json +def run_madmail_installer(): + with open("./settings.txt", "r") as f: + settings = json.load(f) + butterbox_hostname = settings["butterbox_hostname"] + + cmd = f"sudo ../madmail/madmail install" + child = pexpect.spawn(cmd, encoding = "utf-8")# + child.logfile = open("install_log.txt", "w") + child.expect("Customize every setting") + child.sendline("2") + child.expect("Primary domain") + child.sendline(butterbox_hostname) + child.expect("MX record") + child.sendline(butterbox_hostname) + child.expect("Public IP address") + child.sendline("127.0.0.1") + child.expect("Additional domains") + child.sendline("") + child.expect("State directory") + child.sendline("") + child.expect("Configuration directory") + child.sendline("") + child.expect("TLS certificate path") + child.sendline("") + child.expect("TLS private key path") + child.sendline("") + child.expect("SMTP port") + child.sendline("") + child.expect("Submission port") + child.sendline("") + child.expect("Submission TLS port") + child.sendline("") + child.expect("IMAP port") + child.sendline("") + child.expect("IMAP TLS port") + child.sendline("") + child.expect("Allow insecure") + child.sendline("n") + child.expect("Enable chatmail endpoint for user registration") + child.sendline("y") + child.expect("Chatmail HTTP port") + child.sendline("8081") + child.expect("Chatmail HTTPS port") + child.sendline("8443") + child.expect("Chatmail username length") + child.sendline("") + child.expect("Chatmail password length") + child.sendline("") + child.expect("Enable Shadowsocks proxy for faster messaging") + child.sendline("n") + child.expect("Enable TURN server") + child.sendline("n") + child.expect("Require PGP encryption for outgoing messages") + child.sendline("y") + child.expect("Allow secure join requests without encryption") + child.sendline("n") + child.expect("Passthrough senders") + child.sendline("") + child.expect("Passthrough recipients") + child.sendline("") + child.expect("Maximum message size") + child.sendline("") + child.expect("Add Cloudflare proxy disable tags to DNS records") + child.sendline("n") + child.expect("Enable logging for the server") + child.sendline("y") + child.expect(pexpect.EOF) \ No newline at end of file