Browse Source

gluon-mesh-batman-adv: preserve gw_mode on upgrades

When a Gluon node is used to connect to an uplink router/DHCP server (for
example in deployments without VPN tunnels), the gw_mode must be set to
server; this should be preserved on upgrades.

Fixes #1196
Matthias Schiffer 6 years ago
parent
commit
c197d028ec

+ 6 - 6
package/gluon-mesh-batman-adv/luasrc/lib/gluon/upgrade/310-gluon-mesh-batman-adv-mesh

@@ -7,20 +7,20 @@ local util = require 'gluon.util'
 local uci = require('simple-uci').cursor()
 
 
-local gw_sel_class
-if site.mesh and site.mesh.batman_adv then
-	gw_sel_class = site.mesh.batman_adv.gw_sel_class
-end
+local gw_mode, gw_sel_class, routing_algo
+
+gw_mode = uci:get('batman-adv', 'bat0', 'gw_mode') or 'client'
 
-local routing_algo
 if site.mesh and site.mesh.batman_adv then
+	gw_sel_class = site.mesh.batman_adv.gw_sel_class
 	routing_algo = site.mesh.batman_adv.routing_algo
 end
 
+
 uci:delete('batman-adv', 'bat0')
 uci:section('batman-adv', 'mesh', 'bat0', {
 	orig_interval = 5000,
-	gw_mode = 'client',
+	gw_mode = gw_mode,
 	gw_sel_class = gw_sel_class,
 	hop_penalty = 15,
 	routing_algo = routing_algo,