Configure panel mail and hosting defaults in the installer
This commit is contained in:
1 parent
23adbe7b2d
commit
570addf37a
5 files changed
+149
-6
No files matched your search
@@ -4,6 +4,7 @@ import json
|
||||
import os
|
||||
import pwd
|
||||
import secrets
|
||||
import smtplib
|
||||
import socket
|
||||
import stat
|
||||
import subprocess
|
||||
@@ -551,6 +552,7 @@ class Installer:
|
||||
"COULOBRE_ALLOWED_HOSTS": self.plan.hostname,
|
||||
"COULOBRE_HTTPS_PROXY": "1",
|
||||
"COULOBRE_REQUIRE_PRIVILEGED_MFA": "1",
|
||||
"COULOBRE_PASSWORD_RESET_ORIGIN": f"https://{self.plan.hostname}",
|
||||
"COULOBRE_TRUST_APACHE_CLIENT_IP": "1",
|
||||
"COULOBRE_STATIC_ROOT": str(STATIC),
|
||||
"COULOBRE_SECRET_KEY": self.state["secret_key"],
|
||||
@@ -572,8 +574,49 @@ class Installer:
|
||||
options["COULOBRE_LOCAL_MAILBOX_PROVISIONING"] = "1"
|
||||
if self.plan.mail.mode in {"local", "remote-install"}:
|
||||
options["COULOBRE_MAIL_NODE_DKIM"] = "1"
|
||||
if self.plan.mail.mode == "local":
|
||||
options.update(
|
||||
COULOBRE_SMTP_HOST="127.0.0.1",
|
||||
COULOBRE_SMTP_PORT="25",
|
||||
COULOBRE_SMTP_STARTTLS="0",
|
||||
COULOBRE_EMAIL_FROM=f"panel@{self.plan.mail.host}",
|
||||
)
|
||||
hosting = self.plan.hosting
|
||||
if hosting.public_addresses:
|
||||
options["COULOBRE_HOSTING_PUBLIC_ADDRESSES"] = ",".join(
|
||||
hosting.public_addresses
|
||||
)
|
||||
if hosting.nameservers:
|
||||
options["COULOBRE_HOSTING_NAMESERVERS"] = ",".join(
|
||||
hosting.nameservers
|
||||
)
|
||||
if hosting.mail_sending_addresses:
|
||||
options.update(
|
||||
COULOBRE_MAIL_MX_HOST=self.plan.mail.mail_hostname,
|
||||
COULOBRE_MAIL_SENDING_IPS=",".join(
|
||||
hosting.mail_sending_addresses
|
||||
),
|
||||
COULOBRE_MANAGE_MAIL_DNS="1",
|
||||
)
|
||||
return "".join(f"{key}={value}\n" for key, value in options.items())
|
||||
|
||||
def verify_notification_mail(self):
|
||||
if self.plan.mail.mode != "local":
|
||||
return
|
||||
try:
|
||||
with smtplib.SMTP("127.0.0.1", 25, timeout=8) as relay:
|
||||
relay.ehlo_or_helo_if_needed()
|
||||
mail_code, _ = relay.mail(f"panel@{self.plan.mail.host}")
|
||||
recipient_code, _ = relay.rcpt("smtp-check@example.invalid")
|
||||
relay.rset()
|
||||
if mail_code != 250 or recipient_code not in (250, 251):
|
||||
raise OSError("Loopback SMTP relay rejected the envelope.")
|
||||
except OSError as error:
|
||||
raise InstallError(
|
||||
"Local Postfix did not accept outgoing panel mail over "
|
||||
"loopback. Check journalctl -u postfix and the relay policy."
|
||||
) from error
|
||||
|
||||
def prepare_panel(self):
|
||||
panel = identity("coulobre-panel")
|
||||
root_directory(ETC, mode=0o750)
|
||||
@@ -708,6 +751,7 @@ class Installer:
|
||||
"Coulobre is already installed with these settings."
|
||||
)
|
||||
self.verify_panel()
|
||||
self.verify_notification_mail()
|
||||
return
|
||||
self.progress(
|
||||
"Installing system packages and the Coulobre release."
|
||||
@@ -793,6 +837,9 @@ class Installer:
|
||||
)
|
||||
systemctl("reload", "apache2.service")
|
||||
self.verify_panel()
|
||||
if self.plan.mail.mode == "local":
|
||||
with self.step("Checking Postfix for outgoing panel email"):
|
||||
self.verify_notification_mail()
|
||||
for key in ("secret_key", "database_password", "broker_password"):
|
||||
self.state.pop(key, None)
|
||||
self.state["complete"] = True
|
||||
|
||||
Reference in new issue
Block a user