340-gluon-mesh-batman-adv-core-mesh-on-lan 987 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/lua
  2. local site = require 'gluon.site_config'
  3. local util = require 'gluon.util'
  4. local sysconfig = require 'gluon.sysconfig'
  5. local uci = require('luci.model.uci').cursor()
  6. local lutil = require 'luci.util'
  7. if not sysconfig.lan_ifname then
  8. os.exit(0)
  9. end
  10. uci:section('network', 'interface', 'mesh_lan', {
  11. ifname = sysconfig.lan_ifname,
  12. type = 'bridge',
  13. igmp_snooping = 0,
  14. proto = 'batadv',
  15. mesh = 'bat0',
  16. mesh_no_rebroadcast = '1',
  17. macaddr = util.generate_mac(6),
  18. })
  19. if uci:get('network', 'mesh_lan', 'auto') == nil then
  20. local enable = site.mesh_on_lan
  21. if enable then
  22. local interfaces = uci:get_list('network', 'client', 'ifname')
  23. if interfaces then
  24. for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do
  25. if lutil.contains(interfaces, lanif) then
  26. enable = false
  27. break
  28. end
  29. end
  30. end
  31. end
  32. uci:set('network', 'mesh_lan', 'auto', enable and 1 or 0)
  33. end
  34. uci:save('network')