340-gluon-mesh-batman-adv-core-mesh-on-lan 840 B

1234567891011121314151617181920212223242526272829303132
  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('luci.model.uci').cursor()
  6. local lutil = require 'luci.util'
  7. if sysconfig.lan_ifname and not uci:get('network', 'mesh_lan') then
  8. local enable = site.mesh_on_lan
  9. if enable then
  10. local interfaces = uci:get('network', 'client', 'ifname')
  11. if interfaces and lutil.contains(interfaces:split(' '), sysconfig.lan_ifname) then
  12. enable = false
  13. end
  14. end
  15. uci:section('network', 'interface', 'mesh_lan',
  16. { ifname = sysconfig.lan_ifname
  17. , proto = 'batadv'
  18. , mesh = 'bat0'
  19. , macaddr = util.generate_mac(1, 1)
  20. , auto = enable and 1 or 0
  21. })
  22. uci:save('network')
  23. uci:commit('network')
  24. end