D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
lib
/
imh-dnskeyapi
/
Filename :
sync_user_zones
back
Copy
#!/usr/lib/imh-dnskeyapi/venv/bin/python3 """Syncs all zones owned by the user to the cluster""" from argparse import ArgumentParser from pathlib import Path import shlex from subprocess import run def main(): """Syncs all zones owned by the user to the cluster""" parser = ArgumentParser(description=__doc__) parser.add_argument('--user', help='cPanel user') user: str = parser.parse_args().user sync(user) def sync(user: str): """Run dnscluster synczone in serial for each domain for a user""" with open('/etc/userdomains', encoding='utf-8') as file: for line in file: domain, owner = line.strip().split(': ', maxsplit=1) if owner != user or not Path(f"/var/named/{domain}.db").exists(): continue cmd = ["/usr/local/cpanel/scripts/dnscluster", "synczone", domain] print(shlex.join(cmd)) run(cmd, check=False) if __name__ == '__main__': main()