From 9aad34a95c6cc7d68e12cd7d3fc2436f3106e9c6 Mon Sep 17 00:00:00 2001 From: nbd Date: Mon, 8 Jun 2009 01:27:01 +0000 Subject: add ucitrigger: a uci plugin, command line tool and lua interface for automatically applying uci config changes git-svn-id: svn://svn.openwrt.org/openwrt/trunk@16375 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/uci/trigger/apply_config | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 package/uci/trigger/apply_config (limited to 'package/uci/trigger/apply_config') diff --git a/package/uci/trigger/apply_config b/package/uci/trigger/apply_config new file mode 100644 index 000000000..0d9c6cf15 --- /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 -- cgit v1.2.3