Created
November 5, 2015 14:28
-
-
Save oliveratgithub/a50a3d6bcb1e030ed06e to your computer and use it in GitHub Desktop.
Automatic Dynamics DNS updater using HTTP API calls, prepared for TwoDNS.de / Two-DNS.de (works with any other DDNS Service, allowing IP updates via HTTP API calls)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
log="ddns_updater.log.txt" | |
my_ext_ip=$(curl -sS http://icanhazip.com) | |
echo "\n\n\n===== \ | |
\n$(date -u) \ | |
\nUpdating IP to: $my_ext_ip \n" >> $log | |
curl -isSX PUT \ | |
-u "[email protected]:api_token" \ | |
-H "Content-Type: application/json" \ | |
--data '{"ip_address":"'$my_ext_ip'", "activate_wildcard": "false"}' \ | |
https://api.twodns.de/hosts/host.dynvpn.de >> $log | |
exit |
Your suggestion is indeed very useful, thanks! Currently I have the script scheduled via Cron to fire it up periodically. To run it via nohup there would need to be some sort of loop and a waiting mechanism between the actions. And if I'm understanding it correctly if any changes to the script were to be made, the current nohup instance must be stopped and a new one needs to be started.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gerlof85 cool thanks for pointing this out. It would be possible to make the Shell Script run using nohup and thus won’t need to write the current IP into an additional file - only store it in a global var within the script.
Would this adjustment serve your needs as well?