applications/luci-multiwan: use new uci disable option instead of disabling the init...
authorJo-Philipp Wich <jow@openwrt.org>
Wed, 7 Mar 2012 13:06:17 +0000 (13:06 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Wed, 7 Mar 2012 13:06:17 +0000 (13:06 +0000)
applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwan.lua
applications/luci-multiwan/luasrc/model/cbi/multiwan/multiwanmini.lua

index 96718f7cf02041973def28675520917ee902a188..586b6307de2603a1ea655bf4ec5c3b689bb6a226 100644 (file)
@@ -4,19 +4,18 @@ m = Map("multiwan", translate("Multi-WAN"),
        translate("Multi-WAN allows for the use of multiple uplinks for load balancing and failover."))
 
 s = m:section(NamedSection, "config", "multiwan", "")
+
 e = s:option(Flag, "enabled", translate("Enable"))
 e.rmempty = false
+e.default = e.enabled
 
 function e.write(self, section, value)
-        local cmd = (value == "1") and "enable" or "disable"
-        if value ~= "1" then
-                os.execute("/etc/init.d/multiwan stop")
-        end
-        os.execute("/etc/init.d/multiwan " .. cmd)
-end
-
-function e.cfgvalue(self, section)
-        return (os.execute("/etc/init.d/multiwan enabled") == 0) and "1" or "0"
+       if value == "0" then
+               os.execute("/etc/init.d/multiwan stop")
+       else
+               os.execute("/etc/init.d/multiwan enable")
+       end
+       Flag.write(self, section, value)
 end
 
 s = m:section(TypedSection, "interface", translate("WAN Interfaces"),
index e14dc0a9fd81e025ddb1c6074e745830c01368c5..d38974549cdec946d348c6373dfb08491af06eff 100644 (file)
@@ -4,19 +4,18 @@ m = Map("multiwan", translate("Multi-WAN"),
        translate("Multi-WAN allows for the use of multiple uplinks for load balancing and failover."))
 
 s = m:section(NamedSection, "config", "multiwan", "")
+
 e = s:option(Flag, "enabled", translate("Enable"))
 e.rmempty = false
+e.default = "1"
 
 function e.write(self, section, value)
-        local cmd = (value == "1") and "enable" or "disable"
-        if value ~= "1" then
-                os.execute("/etc/init.d/multiwan stop")
-        end
-        os.execute("/etc/init.d/multiwan " .. cmd)
-end
-
-function e.cfgvalue(self, section)
-        return (os.execute("/etc/init.d/multiwan enabled") == 0) and "1" or "0"
+       if value == "0" then
+               os.execute("/etc/init.d/multiwan stop")
+       else
+               os.execute("/etc/init.d/multiwan enable")
+       end
+       Flag.write(self, section, value)
 end
 
 s = m:section(TypedSection, "mwanfw", translate("Multi-WAN Traffic Rules"),