diff --git a/README.md b/README.md index 6e80a26f52c25b68c4467b70a38ce03487013ddd..d8c46c16875b7ea47d9b7c96c772e5f3617cde71 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ The config-template.txt file should be renamed to config.txt, and modified with Every time the script runs, it will query an external service to retrieve the external IP of the machine, compare it to the current A record in the zone at gandi.net, and then update the record if the IP has changed. Requirements: - - Python 2.7 - ipaddress module (pip install ipaddress) - requests module (pip install requests) - json module (pip install json) diff --git a/gandi-ddns.py b/gandi-ddns.py index 7a73ec1c6a77873225b9e17c688aae1f350da8c3..e71ae3b542307db9aa7aadc8651c6a71dc897cd0 100755 --- a/gandi-ddns.py +++ b/gandi-ddns.py @@ -4,6 +4,7 @@ import os import requests import json import ipaddress +from datetime import datetime config_file = "config.txt" @@ -62,7 +63,8 @@ def main(): sys.exit("Please fill in the 'config.txt' file.") for section in config.sections(): - + print('%s - section %s' % (str(datetime.now()), section)) + #Retrieve API key apikey = config.get(section, 'apikey') @@ -86,7 +88,7 @@ def main(): print(('Current record value is: %s' % json.loads(record.text)['rrset_values'][0])) if(json.loads(record.text)['rrset_values'][0] == external_ip): print('No change in IP address. Goodbye.') - sys.exit() + continue else: print('No existing record. Adding...')