X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-app-ddns%2Fluasrc%2Ftools%2Fddns.lua;h=209d9c3a4152576ce8f44c7439f5a6306d2103a5;hp=8868f32bcdf9f1fc1b1684088d1eec41077a9075;hb=5180a5bb8bcab18e06d25dbe94ba3f5e37e66248;hpb=6982bbb3fef11c0817c5674db2082fe87ba11a92 diff --git a/applications/luci-app-ddns/luasrc/tools/ddns.lua b/applications/luci-app-ddns/luasrc/tools/ddns.lua index 8868f32bc..209d9c3a4 100755 --- a/applications/luci-app-ddns/luasrc/tools/ddns.lua +++ b/applications/luci-app-ddns/luasrc/tools/ddns.lua @@ -16,20 +16,22 @@ local function _check_certs() return (v > 0) end -has_wgetssl = (UTIL.exec( [[which wget-ssl]] ) ~= "") -- and true or nil -has_curl = (UTIL.exec( [[which curl]] ) ~= "") -has_curlssl = (SYS.call( [[$(which curl) -V | grep "Protocols:" | grep -qF "https"]] ) ~= 0) +has_wgetssl = (SYS.call( [[which wget-ssl >/dev/null 2>&1]] ) == 0) -- and true or nil +has_curl = (SYS.call( [[which curl >/dev/null 2>&1]] ) == 0) +has_curlssl = (SYS.call( [[$(which curl) -V 2>&1 | grep "Protocols:" | grep -qF "https"]] ) ~= 0) has_curlpxy = (SYS.call( [[grep -i "all_proxy" /usr/lib/libcurl.so* >/dev/null 2>&1]] ) == 0) -has_fetch = (UTIL.exec( [[which uclient-fetch]] ) ~= "") +has_fetch = (SYS.call( [[which uclient-fetch >/dev/null 2>&1]] ) == 0) has_fetchssl = NXFS.access("/lib/libustream-ssl.so") -has_bbwget = (SYS.call( [[/usr/bin/wget -V 2>&1 | grep -iqF "busybox"]] ) == 0) -has_bindhost = (UTIL.exec( [[which host]] ) ~= "") -has_hostip = (UTIL.exec( [[which hostip]] ) ~= "") -has_nslookup = (SYS.call( [[$(which nslookup) 127.0.0.1 0 >/dev/null 2>&1]] ) ~= 0) +has_bbwget = (SYS.call( [[$(which wget) -V 2>&1 | grep -iqF "busybox"]] ) == 0) +has_bindhost = (SYS.call( [[which host >/dev/null 2>&1]] ) == 0) + or (SYS.call( [[which khost >/dev/null 2>&1]] ) == 0) + or (SYS.call( [[which drill >/dev/null 2>&1]] ) == 0) +has_hostip = (SYS.call( [[which hostip >/dev/null 2>&1]] ) == 0) +has_nslookup = (SYS.call( [[$(which nslookup) localhost 2>&1 | grep -qF "(null)"]] ) ~= 0) has_ipv6 = (NXFS.access("/proc/net/ipv6_route") and NXFS.access("/usr/sbin/ip6tables")) has_ssl = (has_wgetssl or has_curlssl or (has_fetch and has_fetchssl)) has_proxy = (has_wgetssl or has_curlpxy or has_fetch or has_bbwget) -has_forceip = ((has_wgetssl or has_curl) and (has_bindhost or has_hostip)) +has_forceip = (has_wgetssl or has_curl or has_fetch) -- only really needed for transfer has_dnsserver = (has_bindhost or has_hostip or has_nslookup) has_bindnet = (has_wgetssl or has_curl) has_cacerts = _check_certs() @@ -55,7 +57,7 @@ end function epoch2date(epoch, format) if not format or #format < 2 then local uci = UCI.cursor() - format = uci:get("ddns", "global", "date_format") or "%F %R" + format = uci:get("ddns", "global", "ddns_dateformat") or "%F %R" uci:unload("ddns") end format = format:gsub("%%n", "
") -- replace newline @@ -65,18 +67,18 @@ end -- read lastupdate from [section].update file function get_lastupd(section) - local uci = UCI.cursor() - local run_dir = uci:get("ddns", "global", "run_dir") or "/var/run/ddns" - local etime = tonumber(NXFS.readfile("%s/%s.update" % { run_dir, section } ) or 0 ) + local uci = UCI.cursor() + local rdir = uci:get("ddns", "global", "ddns_rundir") or "/var/run/ddns" + local etime = tonumber(NXFS.readfile("%s/%s.update" % { rdir, section } ) or 0 ) uci:unload("ddns") return etime end -- read PID from run file and verify if still running function get_pid(section) - local uci = UCI.cursor() - local run_dir = uci:get("ddns", "global", "run_dir") or "/var/run/ddns" - local pid = tonumber(NXFS.readfile("%s/%s.pid" % { run_dir, section } ) or 0 ) + local uci = UCI.cursor() + local rdir = uci:get("ddns", "global", "ddns_rundir") or "/var/run/ddns" + local pid = tonumber(NXFS.readfile("%s/%s.pid" % { rdir, section } ) or 0 ) if pid > 0 and not NX.kill(pid, 0) then pid = 0 end