2 .\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 .\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .Nd FreeBSD config module
37 contains configuration and module loading functionality.
39 Before hooking into or using the functionality provided by
41 it must be included with a statement such as the following:
43 .Dl local config = require("config")
44 .Ss Exported functions
45 The following functions are exported from
47 .Bl -tag -width "config.setCarouselIndex(id, idx)" -offset indent
48 .It Fn config.getCarouselIndex id
49 Returns the currently chosen index in the carousel menu entry described by
53 for a more in-depth explanation of carousels.
54 .It Fn config.setCarouselIndex id idx
55 Set the chosen index for the carousel menu entry described by
59 A lookup will be done as needed to determine what value
61 actually corresponds to.
62 .It Fn config.readConf file loaded_files
65 as a configuration file
69 and then processing files listed in
75 The caller may optionally pass in a table as the
77 argument, which uses filenames as keys and any non-nil value to
78 indicate that the file named by the key has already been loaded and
79 should not be loaded again.
80 .It Fn config.processFile name silent
83 as a configuration file.
86 exists and parses without error, false otherwise.
90 .Fn config.processFile
91 will not consider a failure to read the file as a failure.
92 .It Fn config.parse text
95 as a configuration file.
96 This is used internally by
97 .Fn config.processFile
98 to parse the contents of a configuration file.
99 Returns true if parsing succeeds without error, false if an error occurred.
100 A message is also printed to the console if an error is encountered.
101 .It Fn config.loadKernel other_kernel
108 .Fn config.loadKernel
111 Otherwise, it will try to load
114 .Pa /boot/{other_kernel} ,
118 The latter is tried in case an absolute path has been specified to the kernel
121 is amended to include the directory the kernel was found in if either of these
122 paths result in a loaded kernel.
124 If no kernel was loaded from either of these paths,
125 .Fn config.loadKernel
126 will attempt to load a kernel named
130 instead of attempting to load a kernel named
133 Returns true if a kernel was loaded, false if no kernel was loaded.
134 .It Fn config.selectKernel kernel
137 to the kernel that will be loaded when either
142 This is usually called by the menu system as the kernel selector carousel is
144 .It Fn config.load file reload
147 as a configuration file.
151 .Pa /boot/defaults/loader.conf
154 will then silently attempt to process any files specified in
155 .Ev loader_conf_files
160 configuration will also be checked as part of
162 Before returning, all
167 .It Fn config.reload file
170 as a configuration file.
172 will restore the environment to how it existed before the last config was
173 loaded, then it will invoke
174 .Fn config.load file .
175 Before returning, all
178 .It Fn config.loadelf
179 Loads all ELF objects, the selected kernel as well as any modules configured to
182 This will be called by the Lua intercepted
189 The following hooks are defined in
191 .Bl -tag -width "config.reloaded" -offset indent
193 .It Fn config.reloaded
195 .It Fn modules.loaded
205 file was originally written by
206 .An Pedro Souza Aq Mt pedrosouza@FreeBSD.org .
207 Later work and this manual page was done by
208 .An Kyle Evans Aq Mt kevans@FreeBSD.org .