|
Server : Apache System : Linux ecngx264.inmotionhosting.com 4.18.0-553.77.1.lve.el8.x86_64 #1 SMP Wed Oct 8 14:21:00 UTC 2025 x86_64 User : lonias5 ( 3576) PHP Version : 7.3.33 Disable Function : NONE Directory : /proc/self/root/proc/thread-self/root/opt/tier1adv/bin/ |
Upload File : |
#!/opt/imh-python/bin/python3
import argparse
import sys
from pathlib import Path
import subprocess
from rads.color import green
sys.path.insert(0, '/opt/support/lib')
from arg_types import valid_domain
from output import err_exit
def get_args() -> str:
"""Parse domain from command arguments"""
parser = argparse.ArgumentParser()
parser.add_argument('domain', type=valid_domain, help='domain to check')
return parser.parse_args().domain
def main():
domain = get_args()
zone_file = Path('/var/named', f"{domain}.db")
if zone_file.is_file():
print(green(f'Zone File exists at {zone_file}'))
else:
err_exit(f'Zone file does not exist at {zone_file}')
try:
ret_code = subprocess.call(['named-checkzone', domain, str(zone_file)])
except FileNotFoundError as exc: # named-checkzone is missing
err_exit(str(exc))
if ret_code: # non-zero return code
err_exit(f'Failed to validate the zone file at {zone_file}')
print(green(f'Successfully validated the zone file at {zone_file}'))
if __name__ == "__main__":
main()