diff --git a/TODO b/TODO index 4a65b51..4c1719f 100644 --- a/TODO +++ b/TODO @@ -21,9 +21,9 @@ Done: -i ipadress -k keyname -n hostname - -p password -q quiet - -s showcfg * + -s keysecret + --showcfg -t ttl -v verbose - Auto-detect the machine's external ip address' diff --git a/dnsupdate.py b/dnsupdate.py index dd9ab80..09a39ff 100644 --- a/dnsupdate.py +++ b/dnsupdate.py @@ -65,6 +65,9 @@ def getparams(msg): parser.add_option("-s", "--keysecret", type="string", help="TSIG key") + parser.add_option("--showcfg", + type="string", + help="Display config file data") parser.add_option("-u", "--ipurl", type="string", help="URL to ip server") @@ -90,6 +93,7 @@ def getparams(msg): 'keyname', 'keysecret', 'quiet', + 'showcfg', 'ttl', 'ipurl'] @@ -112,7 +116,7 @@ def getparams(msg): -def readcfg(msg): +def readcfg(msg, show=""): # Read the config file for pre configured values import os.path if not msg.has_key('cfgfile'): @@ -126,11 +130,18 @@ def readcfg(msg): return msg cfgfile = open(msg['cfgfile'], 'r') + if show: + print "Current configuration values:" + for line in cfgfile.readlines(): line = line.strip() if line.find("#", 0, 1) == 0 or not line: continue (key, value) = line.split('\t', 1) + + if show: + print "%s: %s" % (key.strip(), value.strip()) + if not value.strip().lower() == "false": msg[key] = value.strip() @@ -221,6 +232,11 @@ if __name__=="__main__": msg['error'] = [] getparams(msg) + + if msg.has_key('showcfg'): + readcfg(msg, show="config") + sys.exit(0) + validate(msg) err = checkerror(msg)