gluon-web: remove unneeded functions from gluon.web.util

exec() is moved to gluon.util.
This commit is contained in:
Matthias Schiffer 2018-02-25 07:19:57 +01:00
parent 5dcb784308
commit 83a6847fbd
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
7 changed files with 16 additions and 37 deletions

View File

@ -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()

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'))

View File

@ -2,14 +2,10 @@
-- Copyright 2017 Matthias Schiffer <mschiffer@universe-factory.net>
-- 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