gluon-mesh-vpn: fix fastd <-> tunneldigger migration
The generic upgrade script is moved to run after the more specific scripts. In addition, the script will now remove the configuration sections of uninstalled VPN packages, so both positive and negative changes of the default enable state can be migrated correctly. Based-on-patch-by: Cyrus Fox <cyrus@lambdacore.de> Fixes: #1187
This commit is contained in:
parent
23a8947628
commit
952439885e
@ -62,15 +62,36 @@ uci:save('firewall')
|
||||
|
||||
-- VPN migration
|
||||
local has_fastd = fs.access('/lib/gluon/mesh-vpn/fastd')
|
||||
local fastd_enabled = uci:get_bool("fastd", "mesh_vpn", "enabled")
|
||||
local fastd_enabled = uci:get('fastd', 'mesh_vpn', 'enabled')
|
||||
|
||||
local has_tunneldigger = fs.access('/lib/gluon/mesh-vpn/tunneldigger')
|
||||
local tunneldigger_enabled = uci:get_bool("tunneldigger", "mesh_vpn", "enabled")
|
||||
local tunneldigger_enabled = uci:get('tunneldigger', 'mesh_vpn', 'enabled')
|
||||
|
||||
local enabled = fastd_enabled or tunneldigger_enabled or false
|
||||
local enabled
|
||||
|
||||
uci:set("fastd", "mesh_vpn", "enabled", has_fastd and enabled)
|
||||
uci:save("fastd")
|
||||
-- If the installed VPN package has its enabled state set, keep the value
|
||||
if has_fastd and fastd_enabled then
|
||||
enabled = fastd_enabled == '1'
|
||||
elseif has_tunneldigger and tunneldigger_enabled then
|
||||
enabled = tunneldigger_enabled == '1'
|
||||
-- Otherwise, migrate the other package's value if any is set
|
||||
elseif fastd_enabled or tunneldigger_enabled then
|
||||
enabled = fastd_enabled == '1' or tunneldigger_enabled == '1'
|
||||
-- If nothing is set, use the default
|
||||
else
|
||||
enabled = site.mesh_vpn.enabled or false
|
||||
end
|
||||
|
||||
uci:set("tunneldigger", "mesh_vpn", "enabled", has_tunneldigger and enabled)
|
||||
uci:save("tunneldigger")
|
||||
if has_fastd then
|
||||
uci:set('fastd', 'mesh_vpn', 'enabled', enabled)
|
||||
else
|
||||
uci:delete('fastd', 'mesh_vpn')
|
||||
end
|
||||
uci:save('fastd')
|
||||
|
||||
if has_tunneldigger then
|
||||
uci:set('tunneldigger', 'mesh_vpn', 'enabled', enabled)
|
||||
else
|
||||
uci:delete('tunneldigger', 'mesh_vpn')
|
||||
end
|
||||
uci:save('tunneldigger')
|
@ -6,11 +6,6 @@ local util = require 'gluon.util'
|
||||
local uci = require('simple-uci').cursor()
|
||||
|
||||
|
||||
local enabled = uci:get('fastd', 'mesh_vpn', 'enabled')
|
||||
if enabled == nil then
|
||||
enabled = site.mesh_vpn.enabled or false
|
||||
end
|
||||
|
||||
local syslog_level = uci:get('fastd', 'mesh_vpn', 'syslog_level') or 'verbose'
|
||||
|
||||
local methods
|
||||
@ -40,7 +35,6 @@ end
|
||||
|
||||
|
||||
uci:section('fastd', 'fastd', 'mesh_vpn', {
|
||||
enabled = enabled,
|
||||
group = 'gluon-mesh-vpn',
|
||||
syslog_level = syslog_level,
|
||||
interface = 'mesh-vpn',
|
||||
|
@ -6,18 +6,17 @@ local util = require 'gluon.util'
|
||||
local uci = require('simple-uci').cursor()
|
||||
|
||||
|
||||
local enabled = uci:get('tunneldigger', 'mesh_vpn', 'enabled')
|
||||
if enabled == nil then
|
||||
if uci:get_first('tunneldigger', 'broker', 'interface') == "mesh-vpn" then
|
||||
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
|
||||
enabled = uci:get_first('tunneldigger', 'broker', 'enabled')
|
||||
end
|
||||
end
|
||||
if enabled == nil then
|
||||
enabled = site.mesh_vpn.enabled or false
|
||||
end
|
||||
|
||||
-- Delete old broker config section
|
||||
if not uci:get('tunneldigger', 'mesh_vpn') then
|
||||
-- In the usual case (no migration from old tunneldigger package), the
|
||||
-- enabled state is set in the 500-mesh-vpn script
|
||||
|
||||
uci:delete_all('tunneldigger', 'broker')
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user