diff options
author | Stan Grishin <stangri@melmac.net> | 2020-03-29 05:22:21 +0000 |
---|---|---|
committer | Stan Grishin <stangri@melmac.net> | 2020-03-29 05:22:21 +0000 |
commit | 5bf31bb1ae2b8192080ebc317fec1dfeaf337e76 (patch) | |
tree | 2470888d078e6d3eff8eb61756f0dcf668bb9fb0 /applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua | |
parent | e22d832b296066b16450c658e1af00be2f9e9926 (diff) |
luci-app-simple-adblock: better status/error display
Signed-off-by: Stan Grishin <stangri@melmac.net>
Diffstat (limited to 'applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua')
-rw-r--r-- | applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua b/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua new file mode 100644 index 000000000..22c75e4c8 --- /dev/null +++ b/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua @@ -0,0 +1,24 @@ +module("luci.controller.simple-adblock", package.seeall) +function index() + if nixio.fs.access("/etc/config/simple-adblock") then + entry({"admin", "services", "simple-adblock"}, cbi("simple-adblock"), _("Simple AdBlock")) + entry({"admin", "services", "simple-adblock", "action"}, call("simple_adblock_action"), nil).leaf = true + end +end + +function simple_adblock_action(name) + local packageName = "simple-adblock" + if name == "start" then + luci.sys.init.start(packageName) + elseif name == "action" then + luci.util.exec("/etc/init.d/" .. packageName .. " dl >/dev/null 2>&1") + elseif name == "stop" then + luci.sys.init.stop(packageName) + elseif name == "enable" then + luci.util.exec("uci set " .. packageName .. ".config.enabled=1; uci commit " .. packageName) + elseif name == "disable" then + luci.util.exec("uci set " .. packageName .. ".config.enabled=0; uci commit " .. packageName) + end + luci.http.prepare_content("text/plain") + luci.http.write("0") +end |