lualoader: add loader_conf_dirs support (loader.conf.d)
loader_conf_dirs is the supporting mechanism for the included /boot/loader.conf.d directory. When lualoader finishes processing all of the loader_conf_files it finds after walking /boot/defaults/loader.conf, it will now check any and all loader_conf_dirs and process files ending in ".conf" as if they were a loader.conf. Note that loader_conf_files may be specified in a loader.conf.d config file, but loader_conf_dirs may *not*. It will only be processed as specified in /boot/defaults/loader.conf and any loader_conf_files that were loaded from there. Reviewed by: allanjude, freqlabs, rpokala, tsoome Includes suggestion from: imp Relnotes: yes Differential Revision: https://reviews.freebsd.org/D25608
This commit is contained in:
parent
37df9d3bba
commit
72cf7db3aa
@ -22,6 +22,8 @@
|
||||
..
|
||||
firmware
|
||||
..
|
||||
loader.conf.d tags=package=bootloader
|
||||
..
|
||||
lua
|
||||
..
|
||||
kernel
|
||||
|
@ -15,6 +15,7 @@ kernel="kernel" # /boot sub-directory containing kernel and modules
|
||||
bootfile="kernel" # Kernel name (possibly absolute path)
|
||||
kernel_options="" # Flags to be passed to the kernel
|
||||
loader_conf_files="/boot/device.hints /boot/loader.conf /boot/loader.conf.local"
|
||||
loader_conf_dirs="/boot/loader.conf.d"
|
||||
nextboot_conf="/boot/nextboot.conf"
|
||||
verbose_loading="NO" # Set to YES for verbose loader output
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.Dd April 29, 2020
|
||||
.Dd December 31, 2020
|
||||
.Dt LOADER.CONF 5
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -87,6 +87,11 @@ than
|
||||
so its use should be avoided.
|
||||
Multiple instances of it will be processed
|
||||
independently.
|
||||
.It Ar loader_conf_dirs
|
||||
Space separated list of directories to process for configuration files.
|
||||
The lua-based loader will process files with a
|
||||
.Dq .conf
|
||||
suffix that are placed in these directories.
|
||||
.It Ar loader_conf_files
|
||||
Defines additional configuration files to be processed right after the
|
||||
present file.
|
||||
@ -252,6 +257,8 @@ The following values are accepted:
|
||||
Space or comma separated list of kernels to present in the boot menu.
|
||||
.It Va loader_conf_files
|
||||
.Pq Dq Pa /boot/loader.conf /boot/loader.conf.local
|
||||
.It Va loader_conf_dirs
|
||||
.Pq Dq Pa /boot/loader.conf.d
|
||||
.It Va splash_bmp_load
|
||||
.Pq Dq NO
|
||||
If set to
|
||||
|
@ -39,6 +39,7 @@ local env_changed = {}
|
||||
-- Values to restore env to (nil to unset)
|
||||
local env_restore = {}
|
||||
|
||||
local MSG_FAILDIR = "Failed to load conf dir '%s': not a directory"
|
||||
local MSG_FAILEXEC = "Failed to exec '%s'"
|
||||
local MSG_FAILSETENV = "Failed to '%s' with value: %s"
|
||||
local MSG_FAILOPENCFG = "Failed to open config: '%s'"
|
||||
@ -506,6 +507,8 @@ function config.readConf(file, loaded_files)
|
||||
return
|
||||
end
|
||||
|
||||
-- We'll process loader_conf_dirs at the top-level readConf
|
||||
local load_conf_dirs = next(loaded_files) == nil
|
||||
print("Loading " .. file)
|
||||
|
||||
-- The final value of loader_conf_files is not important, so just
|
||||
@ -529,6 +532,27 @@ function config.readConf(file, loaded_files)
|
||||
config.readConf(name, loaded_files)
|
||||
end
|
||||
end
|
||||
|
||||
if load_conf_dirs then
|
||||
local loader_conf_dirs = getEnv("loader_conf_dirs")
|
||||
if loader_conf_dirs ~= nil then
|
||||
for name in loader_conf_dirs:gmatch("[%w%p]+") do
|
||||
if lfs.attributes(name, "mode") ~= "directory" then
|
||||
print(MSG_FAILDIR:format(name))
|
||||
goto nextdir
|
||||
end
|
||||
for cfile in lfs.dir(name) do
|
||||
if cfile:match(".conf$") then
|
||||
local fpath = name .. "/" .. cfile
|
||||
if lfs.attributes(fpath, "mode") == "file" then
|
||||
config.readConf(fpath, loaded_files)
|
||||
end
|
||||
end
|
||||
end
|
||||
::nextdir::
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- other_kernel is optionally the name of a kernel to load, if not the default
|
||||
|
Loading…
Reference in New Issue
Block a user