Skip to content

Commit

Permalink
DDNS_spdyn.sh : Send new IP only when changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTurnschuh authored and nachoparker committed Sep 23, 2018
1 parent 4720e20 commit 5914624
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion etc/ncp-config.d/DDNS_spDYN.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,29 @@ function spdnsUpdater {
if [ $# -eq 3 ]
then
# if hostname and token
# Get current IP address
# Get registered IP address
registeredIP=\$(nslookup ${DOMAIN_}|tail -n2|grep A|sed s/[^0-9.]//g)
# Get current IP address
currip=$(curl -s "$get_ip_url");
# Update only when IP address has changed.
[ "\$currentIP" == "\$registeredIP" ] && {
return 0
}
host=$1
token=$2
params="-d hostname=$host -d myip=$currip -d user=$host -d pass=$token"
spdnsUpdater "$params"
elif [ $# -eq 4 ]
then
# if hostname and user and passwd
# Get registered IP address
registeredIP=\$(nslookup ${DOMAIN_}|tail -n2|grep A|sed s/[^0-9.]//g)
# Get current IP address
currip=$(curl -s "$get_ip_url");
# Update only when IP address has changed.
[ "\$currentIP" == "\$registeredIP" ] && {
return 0
}
host=$1
user=$2
pass=$4
Expand Down

0 comments on commit 5914624

Please sign in to comment.