220-interface-lan 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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('simple-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 = false,
  14. proto = 'gluon_mesh',
  15. transitive = true,
  16. fixed_mtu = true,
  17. })
  18. if uci:get('network', 'mesh_lan', 'auto') == nil then
  19. local enable = site.mesh_on_lan
  20. if enable then
  21. local interfaces = uci:get_list('network', 'client', 'ifname')
  22. if interfaces then
  23. for _, lanif in ipairs(lutil.split(sysconfig.lan_ifname, ' ')) do
  24. if lutil.contains(interfaces, lanif) then
  25. enable = false
  26. break
  27. end
  28. end
  29. end
  30. end
  31. uci:set('network', 'mesh_lan', 'auto', enable or false)
  32. end
  33. uci:save('network')