2020-03-29 05:22:21 +00:00
|
|
|
module("luci.controller.simple-adblock", package.seeall)
|
|
|
|
function index()
|
|
|
|
if nixio.fs.access("/etc/config/simple-adblock") then
|
2020-04-19 15:14:58 +00:00
|
|
|
entry({"admin", "services", "simple-adblock"}, cbi("simple-adblock"), _("Simple AdBlock")).acl_depends = { "luci-app-simple-adblock" }
|
2020-03-29 05:22:21 +00:00
|
|
|
entry({"admin", "services", "simple-adblock", "action"}, call("simple_adblock_action"), nil).leaf = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function simple_adblock_action(name)
|
|
|
|
local packageName = "simple-adblock"
|
2020-09-20 00:26:08 +00:00
|
|
|
local http = require "luci.http"
|
|
|
|
local sys = require "luci.sys"
|
|
|
|
local uci = require "luci.model.uci".cursor()
|
|
|
|
local util = require "luci.util"
|
2020-03-29 05:22:21 +00:00
|
|
|
if name == "start" then
|
2020-09-20 00:26:08 +00:00
|
|
|
sys.init.start(packageName)
|
2020-03-29 05:22:21 +00:00
|
|
|
elseif name == "action" then
|
2020-09-20 00:26:08 +00:00
|
|
|
util.exec("/etc/init.d/" .. packageName .. " dl >/dev/null 2>&1")
|
2020-03-29 05:22:21 +00:00
|
|
|
elseif name == "stop" then
|
2020-09-20 00:26:08 +00:00
|
|
|
sys.init.stop(packageName)
|
2020-03-29 05:22:21 +00:00
|
|
|
elseif name == "enable" then
|
2020-09-20 00:26:08 +00:00
|
|
|
uci:set(packageName, "config", "enabled", "1")
|
|
|
|
uci:commit(packageName)
|
2020-03-29 05:22:21 +00:00
|
|
|
elseif name == "disable" then
|
2020-09-20 00:26:08 +00:00
|
|
|
uci:set(packageName, "config", "enabled", "0")
|
|
|
|
uci:commit(packageName)
|
2020-03-29 05:22:21 +00:00
|
|
|
end
|
2020-09-20 00:26:08 +00:00
|
|
|
http.prepare_content("text/plain")
|
|
|
|
http.write("0")
|
2020-03-29 05:22:21 +00:00
|
|
|
end
|