From 74681fcd9f86177ad429e29451dfcbe90ce36e23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Magnus=20Fr=C3=BChling?= <skorpy@frankfurt.ccc.de>
Date: Thu, 21 Dec 2023 13:37:06 +0100
Subject: [PATCH] mesh-vpn-core: remove old migrations (#3113)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Remove legacy migrations. These predate the currently supported upgrade path,
therefore we no longer need them.

Signed-off-by: Magnus Frühling <skorpy@frankfurt.ccc.de>
---
 .../luasrc/lib/gluon/upgrade/500-mesh-vpn     | 47 ++-----------------
 1 file changed, 5 insertions(+), 42 deletions(-)

diff --git a/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn b/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn
index 77c76a35b..a753ca90d 100755
--- a/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn
+++ b/package/gluon-mesh-vpn-core/luasrc/lib/gluon/upgrade/500-mesh-vpn
@@ -28,50 +28,13 @@ uci:section('firewall', 'include', 'mesh_vpn_dns', {
 
 uci:save('firewall')
 
-
--- VPN migration
+-- Inital VPN setup
 if not uci:get('gluon', 'mesh_vpn') then
-	local vpn, _ = vpn_core.get_active_provider()
-
-	local fastd_enabled = uci:get('fastd', 'mesh_vpn', 'enabled')
-	local tunneldigger_enabled = uci:get('tunneldigger', 'mesh_vpn', 'enabled')
-
-	local enabled
-
-	-- If the installed VPN package has its enabled state set, keep the value
-	if vpn == 'fastd' and fastd_enabled then
-		enabled = fastd_enabled == '1'
-	elseif vpn == '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(false)
-	end
-	-- wireguard is not listed here, as it didn't exist before the uci section
-	-- gluon.mesh_vpn was introduced. Therefore no migration is necessary.
-
-
-	local limit_enabled = tonumber((uci:get('simple-tc', 'mesh_vpn', 'enabled')))
-	if limit_enabled == nil then
-		limit_enabled = site.mesh_vpn.bandwidth_limit.enabled(false)
-	end
-
-	local limit_ingress = tonumber((uci:get('tunneldigger', 'mesh_vpn', 'limit_bw_down')))
-	if limit_ingress == nil then
-		limit_ingress = tonumber((uci:get('simple-tc', 'mesh_vpn', 'limit_ingress')))
-	end
-	if limit_ingress == nil then
-		limit_ingress = site.mesh_vpn.bandwidth_limit.ingress()
-	end
-
-	local limit_egress = tonumber((uci:get('simple-tc', 'mesh_vpn', 'limit_egress')))
-	if limit_egress == nil then
-		limit_egress = site.mesh_vpn.bandwidth_limit.egress()
-	end
+	local enabled = site.mesh_vpn.enabled(false)
 
+	local limit_enabled = site.mesh_vpn.bandwidth_limit.enabled(false)
+	local limit_ingress = site.mesh_vpn.bandwidth_limit.ingress()
+	local limit_egress = site.mesh_vpn.bandwidth_limit.egress()
 
 	uci:section('gluon', 'mesh_vpn', 'mesh_vpn', {
 		enabled = enabled,
-- 
GitLab