diff --git a/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua b/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua index d328f438..22d661c1 100644 --- a/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua +++ b/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua @@ -1,5 +1,5 @@ local fs = require "nixio.fs" -local util = require "gluon.web.util" +local util = require "gluon.util" local nixio_util = require "nixio.util" local uci = require("simple-uci").cursor() diff --git a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua index 8a72bffe..140cb821 100644 --- a/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua +++ b/package/gluon-config-mode-mesh-vpn/luasrc/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua @@ -1,7 +1,6 @@ local site_i18n = i18n 'gluon-site' local uci = require("simple-uci").cursor() -local lutil = require "gluon.web.util" local fs = require "nixio.fs" local site = require 'gluon.site' @@ -30,7 +29,7 @@ if has_tunneldigger then elseif has_fastd then local fastd_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") if fastd_enabled then - pubkey = util.trim(lutil.exec("/etc/init.d/fastd show_key mesh_vpn")) + pubkey = util.trim(util.exec("/etc/init.d/fastd show_key mesh_vpn")) msg = site_i18n._translate('gluon-config-mode:pubkey') else msg = site_i18n._translate('gluon-config-mode:novpn') diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua index 1b9bdf3f..d6891c5f 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua @@ -83,6 +83,14 @@ function readline(fd) return line end +function exec(command) + local pp = io.popen(command) + local data = pp:read("*a") + pp:close() + + return data +end + function node_id() return string.gsub(sysconfig.primary_mac, ':', '') end diff --git a/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html b/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html index 889b0ca3..7e060f57 100644 --- a/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html +++ b/package/gluon-web-admin/files/lib/gluon/web/view/admin/info.html @@ -1,7 +1,6 @@ <%- local fs = require 'nixio.fs' local uci = require('simple-uci').cursor() - local lutil = require 'gluon.web.util' local pretty_hostname = require 'pretty_hostname' local site = require 'gluon.site' @@ -15,7 +14,7 @@ local pubkey local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled") if meshvpn_enabled then - pubkey = util.trim(lutil.exec('/etc/init.d/fastd show_key mesh_vpn')) + pubkey = util.trim(util.exec('/etc/init.d/fastd show_key mesh_vpn')) if pubkey == '' then pubkey = nil end diff --git a/package/gluon-web-admin/luasrc/lib/gluon/web/controller/admin/upgrade.lua b/package/gluon-web-admin/luasrc/lib/gluon/web/controller/admin/upgrade.lua index dc6dbea2..6d8e1545 100644 --- a/package/gluon-web-admin/luasrc/lib/gluon/web/controller/admin/upgrade.lua +++ b/package/gluon-web-admin/luasrc/lib/gluon/web/controller/admin/upgrade.lua @@ -12,6 +12,7 @@ You may obtain a copy of the License at package 'gluon-web-admin' +local util = require 'gluon.util' local fs = require 'nixio.fs' local tmpfile = "/tmp/firmware.img" @@ -61,8 +62,7 @@ local function action_upgrade(http, renderer) end local function image_supported(tmpfile) - -- XXX: yay... - return (os.execute(string.format("/sbin/sysupgrade -T %q >/dev/null", tmpfile)) == 0) + return (os.execute(string.format("exec /sbin/sysupgrade -T %q >/dev/null", tmpfile)) == 0) end local function storage_size() @@ -88,7 +88,7 @@ local function action_upgrade(http, renderer) end local function image_checksum(tmpfile) - return (gluon.web.util.exec(string.format("md5sum %q", tmpfile)):match("^([^%s]+)")) + return (util.exec(string.format("exec md5sum %q", tmpfile)):match("^([^%s]+)")) end diff --git a/package/gluon-web-mesh-vpn-fastd/luasrc/lib/gluon/web/model/admin/mesh_vpn_fastd.lua b/package/gluon-web-mesh-vpn-fastd/luasrc/lib/gluon/web/model/admin/mesh_vpn_fastd.lua index 507f8590..c4fb21de 100644 --- a/package/gluon-web-mesh-vpn-fastd/luasrc/lib/gluon/web/model/admin/mesh_vpn_fastd.lua +++ b/package/gluon-web-mesh-vpn-fastd/luasrc/lib/gluon/web/model/admin/mesh_vpn_fastd.lua @@ -1,5 +1,5 @@ local uci = require("simple-uci").cursor() -local util = gluon.web.util +local util = gluon.util local f = Form(translate('Mesh VPN')) diff --git a/package/gluon-web/luasrc/usr/lib/lua/gluon/web/util.lua b/package/gluon-web/luasrc/usr/lib/lua/gluon/web/util.lua index 3e32ec50..045a16fb 100644 --- a/package/gluon-web/luasrc/usr/lib/lua/gluon/web/util.lua +++ b/package/gluon-web/luasrc/usr/lib/lua/gluon/web/util.lua @@ -2,14 +2,10 @@ -- Copyright 2017 Matthias Schiffer -- Licensed to the public under the Apache License 2.0. -local io = require "io" -local table = require "table" local tparser = require "gluon.web.template.parser" -local nixio = require "nixio" -local fs = require "nixio.fs" local getmetatable, setmetatable = getmetatable, setmetatable -local tostring, pairs = tostring, pairs +local tostring = tostring module "gluon.web.util" @@ -63,26 +59,3 @@ end function pcdata(value) return value and tparser.pcdata(tostring(value)) end - - -function contains(table, value) - for k, v in pairs(table) do - if value == v then - return k - end - end - return false -end - - --- --- System utility functions --- - -function exec(command) - local pp = io.popen(command) - local data = pp:read("*a") - pp:close() - - return data -end