From 30178ef019a0ec4ee69ea7d647b2106b318e0703 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Fri, 1 Aug 2014 12:05:34 +0000 Subject: [PATCH] add a --force flag to dns_update --- management/daemon.py | 2 +- management/dns_update.py | 8 ++++---- tools/dns_update | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/management/daemon.py b/management/daemon.py index 4b302566..fe0787ff 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -65,7 +65,7 @@ def mail_domains(): def dns_update(): from dns_update import do_dns_update try: - return do_dns_update(env) + return do_dns_update(env, force=request.form.get('force', '') == '1') except Exception as e: return (str(e), 500) diff --git a/management/dns_update.py b/management/dns_update.py index db5b9d73..6d9fbfa2 100755 --- a/management/dns_update.py +++ b/management/dns_update.py @@ -54,7 +54,7 @@ def get_custom_dns_config(env): except: return { } -def do_dns_update(env): +def do_dns_update(env, force=False): # What domains (and their zone filenames) should we build? domains = get_dns_domains(env) zonefiles = get_dns_zones(env) @@ -71,7 +71,7 @@ def do_dns_update(env): # See if the zone has changed, and if so update the serial number # and write the zone file. - if not write_nsd_zone(domain, "/etc/nsd/zones/" + zonefile, records, env): + if not write_nsd_zone(domain, "/etc/nsd/zones/" + zonefile, records, env, force): # Zone was not updated. There were no changes. continue @@ -288,7 +288,7 @@ def build_tlsa_record(env): ######################################################################## -def write_nsd_zone(domain, zonefile, records, env): +def write_nsd_zone(domain, zonefile, records, env, force): # We set the administrative email address for every domain to domain_contact@[domain.com]. # You should probably create an alias to your email address. @@ -363,7 +363,7 @@ $TTL 86400 ; default time to live # If the existing zone is the same as the new zone (modulo the serial number), # there is no need to update the file. Unless we're forcing a bump. - if zone == existing_zone and not force_bump: + if zone == existing_zone and not force_bump and not force: return False # If the existing serial is not less than a serial number diff --git a/tools/dns_update b/tools/dns_update index f8ee4b2d..947c3dd1 100755 --- a/tools/dns_update +++ b/tools/dns_update @@ -1,2 +1,6 @@ #!/bin/bash -curl -s -d POSTDATA --user $(