Last active
December 17, 2015 18:39
-
-
Save beigna/5655116 to your computer and use it in GitHub Desktop.
Use Linode as DynDNS (DDNS) with your OpenWRT router (or Linux Box) for a cute domains ;)
This file contains hidden or 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 | |
DOMAIN_ID=$(uci get linode_dns.casa.domain_id) | |
RESOURCE_ID=$(uci get linode_dns.casa.resource_id) | |
API_KEY=$(uci get linode_dns.casa.api_key) | |
WGET="wget --no-check-certificate -qO - " | |
LAST_IP=$($WGET https://api.linode.com/?api_key=$API_KEY\&api_action=domain.resource.list\&DomainID=$DOMAIN_ID\&ResourceID=$RESOURCE_ID | sed -e 's/.*TARGET":"//' -e 's/".*$//') | |
CURRENT_IP=$($WGET http://checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//') | |
logger "Asigned: $LAST_IP - Current: $CURRENT_IP" | |
if [ "$CURRENT_IP" = "$LAST_IP" ]; then | |
logger "No IP address change detected. Keeping $CURRENT_IP" | |
else | |
RESPONSE=$($WGET https://api.linode.com/?api_key=$API_KEY\&api_action=domain.resource.update\&DomainID=$DOMAIN_ID\&ResourceID=$RESOURCE_ID\&Target=$CURRENT_IP) | |
logger "Updated IP address to $CURRENT_IP" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment