Private GIT

Skip to content
Snippets Groups Projects
Unverified Commit d77857f8 authored by rmarchant's avatar rmarchant Committed by GitHub
Browse files

Merge pull request #7 from guillaumewuip/sections

Fix sections loop and log datetime + session name
parents 451ba975 98845041
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -4,6 +4,7 @@ import os
import requests
import json
import ipaddress
from datetime import datetime
config_file = "config.txt"
......@@ -62,6 +63,7 @@ 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...')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment