2017-03-10 02:22:41 +00:00
|
|
|
#!/usr/bin/lua
|
|
|
|
|
2017-08-11 18:47:35 +00:00
|
|
|
local site = require 'gluon.site'
|
2017-03-10 02:22:41 +00:00
|
|
|
local util = require 'gluon.util'
|
2020-08-16 16:03:21 +00:00
|
|
|
local vpn_core = require 'gluon.mesh-vpn'
|
2017-03-10 02:22:41 +00:00
|
|
|
|
|
|
|
local uci = require('simple-uci').cursor()
|
|
|
|
|
|
|
|
|
2017-08-07 23:28:53 +00:00
|
|
|
local enabled
|
|
|
|
|
|
|
|
-- Delete old broker config section (remove in 2019)
|
|
|
|
if not uci:get('tunneldigger', 'mesh_vpn') then
|
|
|
|
if uci:get_first('tunneldigger', 'broker', 'interface') == 'mesh-vpn' then
|
2017-03-23 11:51:41 +00:00
|
|
|
enabled = uci:get_first('tunneldigger', 'broker', 'enabled')
|
|
|
|
end
|
2017-03-10 02:22:41 +00:00
|
|
|
|
2017-08-07 23:28:53 +00:00
|
|
|
-- In the usual case (no migration from old tunneldigger package), the
|
|
|
|
-- enabled state is set in the 500-mesh-vpn script
|
|
|
|
|
2017-03-10 02:22:41 +00:00
|
|
|
uci:delete_all('tunneldigger', 'broker')
|
|
|
|
end
|
|
|
|
|
|
|
|
uci:section('tunneldigger', 'broker', 'mesh_vpn', {
|
|
|
|
enabled = enabled,
|
|
|
|
uuid = util.node_id(),
|
2020-08-16 16:03:21 +00:00
|
|
|
interface = vpn_core.get_interface(),
|
2017-03-10 02:22:41 +00:00
|
|
|
bind_interface = 'br-wan',
|
|
|
|
group = 'gluon-mesh-vpn',
|
|
|
|
broker_selection = 'usage',
|
2017-08-11 18:47:35 +00:00
|
|
|
address = site.mesh_vpn.tunneldigger.brokers(),
|
2017-03-10 02:22:41 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
uci:save('tunneldigger')
|