lualoader: Add a loaded hook for others to execute upon config load

This will not be executed on reload, though later work could allow for that.
It's intended/expected that later work won't generally need to happen on
every config load, just once (for, e.g., menu initialization) or just when
config is reloaded but not upon the initial load.
This commit is contained in:
Kyle Evans 2018-06-06 18:28:17 +00:00
parent cbb009b9fe
commit 7aba5b2f6a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334723

View File

@ -458,7 +458,7 @@ function config.selectKernel(kernel)
config.kernel_selected = kernel config.kernel_selected = kernel
end end
function config.load(file) function config.load(file, reloading)
if not file then if not file then
file = "/boot/defaults/loader.conf" file = "/boot/defaults/loader.conf"
end end
@ -485,13 +485,16 @@ function config.load(file)
config.module_path = loader.getenv("module_path") config.module_path = loader.getenv("module_path")
local verbose = loader.getenv("verbose_loading") or "no" local verbose = loader.getenv("verbose_loading") or "no"
config.verbose = verbose:lower() == "yes" config.verbose = verbose:lower() == "yes"
if not reloading then
hook.runAll("config.loaded")
end
end end
-- Reload configuration -- Reload configuration
function config.reload(file) function config.reload(file)
modules = {} modules = {}
restoreEnv() restoreEnv()
config.load(file) config.load(file, true)
hook.runAll("config.reloaded") hook.runAll("config.reloaded")
end end
@ -512,5 +515,6 @@ function config.loadelf()
end end
end end
hook.registerType("config.loaded")
hook.registerType("config.reloaded") hook.registerType("config.reloaded")
return config return config