mirror of
https://github.com/chatmail/relay.git
synced 2026-05-11 16:34:39 +00:00
Compare commits
4 Commits
docs-inter
...
generate-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03a367a8b2 | ||
|
|
c4af0e49ad | ||
|
|
d760bc617e | ||
|
|
82c317c1d5 |
1
.github/workflows/test-and-deploy.yaml
vendored
1
.github/workflows/test-and-deploy.yaml
vendored
@@ -5,6 +5,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- staging-ci
|
- staging-ci
|
||||||
|
- generate-dkim-selector
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import iniconfig
|
import iniconfig
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
def read_config(inipath):
|
def read_config(inipath):
|
||||||
@@ -24,6 +25,7 @@ class Config:
|
|||||||
self.privacy_mail = params.get("privacy_mail")
|
self.privacy_mail = params.get("privacy_mail")
|
||||||
self.privacy_pdo = params.get("privacy_pdo")
|
self.privacy_pdo = params.get("privacy_pdo")
|
||||||
self.privacy_supervisor = params.get("privacy_supervisor")
|
self.privacy_supervisor = params.get("privacy_supervisor")
|
||||||
|
self.dkim_selector = params.get("dkim_selector")
|
||||||
|
|
||||||
def _getbytefile(self):
|
def _getbytefile(self):
|
||||||
return open(self._inipath, "rb")
|
return open(self._inipath, "rb")
|
||||||
@@ -33,8 +35,16 @@ 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")
|
||||||
|
selector = "dkim"
|
||||||
|
if mail_domain == "staging.testrun.org":
|
||||||
|
selector = datetime.now().strftime("%Y%m%d%H%M")
|
||||||
content = (
|
content = (
|
||||||
inidir.joinpath("chatmail.ini.f").read_text().format(mail_domain=mail_domain)
|
inidir.joinpath("chatmail.ini.f")
|
||||||
|
.read_text()
|
||||||
|
.format(
|
||||||
|
mail_domain=mail_domain,
|
||||||
|
dkim_selector=selector,
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if mail_domain.endswith(".testrun.org"):
|
if mail_domain.endswith(".testrun.org"):
|
||||||
override_inipath = inidir.joinpath("override-testrun.ini")
|
override_inipath = inidir.joinpath("override-testrun.ini")
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ passthrough_senders =
|
|||||||
# list of e-mail recipients for which to accept outbound un-encrypted mails
|
# list of e-mail recipients for which to accept outbound un-encrypted mails
|
||||||
passthrough_recipients = xstore@testrun.org groupsbot@hispanilandia.net
|
passthrough_recipients = xstore@testrun.org groupsbot@hispanilandia.net
|
||||||
|
|
||||||
|
dkim_selector = {dkim_selector}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Deployment Details
|
# Deployment Details
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -495,7 +495,7 @@ def deploy_chatmail(config_path: Path) -> None:
|
|||||||
nginx_need_restart = _configure_nginx(mail_domain)
|
nginx_need_restart = _configure_nginx(mail_domain)
|
||||||
|
|
||||||
remove_opendkim()
|
remove_opendkim()
|
||||||
rspamd_need_restart = _configure_rspamd("dkim", mail_domain)
|
rspamd_need_restart = _configure_rspamd(config.dkim_selector, mail_domain)
|
||||||
|
|
||||||
systemd.service(
|
systemd.service(
|
||||||
name="Start and enable rspamd",
|
name="Start and enable rspamd",
|
||||||
|
|||||||
@@ -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."""
|
"""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")
|
template = importlib.resources.files(__package__).joinpath("chatmail.zone.f")
|
||||||
mail_domain = args.config.mail_domain
|
mail_domain = args.config.mail_domain
|
||||||
|
selector = args.config.dkim_selector
|
||||||
ssh = f"ssh root@{mail_domain}"
|
ssh = f"ssh root@{mail_domain}"
|
||||||
dns = DNS(out, mail_domain)
|
dns = DNS(out, mail_domain)
|
||||||
|
|
||||||
@@ -61,8 +62,8 @@ def show_dns(args, out) -> int:
|
|||||||
continue
|
continue
|
||||||
line = line.replace("\t", " ")
|
line = line.replace("\t", " ")
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
lines[0] = f"dkim._domainkey.{mail_domain}. IN TXT " + lines[0].strip(
|
lines[0] = f"{selector}._domainkey.{mail_domain}. IN TXT " + lines[0].strip(
|
||||||
"dkim._domainkey IN TXT "
|
f"{selector}._domainkey IN TXT "
|
||||||
)
|
)
|
||||||
return "\n".join(lines)
|
return "\n".join(lines)
|
||||||
|
|
||||||
@@ -73,7 +74,9 @@ def show_dns(args, out) -> int:
|
|||||||
print("Please run `cmdeploy run` first.")
|
print("Please run `cmdeploy run` first.")
|
||||||
return 1
|
return 1
|
||||||
dkim_entry = read_dkim_entries(
|
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}.{selector}.zone"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
ipv6 = dns.get_ipv6()
|
ipv6 = dns.get_ipv6()
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
selector = {{ config.dkim_selector }}
|
selector = "{{ config.dkim_selector }}"
|
||||||
use_esld = false # don't cut c1.testrun.org down to testrun.org
|
use_esld = false # don't cut c1.testrun.org down to testrun.org
|
||||||
domain = {
|
domain = {
|
||||||
{{ config.mail_domain }} {
|
{{ config.mail_domain }} {
|
||||||
selectors [
|
selectors [
|
||||||
selector = {{ config.dkim_selector }}
|
selector = "{{ config.dkim_selector }}"
|
||||||
path = {{ config.dkim_key_path }}
|
path = {{ config.dkim_key_path }}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user