From 5b8e044893d01fc4d5044094f7b4c9ce7975c4dd Mon Sep 17 00:00:00 2001 From: Nils Schneider Date: Tue, 21 Jan 2014 22:19:25 +0100 Subject: [PATCH] gluon-config-mode: fix wizard Due to my previous two commits configmode was broken when either meshvpn or bandwidth limit was disabled. This fixes it but there may be a cleaner solution provided by luci. --- .../model/cbi/gluon-config-mode/wizard.lua | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua b/package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua index e3d6afbd..517cf2b7 100644 --- a/package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua +++ b/package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua @@ -69,12 +69,22 @@ function f.handle(self, state, data) uci:save("autoupdater") uci:commit("autoupdater") - uci:set("gluon-simple-tc", meshvpn_name, "interface") - uci:set("gluon-simple-tc", meshvpn_name, "enabled", data._limit_enabled) - uci:set("gluon-simple-tc", meshvpn_name, "ifname", "mesh-vpn") - uci:set("gluon-simple-tc", meshvpn_name, "limit_ingress", data._limit_ingress) - uci:set("gluon-simple-tc", meshvpn_name, "limit_egress", data._limit_egress) - uci:commit("gluon-simple-tc") + -- checks for nil needed due to o:depends(...) + if data._limit_enabled ~= nil then + uci:set("gluon-simple-tc", meshvpn_name, "interface") + uci:set("gluon-simple-tc", meshvpn_name, "enabled", data._limit_enabled) + uci:set("gluon-simple-tc", meshvpn_name, "ifname", "mesh-vpn") + + if data._limit_ingress ~= nil then + uci:set("gluon-simple-tc", meshvpn_name, "limit_ingress", data._limit_ingress) + end + + if data._limit_egress ~= nil then + uci:set("gluon-simple-tc", meshvpn_name, "limit_egress", data._limit_egress) + end + + uci:commit("gluon-simple-tc") + end uci:set("fastd", meshvpn_name, "enabled", data._meshvpn) uci:save("fastd")