File tree Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Expand file tree Collapse file tree 2 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 1
1
import iniconfig
2
- import datetime
2
+ from datetime import datetime
3
3
4
4
5
5
def read_config (inipath ):
@@ -35,12 +35,15 @@ def write_initial_config(inipath, mail_domain):
35
35
from importlib .resources import files
36
36
37
37
inidir = files (__package__ ).joinpath ("ini" )
38
+ selector = "dkim"
39
+ if mail_domain == "staging.testrun.org" :
40
+ selector = datetime .now ().strftime ("%Y%m%d%H%M" )
38
41
content = (
39
42
inidir .joinpath ("chatmail.ini.f" )
40
43
.read_text ()
41
44
.format (
42
45
mail_domain = mail_domain ,
43
- dkim_selector = str ( datetime . datetime . now (). strftime ( "%Y%m%d%H%M" )) ,
46
+ dkim_selector = selector ,
44
47
)
45
48
)
46
49
if mail_domain .endswith (".testrun.org" ):
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def show_dns(args, out) -> int:
51
51
"""Check existing DNS records, optionally write them to zone file, return exit code 0 or 1."""
52
52
template = importlib .resources .files (__package__ ).joinpath ("chatmail.zone.f" )
53
53
mail_domain = args .config .mail_domain
54
- dkim_selector = args .config .dkim_selector
54
+ selector = args .config .dkim_selector
55
55
ssh = f"ssh root@{ mail_domain } "
56
56
dns = DNS (out , mail_domain )
57
57
@@ -62,8 +62,8 @@ def read_dkim_entries(entry):
62
62
continue
63
63
line = line .replace ("\t " , " " )
64
64
lines .append (line )
65
- lines [0 ] = f"{ dkim_selector } ._domainkey.{ mail_domain } . IN TXT " + lines [0 ].strip (
66
- f"{ dkim_selector } ._domainkey IN TXT "
65
+ lines [0 ] = f"{ selector } ._domainkey.{ mail_domain } . IN TXT " + lines [0 ].strip (
66
+ f"{ selector } ._domainkey IN TXT "
67
67
)
68
68
return "\n " .join (lines )
69
69
@@ -74,7 +74,9 @@ def read_dkim_entries(entry):
74
74
print ("Please run `cmdeploy run` first." )
75
75
return 1
76
76
dkim_entry = read_dkim_entries (
77
- out .shell_output (f"{ ssh } -- cat /var/lib/rspamd/dkim/{ mail_domain } .{ dkim_selector } .zone" )
77
+ out .shell_output (
78
+ f"{ ssh } -- cat /var/lib/rspamd/dkim/{ mail_domain } .{ selector } .zone"
79
+ )
78
80
)
79
81
80
82
ipv6 = dns .get_ipv6 ()
You can’t perform that action at this time.
0 commit comments