1 module("ffluci.controller.admin.uci", package.seeall)
5 -- This function has a higher priority than the admin_uci/apply template
6 function action_apply()
7 local changes = ffluci.model.uci.changes()
13 -- Collect files to be applied
14 for i, line in ipairs(ffluci.util.split(changes)) do
15 local r = line:match("^-?([^.]+)")
16 if r and not ffluci.util.contains(apply, ffluci.config.uci_oncommit[r]) then
17 table.insert(apply, ffluci.config.uci_oncommit[r])
22 ffluci.model.uci.commit()
24 -- Search for post-commit commands
25 if ffluci.config.uci_oncommit then
26 for i, cmd in ipairs(apply) do
28 output = output .. cmd .. ":" .. ffluci.sys.exec(cmd)
34 ffluci.template.render("admin_uci/apply", {changes=changes, output=output})
38 function action_revert()
39 local changes = ffluci.model.uci.changes()
43 -- Collect files to be reverted
44 for i, line in ipairs(ffluci.util.split(changes)) do
45 local r = line:match("^-?([^.]+)")
52 for k, v in pairs(revert) do
53 ffluci.model.uci.revert(k)
57 ffluci.template.render("admin_uci/revert", {changes=changes})