treewide: get rid of luci.util outside of config mode/advanced settings
This commit is contained in:
parent
6cf03bab37
commit
c83b5b3cab
@ -5,7 +5,6 @@ local sysconfig = require 'gluon.sysconfig'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
local ip = require 'luci.ip'
|
||||
local lutil = require 'luci.util'
|
||||
local uci = require('simple-uci').cursor()
|
||||
|
||||
|
||||
@ -41,13 +40,13 @@ local interfaces = uci:get('network', 'client', 'ifname') or {}
|
||||
if type(interfaces) == 'string' then
|
||||
local ifname = interfaces
|
||||
interfaces = {}
|
||||
for iface in ifname:gmatch("[^%s]+") do
|
||||
for iface in ifname:gmatch('%S+') do
|
||||
util.add_to_set(interfaces, iface)
|
||||
end
|
||||
end
|
||||
|
||||
if sysconfig.lan_ifname and not ifname and not uci:get_bool('network', 'mesh_lan', 'auto') then
|
||||
for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do
|
||||
for lanif in sysconfig.lan_ifname:gmatch('%S+') do
|
||||
util.add_to_set(interfaces, lanif)
|
||||
end
|
||||
end
|
||||
|
@ -8,10 +8,10 @@ if sysconfig.primary_mac then
|
||||
end
|
||||
|
||||
|
||||
local util = require 'gluon.util'
|
||||
local platform = require 'gluon.platform'
|
||||
|
||||
local fs = require 'nixio.fs'
|
||||
local util = require 'luci.util'
|
||||
|
||||
|
||||
local try_files = {
|
||||
|
@ -5,7 +5,6 @@ local util = require 'gluon.util'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
local uci = require('simple-uci').cursor()
|
||||
local lutil = require 'luci.util'
|
||||
|
||||
if not sysconfig.lan_ifname then
|
||||
os.exit(0)
|
||||
@ -27,8 +26,8 @@ if uci:get('network', 'mesh_lan', 'auto') == nil then
|
||||
local interfaces = uci:get_list('network', 'client', 'ifname')
|
||||
|
||||
if interfaces then
|
||||
for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do
|
||||
if lutil.contains(interfaces, lanif) then
|
||||
for lanif in sysconfig.lan_ifname:gmatch('%S+') do
|
||||
if util.contains(interfaces, lanif) then
|
||||
enable = false
|
||||
break
|
||||
end
|
||||
|
@ -2,13 +2,19 @@
|
||||
|
||||
local fs = require 'nixio.fs'
|
||||
local site = require 'gluon.site_config'
|
||||
local util = require 'luci.util'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
|
||||
local subst = {}
|
||||
|
||||
|
||||
local f = io.popen('. /etc/openwrt_release; echo "$DISTRIB_CODENAME"; echo "$DISTRIB_TARGET"; echo "$DISTRIB_ARCH"')
|
||||
subst['%%n'] = f:read()
|
||||
subst['%%S'] = f:read()
|
||||
subst['%%A'] = f:read()
|
||||
f:close()
|
||||
|
||||
subst['%%v'] = util.trim(fs.readfile('/etc/openwrt_version'))
|
||||
subst['%%n'], subst['%%S'], subst['%%A'] = util.exec('. /etc/openwrt_release; echo "$DISTRIB_CODENAME"; echo "$DISTRIB_TARGET"; echo "$DISTRIB_ARCH"'):match('([^\n]*)\n([^\n]*)\n([^\n]*)')
|
||||
subst['%%GS'] = site.site_code
|
||||
subst['%%GV'] = util.trim(fs.readfile('/lib/gluon/gluon-version'))
|
||||
subst['%%GR'] = util.trim(fs.readfile('/lib/gluon/release'))
|
||||
|
@ -3,7 +3,7 @@
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
local fs = require 'nixio.fs'
|
||||
local util = require 'luci.util'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
|
||||
-- Save the Gluon version in the sysconfig so we know which version we
|
||||
|
@ -1,5 +1,5 @@
|
||||
local platform_info = require 'platform_info'
|
||||
local util = require 'luci.util'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
local setmetatable = setmetatable
|
||||
|
||||
@ -27,5 +27,3 @@ function match(target, subtarget, boards)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
@ -28,6 +28,7 @@ local os = os
|
||||
local string = string
|
||||
local tonumber = tonumber
|
||||
local ipairs = ipairs
|
||||
local pairs = pairs
|
||||
local table = table
|
||||
|
||||
local nixio = require 'nixio'
|
||||
@ -35,12 +36,24 @@ local hash = require 'hash'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local site = require 'gluon.site_config'
|
||||
local uci = require('simple-uci').cursor()
|
||||
local lutil = require 'luci.util'
|
||||
local fs = require 'nixio.fs'
|
||||
|
||||
|
||||
module 'gluon.util'
|
||||
|
||||
function trim(str)
|
||||
return str:gsub("^%s*(.-)%s*$", "%1")
|
||||
end
|
||||
|
||||
function contains(table, value)
|
||||
for k, v in pairs(table) do
|
||||
if value == v then
|
||||
return k
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function add_to_set(t, itm)
|
||||
for _,v in ipairs(t) do
|
||||
if v == itm then return false end
|
||||
@ -117,7 +130,7 @@ end
|
||||
local function find_phy_by_macaddr(macaddr)
|
||||
local addr = macaddr:lower()
|
||||
for file in fs.glob('/sys/class/ieee80211/*/macaddress') do
|
||||
if lutil.trim(fs.readfile(file)) == addr then
|
||||
if trim(fs.readfile(file)) == addr then
|
||||
return file:match('([^/]+)/macaddress$')
|
||||
end
|
||||
end
|
||||
|
@ -13,7 +13,6 @@ $Id$
|
||||
]]--
|
||||
|
||||
local uci = require("simple-uci").cursor()
|
||||
local lutil = require 'luci.util'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
@ -130,7 +129,7 @@ function f.handle(self, state, data)
|
||||
|
||||
local interfaces = uci:get_list("network", "client", "ifname")
|
||||
|
||||
for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do
|
||||
for lanif in sysconfig.lan_ifname:gmatch('%S+') do
|
||||
if data.mesh_lan == '1' then
|
||||
util.remove_from_set(interfaces, lanif)
|
||||
else
|
||||
|
@ -5,7 +5,6 @@ local users = require 'gluon.users'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
local uci = require('simple-uci').cursor()
|
||||
local lutil = require 'luci.util'
|
||||
|
||||
|
||||
-- The previously used user is removed, we need root privileges to use the packet_mark option
|
||||
@ -25,11 +24,11 @@ local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose'
|
||||
local methods
|
||||
|
||||
if site.fastd_mesh_vpn.configurable then
|
||||
local has_null = lutil.contains(site.fastd_mesh_vpn.methods, 'null')
|
||||
local has_null = util.contains(site.fastd_mesh_vpn.methods, 'null')
|
||||
|
||||
local old_methods = uci:get('fastd', 'mesh_vpn', 'method')
|
||||
if old_methods then
|
||||
has_null = lutil.contains(old_methods, 'null')
|
||||
has_null = util.contains(old_methods, 'null')
|
||||
end
|
||||
|
||||
methods = {}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/lua
|
||||
local uci = require('simple-uci').cursor()
|
||||
require 'luci.util'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
local sname = uci:get_first('gluon-node-info', 'location')
|
||||
if sname then
|
||||
@ -8,7 +8,7 @@ if sname then
|
||||
for _, option in ipairs(options) do
|
||||
local value = uci:get('gluon-node-info', sname, option)
|
||||
if value then
|
||||
uci:set('gluon-node-info', sname, option, value:trim())
|
||||
uci:set('gluon-node-info', sname, option, util.trim(value))
|
||||
end
|
||||
end
|
||||
uci:save('gluon-node-info')
|
||||
|
@ -1,17 +1,18 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
util = require 'luci.util'
|
||||
json = require 'luci.jsonc'
|
||||
util = require 'gluon.util'
|
||||
|
||||
fs = require 'nixio.fs'
|
||||
json = require 'luci.jsonc'
|
||||
|
||||
io.write("Access-Control-Allow-Origin: *\n")
|
||||
io.write("Content-type: application/json\n\n")
|
||||
|
||||
list = util.exec('batctl if')
|
||||
f = io.popen('batctl if')
|
||||
|
||||
interfaces = {}
|
||||
|
||||
for _, line in ipairs(util.split(list)) do
|
||||
for line in f:lines() do
|
||||
ifname = line:match('^(.-):')
|
||||
if ifname ~= nil then
|
||||
pcall(function()
|
||||
@ -21,4 +22,6 @@ for _, line in ipairs(util.split(list)) do
|
||||
end
|
||||
end
|
||||
|
||||
f:close()
|
||||
|
||||
io.write(json.stringify(interfaces))
|
||||
|
Loading…
Reference in New Issue
Block a user