54 lines
1.2 KiB
Lua
Executable File
54 lines
1.2 KiB
Lua
Executable File
#!/usr/bin/lua
|
|
|
|
local site = require 'gluon.site'
|
|
local util = require 'gluon.util'
|
|
local sysconfig = require 'gluon.sysconfig'
|
|
|
|
local uci = require('simple-uci').cursor()
|
|
|
|
if not sysconfig.lan_ifname then
|
|
os.exit(0)
|
|
end
|
|
|
|
uci:section('network', 'interface', 'mesh_lan', {
|
|
ifname = sysconfig.lan_ifname,
|
|
igmp_snooping = false,
|
|
proto = 'gluon_wired',
|
|
index = 4,
|
|
vxlan = site.mesh.vxlan(true),
|
|
})
|
|
|
|
if sysconfig.lan_ifname:match(' ') then
|
|
uci:set('network', 'mesh_lan', 'type', 'bridge')
|
|
else
|
|
uci:delete('network', 'mesh_lan', 'type')
|
|
end
|
|
|
|
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
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
uci:set('network', 'mesh_lan', 'disabled', not enable)
|
|
|
|
if uci:get('network', 'mesh_lan', 'transitive') == nil then
|
|
uci:set('network', 'mesh_lan', 'transitive', true)
|
|
end
|
|
|
|
uci:save('network')
|