Private GIT

Skip to content
Snippets Groups Projects
Commit 7c6fe2ad authored by arjuan's avatar arjuan
Browse files

typos and clarifications

parent f4bf889c
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,6 @@ Simple Python script to update DNS A record of your domain dynamically using gan ...@@ -2,6 +2,6 @@ Simple Python script to update DNS A record of your domain dynamically using gan
http://doc.livedns.gandi.net/ http://doc.livedns.gandi.net/
The config-example.txt file should be renamed to config.txt, and modified with your gandi.net API key, domain name, and A-record (@, dev, home, pi, etc). The config-template.txt file should be renamed to config.txt, and modified with your gandi.net API key, domain name, and A-record (@, dev, home, pi, etc).
Every time the script runs, it will query an external service to retrieve the external IP of the machine, compare it to the current record (if any) in the zone at gandi.net, and then add a new record (if none currently exists), or delete then add a new record (if a record already exists). Every time the script runs, it will query an external service to retrieve the external IP of the machine, compare it to the current record (if any) in the zone at gandi.net, and then add a new record (if none currently exists), or delete then add a new record (if a record already exists).
...@@ -69,10 +69,6 @@ def main(): ...@@ -69,10 +69,6 @@ def main():
sys.exit("please fill in the 'config.txt' file") sys.exit("please fill in the 'config.txt' file")
for section in config.sections(): for section in config.sections():
print(config.get(section, "api"))
print(config.get(section, "domain"))
print(config.get(section, "a_name"))
print(config.get(section, "ttl"))
#Retrieve API key #Retrieve API key
apikey = config.get(section, "apikey") apikey = config.get(section, "apikey")
...@@ -81,8 +77,8 @@ def main(): ...@@ -81,8 +77,8 @@ def main():
headers = { 'Content-Type': 'application/json', 'X-Api-Key': '%s' % config.get(section, "apikey")} headers = { 'Content-Type': 'application/json', 'X-Api-Key': '%s' % config.get(section, "apikey")}
#Set URL #Set URL
url = 'https://dns.beta.gandi.net/api/v5/domains/%s/records/%s/A' % (config.get(section, "domain"), config.get(section, "a_name")) url = '%sdomains/%s/records/%s/A' % (config.get(section, "api"), config.get(section, "domain"), config.get(section, "a_name"))
print(url)
#Discover External IP #Discover External IP
external_ip = get_ip()[0:-1] external_ip = get_ip()[0:-1]
print("external IP is: %s" % external_ip) print("external IP is: %s" % external_ip)
...@@ -90,7 +86,7 @@ def main(): ...@@ -90,7 +86,7 @@ def main():
#Prepare record #Prepare record
payload = {'rrset_ttl': 900, 'rrset_values': [external_ip]} payload = {'rrset_ttl': 900, 'rrset_values': [external_ip]}
#Check if record already exists #Check if record already exists. If not, add record. If it does, delete then add record.
record = get_record(url, headers) record = get_record(url, headers)
if record.status_code == 404: if record.status_code == 404:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment