diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-10-20 10:07:21 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-10-20 10:08:36 +0200 |
commit | 3395656b9f687fd5e071a7805e0ba4c83f62906d (patch) | |
tree | ba5abed1e3a04396afe7ca63e9230ea55ca71c33 /applications/luci-app-ddns/root | |
parent | 1a47b37f1deadc2dceed0f4ef4817653a293c45c (diff) |
luci-app-ddns: get rid of luci-lib-ipkg depdency
Invoking opkg to obtain the installed package version is very slow and
resource intensive, parse the related control file directly to avoid
the extraneous dependency and resource consumption.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'applications/luci-app-ddns/root')
-rwxr-xr-x | applications/luci-app-ddns/root/usr/libexec/rpcd/luci.ddns | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/applications/luci-app-ddns/root/usr/libexec/rpcd/luci.ddns b/applications/luci-app-ddns/root/usr/libexec/rpcd/luci.ddns index 132c186642..6db329c186 100755 --- a/applications/luci-app-ddns/root/usr/libexec/rpcd/luci.ddns +++ b/applications/luci-app-ddns/root/usr/libexec/rpcd/luci.ddns @@ -153,21 +153,26 @@ local methods = { }, get_ddns_state = { call = function() - local ipkg = require "luci.model.ipkg" local uci = UCI.cursor() local dateformat = uci:get("ddns", "global", "ddns_dateformat") or "%F %R" local services_mtime = fs.stat(ddns_package_path .. "/list", 'mtime') uci:unload("ddns") - local ver, srv_ver_cmd local res = {} + local ver - if ipkg then - ver = ipkg.info(srv_name)[srv_name].Version - else - srv_ver_cmd = luci_helper .. " -V | awk {'print $2'} " - ver = util.exec(srv_ver_cmd) + local _, ctrl = pcall(io.lines, "/usr/lib/opkg/info/%s.control" % srv_name) + if ctrl then + for line in ctrl do + ver = line:match("^Version: (.+)$") + + if ver then + break + end + end end + ver = ver or util.trim(util.exec("%s -V | awk {'print $2'}" % luci_helper)) + res['_version'] = ver and #ver > 0 and ver or nil res['_enabled'] = sys.init.enabled("ddns") res['_curr_dateformat'] = os.date(dateformat) |