210-interface-wan 937 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/lua
  2. local site = require 'gluon.site'
  3. local uci = require('simple-uci').cursor()
  4. local old_proto = uci:get('network', 'mesh_wan', 'proto')
  5. uci:section('network', 'interface', 'mesh_wan', {
  6. ifname = 'br-wan',
  7. proto = 'gluon_wired',
  8. index = 0,
  9. })
  10. local enable = site.mesh_on_wan(false)
  11. local old_auto = uci:get('network', 'mesh_wan', 'auto')
  12. local old_disabled = uci:get('network', 'mesh_wan', 'disabled')
  13. if old_auto ~= nil or old_disabled ~= nil then
  14. enable = old_auto ~= '0' and old_disabled ~= '1'
  15. end
  16. uci:set('network', 'mesh_wan', 'disabled', not enable)
  17. if uci:get('network', 'mesh_wan', 'transitive') == nil then
  18. uci:set('network', 'mesh_wan', 'transitive', true)
  19. end
  20. if uci:get('network', 'mesh_wan', 'legacy') == nil then
  21. uci:set('network', 'mesh_wan', 'legacy', old_proto == 'gluon_mesh')
  22. end
  23. uci:delete('network', 'mesh_wan', 'auto')
  24. uci:delete('network', 'mesh_wan', 'fixed_mtu')
  25. uci:save('network')