2015-05-04 19:18:58 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
|
2017-08-11 18:47:35 +00:00
|
|
|
local site = require 'gluon.site'
|
2015-05-04 19:18:58 +00:00
|
|
|
local util = require 'gluon.util'
|
|
|
|
local sysconfig = require 'gluon.sysconfig'
|
|
|
|
|
2017-01-19 11:51:04 +00:00
|
|
|
local uci = require('simple-uci').cursor()
|
2015-05-04 19:18:58 +00:00
|
|
|
|
2016-04-27 10:20:27 +00:00
|
|
|
if not sysconfig.lan_ifname then
|
2017-06-20 22:56:42 +00:00
|
|
|
os.exit(0)
|
2016-04-27 10:20:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
uci:section('network', 'interface', 'mesh_lan', {
|
2017-06-20 22:56:42 +00:00
|
|
|
ifname = sysconfig.lan_ifname,
|
|
|
|
igmp_snooping = false,
|
2017-06-21 15:14:41 +00:00
|
|
|
proto = 'gluon_wired',
|
|
|
|
index = 4,
|
2021-03-18 22:12:55 +00:00
|
|
|
vxlan = site.mesh.vxlan(true),
|
2016-04-27 10:20:27 +00:00
|
|
|
})
|
|
|
|
|
2018-01-24 20:20:30 +00:00
|
|
|
if sysconfig.lan_ifname:match(' ') then
|
|
|
|
uci:set('network', 'mesh_lan', 'type', 'bridge')
|
|
|
|
else
|
|
|
|
uci:delete('network', 'mesh_lan', 'type')
|
|
|
|
end
|
|
|
|
|
2018-01-10 00:00:28 +00:00
|
|
|
local enable = site.mesh_on_lan(false)
|
|
|
|
local old_auto = uci:get('network', 'mesh_lan', 'auto')
|
|
|
|
local old_disabled = uci:get('network', 'mesh_lan', 'disabled')
|
|
|
|
if old_auto ~= nil or old_disabled ~= nil then
|
|
|
|
enable = old_auto ~= '0' and old_disabled ~= '1'
|
|
|
|
end
|
|
|
|
|
|
|
|
if enable then
|
|
|
|
local interfaces = uci:get_list('network', 'client', 'ifname')
|
|
|
|
|
|
|
|
if interfaces then
|
|
|
|
for lanif in sysconfig.lan_ifname:gmatch('%S+') do
|
|
|
|
if util.contains(interfaces, lanif) then
|
|
|
|
enable = false
|
|
|
|
break
|
2017-06-20 22:56:42 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-05-04 19:18:58 +00:00
|
|
|
end
|
2016-04-27 10:20:27 +00:00
|
|
|
|
2018-01-10 00:00:28 +00:00
|
|
|
uci:set('network', 'mesh_lan', 'disabled', not enable)
|
|
|
|
|
2017-06-21 15:14:41 +00:00
|
|
|
if uci:get('network', 'mesh_lan', 'transitive') == nil then
|
|
|
|
uci:set('network', 'mesh_lan', 'transitive', true)
|
|
|
|
end
|
|
|
|
|
2016-04-27 10:20:27 +00:00
|
|
|
uci:save('network')
|