diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000000000000000000000000000000000..f8d72addd5b40987096c2feb926b8dc940da4395 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,13 @@ +{ + "language": "python", + "python": "2.7", + "install": [ + "pip install -r requirements.txt" + ], + "script": [ + "pytest" + ], + "group": "stable", + "dist": "trusty", + "os": "linux" +} diff --git a/README.md b/README.md index d8c46c16875b7ea47d9b7c96c772e5f3617cde71..87cc9796db9d9bef7aca225d096e8e582b1d3958 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,14 @@ 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: - - ipaddress module (pip install ipaddress) - - requests module (pip install requests) - - json module (pip install json) +Requirements: + + pip install -r requirements.txt You can then run the script as a cron job : ``` -*/15 * * * * python /home/user/gandi-ddns.py +*/15 * * * * python /home/user/gandi_ddns.py ``` macOS diff --git a/gandi.ddns.plist b/gandi.ddns.plist index e0c6695238c17553d5fb8c288628e39e476abc81..f99a8ca210c6fcbf19743046ac15736565a63e2f 100644 --- a/gandi.ddns.plist +++ b/gandi.ddns.plist @@ -7,7 +7,7 @@ <key>ProgramArguments</key> <array> <string>/usr/local/bin/python3</string> - <string>gandi-ddns.py</string> + <string>gandi_ddns.py</string> </array> <key>RunAtLoad</key> diff --git a/gandi-ddns.py b/gandi_ddns.py similarity index 99% rename from gandi-ddns.py rename to gandi_ddns.py index e71ae3b542307db9aa7aadc8651c6a71dc897cd0..dcf6bd39e7bb59254d218cf1169db7cb6ba65dbe 100755 --- a/gandi-ddns.py +++ b/gandi_ddns.py @@ -95,4 +95,4 @@ def main(): update_record(url, headers, payload) if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..b7ccff5492b2823f8ba350316fb980ae42418cd0 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +configparser +ipaddress +requests \ No newline at end of file diff --git a/test_gandi_ddns.py b/test_gandi_ddns.py new file mode 100644 index 0000000000000000000000000000000000000000..d8235a885ef6916f91cf97807f4338bd39668e9e --- /dev/null +++ b/test_gandi_ddns.py @@ -0,0 +1,5 @@ +import gandi_ddns as script +import requests + +def test_get_ip(): + assert script.get_ip() == requests.get("http://ipecho.net/plain?").text \ No newline at end of file