forked from PowerDNS-Admin/PowerDNS-Admin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow syncing of all known accounts from PowerDNS, in the same way that Domain().update() does for domains.
- Loading branch information
Showing
4 changed files
with
103 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
|
||
#################################################################################################################################### | ||
# A CLI Script to update list of accounts. 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_accounts.py >/dev/null 2>&1 | ||
# | ||
############################################################## | ||
|
||
### Imports | ||
import sys | ||
import logging | ||
|
||
from powerdnsadmin import create_app | ||
from powerdnsadmin.models.account import Account | ||
from powerdnsadmin.models.domain import Domain | ||
from powerdnsadmin.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) | ||
|
||
Account().update() | ||
Domain().update() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters