420-mesh-vpn-fastd-simple-tc 742 B

12345678910111213141516171819202122232425262728293031
  1. #!/usr/bin/lua
  2. local site = require 'gluon.site_config'
  3. local uci = require('luci.model.uci').cursor()
  4. local fs = require 'nixio.fs'
  5. if fs.access('/etc/config/gluon-simple-tc') then
  6. os.rename('/etc/config/gluon-simple-tc', '/etc/config/simple-tc')
  7. end
  8. if not uci:get('simple-tc', 'mesh_vpn') then
  9. local config = {
  10. ifname = 'mesh-vpn',
  11. enabled = 0,
  12. }
  13. if site.fastd_mesh_vpn.bandwidth_limit then
  14. if site.fastd_mesh_vpn.bandwidth_limit.enabled then
  15. config.enabled = 1
  16. end
  17. config.limit_ingress = site.fastd_mesh_vpn.bandwidth_limit.ingress
  18. config.limit_egress = site.fastd_mesh_vpn.bandwidth_limit.egress
  19. end
  20. uci:section('simple-tc', 'interface', 'mesh_vpn', config)
  21. uci:save('simple-tc')
  22. end