DKIM: generate dkim_selector with cmdeploy init

This commit is contained in:
missytake
2024-01-17 16:42:19 +01:00
parent a6b333672d
commit 82c317c1d5
4 changed files with 15 additions and 5 deletions

View File

@@ -495,7 +495,7 @@ def deploy_chatmail(config_path: Path) -> None:
nginx_need_restart = _configure_nginx(mail_domain)
remove_opendkim()
rspamd_need_restart = _configure_rspamd("dkim", mail_domain)
rspamd_need_restart = _configure_rspamd(config.dkim_selector, mail_domain)
systemd.service(
name="Start and enable rspamd",

View File

@@ -51,6 +51,7 @@ def show_dns(args, out) -> int:
"""Check existing DNS records, optionally write them to zone file, return exit code 0 or 1."""
template = importlib.resources.files(__package__).joinpath("chatmail.zone.f")
mail_domain = args.config.mail_domain
dkim_selector = args.config.dkim_selector
ssh = f"ssh root@{mail_domain}"
dns = DNS(out, mail_domain)
@@ -61,8 +62,8 @@ def show_dns(args, out) -> int:
continue
line = line.replace("\t", " ")
lines.append(line)
lines[0] = f"dkim._domainkey.{mail_domain}. IN TXT " + lines[0].strip(
"dkim._domainkey IN TXT "
lines[0] = f"{dkim_selector}._domainkey.{mail_domain}. IN TXT " + lines[0].strip(
f"{dkim_selector}._domainkey IN TXT "
)
return "\n".join(lines)
@@ -73,7 +74,7 @@ def show_dns(args, out) -> int:
print("Please run `cmdeploy run` first.")
return 1
dkim_entry = read_dkim_entries(
out.shell_output(f"{ssh} -- cat /var/lib/rspamd/dkim/{mail_domain}.dkim.zone")
out.shell_output(f"{ssh} -- cat /var/lib/rspamd/dkim/{mail_domain}.{dkim_selector}.zone")
)
ipv6 = dns.get_ipv6()