From 0dd03597a6e8757b185f8036de3ea757ebac1bdc Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 15 Feb 2018 18:50:10 +0100 Subject: [PATCH] gluon-config-mode-core: allow returning functions from wizard modules Allow returning functions in addition to the names of UCI packages to commit. Functions are run after all packages have been committed. --- .../gluon/web/model/gluon-config-mode/wizard.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua b/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua index 6cafb0e2..35b605d2 100644 --- a/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua +++ b/package/gluon-config-mode-core/luasrc/lib/gluon/web/model/gluon-config-mode/wizard.lua @@ -28,11 +28,18 @@ local s = f:section(Section) s.template = "gluon/config-mode/welcome" local commit = {'gluon-setup-mode'} +local run = {} for _, w in ipairs(wizard) do for _, c in ipairs(w(f, uci) or {}) do - if not util.contains(commit, c) then - table.insert(commit, c) + if type(c) == 'string' then + if not util.contains(commit, c) then + table.insert(commit, c) + end + elseif type(c) == 'function' then + table.insert(run, c) + else + error('invalid wizard module return') end end end @@ -45,6 +52,9 @@ function f:write() for _, c in ipairs(commit) do uci:commit(c) end + for _, r in ipairs(run) do + r() + end f.template = "gluon/config-mode/reboot" f.hidenav = true