220-interface-lan 922 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. if not sysconfig.lan_ifname then
  7. os.exit(0)
  8. end
  9. uci:section('network', 'interface', 'mesh_lan', {
  10. ifname = sysconfig.lan_ifname,
  11. type = 'bridge',
  12. igmp_snooping = false,
  13. proto = 'gluon_mesh',
  14. transitive = true,
  15. fixed_mtu = true,
  16. })
  17. if uci:get('network', 'mesh_lan', 'auto') == nil then
  18. local enable = site.mesh_on_lan
  19. if enable then
  20. local interfaces = uci:get_list('network', 'client', 'ifname')
  21. if interfaces then
  22. for lanif in sysconfig.lan_ifname:gmatch('%S+') do
  23. if util.contains(interfaces, lanif) then
  24. enable = false
  25. break
  26. end
  27. end
  28. end
  29. end
  30. uci:set('network', 'mesh_lan', 'auto', enable or false)
  31. end
  32. uci:save('network')