allow config of dyndomains
This commit is contained in:
@@ -253,10 +253,10 @@ def pushmattermost(msg):
|
||||
|
||||
# nsupdate: set the DNS A record for a fqdn
|
||||
# return: None if ok, else error text
|
||||
def nsupdate(hostname, newip):
|
||||
def nsupdate(hostname, newip, dyndomain):
|
||||
D = {}
|
||||
D['domain'] = dyndomain
|
||||
D['fqdn'] = dynfqdn % hostname
|
||||
D['fqdn'] = "%s.dy.%s" % (hostname, dyndomain)
|
||||
D['dnsttl'] = '5'
|
||||
D['newip'] = newip
|
||||
D['ts'] = time.strftime('%Y-%m-%d.%H:%M:%S', time.gmtime())
|
||||
@@ -280,7 +280,7 @@ answer
|
||||
""" % D
|
||||
|
||||
if DEBUG > 0: log(None, "DBG: nsup %s" % nsup)
|
||||
cmd = [nsupdate_bin, "-k", "/etc/dhcpc/K%(domain)s.+157+00000." % D, "-v"]
|
||||
cmd = [nsupdate_bin, "-k", "/etc/dhcpc/Kdy.%(domain)s.+157+00000." % D, "-v"]
|
||||
if DEBUG > 0: log(None, "DBG: cmd %s" % cmd)
|
||||
try:
|
||||
p = Popen(cmd, shell=False, bufsize=1, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
|
||||
@@ -389,10 +389,11 @@ def dnsupdatethread():
|
||||
while True:
|
||||
name, addr = hbdclass.Host.dnsQ.get()
|
||||
m = "changed address to %s" % (addr)
|
||||
err = nsupdate(name, addr)
|
||||
for dyndomain in dyndomains:
|
||||
err = nsupdate(name, addr, dyndomain)
|
||||
if err:
|
||||
m += ", DNS update failed: %s" % err
|
||||
email("error: nsupdate failed", "%s: %s" % (name, m))
|
||||
email("error: nsupdate failed", "%s.dy.%s: %s" % (name, dyndomain, m))
|
||||
else:
|
||||
m += ", DNS updated."
|
||||
hbdclass.Host.dnsQ.task_done()
|
||||
|
||||
Reference in New Issue
Block a user