gluon-web-network: initial draft of role configuration
This commit is contained in:
parent
7cd4a189e0
commit
f0b2e632d0
@ -9,13 +9,12 @@ http://www.apache.org/licenses/LICENSE-2.0
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
local uci = require("simple-uci").cursor()
|
local uci = require("simple-uci").cursor()
|
||||||
local sysconfig = require 'gluon.sysconfig'
|
|
||||||
local util = require 'gluon.util'
|
|
||||||
|
|
||||||
local wan = uci:get_all("network", "wan")
|
local wan = uci:get_all("network", "wan")
|
||||||
local wan6 = uci:get_all("network", "wan6")
|
local wan6 = uci:get_all("network", "wan6")
|
||||||
local dns_static = uci:get_first("gluon-wan-dnsmasq", "static")
|
local dns_static = uci:get_first("gluon-wan-dnsmasq", "static")
|
||||||
|
|
||||||
|
|
||||||
local f = Form(translate("WAN connection"))
|
local f = Form(translate("WAN connection"))
|
||||||
|
|
||||||
local s = f:section(Section)
|
local s = f:section(Section)
|
||||||
@ -76,36 +75,22 @@ end
|
|||||||
|
|
||||||
s = f:section(Section)
|
s = f:section(Section)
|
||||||
|
|
||||||
local wired_mesh_help = {
|
uci:foreach('gluon', 'interface', function(config)
|
||||||
single = translate('Enable meshing on the Ethernet interface'),
|
local section_name = config['.name']
|
||||||
wan = translate('Enable meshing on the WAN interface'),
|
local ifaces = s:option(MultiListValue, section_name, config.name)
|
||||||
lan = translate('Enable meshing on the LAN interface'),
|
|
||||||
}
|
|
||||||
|
|
||||||
local function wired_mesh(iface)
|
ifaces.orientation = 'horizontal'
|
||||||
if not sysconfig[iface .. '_ifname'] then return end
|
ifaces:value('uplink', 'Uplink') -- TODO: Uplink and Client should be mutually exclusive.
|
||||||
local iface_roles = uci:get_list('gluon', 'iface_' .. iface, 'role')
|
ifaces:value('mesh', 'Mesh')
|
||||||
|
ifaces:value('client', 'Client')
|
||||||
|
|
||||||
local option = s:option(Flag, 'mesh_' .. iface, wired_mesh_help[iface])
|
ifaces.default = config.role
|
||||||
option.default = util.contains(iface_roles, 'mesh') ~= false
|
|
||||||
|
|
||||||
function option:write(data)
|
function ifaces:write(data)
|
||||||
local roles = uci:get_list('gluon', 'iface_' .. iface, 'role')
|
uci:set_list("gluon", section_name, "role", data)
|
||||||
if data then
|
|
||||||
util.add_to_set(roles, 'mesh')
|
|
||||||
else
|
|
||||||
util.remove_from_set(roles, 'mesh')
|
|
||||||
end
|
end
|
||||||
uci:set_list('gluon', 'iface_' .. iface, 'role', roles)
|
end)
|
||||||
|
|
||||||
-- Reconfigure on next reboot
|
|
||||||
uci:set('gluon', 'core', 'reconfigure', true)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
wired_mesh('single')
|
|
||||||
wired_mesh('wan')
|
|
||||||
wired_mesh('lan')
|
|
||||||
|
|
||||||
local section
|
local section
|
||||||
uci:foreach("system", "gpio_switch", function(si)
|
uci:foreach("system", "gpio_switch", function(si)
|
||||||
@ -166,4 +151,5 @@ function f:write()
|
|||||||
uci:commit('system')
|
uci:commit('system')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
Loading…
Reference in New Issue
Block a user