From: Ralf Jung Date: Tue, 10 Sep 2013 15:33:26 +0000 (+0200) Subject: update-client: exit 1 in case of failure; make the server we talk to configurable X-Git-Url: https://git.ralfj.de/dyn-nsupdate.git/commitdiff_plain/0f7c85cebd0ecebf94390fb7ab380327e1068b20?ds=inline update-client: exit 1 in case of failure; make the server we talk to configurable --- diff --git a/client.py b/client.py index 5c1b630..a4d41fa 100755 --- a/client.py +++ b/client.py @@ -1,21 +1,26 @@ #!/usr/bin/python import urllib2, socket, urllib, sys + # configuration variables +server = 'ns.ralfj.de' user = 'yourusername' password = 'yourpassword' domain = 'your.domain.ralfj.de' # END of configuration variables -myip = urllib2.urlopen('https://ns.ralfj.de/checkip').read().strip() + +# check if the domain is already mapped to our current IP +myip = urllib2.urlopen('https://'+server+'/checkip').read().strip() currip = socket.gethostbyname(domain) if myip == currip: # nothing to do sys.exit(0) # we need to update the IP -result = urllib2.urlopen('https://ns.ralfj.de/update?user='+urllib.quote(user)+'&password='+urllib.quote(password)+'&domain='+urllib.quote(domain)+'&ip='+urllib.quote(myip)).read().strip() +result = urllib2.urlopen('https://'+server+'/update?user='+urllib.quote(user)+'&password='+urllib.quote(password)+'&domain='+urllib.quote(domain)+'&ip='+urllib.quote(myip)).read().strip() if 'good '+myip == result: # nothing to do, all went all right sys.exit(0) # there was an error :( print result +sys.exit(1)