|
Server : Apache System : Linux ecngx264.inmotionhosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : lonias5 ( 3576) PHP Version : 7.3.33 Disable Function : NONE Directory : /usr/lib/imh-dnskeyapi/ |
Upload File : |
#!/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()