Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomTurnschuh <36013390+TomTurnschuh@users.noreply.github.com>2018-09-21 15:29:25 +0300
committernachoparker <nacho@ownyourbits.com>2018-09-23 17:55:00 +0300
commit5914624e3f7ac559c8f379cb0547e5bdf859adb5 (patch)
treec1d2a30d203ec1f540721f2442cb9fdbae360d5e
parent4720e20385f71af6fc4f5508aabff7061a569261 (diff)
DDNS_spdyn.sh : Send new IP only when changed.v0.60.2
-rw-r--r--etc/ncp-config.d/DDNS_spDYN.sh14
1 files changed, 13 insertions, 1 deletions
diff --git a/etc/ncp-config.d/DDNS_spDYN.sh b/etc/ncp-config.d/DDNS_spDYN.sh
index 8543d218..6ab22b67 100644
--- a/etc/ncp-config.d/DDNS_spDYN.sh
+++ b/etc/ncp-config.d/DDNS_spDYN.sh
@@ -89,8 +89,14 @@ 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"
@@ -98,8 +104,14 @@ if [ $# -eq 3 ]
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