Hi
Attached modified patchs for multiwan and luci-app-multiwan
Signed-off-by: Etienne CHAMPETIER <[email protected]>
Le 19/12/2011 18:30, Etienne Champetier a écrit :
> Hi
>
> Here follows the patch for luci multiwan package
> I've also opened a ticket on the luci trac
>
> Regards
>
> Le 19/12/2011 16:38, Etienne Champetier a écrit :
>> Hi
>>
>> The only mean to disable multiwan is to delete the symlink in /etc/rc.d, but
>> if you make a backup and restore it you have to re-delete the symlink.
>>
>> This small patch add an "enabled" option to multiwan script.
>>
>> It will allow me to have one image per router model, not one with multiwan
>> and one without.
>>
>> Best regards
>>
>> Signed-off-by: Etienne CHAMPETIER <[email protected]>
>>
>>
>>
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> [email protected]
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
>>
>>
>> _______________________________________________
>> openwrt-devel mailing list
>> [email protected]
>> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Index: net/multiwan/files/usr/bin/multiwan
===================================================================
--- net/multiwan/files/usr/bin/multiwan (révision 29722)
+++ net/multiwan/files/usr/bin/multiwan (copie de travail)
@@ -1011,6 +1011,8 @@
config_clear
config_load "multiwan"
+config_get_bool enabled config enabled '1'
+[ "$enabled" -gt 0 ] || exit
config_get default_route config default_route
config_get health_monitor config health_monitor
config_get iptables_interval config iptables_interval '30'
Index: net/multiwan/files/etc/config/multiwan
===================================================================
--- net/multiwan/files/etc/config/multiwan (révision 29722)
+++ net/multiwan/files/etc/config/multiwan (copie de travail)
@@ -1,5 +1,8 @@
config 'multiwan' 'config'
+ # REMOVE THIS LINE OR PUT TO 1 TO ENABLE MULTIWAN
+ option 'enabled' '0'
+
option 'default_route' 'balancer'
# health_monitor below is defaulted to parallel, and can be set to
# serial to save system resources.
Index: net/multiwan/Makefile
===================================================================
--- net/multiwan/Makefile (révision 29722)
+++ net/multiwan/Makefile (copie de travail)
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=multiwan
-PKG_VERSION:=1.0.19
+PKG_VERSION:=1.0.20
PKG_RELEASE:=1
include $(INCLUDE_DIR)/package.mk
@@ -39,4 +39,9 @@
$(CP) ./files/* $(1)
endef
+define Package/multiwan/postinst
+[ -n "$${IPKG_INSTROOT}" ] || /etc/init.d/multiwan enable
+exit 0
+endef
+
$(eval $(call BuildPackage,multiwan))
Index: multiwan.lua
===================================================================
--- multiwan.lua (revision 8176)
+++ multiwan.lua (working copy)
@@ -4,21 +4,20 @@
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)
+ if value == "0" then
+ os.execute("/etc/init.d/multiwan stop")
+ else
+ os.execute("/etc/init.d/multiwan enable")
+ end
+ self.map.uci:set("multiwan", section, "enabled", value)
end
-function e.cfgvalue(self, section)
- return (os.execute("/etc/init.d/multiwan enabled") == 0) and "1" or "0"
-end
-
s = m:section(TypedSection, "interface", translate("WAN Interfaces"),
translate("Health Monitor detects and corrects network changes and
failed connections."))
s.addremove = true
Index: multiwanmini.lua
===================================================================
--- multiwanmini.lua (revision 8176)
+++ multiwanmini.lua (working copy)
@@ -4,21 +4,20 @@
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)
+ if value == "0" then
+ os.execute("/etc/init.d/multiwan stop")
+ else
+ os.execute("/etc/init.d/multiwan enable")
+ end
+ self.map.uci:set("multiwan", section, "enabled", value)
end
-function e.cfgvalue(self, section)
- return (os.execute("/etc/init.d/multiwan enabled") == 0) and "1" or "0"
-end
-
s = m:section(TypedSection, "mwanfw", translate("Multi-WAN Traffic Rules"),
translate("Configure rules for directing outbound traffic through
specified WAN Uplinks."))
s.template = "cbi/tblsection"
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel