updated README, added command line Arguments.
This commit is contained in:
parent
e3cc81a10d
commit
a2adf9ecab
27
README.md
27
README.md
|
@ -3,13 +3,11 @@ gandi_live_dns
|
||||||
|
|
||||||
This is a simple dynamic DNS updater for the
|
This is a simple dynamic DNS updater for the
|
||||||
[Gandi](https://www.gandi.net) registrar. It uses their REST API to update
|
[Gandi](https://www.gandi.net) registrar. It uses their REST API to update
|
||||||
the zone file for a subdomain of a domain name to point at the external IPv4
|
the zone file for a subdomain of a domain to point at the external IPv4
|
||||||
address of the computer it has been run from.
|
address of the computer it has been run from.
|
||||||
|
|
||||||
It has been developed and tested on Debian 8 Jessie GNU/Linux using Python 2.7.
|
It has been developed and tested on Debian 8 Jessie GNU/Linux using Python 2.7.
|
||||||
|
|
||||||
This DynDNS updater is inspired by https://github.com/jasontbradshaw/gandi-dyndns which worked very well
|
|
||||||
with the classic DNS from Gandi v4Website and their XML-RPC API.
|
|
||||||
With the new v5 Website, Gandi has also launched a
|
With the new v5 Website, Gandi has also launched a
|
||||||
new REST API which makes it easier to communicate via bash/curl or python/requests.
|
new REST API which makes it easier to communicate via bash/curl or python/requests.
|
||||||
|
|
||||||
|
@ -25,12 +23,29 @@ key by following their directions.
|
||||||
#### A Record Setup
|
#### A Record Setup
|
||||||
Create the DNS A Records in the GANDI Webinterface which you want to update if your IP changes.
|
Create the DNS A Records in the GANDI Webinterface which you want to update if your IP changes.
|
||||||
|
|
||||||
|
#### Git Clone or Download the Script
|
||||||
|
Download the Script from [GitHub](https://github.com/cavebeat/gandi_live_dns/archive/master.zip)
|
||||||
|
or
|
||||||
|
`git clone https://github.com/cavebeat/gandi_live_dns.git`
|
||||||
|
|
||||||
#### Script Configuration
|
#### Script Configuration
|
||||||
Then you'd need to configure the script.
|
Then you'd need to configure the script in the src directory.
|
||||||
|
|
||||||
Copy `example.config.py` to `config.py`, and put it in the same directory
|
Copy `example.config.py` to `config.py`, and put it in the same directory
|
||||||
as the script.
|
as the script.
|
||||||
|
|
||||||
|
#### Run the script
|
||||||
|
|
||||||
yada yada ...
|
Make the script executeable.
|
||||||
more to come
|
|
||||||
|
`
|
||||||
|
$ cd gandi_live_dns/src
|
||||||
|
$ chmod +x gandi_live_dns.py
|
||||||
|
`
|
||||||
|
And run the script
|
||||||
|
`
|
||||||
|
$ ./gandi_live_dns.py
|
||||||
|
`
|
||||||
|
|
||||||
|
This DynDNS updater is inspired by https://github.com/jasontbradshaw/gandi-dyndns which worked very well
|
||||||
|
with the classic DNS from Gandiv4 Website and their XML-RPC API.
|
34
src/gandi_live_dns.py
Normal file → Executable file
34
src/gandi_live_dns.py
Normal file → Executable file
|
@ -1,8 +1,10 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
'''
|
'''
|
||||||
Gandi v5 LiveDNS - DynDNS Update via REST API and CURL/requests
|
Gandi v5 LiveDNS - DynDNS Update via REST API and CURL/requests
|
||||||
|
|
||||||
@author: cave
|
@author: cave
|
||||||
Licsense GPLv3
|
License GPLv3
|
||||||
https://www.gnu.org/licenses/gpl-3.0.html
|
https://www.gnu.org/licenses/gpl-3.0.html
|
||||||
|
|
||||||
Created on 13 Aug 2017
|
Created on 13 Aug 2017
|
||||||
|
@ -12,6 +14,7 @@ http://doc.livedns.gandi.net/#api-endpoint -> https://dns.beta.gandi.net/api/v5/
|
||||||
|
|
||||||
import requests, json
|
import requests, json
|
||||||
import config
|
import config
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def get_dynip(ifconfig_provider):
|
def get_dynip(ifconfig_provider):
|
||||||
|
@ -66,7 +69,13 @@ def update_records(uuid, dynIP, subdomain):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(force_update, verbosity):
|
||||||
|
|
||||||
|
if force_update:
|
||||||
|
print "force update turned on"
|
||||||
|
if verbosity:
|
||||||
|
print "verbosity turned on"
|
||||||
|
|
||||||
|
|
||||||
#get zone ID from Account
|
#get zone ID from Account
|
||||||
uuid = get_uuid()
|
uuid = get_uuid()
|
||||||
|
@ -75,15 +84,26 @@ def main():
|
||||||
dynIP = get_dynip(config.ifconfig)
|
dynIP = get_dynip(config.ifconfig)
|
||||||
dnsIP = get_dnsip(uuid)
|
dnsIP = get_dnsip(uuid)
|
||||||
|
|
||||||
if dynIP == dnsIP:
|
if force_update:
|
||||||
print "IP Address match - no further action"
|
print "Going to update the DNS Records for the subdomains"
|
||||||
else:
|
|
||||||
print "IP Address mismatch - going to update the DNS Records for the subdomains"
|
|
||||||
for sub in config.subdomains:
|
for sub in config.subdomains:
|
||||||
update_records(uuid, dynIP, sub)
|
update_records(uuid, dynIP, sub)
|
||||||
|
else:
|
||||||
|
if dynIP == dnsIP:
|
||||||
|
print "IP Address Match - no further action"
|
||||||
|
else:
|
||||||
|
print "IP Address Mismatch - going to update the DNS Records for the subdomains"
|
||||||
|
for sub in config.subdomains:
|
||||||
|
update_records(uuid, dynIP, sub)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('-v', '--verbose', help="increase output verbosity", action="store_true")
|
||||||
|
parser.add_argument('-f', '--force', help="force an update", action="store_true")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
main(args.force, args.verbose)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue