summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAnsuel Smith <ansuelsmth@gmail.com>2018-06-11 17:13:31 +0200
committerAnsuel Smith <ansuelsmth@gmail.com>2018-06-11 17:13:31 +0200
commit492d4d91b91b8fe6a7a03dd7304b787c2479364f (patch)
treee399a9082ca36744d3f0c86621833331ae86937e
parent8a4c3a01bf5a9a9dfda17aea1eaab72a1c71e8a9 (diff)
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 <ansuelsmth@gmail.com>
-rwxr-xr-xapplications/luci-app-ddns/luasrc/controller/ddns.lua31
1 files changed, 11 insertions, 20 deletions
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] = [[<a href="javascript:alert(']]
tmp[#tmp+1] = I18N.translate("Version Information")
tmp[#tmp+1] = [[\n\n]] .. app_name
- tmp[#tmp+1] = [[\n\t]] .. I18N.translate("Version") .. [[:\t]] .. app_version
+ tmp[#tmp+1] = [[\n]] .. I18N.translate("Version") .. [[: ]] .. app_version
tmp[#tmp+1] = [[\n\n]] .. srv_name .. [[ ]] .. I18N.translate("required") .. [[:]]
- tmp[#tmp+1] = [[\n\t]] .. I18N.translate("Version") .. [[:\t]]
+ tmp[#tmp+1] = [[\n]] .. I18N.translate("Version") .. [[: ]]
tmp[#tmp+1] = srv_ver_min .. [[ ]] .. I18N.translate("or higher")
tmp[#tmp+1] = [[\n\n]] .. srv_name .. [[ ]] .. I18N.translate("installed") .. [[:]]
- tmp[#tmp+1] = [[\n\t]] .. I18N.translate("Version") .. [[:\t]]
+ tmp[#tmp+1] = [[\n]] .. I18N.translate("Version") .. [[: ]]
tmp[#tmp+1] = (service_version() or I18N.translate("NOT installed"))
tmp[#tmp+1] = [[\n\n]]
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()