Added --showcfg option to display config file data
This commit is contained in:
4
TODO
4
TODO
@@ -21,9 +21,9 @@ Done:
|
|||||||
-i ipadress
|
-i ipadress
|
||||||
-k keyname
|
-k keyname
|
||||||
-n hostname
|
-n hostname
|
||||||
-p password
|
|
||||||
-q quiet
|
-q quiet
|
||||||
-s showcfg *
|
-s keysecret
|
||||||
|
--showcfg
|
||||||
-t ttl
|
-t ttl
|
||||||
-v verbose
|
-v verbose
|
||||||
- Auto-detect the machine's external ip address'
|
- 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",
|
parser.add_option("-s", "--keysecret",
|
||||||
type="string",
|
type="string",
|
||||||
help="TSIG key")
|
help="TSIG key")
|
||||||
|
parser.add_option("--showcfg",
|
||||||
|
type="string",
|
||||||
|
help="Display config file data")
|
||||||
parser.add_option("-u", "--ipurl",
|
parser.add_option("-u", "--ipurl",
|
||||||
type="string",
|
type="string",
|
||||||
help="URL to ip server")
|
help="URL to ip server")
|
||||||
@@ -90,6 +93,7 @@ def getparams(msg):
|
|||||||
'keyname',
|
'keyname',
|
||||||
'keysecret',
|
'keysecret',
|
||||||
'quiet',
|
'quiet',
|
||||||
|
'showcfg',
|
||||||
'ttl',
|
'ttl',
|
||||||
'ipurl']
|
'ipurl']
|
||||||
|
|
||||||
@@ -112,7 +116,7 @@ def getparams(msg):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def readcfg(msg):
|
def readcfg(msg, show=""):
|
||||||
# Read the config file for pre configured values
|
# Read the config file for pre configured values
|
||||||
import os.path
|
import os.path
|
||||||
if not msg.has_key('cfgfile'):
|
if not msg.has_key('cfgfile'):
|
||||||
@@ -126,11 +130,18 @@ def readcfg(msg):
|
|||||||
return msg
|
return msg
|
||||||
cfgfile = open(msg['cfgfile'], 'r')
|
cfgfile = open(msg['cfgfile'], 'r')
|
||||||
|
|
||||||
|
if show:
|
||||||
|
print "Current configuration values:"
|
||||||
|
|
||||||
for line in cfgfile.readlines():
|
for line in cfgfile.readlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line.find("#", 0, 1) == 0 or not line:
|
if line.find("#", 0, 1) == 0 or not line:
|
||||||
continue
|
continue
|
||||||
(key, value) = line.split('\t', 1)
|
(key, value) = line.split('\t', 1)
|
||||||
|
|
||||||
|
if show:
|
||||||
|
print "%s: %s" % (key.strip(), value.strip())
|
||||||
|
|
||||||
if not value.strip().lower() == "false":
|
if not value.strip().lower() == "false":
|
||||||
msg[key] = value.strip()
|
msg[key] = value.strip()
|
||||||
|
|
||||||
@@ -221,6 +232,11 @@ if __name__=="__main__":
|
|||||||
msg['error'] = []
|
msg['error'] = []
|
||||||
|
|
||||||
getparams(msg)
|
getparams(msg)
|
||||||
|
|
||||||
|
if msg.has_key('showcfg'):
|
||||||
|
readcfg(msg, show="config")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
validate(msg)
|
validate(msg)
|
||||||
|
|
||||||
err = checkerror(msg)
|
err = checkerror(msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user