1 module("luci.controller.admin.uci", package.seeall)
6 node("admin", "uci", "changes").target = call("action_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)
32 return table.concat(ret, "\n")
35 function action_changes()
36 local changes = convert_changes(luci.model.uci.changes())
37 luci.template.render("admin_uci/changes", {changes=changes})
40 function action_apply()
41 local changes = luci.model.uci.changes()
48 -- Collect files to be applied and commit changes
49 for r, tbl in pairs(changes) do
51 luci.model.uci.load(r)
52 luci.model.uci.commit(r)
53 luci.model.uci.unload(r)
54 if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then
55 run[luci.config.uci_oncommit[r]] = true
60 -- Search for post-commit commands
61 for cmd, i in pairs(run) do
62 output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n"
67 luci.template.render("admin_uci/apply", {changes=convert_changes(changes), output=output})
71 function action_revert()
72 local changes = luci.model.uci.changes()
76 -- Collect files to be reverted
77 for r, tbl in pairs(changes) do
78 luci.model.uci.load(r)
79 luci.model.uci.revert(r)
80 luci.model.uci.unload(r)
84 luci.template.render("admin_uci/revert", {changes=convert_changes(changes)})