update-client: exit 1 in case of failure; make the server we talk to configurable
authorRalf Jung <post@ralfj.de>
Tue, 10 Sep 2013 15:33:26 +0000 (17:33 +0200)
committerRalf Jung <post@ralfj.de>
Tue, 10 Sep 2013 15:33:26 +0000 (17:33 +0200)
client.py

index 5c1b6309ca2bf4f7bee4c02c7c0084434e43c24f..a4d41fa86ac646da3008a89fddc1b652927ba1ac 100755 (executable)
--- 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)