gluon/package/gluon-mesh-vpn-fastd/luasrc/lib/gluon/upgrade/420-mesh-vpn-fastd-simple-tc
Matthias Schiffer 6cf03bab37
treewide: replace normal uses of luci.model.uci with simple-uci to reduce LuCI dependencies
We also make use of the boolean support of simple-uci to make scripts
clearer.
2017-02-10 02:10:01 +01:00

32 lines
745 B
Lua
Executable File

#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require('simple-uci').cursor()
local fs = require 'nixio.fs'
if fs.access('/etc/config/gluon-simple-tc') then
os.rename('/etc/config/gluon-simple-tc', '/etc/config/simple-tc')
end
if not uci:get('simple-tc', 'mesh_vpn') then
local config = {
ifname = 'mesh-vpn',
enabled = false,
}
if site.fastd_mesh_vpn.bandwidth_limit then
if site.fastd_mesh_vpn.bandwidth_limit.enabled then
config.enabled = true
end
config.limit_ingress = site.fastd_mesh_vpn.bandwidth_limit.ingress
config.limit_egress = site.fastd_mesh_vpn.bandwidth_limit.egress
end
uci:section('simple-tc', 'interface', 'mesh_vpn', config)
uci:save('simple-tc')
end