updated README, added command line Arguments.
This commit is contained in:
parent
e3cc81a10d
commit
a2adf9ecab
33
README.md
33
README.md
|
@ -3,13 +3,11 @@ gandi_live_dns
|
|||
|
||||
This is a simple dynamic DNS updater for the
|
||||
[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.
|
||||
|
||||
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
|
||||
new REST API which makes it easier to communicate via bash/curl or python/requests.
|
||||
|
||||
|
@ -18,19 +16,36 @@ new REST API which makes it easier to communicate via bash/curl or python/reques
|
|||
You want your homeserver to be always available at `dynamic.mydomain.tld`.
|
||||
|
||||
#### API Key
|
||||
First, you must apply for an API key with Gandi. Visit
|
||||
https://account.gandi.net/en/ and apply for (at least) the production API
|
||||
First, you must apply for an API key with Gandi. Visit
|
||||
https://account.gandi.net/en/ and apply for (at least) the production API
|
||||
key by following their directions.
|
||||
|
||||
#### A Record Setup
|
||||
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
|
||||
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
|
||||
as the script.
|
||||
|
||||
|
||||
yada yada ...
|
||||
more to come
|
||||
#### Run the script
|
||||
|
||||
Make the script executeable.
|
||||
|
||||
`
|
||||
$ 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.
|
36
src/gandi_live_dns.py
Normal file → Executable file
36
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
|
||||
|
||||
@author: cave
|
||||
Licsense GPLv3
|
||||
License GPLv3
|
||||
https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
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 config
|
||||
import argparse
|
||||
|
||||
|
||||
def get_dynip(ifconfig_provider):
|
||||
|
@ -66,8 +69,14 @@ def update_records(uuid, dynIP, subdomain):
|
|||
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
|
||||
uuid = get_uuid()
|
||||
|
||||
|
@ -75,15 +84,26 @@ def main():
|
|||
dynIP = get_dynip(config.ifconfig)
|
||||
dnsIP = get_dnsip(uuid)
|
||||
|
||||
if dynIP == dnsIP:
|
||||
print "IP Address match - no further action"
|
||||
else:
|
||||
print "IP Address mismatch - going to update the DNS Records for the subdomains"
|
||||
if force_update:
|
||||
print "Going to update the DNS Records for the subdomains"
|
||||
for sub in config.subdomains:
|
||||
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__":
|
||||
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