add a --force flag to dns_update
This commit is contained in:
parent
cd59025979
commit
30178ef019
|
@ -65,7 +65,7 @@ def mail_domains():
|
||||||
def dns_update():
|
def dns_update():
|
||||||
from dns_update import do_dns_update
|
from dns_update import do_dns_update
|
||||||
try:
|
try:
|
||||||
return do_dns_update(env)
|
return do_dns_update(env, force=request.form.get('force', '') == '1')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return (str(e), 500)
|
return (str(e), 500)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ def get_custom_dns_config(env):
|
||||||
except:
|
except:
|
||||||
return { }
|
return { }
|
||||||
|
|
||||||
def do_dns_update(env):
|
def do_dns_update(env, force=False):
|
||||||
# What domains (and their zone filenames) should we build?
|
# What domains (and their zone filenames) should we build?
|
||||||
domains = get_dns_domains(env)
|
domains = get_dns_domains(env)
|
||||||
zonefiles = get_dns_zones(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
|
# See if the zone has changed, and if so update the serial number
|
||||||
# and write the zone file.
|
# 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.
|
# Zone was not updated. There were no changes.
|
||||||
continue
|
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].
|
# We set the administrative email address for every domain to domain_contact@[domain.com].
|
||||||
# You should probably create an alias to your email address.
|
# 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),
|
# 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.
|
# 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
|
return False
|
||||||
|
|
||||||
# If the existing serial is not less than a serial number
|
# If the existing serial is not less than a serial number
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
#!/bin/bash
|
#!/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
|
||||||
|
|
Loading…
Reference in New Issue