220-interface-lan 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/lua
  2. local site = require 'gluon.site'
  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. local old_proto = uci:get('network', 'mesh_lan', 'proto')
  10. uci:section('network', 'interface', 'mesh_lan', {
  11. ifname = sysconfig.lan_ifname,
  12. type = 'bridge',
  13. igmp_snooping = false,
  14. proto = 'gluon_wired',
  15. index = 4,
  16. legacy = old_proto == 'gluon_mesh',
  17. })
  18. if uci:get('network', 'mesh_lan', 'auto') == nil then
  19. local enable = site.mesh_on_lan(false)
  20. if enable then
  21. local interfaces = uci:get_list('network', 'client', 'ifname')
  22. if interfaces then
  23. for lanif in sysconfig.lan_ifname:gmatch('%S+') do
  24. if util.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)
  32. end
  33. if uci:get('network', 'mesh_lan', 'transitive') == nil then
  34. uci:set('network', 'mesh_lan', 'transitive', true)
  35. end
  36. if uci:get('network', 'mesh_lan', 'legacy') == nil then
  37. uci:set('network', 'mesh_lan', 'legacy', old_proto == 'gluon_mesh')
  38. end
  39. uci:delete('network', 'mesh_lan', 'fixed_mtu')
  40. uci:save('network')