mirror of
https://github.com/chatmail/relay.git
synced 2026-05-19 04:18:09 +00:00
DNS: add -all to cmdeploy dns
This commit is contained in:
@@ -106,6 +106,12 @@ def dns_cmd_options(parser):
|
|||||||
default=None,
|
default=None,
|
||||||
help="write out a zonefile",
|
help="write out a zonefile",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--all",
|
||||||
|
dest="all",
|
||||||
|
action="store_true",
|
||||||
|
help="check both required and recommended DNS records"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def dns_cmd(args, out):
|
def dns_cmd(args, out):
|
||||||
@@ -131,7 +137,7 @@ def dns_cmd(args, out):
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
retcode = dns.check_full_zone(
|
retcode = dns.check_full_zone(
|
||||||
sshexec, remote_data=remote_data, zonefile=zonefile, out=out
|
sshexec, remote_data=remote_data, zonefile=zonefile, out=out, all=args.all
|
||||||
)
|
)
|
||||||
return retcode
|
return retcode
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ def get_filled_zone_file(remote_data):
|
|||||||
return zonefile
|
return zonefile
|
||||||
|
|
||||||
|
|
||||||
def check_full_zone(sshexec, remote_data, out, zonefile) -> int:
|
def check_full_zone(sshexec, remote_data, out, zonefile, all) -> int:
|
||||||
"""Check existing DNS records, optionally write them to zone file
|
"""Check existing DNS records, optionally write them to zone file
|
||||||
and return (exitcode, remote_data) tuple."""
|
and return (exitcode, remote_data) tuple."""
|
||||||
|
|
||||||
@@ -49,16 +49,18 @@ def check_full_zone(sshexec, remote_data, out, zonefile) -> int:
|
|||||||
kwargs=dict(zonefile=zonefile, mail_domain=remote_data["mail_domain"]),
|
kwargs=dict(zonefile=zonefile, mail_domain=remote_data["mail_domain"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
returncode = 0
|
||||||
if required_diff:
|
if required_diff:
|
||||||
out.red("Please set required DNS entries at your DNS provider:\n")
|
out.red("Please set required DNS entries at your DNS provider:\n")
|
||||||
for line in required_diff:
|
for line in required_diff:
|
||||||
out(line)
|
out(line)
|
||||||
return 1
|
print()
|
||||||
elif recommended_diff:
|
returncode += 1
|
||||||
|
if recommended_diff and (all or not required_diff):
|
||||||
out("WARNING: these recommended DNS entries are not set:\n")
|
out("WARNING: these recommended DNS entries are not set:\n")
|
||||||
for line in recommended_diff:
|
for line in recommended_diff:
|
||||||
out(line)
|
out(line)
|
||||||
return 0
|
|
||||||
|
|
||||||
out.green("Great! All your DNS entries are verified and correct.")
|
if not (recommended_diff or required_diff):
|
||||||
return 0
|
out.green("Great! All your DNS entries are verified and correct.")
|
||||||
|
return returncode
|
||||||
|
|||||||
Reference in New Issue
Block a user