mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-11-24 02:37:05 +00:00
show less output when updating DNS configuration
This commit is contained in:
parent
389c354c8f
commit
f1dac1fe13
@ -31,19 +31,27 @@ def do_dns_update(env):
|
|||||||
updated_domains.append(domain)
|
updated_domains.append(domain)
|
||||||
|
|
||||||
# Write the main nsd.conf file.
|
# Write the main nsd.conf file.
|
||||||
write_nsd_conf(zonefiles)
|
if write_nsd_conf(zonefiles):
|
||||||
|
# Make sure updated_domains contains *something* if we wrote an updated
|
||||||
|
# nsd.conf so that we know to restart nsd.
|
||||||
|
if len(updated_domains) == 0:
|
||||||
|
updated_domains.append("DNS configuration")
|
||||||
|
|
||||||
|
# Kick nsd if anything changed.
|
||||||
|
if len(updated_domains) > 0:
|
||||||
|
os.system("service nsd restart")
|
||||||
|
|
||||||
# Write the OpenDKIM configuration tables.
|
# Write the OpenDKIM configuration tables.
|
||||||
write_opendkim_tables(zonefiles, env)
|
write_opendkim_tables(zonefiles, env)
|
||||||
|
|
||||||
# Kick nsd.
|
|
||||||
os.system("service nsd restart")
|
|
||||||
|
|
||||||
# Kick opendkim.
|
# Kick opendkim.
|
||||||
os.system("service opendkim restart")
|
os.system("service opendkim restart")
|
||||||
|
|
||||||
if len(updated_domains) == 0: updated_domains = ['(no domains required an update)']
|
if len(updated_domains) == 0:
|
||||||
return "Updated: " + ",".join(updated_domains) + "\n"
|
# if nothing was updated (except maybe DKIM), don't show any output
|
||||||
|
return ""
|
||||||
|
else:
|
||||||
|
return "updated: " + ",".join(updated_domains) + "\n"
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
@ -136,8 +144,7 @@ $TTL 86400 ; default time to live
|
|||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
def write_nsd_conf(zonefiles):
|
def write_nsd_conf(zonefiles):
|
||||||
with open("/etc/nsd/nsd.conf", "w") as f:
|
nsdconf = """
|
||||||
f.write("""
|
|
||||||
server:
|
server:
|
||||||
hide-version: yes
|
hide-version: yes
|
||||||
|
|
||||||
@ -148,14 +155,25 @@ server:
|
|||||||
zonesdir: "/etc/nsd/zones"
|
zonesdir: "/etc/nsd/zones"
|
||||||
|
|
||||||
# ZONES
|
# ZONES
|
||||||
""")
|
"""
|
||||||
|
|
||||||
for domain, zonefile in zonefiles:
|
for domain, zonefile in zonefiles:
|
||||||
f.write("""
|
nsdconf += """
|
||||||
zone:
|
zone:
|
||||||
name: %s
|
name: %s
|
||||||
zonefile: %s
|
zonefile: %s
|
||||||
""" % (domain, zonefile))
|
""" % (domain, zonefile)
|
||||||
|
|
||||||
|
# Check if the nsd.conf is changing. If it isn't changing,
|
||||||
|
# return False to flag that no change was made.
|
||||||
|
with open("/etc/nsd/nsd.conf") as f:
|
||||||
|
if f.read() == nsdconf:
|
||||||
|
return False
|
||||||
|
|
||||||
|
with open("/etc/nsd/nsd.conf", "w") as f:
|
||||||
|
f.write(nsdconf)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ EOF
|
|||||||
|
|
||||||
# Write the DNS configuration files.
|
# Write the DNS configuration files.
|
||||||
sleep 5 # wait for the daemon to start
|
sleep 5 # wait for the daemon to start
|
||||||
curl -d POSTDATA http://127.0.0.1:10222/dns/update
|
curl -s -d POSTDATA http://127.0.0.1:10222/dns/update
|
||||||
|
|
||||||
# If there aren't any mail users yet, create one.
|
# If there aren't any mail users yet, create one.
|
||||||
if [ -z "`tools/mail.py user`" ]; then
|
if [ -z "`tools/mail.py user`" ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user