From 8bb49eb5edb9aa455816324b1fe69cb188c9f592 Mon Sep 17 00:00:00 2001 From: Ansuel Smith Date: Thu, 24 May 2018 03:36:38 +0200 Subject: [PATCH] ddns-scripts: fix unefficent sh script Currently this 3 variable are used only 1 time in the sh script and cause 10s of delay for them to load... move them to load only if it's required by the command. This also fix luci-app-ddns delay problem derived by calling dns_lucihelper (that use tdns_functions to load data) for the version. Signed-off-by: Ansuel Smith --- net/ddns-scripts/Makefile | 2 +- net/ddns-scripts/files/dynamic_dns_functions.sh | 11 ++++++----- net/ddns-scripts/files/update_cloudflare_com_v4.sh | 2 +- net/ddns-scripts/files/update_godaddy_com_v1.sh | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/net/ddns-scripts/Makefile b/net/ddns-scripts/Makefile index 792a2ea92..5487bf60d 100755 --- a/net/ddns-scripts/Makefile +++ b/net/ddns-scripts/Makefile @@ -12,7 +12,7 @@ PKG_NAME:=ddns-scripts PKG_VERSION:=2.7.7 # Release == build # increase on changes of services files or tld_names.dat -PKG_RELEASE:=6 +PKG_RELEASE:=7 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 c944fc2aa..845cc2b00 100755 --- a/net/ddns-scripts/files/dynamic_dns_functions.sh +++ b/net/ddns-scripts/files/dynamic_dns_functions.sh @@ -72,21 +72,17 @@ KNOT_HOST=$(which khost) DRILL=$(which drill) HOSTIP=$(which hostip) NSLOOKUP=$(which nslookup) -NSLOOKUP_MUSL=$($(which nslookup) localhost 2>&1 | grep -F "(null)") # not empty busybox compiled with musl # Transfer Programs WGET=$(which wget) WGET_SSL=$(which wget-ssl) CURL=$(which curl) -# CURL_SSL not empty then SSL support available -CURL_SSL=$($(which curl) -V 2>/dev/null | grep "Protocols:" | grep -F "https") + # CURL_PROXY not empty then Proxy support available CURL_PROXY=$(find /lib /usr/lib -name libcurl.so* -exec strings {} 2>/dev/null \; | grep -im1 "all_proxy") UCLIENT_FETCH=$(which uclient-fetch) -# UCLIENT_FETCH_SSL not empty then SSL support available -UCLIENT_FETCH_SSL=$(find /lib /usr/lib -name libustream-ssl.so* 2>/dev/null) # Global configuration settings # allow NON-public IP's @@ -723,6 +719,8 @@ do_transfer() { # 2nd choice is cURL IPv4/IPv6/HTTPS # libcurl might be compiled without Proxy or HTTPS Support elif [ -n "$CURL" ]; then + # CURL_SSL not empty then SSL support available + CURL_SSL=$($(which curl) -V 2>/dev/null | grep "Protocols:" | grep -F "https") __PROG="$CURL -RsS -o $DATFILE --stderr $ERRFILE" # check HTTPS support [ -z "$CURL_SSL" -a $use_https -eq 1 ] && \ @@ -765,6 +763,8 @@ do_transfer() { # uclient-fetch possibly with ssl support if /lib/libustream-ssl.so installed elif [ -n "$UCLIENT_FETCH" ]; then + # UCLIENT_FETCH_SSL not empty then SSL support available + UCLIENT_FETCH_SSL=$(find /lib /usr/lib -name libustream-ssl.so* 2>/dev/null) __PROG="$UCLIENT_FETCH -q -O $DATFILE" # force network/ip not supported [ -n "$__BINDIP" ] && \ @@ -1108,6 +1108,7 @@ get_registered_ip() { __RUNPROG="$__PROG $lookup_host >$DATFILE 2>$ERRFILE" __PROG="hostip" elif [ -n "$NSLOOKUP" ]; then # last use BusyBox nslookup + NSLOOKUP_MUSL=$($(which nslookup) localhost 2>&1 | grep -F "(null)") # not empty busybox compiled with musl [ $force_dnstcp -ne 0 ] && \ write_log 14 "Busybox nslookup - no support for 'DNS over TCP'" [ -n "$NSLOOKUP_MUSL" -a -n "$dns_server" ] && \ diff --git a/net/ddns-scripts/files/update_cloudflare_com_v4.sh b/net/ddns-scripts/files/update_cloudflare_com_v4.sh index 0c77e8b2b..1a800d286 100755 --- a/net/ddns-scripts/files/update_cloudflare_com_v4.sh +++ b/net/ddns-scripts/files/update_cloudflare_com_v4.sh @@ -20,7 +20,7 @@ # # check parameters -[ -z "$CURL_SSL" ] && write_log 14 "Cloudflare communication require cURL with SSL support. Please install" +[ -z "$CURL" ] && [ -z "$CURL_SSL" ] && write_log 14 "Cloudflare communication require cURL with SSL support. Please install" [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing key as 'username'" [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing secret as 'password'" [ $use_https -eq 0 ] && use_https=1 # force HTTPS diff --git a/net/ddns-scripts/files/update_godaddy_com_v1.sh b/net/ddns-scripts/files/update_godaddy_com_v1.sh index 9845d20a0..b8d527ca6 100755 --- a/net/ddns-scripts/files/update_godaddy_com_v1.sh +++ b/net/ddns-scripts/files/update_godaddy_com_v1.sh @@ -18,7 +18,7 @@ # # check parameters -[ -z "$CURL_SSL" ] && write_log 14 "GoDaddy communication require cURL with SSL support. Please install" +[ -z "$CURL" ] && [ -z "$CURL_SSL" ] && write_log 14 "GoDaddy communication require cURL with SSL support. Please install" [ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing key as 'username'" [ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing secret as 'password'" [ $use_https -eq 0 ] && use_https=1 # force HTTPS