summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Moeller <moeller0@gmx.de>2015-06-17 20:45:35 +0200
committerToke Høiland-Jørgensen <toke@toke.dk>2015-07-12 22:30:34 +0200
commita01d871099ca445d42cc48a75c269667bffed207 (patch)
treedaf9cf076ff7c37549b1b2d9644e4b2b95f89b86
parentb4b1bcfcf8d1379c88c6df751898ee6f222a1175 (diff)
[SQM/luci-app-sqm] Enable sqm initiscript if a single sqm instance gets enabled
The SQM gui has confused its users with an enable button, that only served to selecively activate/de-activate sqm instances instead of controlling sqm's initscript (which needs to be enabled so the sqm properly starts up after a reboot and also for hotplug to work properly). luci-app-sqm will now enable sqm's initscript when a single sqm instance get enabled. It also informs the user about this fact in the top margin of the sqm page. Note sqm will not disable the initscript behind the user's back if sqm instances get disabled. While I would have prefered this notice to be more prominent an attentive user should notice, and most users should not care anyway. This also increases the package release number. Signed-off-by: Sebastian Moeller <moeller0@gmx.de>
-rw-r--r--net/luci-app-sqm/Makefile2
-rw-r--r--net/luci-app-sqm/files/sqm-cbi.lua23
2 files changed, 23 insertions, 2 deletions
diff --git a/net/luci-app-sqm/Makefile b/net/luci-app-sqm/Makefile
index c4fbc1283..b5ec1add6 100644
--- a/net/luci-app-sqm/Makefile
+++ b/net/luci-app-sqm/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-sqm
PKG_VERSION:=3
-PKG_RELEASE:=2
+PKG_RELEASE:=3
PKG_LICENSE:=GPLv2
LUCI_DIR:=/usr/lib/lua/luci
diff --git a/net/luci-app-sqm/files/sqm-cbi.lua b/net/luci-app-sqm/files/sqm-cbi.lua
index 49ab13057..7633b7a1a 100644
--- a/net/luci-app-sqm/files/sqm-cbi.lua
+++ b/net/luci-app-sqm/files/sqm-cbi.lua
@@ -36,9 +36,30 @@ s.addremove = true -- set to true to allow adding SQM instances in the GUI
s.anonymous = true
-- BASIC
-e = s:taboption("tab_basic", Flag, "enabled", translate("Enable"))
+e = s:taboption("tab_basic", Flag, "enabled", translate("Enable this SQM instance."))
e.rmempty = false
+-- sm: following jow's advise, be helpful to the user and enable
+-- sqm's init script if even a single sm instance/interface
+-- is enabled; this is unexpected in that the init script gets
+-- enabled as soon as at least one sqm instance is enabled
+-- and that state is saved, so it does not require "Save & Apply"
+-- to effect the init scripts.
+-- the implementation was inpired/lifted from
+-- https://github.com/openwrt/luci/blob/master/applications/luci-app-minidlna/luasrc/model/cbi/minidlna.lua
+function e.write(self, section, value)
+ if value == "1" then
+ luci.sys.init.enable("sqm")
+ m.message = translate("The SQM GUI has just enabled the sqm initscript on your behalf. Remember to disable the sqm initscript manually under System Startup menu in case this change was not wished for.")
+-- luci.sys.call("/etc/init.d/sqm start >/dev/null")
+-- else
+-- luci.sys.call("/etc/init.d/sqm stop >/dev/null")
+-- luci.sys.init.disable("sqm")
+ end
+ return Flag.write(self, section, value)
+end
+-- TODO: inform the user what we just did...
+
n = s:taboption("tab_basic", ListValue, "interface", translate("Interface name"))
-- sm lifted from luci-app-wol, the original implementation failed to show pppoe-ge00 type interface names
for _, iface in ipairs(ifaces) do