220-interface-lan 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. igmp_snooping = false,
  13. proto = 'gluon_wired',
  14. index = 4,
  15. legacy = old_proto == 'gluon_mesh',
  16. })
  17. if sysconfig.lan_ifname:match(' ') then
  18. uci:set('network', 'mesh_lan', 'type', 'bridge')
  19. else
  20. uci:delete('network', 'mesh_lan', 'type')
  21. end
  22. local enable = site.mesh_on_lan(false)
  23. local old_auto = uci:get('network', 'mesh_lan', 'auto')
  24. local old_disabled = uci:get('network', 'mesh_lan', 'disabled')
  25. if old_auto ~= nil or old_disabled ~= nil then
  26. enable = old_auto ~= '0' and old_disabled ~= '1'
  27. end
  28. if enable then
  29. local interfaces = uci:get_list('network', 'client', 'ifname')
  30. if interfaces then
  31. for lanif in sysconfig.lan_ifname:gmatch('%S+') do
  32. if util.contains(interfaces, lanif) then
  33. enable = false
  34. break
  35. end
  36. end
  37. end
  38. end
  39. uci:set('network', 'mesh_lan', 'disabled', not enable)
  40. if uci:get('network', 'mesh_lan', 'transitive') == nil then
  41. uci:set('network', 'mesh_lan', 'transitive', true)
  42. end
  43. if uci:get('network', 'mesh_lan', 'legacy') == nil then
  44. uci:set('network', 'mesh_lan', 'legacy', old_proto == 'gluon_mesh')
  45. end
  46. uci:delete('network', 'mesh_lan', 'auto')
  47. uci:delete('network', 'mesh_lan', 'fixed_mtu')
  48. uci:save('network')