37 lines
938 B
Lua
Executable File
37 lines
938 B
Lua
Executable File
#!/usr/bin/lua
|
|
|
|
local site = require 'gluon.site_config'
|
|
local util = require 'gluon.util'
|
|
local sysconfig = require 'gluon.sysconfig'
|
|
|
|
local uci = require('luci.model.uci').cursor()
|
|
local lutil = require 'luci.util'
|
|
|
|
if sysconfig.lan_ifname and not uci:get('network', 'mesh_lan') then
|
|
local enable = site.mesh_on_lan
|
|
|
|
if enable 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
|
|
enable = false
|
|
break
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
uci:section('network', 'interface', 'mesh_lan',
|
|
{ ifname = sysconfig.lan_ifname
|
|
, proto = 'batadv'
|
|
, mesh = 'bat0'
|
|
, mesh_no_rebroadcast = '1'
|
|
, macaddr = util.generate_mac(6)
|
|
, auto = enable and 1 or 0
|
|
})
|
|
|
|
uci:save('network')
|
|
end
|