From: Ansuel Smith Date: Mon, 11 Jun 2018 15:13:31 +0000 (+0200) Subject: luci-app-ddns: use standard pkg info function X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=492d4d91b91b8fe6a7a03dd7304b787c2479364f;p=oweals%2Fluci.git luci-app-ddns: use standard pkg info function DDns script call another sh script to check ddns-scripts version. We can use the quicker IPKG.info function instead of execute another slow command. Signed-off-by: Ansuel Smith --- diff --git a/applications/luci-app-ddns/luasrc/controller/ddns.lua b/applications/luci-app-ddns/luasrc/controller/ddns.lua index bfd7a2a41..e152bb0d9 100755 --- a/applications/luci-app-ddns/luasrc/controller/ddns.lua +++ b/applications/luci-app-ddns/luasrc/controller/ddns.lua @@ -83,12 +83,12 @@ function app_title_main() tmp[#tmp+1] = [[]] @@ -97,29 +97,20 @@ function app_title_main() return table.concat(tmp) end -function service_version() - - local nxfs = require "nixio.fs" - local ver = nil - local ver_helper +function service_version() - if nxfs.access("/bin/opkg") then - ver_helper = "/bin/opkg info " .. srv_name .. " | grep 'Version'" + local srv_ver_cmd = luci_helper .. " -V | awk {'print $2'} " + local ver + + if IPKG then + ver = IPKG.info(srv_name)[srv_name].Version else - ver_helper = luci_helper .. " -V" + ver = UTIL.exec(srv_ver_cmd) end - local srv_ver_cmd = ver_helper .. " | awk {'print $2'} " + if ver and #ver > 0 then return ver or nil end - ver = UTIL.exec(srv_ver_cmd) - if ver and #ver > 0 then return ver end - - IPKG.list_installed(srv_name, function(n, v, d) - if v and (#v > 0) then ver = v end - end - ) - return ver end function service_ok()