1 module("luci.controller.admin.uci", package.seeall)
6 node("admin", "uci", "changes").target = template("admin_uci/changes")
7 node("admin", "uci", "revert").target = call("action_revert")
8 node("admin", "uci", "apply").target = call("action_apply")
11 function convert_changes(changes)
13 for r, tbl in pairs(changes) do
14 for s, os in pairs(tbl) do
15 for o, v in pairs(os) do
28 table.insert(ret, str..val)
34 -- This function has a higher priority than the admin_uci/apply template
35 function action_apply()
36 local changes = luci.model.uci.changes()
43 -- Collect files to be applied and commit changes
44 for r, tbl in pairs(changes) do
48 if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then
49 run[luci.config.uci_oncommit[r]] = true
55 for config, i in pairs(com) do
56 luci.model.uci.commit(config)
59 -- Search for post-commit commands
60 for cmd, i in pairs(run) do
61 output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n"
66 luci.template.render("admin_uci/apply", {changes=convert_changes(changes), output=output})
70 function action_revert()
71 local changes = luci.model.uci.changes()
75 -- Collect files to be reverted
76 for r, tbl in ipairs(changes) do
83 for k, v in pairs(revert) do
84 luci.model.uci.revert(k)
88 luci.template.render("admin_uci/revert", {changes=convert_changes(changes)})