1 module("luci.controller.admin.uci", package.seeall)
4 node("admin", "uci", "changes").target = call("action_changes")
5 node("admin", "uci", "revert").target = call("action_revert")
6 node("admin", "uci", "apply").target = call("action_apply")
9 function convert_changes(changes)
11 for r, tbl in pairs(changes) do
12 for s, os in pairs(tbl) do
13 for o, v in pairs(os) do
26 table.insert(ret, str..val)
30 return table.concat(ret, "\n")
33 function action_changes()
34 local changes = convert_changes(luci.model.uci.changes())
35 luci.template.render("admin_uci/changes", {changes=changes})
38 function action_apply()
39 local changes = luci.model.uci.changes()
46 -- Collect files to be applied and commit changes
47 for r, tbl in pairs(changes) do
49 luci.model.uci.load(r)
50 luci.model.uci.commit(r)
51 luci.model.uci.unload(r)
52 if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then
53 run[luci.config.uci_oncommit[r]] = true
58 -- Search for post-commit commands
59 for cmd, i in pairs(run) do
60 output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n"
65 luci.template.render("admin_uci/apply", {changes=convert_changes(changes), output=output})
69 function action_revert()
70 local changes = luci.model.uci.changes()
74 -- Collect files to be reverted
75 for r, tbl in pairs(changes) do
76 luci.model.uci.load(r)
77 luci.model.uci.revert(r)
78 luci.model.uci.unload(r)
82 luci.template.render("admin_uci/revert", {changes=convert_changes(changes)})