aboutsummaryrefslogtreecommitdiffstats
path: root/package/uci/trigger/lib/trigger.lua
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2009-07-06 19:04:07 +0000
committerFelix Fietkau <nbd@openwrt.org>2009-07-06 19:04:07 +0000
commit069dbf6fd412aa01e384c8ca5fd2b51306a51412 (patch)
tree6083ef159a7c4c4e97659ad58d4967eb3b44018c /package/uci/trigger/lib/trigger.lua
parent7ffee1f66f96c514642b247a8c47e8fd1eca89da (diff)
downloadupstream-069dbf6fd412aa01e384c8ca5fd2b51306a51412.tar.gz
upstream-069dbf6fd412aa01e384c8ca5fd2b51306a51412.tar.bz2
upstream-069dbf6fd412aa01e384c8ca5fd2b51306a51412.zip
ucitrigger: add options to force enable/disable specific triggers
SVN-Revision: 16718
Diffstat (limited to 'package/uci/trigger/lib/trigger.lua')
-rw-r--r--package/uci/trigger/lib/trigger.lua56
1 files changed, 52 insertions, 4 deletions
diff --git a/package/uci/trigger/lib/trigger.lua b/package/uci/trigger/lib/trigger.lua
index 6710211d00..104d27ae44 100644
--- a/package/uci/trigger/lib/trigger.lua
+++ b/package/uci/trigger/lib/trigger.lua
@@ -253,6 +253,17 @@ function add(ts)
end
end
+function save_trigger(name)
+ if triggers.active[name] then
+ local slist = get_names(triggers.active[name])
+ if #slist > 0 then
+ tctx:set("uci_trigger", name, "sections", slist)
+ end
+ else
+ tctx:delete("uci_trigger", name)
+ end
+end
+
function set(data, cursor)
assert(data ~= nil)
if cursor == nil then
@@ -296,10 +307,7 @@ function set(data, cursor)
if section[".name"] then
active[section[".name"]] = true
end
- local slist = get_names(triggers.active[t.id])
- if #slist > 0 then
- tctx:set("uci_trigger", t.id, "sections", slist)
- end
+ save_trigger(t.id)
end
tctx:save("uci_trigger")
end
@@ -335,6 +343,46 @@ function get_active()
return slist
end
+function set_active(trigger, sections)
+ if triggers == nil then
+ load_state()
+ end
+ if not triggers.list[trigger] then
+ return
+ end
+ if triggers.active[trigger] == nil then
+ tctx:set("uci_trigger", trigger, "trigger")
+ triggers.active[trigger] = {}
+ end
+ local active = triggers.active[trigger]
+ if triggers.list[trigger].section_only or sections ~= nil then
+ for i, t in ipairs(sections) do
+ triggers.active[trigger][t] = true
+ end
+ end
+ save_trigger(trigger)
+ tctx:save("uci_trigger")
+end
+
+function clear_active(trigger, sections)
+ if triggers == nil then
+ load_state()
+ end
+ if triggers.list[trigger] == nil or triggers.active[trigger] == nil then
+ return
+ end
+ local active = triggers.active[trigger]
+ if not triggers.list[trigger].section_only or sections == nil then
+ triggers.active[trigger] = nil
+ else
+ for i, t in ipairs(sections) do
+ triggers.active[trigger][t] = false
+ end
+ end
+ save_trigger(trigger)
+ tctx:save("uci_trigger")
+end
+
function run(ts)
if ts == nil then
ts = get_active()