The script it self can run forver now
* Add option for the script to repeat itself after N seconds * Add a Dockerfile so that this could be run inside docker
This commit is contained in:
parent
d46419ef3d
commit
b55e96d78c
13
Dockerfile
Normal file
13
Dockerfile
Normal file
|
@ -0,0 +1,13 @@
|
|||
FROM python:3.7-buster
|
||||
|
||||
LABEL maintainer=david@dme.ninja
|
||||
LABEL version="0.1"
|
||||
|
||||
# Copy scripts and requirements.txt
|
||||
COPY src/ /gandi-live-dns
|
||||
COPY requirements.txt /requirements.txt
|
||||
|
||||
# Install script requirements.txt
|
||||
RUN pip install -r /requirements.txt
|
||||
|
||||
CMD ["python", "/gandi-live-dns/gandi-live-dns.py", "-v", "-r", "3600"]
|
15
README.md
15
README.md
|
@ -99,12 +99,14 @@ Status Code: 201 , DNS Record Created , IP updated for subdomain3
|
|||
|
||||
```
|
||||
root@dyndns:~/gandi-live-dns-master/src# ./gandi-live-dns.py -h
|
||||
usage: gandi-live-dns.py [-h] [-f]
|
||||
usage: gandi-live-dns.py [-h] [-f] [-v] [-r]
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-f, --force force an update/create
|
||||
|
||||
-h, --help show this help message and exit
|
||||
-v, --verbose increase output verbosity
|
||||
-f, --force force an update/create
|
||||
-r REPEAT, --repeat REPEAT
|
||||
keep running and repeat every N seconds
|
||||
```
|
||||
|
||||
The force option runs the script, even when no IP change has been detected.
|
||||
|
@ -135,6 +137,11 @@ Run the script every five minutes.
|
|||
```
|
||||
*/5 * * * * /root/gandi-live-dns-master/src/gandi-live-dns.py >/dev/null 2>&1
|
||||
```
|
||||
|
||||
### Run with Docker
|
||||
|
||||
Use the docker file to build the image. With docker, the script will run every 3600 seconds. (This value can be changed in the Dockerfile.
|
||||
|
||||
### Limitations
|
||||
The XML-RPC API has a limit of 30 requests per 2 seconds, so i guess it's safe to update 25 subdomains at once with the REST API.
|
||||
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
Gandi v5 LiveDNS - DynDNS Update via REST API and CURL/requests
|
||||
|
||||
@author: cave
|
||||
@author: dvdme
|
||||
License GPLv3
|
||||
https://www.gnu.org/licenses/gpl-3.0.html
|
||||
|
||||
Created on 13 Aug 2017
|
||||
Forked on 08 Dec 2019
|
||||
http://doc.livedns.gandi.net/
|
||||
http://doc.livedns.gandi.net/#api-endpoint -> https://dns.gandi.net/api/v5/
|
||||
'''
|
||||
|
@ -17,6 +19,7 @@ import requests
|
|||
import ipaddress
|
||||
import config
|
||||
import argparse
|
||||
import threading as th
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
|
@ -111,7 +114,7 @@ def update_records(uuid, dynIP, subdomain, is_ipv6=False, verbose=False):
|
|||
|
||||
|
||||
|
||||
def main(force_update, verbosity):
|
||||
def main(force_update, verbosity, repeat):
|
||||
|
||||
if verbosity:
|
||||
print('verbosity turned on')
|
||||
|
@ -119,6 +122,9 @@ def main(force_update, verbosity):
|
|||
else:
|
||||
verbose =False
|
||||
|
||||
if repeat and verbose:
|
||||
print(f'repeat turned on, will repeat every {repeat} seconds')
|
||||
|
||||
#get zone ID from Account
|
||||
uuid = get_uuid()
|
||||
|
||||
|
@ -150,10 +156,16 @@ def main(force_update, verbosity):
|
|||
print (f'IP Address Mismatch - going to update the DNS Records for the subdomains with new IP {dynIP}')
|
||||
for sub in subdomains:
|
||||
update_records(uuid, dynIP, sub, is_ipv6, verbose)
|
||||
if repeat:
|
||||
if verbosity:
|
||||
print(f'Repeating in {repeat} seconds')
|
||||
th.Timer(repeat, main, [force_update, verbosity, repeat]).start()
|
||||
|
||||
|
||||
if __name__ == '__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/create', action='store_true')
|
||||
parser.add_argument('-r', '--repeat', type=int, help='keep running and repeat every N seconds')
|
||||
args = parser.parse_args()
|
||||
main(args.force, args.verbose)
|
||||
main(args.force, args.verbose, args.repeat)
|
||||
|
|
Loading…
Reference in a new issue