summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-vpnbypass/luasrc/model
diff options
context:
space:
mode:
authorStan Grishin <stangri@melmac.net>2020-09-21 18:33:51 +0000
committerStan Grishin <stangri@melmac.net>2020-09-21 18:33:51 +0000
commit053e3952f02319ae5e0d8668cf67ce8c4a8c7f6d (patch)
tree9d60e1d969d516c0117591a5064d1a9263b89ce3 /applications/luci-app-vpnbypass/luasrc/model
parent073b9ba3bdc932d28dbc49fb005e13bea494e610 (diff)
luci-app-vpnbypass: ACL update
Signed-off-by: Stan Grishin <stangri@melmac.net>
Diffstat (limited to 'applications/luci-app-vpnbypass/luasrc/model')
-rw-r--r--applications/luci-app-vpnbypass/luasrc/model/cbi/vpnbypass.lua18
1 files changed, 16 insertions, 2 deletions
diff --git a/applications/luci-app-vpnbypass/luasrc/model/cbi/vpnbypass.lua b/applications/luci-app-vpnbypass/luasrc/model/cbi/vpnbypass.lua
index 8a70bd1bb9..ed9599c90e 100644
--- a/applications/luci-app-vpnbypass/luasrc/model/cbi/vpnbypass.lua
+++ b/applications/luci-app-vpnbypass/luasrc/model/cbi/vpnbypass.lua
@@ -4,8 +4,22 @@ local sys = require "luci.sys"
local util = require "luci.util"
local packageName = "vpnbypass"
-local packageVersion, statusText = nil, nil
-packageVersion = tostring(util.trim(sys.exec("opkg list-installed " .. packageName .. " | awk '{print $3}'"))) or ""
+function getPackageVersion()
+ local opkgFile = "/usr/lib/opkg/status"
+ local line
+ local flag = false
+ for line in io.lines(opkgFile) do
+ if flag then
+ return line:match('[%d%.$-]+') or ""
+ elseif line:find("Package: " .. packageName:gsub("%-", "%%%-")) then
+ flag = true
+ end
+ end
+ return ""
+end
+
+local packageVersion = getPackageVersion()
+local statusText = nil
if packageVersion == "" then
statusText = translatef("%s is not installed or not found", packageName)
end