aboutsummaryrefslogtreecommitdiffstats
path: root/package/uci/trigger/apply_config
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2009-06-08 01:27:01 +0000
committerFelix Fietkau <nbd@openwrt.org>2009-06-08 01:27:01 +0000
commite7cbce1f9e99ddf686bdef99574c0f62356b5a07 (patch)
tree16a309a2dc39312852cc467a8c7452b2ad96e488 /package/uci/trigger/apply_config
parent2cda2ff5752de60b39ced1e445364f76f5c13bdd (diff)
downloadupstream-e7cbce1f9e99ddf686bdef99574c0f62356b5a07.tar.gz
upstream-e7cbce1f9e99ddf686bdef99574c0f62356b5a07.tar.bz2
upstream-e7cbce1f9e99ddf686bdef99574c0f62356b5a07.zip
add ucitrigger: a uci plugin, command line tool and lua interface for automatically applying uci config changes
SVN-Revision: 16375
Diffstat (limited to 'package/uci/trigger/apply_config')
-rw-r--r--package/uci/trigger/apply_config44
1 files changed, 44 insertions, 0 deletions
diff --git a/package/uci/trigger/apply_config b/package/uci/trigger/apply_config
new file mode 100644
index 0000000000..0d9c6cf15e
--- /dev/null
+++ b/package/uci/trigger/apply_config
@@ -0,0 +1,44 @@
+#!/usr/bin/lua
+require("uci")
+require("uci.trigger")
+
+function usage()
+ print("Usage: " .. arg[0] .. " [options]")
+ print("Options:")
+ print(" -a: apply the config changes")
+ print(" -t: show matching UCI triggers")
+ print(" -s: show information about tasks to be executed")
+ print(" -r: reset all triggers")
+ print("")
+end
+
+if arg[1] == "-s" then
+ local triggers = uci.trigger.get_active()
+ if #triggers > 0 then
+ print("Tasks:")
+ for i, a in ipairs(triggers) do
+ local trigger = a[1]
+ local sections = a[2]
+ print(" - " .. uci.trigger.get_description(trigger, sections))
+ end
+ else
+ print "Nothing to do"
+ end
+elseif arg[1] == "-t" then
+ local triggers = uci.trigger.get_active()
+ for i, a in ipairs(triggers) do
+ local trigger = a[1]
+ local sections = a[2]
+ if trigger.section_only then
+ print(trigger.id .. " " .. table.concat(" ", sections))
+ else
+ print(trigger.id)
+ end
+ end
+elseif arg[1] == "-a" then
+ uci.trigger.run()
+elseif arg[1] == "-r" then
+ uci.trigger.reset_state()
+else
+ usage()
+end