From 306cfaef2a9da739af600b91d6cc5fd7f187c25a Mon Sep 17 00:00:00 2001 From: Stan Grishin Date: Sun, 20 Sep 2020 00:26:08 +0000 Subject: luci-app-simple-adblock: support for config auto-update Signed-off-by: Stan Grishin --- .../luasrc/controller/simple-adblock.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'applications/luci-app-simple-adblock/luasrc/controller/simple-adblock.lua') 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 -- cgit v1.2.3