make nsupdate bin configurable

This commit is contained in:
2020-01-15 16:38:42 -05:00
parent b607e652fe
commit 7cb3717176
+8 -3
View File
@@ -34,6 +34,8 @@ from subprocess import Popen, STDOUT, PIPE
import hbdclass
NSUPDATE_BIN = "/usr/local/bin/nsupdate" # override in .hbrc possible
SEND_EMAIL=False
SEND_PUSHOVER=True
@@ -241,7 +243,7 @@ answer
""" % D
if DEBUG > 0: log(None, "DBG: nsup %s" % nsup)
cmd = ["/usr/local/bin/nsupdate", "-k", "/etc/dhcpc/K%(domain)s.+157+00000." % D, "-v"]
cmd = [nsupdate_bin, "-k", "/etc/dhcpc/K%(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)
@@ -251,9 +253,9 @@ answer
return "nsupdate: some error occured"
(output, err) = p.communicate(nsup.encode())
if output.find('status: NOERROR') >= 0:
if output.decode().find('status: NOERROR') >= 0:
return None
return output
return output.decode()
#
@@ -826,6 +828,7 @@ grace = GRACE
watchhosts = []
dyndnshosts = []
drophosts = []
nsupdate_bin = NSUPDATE_BIN
try:
f = open(configfile, "r")
@@ -874,6 +877,8 @@ if f:
dyndnshosts = a
elif o == 'drophosts':
drophosts = a
elif o == 'nsupdate_bin':
nsupdate_bin = a
f.close()
if len(args) != 0: