2 LuCI - Lua Configuration Interface
4 Copyright 2008 Steven Barth <steven@midlink.org>
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
14 module("luci.controller.admin.uci", package.seeall)
17 node("admin", "uci", "changes").target = call("action_changes")
18 node("admin", "uci", "revert").target = call("action_revert")
19 node("admin", "uci", "apply").target = call("action_apply")
22 function convert_changes(changes)
24 for r, tbl in pairs(changes) do
25 for s, os in pairs(tbl) do
26 for o, v in pairs(os) do
39 table.insert(ret, str..val)
43 return table.concat(ret, "\n")
46 function action_changes()
47 local changes = convert_changes(luci.model.uci.changes())
48 luci.template.render("admin_uci/changes", {changes=changes})
51 function action_apply()
52 local changes = luci.model.uci.changes()
59 -- Collect files to be applied and commit changes
60 for r, tbl in pairs(changes) do
62 luci.model.uci.load(r)
63 luci.model.uci.commit(r)
64 luci.model.uci.unload(r)
65 if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then
66 run[luci.config.uci_oncommit[r]] = true
71 -- Search for post-commit commands
72 for cmd, i in pairs(run) do
73 output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n"
78 luci.template.render("admin_uci/apply", {changes=convert_changes(changes), output=output})
82 function action_revert()
83 local changes = luci.model.uci.changes()
87 -- Collect files to be reverted
88 for r, tbl in pairs(changes) do
89 luci.model.uci.load(r)
90 luci.model.uci.revert(r)
91 luci.model.uci.unload(r)
95 luci.template.render("admin_uci/revert", {changes=convert_changes(changes)})