forked from PowerDNS-Admin/PowerDNS-Admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_zones.py
30 lines (23 loc) · 1.01 KB
/
update_zones.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3
####################################################################################################################################
# A CLI Script to update list of domains instead from the UI. Can be useful 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.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()