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

123456789101112131415161718192021222324252627282930313233343536
  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 sysconfig.lan_ifname and not uci:get('network', 'mesh_lan') then
  8. local enable = site.mesh_on_lan
  9. if enable then
  10. local interfaces = uci:get_list('network', 'client', 'ifname')
  11. if interfaces then
  12. for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do
  13. if lutil.contains(interfaces, lanif) then
  14. enable = false
  15. break
  16. end
  17. end
  18. end
  19. end
  20. uci:section('network', 'interface', 'mesh_lan',
  21. { ifname = sysconfig.lan_ifname
  22. , proto = 'batadv'
  23. , mesh = 'bat0'
  24. , mesh_no_rebroadcast = '1'
  25. , macaddr = util.generate_mac(1, 1)
  26. , auto = enable and 1 or 0
  27. })
  28. uci:save('network')
  29. end