1 module("luci.controller.admin.uci", package.seeall)
6 node("admin", "uci", "changes").target = template("admin_uci/changes")
7 node("admin", "uci", "revert").target = action_revert
8 node("admin", "uci", "apply").target = action_apply
11 -- This function has a higher priority than the admin_uci/apply template
12 function action_apply()
13 local changes = luci.model.uci.changes()
20 -- Collect files to be applied and commit changes
21 for i, line in ipairs(luci.util.split(changes)) do
22 local r = line:match("^-?([^.]+)")
26 if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then
27 run[luci.config.uci_oncommit[r]] = true
33 for config, i in pairs(com) do
34 luci.model.uci.commit(config)
37 -- Search for post-commit commands
38 for cmd, i in pairs(run) do
39 output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n"
43 luci.template.render("admin_uci/apply", {changes=changes, output=output})
47 function action_revert()
48 local changes = luci.model.uci.changes()
52 -- Collect files to be reverted
53 for i, line in ipairs(luci.util.split(changes)) do
54 local r = line:match("^-?([^.]+)")
61 for k, v in pairs(revert) do
62 luci.model.uci.revert(k)
66 luci.template.render("admin_uci/revert", {changes=changes})