From d093904bc1d47e65bba6e262ee4823090e94a415 Mon Sep 17 00:00:00 2001 From: Christian Schoenebeck Date: Sun, 15 Jan 2017 10:30:38 +0100 Subject: [PATCH 1/2] ddns-scripts: fix detecting local ip from ip command fix detecting local ip from ip command #3834 Signed-off-by: Christian Schoenebeck --- net/ddns-scripts/Makefile | 2 +- net/ddns-scripts/files/dynamic_dns_functions.sh | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net/ddns-scripts/Makefile b/net/ddns-scripts/Makefile index c57c9f326..7c2b388fa 100755 --- a/net/ddns-scripts/Makefile +++ b/net/ddns-scripts/Makefile @@ -12,7 +12,7 @@ PKG_NAME:=ddns-scripts PKG_VERSION:=2.7.6 # Release == build # increase on changes of services files or tld_names.dat -PKG_RELEASE:=11 +PKG_RELEASE:=12 PKG_LICENSE:=GPL-2.0 PKG_MAINTAINER:=Christian Schoenebeck diff --git a/net/ddns-scripts/files/dynamic_dns_functions.sh b/net/ddns-scripts/files/dynamic_dns_functions.sh index 001dfa4e6..597ad732d 100755 --- a/net/ddns-scripts/files/dynamic_dns_functions.sh +++ b/net/ddns-scripts/files/dynamic_dns_functions.sh @@ -907,6 +907,8 @@ get_local_ip () { __ERR=$? if [ $__ERR -eq 0 ]; then # DATFILE (sample) + # 10: l2tp-inet: mtu 1456 qdisc fq_codel state UNKNOWN qlen 3\ link/ppp + # 10: l2tp-inet inet 95.30.176.51 peer 95.30.176.1/32 scope global l2tp-inet\ valid_lft forever preferred_lft forever # 5: eth1: mtu 1500 qdisc fq_codel state UP qlen 1000\ link/ether 08:00:27:d0:10:32 brd ff:ff:ff:ff:ff:ff # 5: eth1 inet 172.27.10.128/24 brd 172.27.10.255 scope global eth1\ valid_lft forever preferred_lft forever # 5: eth1 inet 172.55.55.155/24 brd 172.27.10.255 scope global eth1\ valid_lft 12345sec preferred_lft 12345sec @@ -915,9 +917,9 @@ get_local_ip () { # 5: eth1 inet6 fd43:5368:6f6d:6500:a00:27ff:fed0:1032/64 scope global dynamic \ valid_lft 14352sec preferred_lft 14352sec # 5: eth1 inet6 2002:b0c7:f326::a00:27ff:fed0:1032/64 scope global dynamic \ valid_lft 14352sec preferred_lft 14352sec - # remove remove remove replace remove remove - # BROADCAST inet6 fxxx sec forever=>-1 between / and pref.. linestart to inet - sed -i "/BROADCAST/d; /inet6 f/d; s/sec//g; s/forever/-1/g; s/\/.*preferred_lft//g; s/^.*$ip_interface *//g" $DATFILE + # remove remove remove replace remove remove + # link inet6 fxxx sec forever=>-1 between / and pref.. linestart to inet + sed -i "/link/d; /inet6 f/d; s/sec//g; s/forever/-1/g; s/\/.*preferred_lft//g; s/^.*$ip_interface *//g" $DATFILE local __TIME4=0; local __TIME6=0 local __TYP __ADR __TIME From 04d808ec43ebe19c93cc2c5f01fb3338a8f737f2 Mon Sep 17 00:00:00 2001 From: Christian Schoenebeck Date: Mon, 16 Jan 2017 21:08:33 +0100 Subject: [PATCH 2/2] ddns-scripts: 2nd fix detecting local ip from ip command Signed-off-by: Christian Schoenebeck --- net/ddns-scripts/files/dynamic_dns_functions.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/net/ddns-scripts/files/dynamic_dns_functions.sh b/net/ddns-scripts/files/dynamic_dns_functions.sh index 597ad732d..209409b35 100755 --- a/net/ddns-scripts/files/dynamic_dns_functions.sh +++ b/net/ddns-scripts/files/dynamic_dns_functions.sh @@ -886,7 +886,7 @@ send_update() { get_local_ip () { # $1 Name of Variable to store local IP (LOCAL_IP) local __CNT=0 # error counter - local __RUNPROG __DATA __URL __ERR + local __RUNPROG __DATA __URL __ERR __TMP [ $# -ne 1 ] && write_log 12 "Error calling 'get_local_ip()' - wrong number of parameters" write_log 7 "Detect local IP on '$ip_source'" @@ -917,9 +917,11 @@ get_local_ip () { # 5: eth1 inet6 fd43:5368:6f6d:6500:a00:27ff:fed0:1032/64 scope global dynamic \ valid_lft 14352sec preferred_lft 14352sec # 5: eth1 inet6 2002:b0c7:f326::a00:27ff:fed0:1032/64 scope global dynamic \ valid_lft 14352sec preferred_lft 14352sec - # remove remove remove replace remove remove - # link inet6 fxxx sec forever=>-1 between / and pref.. linestart to inet - sed -i "/link/d; /inet6 f/d; s/sec//g; s/forever/-1/g; s/\/.*preferred_lft//g; s/^.*$ip_interface *//g" $DATFILE + # remove remove remove replace replace + # link inet6 fxxx sec forever=>-1 / => ' ' to separate subnet from ip + sed "/link/d; /inet6 f/d; s/sec//g; s/forever/-1/g; s/\// /g" $DATFILE | \ + awk '{ print $3" "$4" "$NF }' > ${DATFILE}_tmp + # we only need inet? IP prefered time local __TIME4=0; local __TIME6=0 local __TYP __ADR __TIME @@ -934,7 +936,8 @@ get_local_ip () { __DATA4="$__ADR" __TIME4="$__TIME" } - done < $DATFILE + done < ${DATFILE}_tmp + rm ${DATFILE}_tmp else write_log 3 "ip Error: '$__ERR'" write_log 7 "$(cat $ERRFILE)" # report error