gluon-web: remove unneeded functions from gluon.web.util
exec() is moved to gluon.util.
This commit is contained in:
parent
5dcb784308
commit
83a6847fbd
@ -1,5 +1,5 @@
|
|||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
local util = require "gluon.web.util"
|
local util = require "gluon.util"
|
||||||
local nixio_util = require "nixio.util"
|
local nixio_util = require "nixio.util"
|
||||||
|
|
||||||
local uci = require("simple-uci").cursor()
|
local uci = require("simple-uci").cursor()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
local site_i18n = i18n 'gluon-site'
|
local site_i18n = i18n 'gluon-site'
|
||||||
|
|
||||||
local uci = require("simple-uci").cursor()
|
local uci = require("simple-uci").cursor()
|
||||||
local lutil = require "gluon.web.util"
|
|
||||||
local fs = require "nixio.fs"
|
local fs = require "nixio.fs"
|
||||||
|
|
||||||
local site = require 'gluon.site'
|
local site = require 'gluon.site'
|
||||||
@ -30,7 +29,7 @@ if has_tunneldigger then
|
|||||||
elseif has_fastd then
|
elseif has_fastd then
|
||||||
local fastd_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
|
local fastd_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
|
||||||
if fastd_enabled then
|
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')
|
msg = site_i18n._translate('gluon-config-mode:pubkey')
|
||||||
else
|
else
|
||||||
msg = site_i18n._translate('gluon-config-mode:novpn')
|
msg = site_i18n._translate('gluon-config-mode:novpn')
|
||||||
|
@ -83,6 +83,14 @@ function readline(fd)
|
|||||||
return line
|
return line
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function exec(command)
|
||||||
|
local pp = io.popen(command)
|
||||||
|
local data = pp:read("*a")
|
||||||
|
pp:close()
|
||||||
|
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
function node_id()
|
function node_id()
|
||||||
return string.gsub(sysconfig.primary_mac, ':', '')
|
return string.gsub(sysconfig.primary_mac, ':', '')
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
<%-
|
<%-
|
||||||
local fs = require 'nixio.fs'
|
local fs = require 'nixio.fs'
|
||||||
local uci = require('simple-uci').cursor()
|
local uci = require('simple-uci').cursor()
|
||||||
local lutil = require 'gluon.web.util'
|
|
||||||
local pretty_hostname = require 'pretty_hostname'
|
local pretty_hostname = require 'pretty_hostname'
|
||||||
|
|
||||||
local site = require 'gluon.site'
|
local site = require 'gluon.site'
|
||||||
@ -15,7 +14,7 @@
|
|||||||
local pubkey
|
local pubkey
|
||||||
local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
|
local meshvpn_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
|
||||||
if meshvpn_enabled then
|
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
|
if pubkey == '' then
|
||||||
pubkey = nil
|
pubkey = nil
|
||||||
end
|
end
|
||||||
|
@ -12,6 +12,7 @@ You may obtain a copy of the License at
|
|||||||
package 'gluon-web-admin'
|
package 'gluon-web-admin'
|
||||||
|
|
||||||
|
|
||||||
|
local util = require 'gluon.util'
|
||||||
local fs = require 'nixio.fs'
|
local fs = require 'nixio.fs'
|
||||||
|
|
||||||
local tmpfile = "/tmp/firmware.img"
|
local tmpfile = "/tmp/firmware.img"
|
||||||
@ -61,8 +62,7 @@ local function action_upgrade(http, renderer)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function image_supported(tmpfile)
|
local function image_supported(tmpfile)
|
||||||
-- XXX: yay...
|
return (os.execute(string.format("exec /sbin/sysupgrade -T %q >/dev/null", tmpfile)) == 0)
|
||||||
return (os.execute(string.format("/sbin/sysupgrade -T %q >/dev/null", tmpfile)) == 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function storage_size()
|
local function storage_size()
|
||||||
@ -88,7 +88,7 @@ local function action_upgrade(http, renderer)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function image_checksum(tmpfile)
|
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
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
local uci = require("simple-uci").cursor()
|
local uci = require("simple-uci").cursor()
|
||||||
local util = gluon.web.util
|
local util = gluon.util
|
||||||
|
|
||||||
local f = Form(translate('Mesh VPN'))
|
local f = Form(translate('Mesh VPN'))
|
||||||
|
|
||||||
|
@ -2,14 +2,10 @@
|
|||||||
-- Copyright 2017 Matthias Schiffer <mschiffer@universe-factory.net>
|
-- Copyright 2017 Matthias Schiffer <mschiffer@universe-factory.net>
|
||||||
-- Licensed to the public under the Apache License 2.0.
|
-- 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 tparser = require "gluon.web.template.parser"
|
||||||
local nixio = require "nixio"
|
|
||||||
local fs = require "nixio.fs"
|
|
||||||
|
|
||||||
local getmetatable, setmetatable = getmetatable, setmetatable
|
local getmetatable, setmetatable = getmetatable, setmetatable
|
||||||
local tostring, pairs = tostring, pairs
|
local tostring = tostring
|
||||||
|
|
||||||
module "gluon.web.util"
|
module "gluon.web.util"
|
||||||
|
|
||||||
@ -63,26 +59,3 @@ end
|
|||||||
function pcdata(value)
|
function pcdata(value)
|
||||||
return value and tparser.pcdata(tostring(value))
|
return value and tparser.pcdata(tostring(value))
|
||||||
end
|
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
|
|
||||||
|
Loading…
Reference in New Issue
Block a user