From 44c483ffd5286550fff6aa50005836b3307b1fc0 Mon Sep 17 00:00:00 2001 From: rodehoed Date: Tue, 12 Jun 2018 09:42:26 +0200 Subject: [PATCH] CLI script to update zone list A CLI Script to update list of domains instead from the UI. Can be usefull for people who want to execute updates from a cronjob --- update_zones.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 update_zones.py diff --git a/update_zones.py b/update_zones.py new file mode 100644 index 0000000..599f0c4 --- /dev/null +++ b/update_zones.py @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +#################################################################################################################################### +# A CLI Script to update list of domains instead from the UI. Can be usefull for people who want to execute updates from a cronjob +# +# Tip: +# When running from a cron, use flock (you might need to install it) to be sure only one process is running a time. eg: +# */5 * * * * flock -xn "/tmp/pdns-update-zones.lock" python /var/www/html/apps/poweradmin/update_zones.py >/dev/null 2>&1 +# +############################################################## + +### Imports +from app import app +from app.lib import log +from app.models import Domain +from config import BG_DOMAIN_UPDATES + +import sys +import logging as logger + +### Define logging +logging = logger.getLogger(__name__) + +### Check if BG_DOMAIN_UPDATES is set to true +if not BG_DOMAIN_UPDATES: + logging.error('Set BG_DOMAIN_UPDATES to True in config.py') + sys.exit(1) + +### Start the update process +logging.info('Update zones from nameserver API') + +d = Domain().update()