mirror of
https://github.com/chatmail/relay.git
synced 2026-05-10 16:04:37 +00:00
rename mailname to mail_domain everywhere
This commit is contained in:
@@ -9,7 +9,7 @@ def read_config(inipath):
|
|||||||
class Config:
|
class Config:
|
||||||
def __init__(self, inipath, params):
|
def __init__(self, inipath, params):
|
||||||
self._inipath = inipath
|
self._inipath = inipath
|
||||||
self.mailname = self.mail_domain = params["mailname"]
|
self.mail_domain = params["mail_domain"]
|
||||||
self.max_user_send_per_minute = int(params["max_user_send_per_minute"])
|
self.max_user_send_per_minute = int(params["max_user_send_per_minute"])
|
||||||
self.filtermail_smtp_port = int(params["filtermail_smtp_port"])
|
self.filtermail_smtp_port = int(params["filtermail_smtp_port"])
|
||||||
self.postfix_reinject_port = int(params["postfix_reinject_port"])
|
self.postfix_reinject_port = int(params["postfix_reinject_port"])
|
||||||
@@ -23,12 +23,12 @@ class Config:
|
|||||||
return open(self._inipath, "rb")
|
return open(self._inipath, "rb")
|
||||||
|
|
||||||
|
|
||||||
def write_initial_config(inipath, mailname):
|
def write_initial_config(inipath, mail_domain):
|
||||||
from importlib.resources import files
|
from importlib.resources import files
|
||||||
|
|
||||||
inidir = files(__package__).joinpath("ini")
|
inidir = files(__package__).joinpath("ini")
|
||||||
content = inidir.joinpath("chatmail.ini.f").read_text().format(mailname=mailname)
|
content = inidir.joinpath("chatmail.ini.f").read_text().format(mail_domain=mail_domain)
|
||||||
if mailname.endswith(".testrun.org"):
|
if mail_domain.endswith(".testrun.org"):
|
||||||
override_inipath = inidir.joinpath("override-testrun.ini")
|
override_inipath = inidir.joinpath("override-testrun.ini")
|
||||||
privacy = iniconfig.IniConfig(override_inipath)["privacy"]
|
privacy = iniconfig.IniConfig(override_inipath)["privacy"]
|
||||||
lines = []
|
lines = []
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[params]
|
[params]
|
||||||
|
|
||||||
# mail domain (MUST be set to fully qualified chat mail domain)
|
# mail domain (MUST be set to fully qualified chat mail domain)
|
||||||
mailname = {mailname}
|
mail_domain = {mail_domain}
|
||||||
|
|
||||||
#
|
#
|
||||||
# If you only do private test deploys, you don't need to modify any settings below
|
# If you only do private test deploys, you don't need to modify any settings below
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
|
|
||||||
mailname_path = "/etc/mailname"
|
mail_domain_path = "/etc/mailname"
|
||||||
|
|
||||||
|
|
||||||
def create_newemail_dict(domain):
|
def create_newemail_dict(domain):
|
||||||
@@ -16,7 +16,7 @@ def create_newemail_dict(domain):
|
|||||||
|
|
||||||
|
|
||||||
def print_new_account():
|
def print_new_account():
|
||||||
domain = open(mailname_path).read().strip()
|
domain = open(mail_domain_path).read().strip()
|
||||||
creds = create_newemail_dict(domain=domain)
|
creds = create_newemail_dict(domain=domain)
|
||||||
|
|
||||||
print("Content-Type: application/json")
|
print("Content-Type: application/json")
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ from chatmaild.config import read_config, write_initial_config
|
|||||||
def make_config(tmp_path):
|
def make_config(tmp_path):
|
||||||
inipath = tmp_path.joinpath("chatmail.ini")
|
inipath = tmp_path.joinpath("chatmail.ini")
|
||||||
|
|
||||||
def make_conf(mailname):
|
def make_conf(mail_domain):
|
||||||
write_initial_config(inipath, mailname=mailname)
|
write_initial_config(inipath, mail_domain=mail_domain)
|
||||||
return read_config(inipath)
|
return read_config(inipath)
|
||||||
|
|
||||||
return make_conf
|
return make_conf
|
||||||
@@ -27,7 +27,7 @@ def example_config(make_config):
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def maildomain(example_config):
|
def maildomain(example_config):
|
||||||
return example_config.mailname
|
return example_config.mail_domain
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from chatmaild.config import read_config
|
|||||||
|
|
||||||
def test_read_config_basic(make_config):
|
def test_read_config_basic(make_config):
|
||||||
config = make_config("chat.example.org")
|
config = make_config("chat.example.org")
|
||||||
assert config.mailname == "chat.example.org"
|
assert config.mail_domain == "chat.example.org"
|
||||||
assert not config.privacy_supervisor and not config.privacy_mail
|
assert not config.privacy_supervisor and not config.privacy_mail
|
||||||
assert not config.privacy_pdo and not config.privacy_postal
|
assert not config.privacy_pdo and not config.privacy_postal
|
||||||
|
|
||||||
@@ -11,12 +11,12 @@ def test_read_config_basic(make_config):
|
|||||||
inipath.write_text(inipath.read_text().replace("60", "37"))
|
inipath.write_text(inipath.read_text().replace("60", "37"))
|
||||||
config = read_config(inipath)
|
config = read_config(inipath)
|
||||||
assert config.max_user_send_per_minute == 37
|
assert config.max_user_send_per_minute == 37
|
||||||
assert config.mailname == "chat.example.org"
|
assert config.mail_domain == "chat.example.org"
|
||||||
|
|
||||||
|
|
||||||
def test_read_config_testrun(make_config):
|
def test_read_config_testrun(make_config):
|
||||||
config = make_config("something.testrun.org")
|
config = make_config("something.testrun.org")
|
||||||
assert config.mailname == "something.testrun.org"
|
assert config.mail_domain == "something.testrun.org"
|
||||||
assert len(config.privacy_postal.split("\n")) > 1
|
assert len(config.privacy_postal.split("\n")) > 1
|
||||||
assert len(config.privacy_supervisor.split("\n")) > 1
|
assert len(config.privacy_supervisor.split("\n")) > 1
|
||||||
assert len(config.privacy_pdo.split("\n")) > 1
|
assert len(config.privacy_pdo.split("\n")) > 1
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def test_create_newemail_dict():
|
|||||||
def test_print_new_account(capsys, monkeypatch, maildomain, tmpdir):
|
def test_print_new_account(capsys, monkeypatch, maildomain, tmpdir):
|
||||||
p = tmpdir.join("mailname")
|
p = tmpdir.join("mailname")
|
||||||
p.write(maildomain)
|
p.write(maildomain)
|
||||||
monkeypatch.setattr(chatmaild.newemail, "mailname_path", str(p))
|
monkeypatch.setattr(chatmaild.newemail, "mail_domain_path", str(p))
|
||||||
print_new_account()
|
print_new_account()
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
lines = out.split("\n")
|
lines = out.split("\n")
|
||||||
|
|||||||
@@ -347,8 +347,8 @@ def _configure_nginx(domain: str, debug: bool = False) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def check_config(config):
|
def check_config(config):
|
||||||
mailname = config.mailname
|
mail_domain = config.mail_domain
|
||||||
if mailname != "testrun.org" and not mailname.endswith(".testrun.org"):
|
if mail_domain != "testrun.org" and not mail_domain.endswith(".testrun.org"):
|
||||||
blocked_words = "merlinux schmieder testrun.org".split()
|
blocked_words = "merlinux schmieder testrun.org".split()
|
||||||
for value in config.__dict__.values():
|
for value in config.__dict__.values():
|
||||||
if any(x in value for x in blocked_words):
|
if any(x in value for x in blocked_words):
|
||||||
|
|||||||
@@ -52,17 +52,17 @@ def run_cmd(args, out):
|
|||||||
"""Deploy chatmail services on the remote server."""
|
"""Deploy chatmail services on the remote server."""
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env["CHATMAIL_DOMAIN"] = args.config.mailname
|
env["CHATMAIL_DOMAIN"] = args.config.mail_domain
|
||||||
deploypy = "deploy-chatmail/src/deploy_chatmail/deploy.py"
|
deploypy = "deploy-chatmail/src/deploy_chatmail/deploy.py"
|
||||||
pyinf = "pyinfra --dry" if args.dry_run else "pyinfra"
|
pyinf = "pyinfra --dry" if args.dry_run else "pyinfra"
|
||||||
cmd = f"{pyinf} --ssh-user root {args.config.mailname} {deploypy}"
|
cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploypy}"
|
||||||
out.check_call(cmd, env=env)
|
out.check_call(cmd, env=env)
|
||||||
|
|
||||||
|
|
||||||
def dns_cmd(args, out):
|
def dns_cmd(args, out):
|
||||||
"""Generate dns zone file."""
|
"""Generate dns zone file."""
|
||||||
template = importlib.resources.files(__package__).joinpath("chatmail.zone.f")
|
template = importlib.resources.files(__package__).joinpath("chatmail.zone.f")
|
||||||
ssh = f"ssh root@{args.config.mailname}"
|
ssh = f"ssh root@{args.config.mail_domain}"
|
||||||
|
|
||||||
def read_dkim_entries(entry):
|
def read_dkim_entries(entry):
|
||||||
lines = []
|
lines = []
|
||||||
@@ -77,16 +77,16 @@ def dns_cmd(args, out):
|
|||||||
dkim_entry = read_dkim_entries(out.shell_output(f"{ssh} -- opendkim-genzone -F"))
|
dkim_entry = read_dkim_entries(out.shell_output(f"{ssh} -- opendkim-genzone -F"))
|
||||||
|
|
||||||
out(
|
out(
|
||||||
f"[writing {args.config.mailname} zone data (using space as separator) to stdout output]",
|
f"[writing {args.config.mail_domain} zone data (using space as separator) to stdout output]",
|
||||||
green=True,
|
green=True,
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
template.read_text()
|
template.read_text()
|
||||||
.format(
|
.format(
|
||||||
acme_account_url=acme_account_url,
|
acme_account_url=acme_account_url,
|
||||||
email=f"root@{args.config.mailname}",
|
email=f"root@{args.config.mail_domain}",
|
||||||
sts_id=datetime.datetime.now().strftime("%Y%m%d%H%M"),
|
sts_id=datetime.datetime.now().strftime("%Y%m%d%H%M"),
|
||||||
chatmail_domain=args.config.mailname,
|
chatmail_domain=args.config.mail_domain,
|
||||||
dkim_entry=dkim_entry,
|
dkim_entry=dkim_entry,
|
||||||
)
|
)
|
||||||
.strip()
|
.strip()
|
||||||
@@ -96,9 +96,9 @@ def dns_cmd(args, out):
|
|||||||
def status_cmd(args, out):
|
def status_cmd(args, out):
|
||||||
"""Display status for online chatmail instance."""
|
"""Display status for online chatmail instance."""
|
||||||
|
|
||||||
ssh = f"ssh root@{args.config.mailname}"
|
ssh = f"ssh root@{args.config.mail_domain}"
|
||||||
|
|
||||||
out.green(f"chatmail domain: {args.config.mailname}")
|
out.green(f"chatmail domain: {args.config.mail_domain}")
|
||||||
if args.config.privacy_mail:
|
if args.config.privacy_mail:
|
||||||
out.green("privacy settings: present")
|
out.green("privacy settings: present")
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
myorigin = {{ config.mailname }}
|
myorigin = {{ config.mail_domain }}
|
||||||
|
|
||||||
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
|
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
|
||||||
biff = no
|
biff = no
|
||||||
@@ -16,8 +16,8 @@ readme_directory = no
|
|||||||
compatibility_level = 2
|
compatibility_level = 2
|
||||||
|
|
||||||
# TLS parameters
|
# TLS parameters
|
||||||
smtpd_tls_cert_file=/var/lib/acme/live/{{ config.mailname }}/fullchain
|
smtpd_tls_cert_file=/var/lib/acme/live/{{ config.mail_domain }}/fullchain
|
||||||
smtpd_tls_key_file=/var/lib/acme/live/{{ config.mailname }}/privkey
|
smtpd_tls_key_file=/var/lib/acme/live/{{ config.mail_domain }}/privkey
|
||||||
smtpd_tls_security_level=may
|
smtpd_tls_security_level=may
|
||||||
|
|
||||||
smtp_tls_CApath=/etc/ssl/certs
|
smtp_tls_CApath=/etc/ssl/certs
|
||||||
@@ -26,7 +26,7 @@ smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
|
|||||||
smtp_tls_policy_maps = socketmap:inet:127.0.0.1:8461:postfix
|
smtp_tls_policy_maps = socketmap:inet:127.0.0.1:8461:postfix
|
||||||
|
|
||||||
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
|
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
|
||||||
myhostname = {{ config.mailname }}
|
myhostname = {{ config.mail_domain }}
|
||||||
alias_maps = hash:/etc/aliases
|
alias_maps = hash:/etc/aliases
|
||||||
alias_database = hash:/etc/aliases
|
alias_database = hash:/etc/aliases
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ inet_interfaces = all
|
|||||||
inet_protocols = all
|
inet_protocols = all
|
||||||
|
|
||||||
virtual_transport = lmtp:unix:private/dovecot-lmtp
|
virtual_transport = lmtp:unix:private/dovecot-lmtp
|
||||||
virtual_mailbox_domains = {{ config.mailname }}
|
virtual_mailbox_domains = {{ config.mail_domain }}
|
||||||
|
|
||||||
smtpd_milters = unix:opendkim/opendkim.sock
|
smtpd_milters = unix:opendkim/opendkim.sock
|
||||||
non_smtpd_milters = $smtpd_milters
|
non_smtpd_milters = $smtpd_milters
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ def build_webpages(src_dir, build_dir, config):
|
|||||||
|
|
||||||
|
|
||||||
def _build_webpages(src_dir, build_dir, config):
|
def _build_webpages(src_dir, build_dir, config):
|
||||||
mail_domain = config.mailname
|
mail_domain = config.mail_domain
|
||||||
assert src_dir.exists(), src_dir
|
assert src_dir.exists(), src_dir
|
||||||
if not build_dir.exists():
|
if not build_dir.exists():
|
||||||
build_dir.mkdir()
|
build_dir.mkdir()
|
||||||
@@ -71,7 +71,7 @@ def main():
|
|||||||
inipath = reporoot.joinpath("chatmail.ini")
|
inipath = reporoot.joinpath("chatmail.ini")
|
||||||
config = read_config(inipath)
|
config = read_config(inipath)
|
||||||
config.webdev = True
|
config.webdev = True
|
||||||
assert config.mailname
|
assert config.mail_domain
|
||||||
www_path = reporoot.joinpath("www")
|
www_path = reporoot.joinpath("www")
|
||||||
src_path = www_path.joinpath("src")
|
src_path = www_path.joinpath("src")
|
||||||
stats = None
|
stats = None
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ def chatmail_config(pytestconfig):
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def maildomain(chatmail_config):
|
def maildomain(chatmail_config):
|
||||||
return chatmail_config.mailname
|
return chatmail_config.mail_domain
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class TestCmdline:
|
|||||||
main(["init", "chat.example.org"])
|
main(["init", "chat.example.org"])
|
||||||
inipath = tmp_path.joinpath("chatmail.ini")
|
inipath = tmp_path.joinpath("chatmail.ini")
|
||||||
config = read_config(inipath)
|
config = read_config(inipath)
|
||||||
assert config.mailname == "chat.example.org"
|
assert config.mail_domain == "chat.example.org"
|
||||||
|
|
||||||
def test_init_not_overwrite(self):
|
def test_init_not_overwrite(self):
|
||||||
main(["init", "chat.example.org"])
|
main(["init", "chat.example.org"])
|
||||||
|
|||||||
Reference in New Issue
Block a user