-
-
Save bborysenko/7821974 to your computer and use it in GitHub Desktop.
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/bash | |
#WTFPL 2013 "napcae" Chi Trung Nguyen | |
# | |
#just put in your values here | |
#You can find the client_id and api_key in your DO dashboard | |
#To get the domain_id and record_id use just paste this in a browser and copy the values: | |
#domain_id: https://api.digitalocean.com/domains?client_id=[your_client_id]&api_key=[your_api_key] | |
#record_id: https://api.digitalocean.com/domains/[domain_id]/records?client_id=[your_client_id]&api_key=[your_api_key] | |
#see https://api.digitalocean.com/ for more information | |
###################################################################################################################### | |
client_id= | |
api_key= | |
domain_id= | |
record_id= | |
externalIP= | |
#after that '$ crontab -e' and paste '*/15 * * * * /path/to/script', the script will update every 15 minutes | |
function get_externalIP { | |
curl -s http://checkip.dyndns.org | sed 's/[a-zA-Z/<> :]//g' | tr -d '\r' | |
} | |
externalIP_new=$(get_externalIP) | |
function update_record { | |
curl -k "https://api.digitalocean.com/domains/"${domain_id}"/records/"${record_id}"/edit?client_id="${client_id}"&api_key="${api_key}"&data="${externalIP_new}"" | |
} | |
update_record |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment