Added --showcfg option to display config file data
This commit is contained in:
4
TODO
4
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'
|
||||
|
||||
18
dnsupdate.py
18
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)
|
||||
|
||||
Reference in New Issue
Block a user