DNS: flush cache in the beginning
This commit is contained in:
parent
0238437ce7
commit
d642224a73
@ -33,12 +33,13 @@ def init_cmd_options(parser):
|
|||||||
|
|
||||||
def init_cmd(args, out):
|
def init_cmd(args, out):
|
||||||
"""Initialize chatmail config file."""
|
"""Initialize chatmail config file."""
|
||||||
|
mail_domain = args.chatmail_domain
|
||||||
if args.inipath.exists():
|
if args.inipath.exists():
|
||||||
print(f"Path exists, not modifying: {args.inipath}")
|
print(f"Path exists, not modifying: {args.inipath}")
|
||||||
else:
|
else:
|
||||||
write_initial_config(args.inipath, args.chatmail_domain)
|
write_initial_config(args.inipath, mail_domain)
|
||||||
out.green(f"created config file for {args.chatmail_domain} in {args.inipath}")
|
out.green(f"created config file for {mail_domain} in {args.inipath}")
|
||||||
dns = DNS(out, f"ssh root@{args.chatmail_domain}")
|
dns = DNS(out, mail_domain)
|
||||||
try:
|
try:
|
||||||
ipaddress = dns.resolve(args.chatmail_domain)
|
ipaddress = dns.resolve(args.chatmail_domain)
|
||||||
mta_ipadress = dns.resolve("mta-sts." + args.chatmail_domain)
|
mta_ipadress = dns.resolve("mta-sts." + args.chatmail_domain)
|
||||||
@ -86,7 +87,7 @@ def run_cmd(args, out):
|
|||||||
cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploy_path}"
|
cmd = f"{pyinf} --ssh-user root {args.config.mail_domain} {deploy_path}"
|
||||||
|
|
||||||
mail_domain = args.config.mail_domain
|
mail_domain = args.config.mail_domain
|
||||||
dns = DNS()
|
dns = DNS(out, mail_domain)
|
||||||
root_ip = dns.resolve(mail_domain)
|
root_ip = dns.resolve(mail_domain)
|
||||||
mta_ip = dns.resolve(f"mta-sts.{mail_domain}")
|
mta_ip = dns.resolve(f"mta-sts.{mail_domain}")
|
||||||
if not root_ip or root_ip != mta_ip:
|
if not root_ip or root_ip != mta_ip:
|
||||||
@ -107,8 +108,9 @@ def dns_cmd_options(parser):
|
|||||||
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.mail_domain}"
|
mail_domain = args.config.mail_domain
|
||||||
dns = DNS(out, ssh)
|
ssh = f"ssh root@{mail_domain}"
|
||||||
|
dns = DNS(out, mail_domain)
|
||||||
|
|
||||||
def read_dkim_entries(entry):
|
def read_dkim_entries(entry):
|
||||||
lines = []
|
lines = []
|
||||||
|
@ -3,10 +3,11 @@ from ipaddress import ip_address
|
|||||||
|
|
||||||
|
|
||||||
class DNS:
|
class DNS:
|
||||||
def __init__(self, out, ssh):
|
def __init__(self, out, mail_domain):
|
||||||
self.session = requests.Session()
|
self.session = requests.Session()
|
||||||
self.out = out
|
self.out = out
|
||||||
self.ssh = ssh
|
self.ssh = f"ssh root@{mail_domain}"
|
||||||
|
self.out.shell_output(f"{self.ssh} -- unbound-control flush {mail_domain}")
|
||||||
|
|
||||||
def get_ipv4(self):
|
def get_ipv4(self):
|
||||||
cmd = "ip a | grep 'inet ' | grep 'scope global' | grep -oE '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | head -1"
|
cmd = "ip a | grep 'inet ' | grep 'scope global' | grep -oE '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | head -1"
|
||||||
|
Loading…
Reference in New Issue
Block a user