# configuration variables
server = 'ns.ralfj.de'
-user = 'yourusername'
+domains = ['your.domain.ralfj.de'] # list of domains to update
password = 'yourpassword'
-domain = 'your.domain.ralfj.de'
# END of configuration variables
-# 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)
+def update_domain(domain):
+ '''Update the given domain, using the global server, user, password. Returns True on success, False on failure.'''
+ # check if the domain is already mapped to our current IP
+ myip = urllib2.urlopen('https://'+server+'/checkip').read().strip()
+ domainip = socket.gethostbyname(domain)
+ if myip == domainip:
+ # nothing to do
+ return True
-# we need to update the IP
-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)
+ # we need to update the IP
+ result = urllib2.urlopen('https://'+server+'/update?password='+urllib.quote(password)+'&domain='+urllib.quote(domain)+'&ip='+urllib.quote(myip)).read().strip()
+ if 'good '+myip == result:
+ # all went all right
+ return True
+ else:
+ # Something went wrong
+ print "Unexpected answer from server",server,"while updating",domain,"to",myip
+ print result
+ return False
-# there was an error :(
-print result
-sys.exit(1)
+exitcode = 0
+for domain in domains:
+ if not update_domain(domain):
+ exitcode = 1
+sys.exit(exitcode)