-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_zones.py
34 lines (26 loc) · 1.16 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
31
32
33
34
#!/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
import sys
import logging
from gundnsadmin import create_app
from gundnsadmin.models.domain import Domain
from gundnsadmin.models.setting import Setting
app = create_app()
app.logger.setLevel(logging.INFO)
with app.app_context():
status = Setting().get('bg_domain_updates')
### Check if bg_domain_updates is set to true
if not status:
app.logger.error('Please turn on "bg_domain_updates" setting to run this job.')
sys.exit(1)
### Start the update process
app.logger.info('Update zones from nameserver API')
Domain().update()