Commit 30178ef0 authored by Joshua Tauberer's avatar Joshua Tauberer

add a --force flag to dns_update

parent cd590259
......@@ -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)
......
......@@ -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
......
#!/bin/bash
curl -s -d POSTDATA --user $(</var/lib/mailinabox/api.key): http://127.0.0.1:10222/dns/update
POSTDATA=dummy
if [ "$1" == "--force" ]; then
POSTDATA=force=1
fi
curl -s -d $POSTDATA --user $(</var/lib/mailinabox/api.key): http://127.0.0.1:10222/dns/update
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment