From fc9446deff48f889195f4b92df26d25d20e380ed Mon Sep 17 00:00:00 2001 From: Mikaela Suomalainen Date: Sun, 18 Jan 2015 12:31:18 +0200 Subject: [PATCH] ydns-simple: ready for testing... --- bash/ydns-simple | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/bash/ydns-simple b/bash/ydns-simple index 8e7b403..c20aae3 100755 --- a/bash/ydns-simple +++ b/bash/ydns-simple @@ -5,10 +5,15 @@ # which is a lot # more complex than this. +# yDNS details +USEREMAIL="" +PASSWORD="" +HOSTNAME="" + # Get IPv4 address WAN_IP4=$(dig +short myip.opendns.com @resolver1.opendns.com) if [ -f $HOME/.wan_ip4-cf.txt ]; then - OLD_WAN_IP4=$(cat $HOME/.wan_ip4-cf.txt) + OLD_WAN_IP4=$(cat $HOME/.wan_ip4-ydns.txt) else echo "No file, need IP4" OLD_WAN_IP4="" @@ -16,17 +21,27 @@ fi # Get IPv6 address WAN_IP6=$(dig +short myip.opendns.com AAAA @2620:0:ccc::2) -if [ -f $HOME/.wan_ip6-cf.txt ]; then - OLD_WAN_IP6=$(cat $HOME/.wan_ip6-cf.txt) +if [ -f $HOME/.wan_ip6-ydns.txt ]; then + OLD_WAN_IP6=$(cat $HOME/.wan_ip6-ydns.txt) else echo "No file, need IP6" OLD_WAN_IP6="" fi -#if [ "$WAN_IP" = "$OLD_WAN_IP" ]; then -# echo "IP Unchanged" -#else -# echo $WAN_IP > $HOME/.wan_ip-cf.txt -# echo "Updating DNS to $WAN_IP" -# curl -s https://www.cloudflare.com/api.html?a=DIUP\&hosts="$cfhost"\&u="$cfuser"\&tkn="$cfkey"\&ip="$WAN_IP" > /dev/null -#fi +# Update IPv4 +if [ "$WAN_IP4" = "$OLD_WAN_IP4" ]; then + echo "IP4 Unchanged" +else + echo $WAN_IP4 > $HOME/.wan_ip4-ydns.txt + echo "Updating DNS to $WAN_IP4" + curl -4 --basic -u"$USEREMAIL:$PASSWORD" --silent https://ydns.eu/api/v1/update/?host=$HOSTNAME +fi + +# Update IPv6 +if [ "$WAN_IP6" = "$OLD_WAN_IP6" ]; then + echo "IP6 Unchanged" +else + echo $WAN_IP6 > $HOME/.wan_ip6-ydns.txt + echo "Updating DNS to $WAN_IP6" + curl -6 --basic -u"$USEREMAIL:$PASSWORD" --silent https://ydns.eu/api/v1/update/?host=$HOSTNAME +fi