2026-03-30 15:15:22 +01:00
|
|
|
import pexpect
|
|
|
|
|
import json
|
2026-03-31 12:46:38 +01:00
|
|
|
from app import app
|
|
|
|
|
|
2026-03-30 15:15:22 +01:00
|
|
|
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")
|
2026-03-31 15:20:48 +01:00
|
|
|
child.sendline(f"{butterbox_hostname}.local")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("MX record")
|
2026-03-31 15:20:48 +01:00
|
|
|
child.sendline(f"{butterbox_hostname}.local")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("Public IP address")
|
2026-03-31 12:46:38 +01:00
|
|
|
child.sendline(app.config['BUTTERBOX_DEFAULT_IP'])
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("Additional domains")
|
|
|
|
|
child.sendline("")
|
|
|
|
|
child.expect("State directory")
|
|
|
|
|
child.sendline("")
|
|
|
|
|
child.expect("Configuration directory")
|
|
|
|
|
child.sendline("")
|
2026-03-31 10:36:43 +01:00
|
|
|
child.expect("TLS mode")
|
2026-03-31 14:23:02 +01:00
|
|
|
child.sendline("self_signed")
|
2026-03-31 10:36:43 +01:00
|
|
|
child.expect("Disable TLS verification for clients")
|
|
|
|
|
child.sendline("y")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("SMTP port")
|
2026-03-31 14:23:02 +01:00
|
|
|
child.sendline("25")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("Submission port")
|
2026-03-31 14:23:02 +01:00
|
|
|
child.sendline("587")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("Submission TLS port")
|
2026-03-31 14:23:02 +01:00
|
|
|
child.sendline("465")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("IMAP port")
|
2026-03-31 14:23:02 +01:00
|
|
|
child.sendline("143")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("IMAP TLS port")
|
2026-03-31 14:23:02 +01:00
|
|
|
child.sendline("993")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("Allow insecure")
|
2026-03-31 15:20:48 +01:00
|
|
|
child.sendline("y")
|
2026-03-30 15:15:22 +01:00
|
|
|
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")
|
2026-03-31 14:23:02 +01:00
|
|
|
child.sendline("8")
|
2026-03-30 15:15:22 +01:00
|
|
|
child.expect("Chatmail password length")
|
2026-03-31 14:23:02 +01:00
|
|
|
child.sendline("16")
|
2026-03-30 15:15:22 +01:00
|
|
|
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")
|
2026-03-31 12:46:38 +01:00
|
|
|
child.sendline("y")
|
2026-03-30 15:15:22 +01:00
|
|
|
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")
|
2026-03-31 15:20:48 +01:00
|
|
|
child.expect(pexpect.EOF)
|