Skip to content
Snippets Groups Projects
Commit f0b2e632 authored by lemoer's avatar lemoer
Browse files

gluon-web-network: initial draft of role configuration

parent 7cd4a189
No related branches found
No related tags found
No related merge requests found
...@@ -9,13 +9,12 @@ http://www.apache.org/licenses/LICENSE-2.0 ...@@ -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 ...@@ -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'),
} ifaces.orientation = 'horizontal'
ifaces:value('uplink', 'Uplink') -- TODO: Uplink and Client should be mutually exclusive.
local function wired_mesh(iface) ifaces:value('mesh', 'Mesh')
if not sysconfig[iface .. '_ifname'] then return end ifaces:value('client', 'Client')
local iface_roles = uci:get_list('gluon', 'iface_' .. iface, 'role')
ifaces.default = config.role
local option = s:option(Flag, 'mesh_' .. iface, wired_mesh_help[iface])
option.default = util.contains(iface_roles, 'mesh') ~= false
function option:write(data)
local roles = uci:get_list('gluon', 'iface_' .. iface, 'role')
if data then
util.add_to_set(roles, 'mesh')
else
util.remove_from_set(roles, 'mesh')
end
uci:set_list('gluon', 'iface_' .. iface, 'role', roles)
-- Reconfigure on next reboot function ifaces:write(data)
uci:set('gluon', 'core', 'reconfigure', true) uci:set_list("gluon", section_name, "role", data)
end end
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() ...@@ -166,4 +151,5 @@ function f:write()
uci:commit('system') uci:commit('system')
end end
return f return f
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment