summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua
diff options
context:
space:
mode:
authorStan Grishin <stangri@melmac.net>2020-09-20 00:26:08 +0000
committerStan Grishin <stangri@melmac.net>2020-09-20 00:26:08 +0000
commit306cfaef2a9da739af600b91d6cc5fd7f187c25a (patch)
treefddc347ae1f13bdfcce67c555c0de48149c090a6 /applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua
parent7b85227e3b20fbd96fc31f37e5c5e04241db1c51 (diff)
luci-app-simple-adblock: support for config auto-update
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.lua20
1 files changed, 13 insertions, 7 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
index 1dbfd1d40c..1c56502480 100644
--- a/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua
+++ b/applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua
@@ -8,17 +8,23 @@ end
function simple_adblock_action(name)
local packageName = "simple-adblock"
+ local http = require "luci.http"
+ local sys = require "luci.sys"
+ local uci = require "luci.model.uci".cursor()
+ local util = require "luci.util"
if name == "start" then
- luci.sys.init.start(packageName)
+ sys.init.start(packageName)
elseif name == "action" then
- luci.util.exec("/etc/init.d/" .. packageName .. " dl >/dev/null 2>&1")
+ util.exec("/etc/init.d/" .. packageName .. " dl >/dev/null 2>&1")
elseif name == "stop" then
- luci.sys.init.stop(packageName)
+ sys.init.stop(packageName)
elseif name == "enable" then
- luci.util.exec("uci set " .. packageName .. ".config.enabled=1; uci commit " .. packageName)
+ 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)
+ uci:set(packageName, "config", "enabled", "0")
+ uci:commit(packageName)
end
- luci.http.prepare_content("text/plain")
- luci.http.write("0")
+ http.prepare_content("text/plain")
+ http.write("0")
end