xref: /freebsd/stand/lua/config.lua.8 (revision 088b5ad33962fd6f9b682ad31417b4cd14518c27)
1*088b5ad3SKyle Evans.\"
2*088b5ad3SKyle Evans.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3*088b5ad3SKyle Evans.\"
4*088b5ad3SKyle Evans.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
5*088b5ad3SKyle Evans.\"
6*088b5ad3SKyle Evans.\" Redistribution and use in source and binary forms, with or without
7*088b5ad3SKyle Evans.\" modification, are permitted provided that the following conditions
8*088b5ad3SKyle Evans.\" are met:
9*088b5ad3SKyle Evans.\" 1. Redistributions of source code must retain the above copyright
10*088b5ad3SKyle Evans.\"    notice, this list of conditions and the following disclaimer.
11*088b5ad3SKyle Evans.\" 2. Redistributions in binary form must reproduce the above copyright
12*088b5ad3SKyle Evans.\"    notice, this list of conditions and the following disclaimer in the
13*088b5ad3SKyle Evans.\"    documentation and/or other materials provided with the distribution.
14*088b5ad3SKyle Evans.\"
15*088b5ad3SKyle Evans.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16*088b5ad3SKyle Evans.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17*088b5ad3SKyle Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18*088b5ad3SKyle Evans.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19*088b5ad3SKyle Evans.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20*088b5ad3SKyle Evans.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21*088b5ad3SKyle Evans.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22*088b5ad3SKyle Evans.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23*088b5ad3SKyle Evans.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24*088b5ad3SKyle Evans.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25*088b5ad3SKyle Evans.\" SUCH DAMAGE.
26*088b5ad3SKyle Evans.\"
27*088b5ad3SKyle Evans.\" $FreeBSD$
28*088b5ad3SKyle Evans.\"
29*088b5ad3SKyle Evans.Dd June 9, 2018
30*088b5ad3SKyle Evans.Dt CONFIG.LUA 8
31*088b5ad3SKyle Evans.Os
32*088b5ad3SKyle Evans.Sh NAME
33*088b5ad3SKyle Evans.Nm config.lua
34*088b5ad3SKyle Evans.Nd FreeBSD config module
35*088b5ad3SKyle Evans.Sh DESCRIPTION
36*088b5ad3SKyle Evans.Nm
37*088b5ad3SKyle Evanscontains configuration and module loading functionality.
38*088b5ad3SKyle Evans.Pp
39*088b5ad3SKyle EvansBefore hooking into or using the functionality provided by
40*088b5ad3SKyle Evans.Nm ,
41*088b5ad3SKyle Evansit must be included with a statement such as the following:
42*088b5ad3SKyle Evans.Pp
43*088b5ad3SKyle Evans.Dl local config = require("config")
44*088b5ad3SKyle Evans.Ss Exported functions
45*088b5ad3SKyle EvansThe following functions are exported from
46*088b5ad3SKyle Evans.Nm :
47*088b5ad3SKyle Evans.Bl -tag -width "config.setCarouselIndex(id, idx)" -offset indent
48*088b5ad3SKyle Evans.It Fn config.getCarouselIndex id
49*088b5ad3SKyle EvansReturns the currently chosen index in the carousel menu entry described by
50*088b5ad3SKyle Evans.Ev id .
51*088b5ad3SKyle EvansSee the definition of
52*088b5ad3SKyle Evans.Xr menu.lua 8
53*088b5ad3SKyle Evansfor a more in-depth explanation of carousels.
54*088b5ad3SKyle Evans.It Fn config.setCarouselIndex id idx
55*088b5ad3SKyle EvansSet the chosen index for the carousel menu entry described by
56*088b5ad3SKyle Evans.Ev id
57*088b5ad3SKyle Evansto
58*088b5ad3SKyle Evans.Ev idx .
59*088b5ad3SKyle EvansA lookup will be done as needed to determine what value
60*088b5ad3SKyle Evans.Ev idx
61*088b5ad3SKyle Evansactually corresponds to.
62*088b5ad3SKyle Evans.It Fn config.processFile name silent
63*088b5ad3SKyle EvansProcess and parse
64*088b5ad3SKyle Evans.Ev name
65*088b5ad3SKyle Evansas a configuration file.
66*088b5ad3SKyle EvansReturns true if
67*088b5ad3SKyle Evans.Ev name
68*088b5ad3SKyle Evansexists and parses without error, false otherwise.
69*088b5ad3SKyle EvansIf
70*088b5ad3SKyle Evans.Ev silent
71*088b5ad3SKyle Evansis true,
72*088b5ad3SKyle Evans.Fn config.processFile
73*088b5ad3SKyle Evanswill not consider a failure to read the file as a failure.
74*088b5ad3SKyle Evans.It Fn config.parse text
75*088b5ad3SKyle EvansParse
76*088b5ad3SKyle Evans.Ev text
77*088b5ad3SKyle Evansas a configuration file.
78*088b5ad3SKyle EvansThis is used internally by
79*088b5ad3SKyle Evans.Fn config.processFile
80*088b5ad3SKyle Evansto parse the contents of a configuration file.
81*088b5ad3SKyle EvansReturns true if parsing succeeds without error, false if an error occurred.
82*088b5ad3SKyle EvansA message is also printed to the console if an error is encountered.
83*088b5ad3SKyle Evans.It Fn config.loadKernel other_kernel
84*088b5ad3SKyle EvansAttempts to load
85*088b5ad3SKyle Evans.Ev other_kernel
86*088b5ad3SKyle Evansas a kernel.
87*088b5ad3SKyle EvansIf
88*088b5ad3SKyle Evans.Ev other_kernel
89*088b5ad3SKyle Evansis unset
90*088b5ad3SKyle Evans.Fn config.loadKernel
91*088b5ad3SKyle Evanswill attempt to load
92*088b5ad3SKyle Evans.Dq kernel .
93*088b5ad3SKyle EvansOtherwise, it will try to load
94*088b5ad3SKyle Evans.Dq kernel
95*088b5ad3SKyle Evansfirst from
96*088b5ad3SKyle Evans.Pa /boot/{other_kernel} ,
97*088b5ad3SKyle Evansthen from
98*088b5ad3SKyle Evans.Pa {other_kernel} .
99*088b5ad3SKyle Evans.Pp
100*088b5ad3SKyle EvansThe latter is tried in case an absolute path has been specified to the kernel
101*088b5ad3SKyle Evansto use.
102*088b5ad3SKyle Evans.Ev module_path
103*088b5ad3SKyle Evansis amended to include the directory the kernel was found in if either of these
104*088b5ad3SKyle Evanspaths result in a loaded kernel.
105*088b5ad3SKyle Evans.Pp
106*088b5ad3SKyle EvansIf no kernel was loaded from either of these paths,
107*088b5ad3SKyle Evans.Fn config.loadKernel
108*088b5ad3SKyle Evanswill attempt to load a kernel named
109*088b5ad3SKyle Evans.Dq {other_kernel}
110*088b5ad3SKyle Evansfrom
111*088b5ad3SKyle Evans.Ev module_path
112*088b5ad3SKyle Evansinstead of attempting to load a kernel named
113*088b5ad3SKyle Evans.Dq kernel .
114*088b5ad3SKyle Evans.Pp
115*088b5ad3SKyle EvansReturns true if a kernel was loaded, false if no kernel was loaded.
116*088b5ad3SKyle Evans.It Fn config.selectKernel kernel
117*088b5ad3SKyle EvansSet
118*088b5ad3SKyle Evans.Ev kernel
119*088b5ad3SKyle Evansto the kernel that will be loaded when either
120*088b5ad3SKyle Evans.Ic autoboot
121*088b5ad3SKyle Evansor
122*088b5ad3SKyle Evans.Ic boot
123*088b5ad3SKyle Evansare invoked.
124*088b5ad3SKyle EvansThis is usually called by the menu system as the kernel selector carousel is
125*088b5ad3SKyle Evanstoggled through.
126*088b5ad3SKyle Evans.It Fn config.load file reload
127*088b5ad3SKyle EvansLoads
128*088b5ad3SKyle Evans.Ev file
129*088b5ad3SKyle Evansas a configuration file.
130*088b5ad3SKyle EvansIf
131*088b5ad3SKyle Evans.Ev file
132*088b5ad3SKyle Evansis not specified,
133*088b5ad3SKyle Evans.Pa /boot/defaults/loader.conf
134*088b5ad3SKyle Evansis used.
135*088b5ad3SKyle Evans.Fn config.load
136*088b5ad3SKyle Evanswill then silently attempt to process any files specified in
137*088b5ad3SKyle Evans.Ev loader_conf_files
138*088b5ad3SKyle Evansafter
139*088b5ad3SKyle Evans.Ev file
140*088b5ad3SKyle Evanshas been processed.
141*088b5ad3SKyle Evans.Xr nextboot 8
142*088b5ad3SKyle Evansconfiguration will also be checked as part of
143*088b5ad3SKyle Evans.Fn config.load .
144*088b5ad3SKyle EvansBefore returning, all
145*088b5ad3SKyle Evans.Dq config.loaded
146*088b5ad3SKyle Evanshooks will be run if
147*088b5ad3SKyle Evans.Ev reload
148*088b5ad3SKyle Evansis not set to true.
149*088b5ad3SKyle Evans.It Fn config.reload file
150*088b5ad3SKyle EvansReloads
151*088b5ad3SKyle Evans.Ev file
152*088b5ad3SKyle Evansas a configuration file.
153*088b5ad3SKyle Evans.Fn config.reload
154*088b5ad3SKyle Evanswill restore the environment to how it existed before the last config was
155*088b5ad3SKyle Evansloaded, then it will invoke
156*088b5ad3SKyle Evans.Fn config.load file .
157*088b5ad3SKyle EvansBefore returning, all
158*088b5ad3SKyle Evans.Dq config.reloaded
159*088b5ad3SKyle Evanshooks will be run.
160*088b5ad3SKyle Evans.It Fn config.loadelf
161*088b5ad3SKyle EvansLoads all ELF objects, the selected kernel as well as any modules configured to
162*088b5ad3SKyle Evansbe preloaded in
163*088b5ad3SKyle Evans.Xr loader.conf 5 .
164*088b5ad3SKyle EvansThis will be called by the Lua intercepted
165*088b5ad3SKyle Evans.Ic autoboot
166*088b5ad3SKyle Evansand
167*088b5ad3SKyle Evans.Ic boot
168*088b5ad3SKyle Evanscommands.
169*088b5ad3SKyle Evans.El
170*088b5ad3SKyle Evans.Ss Defined Hooks
171*088b5ad3SKyle EvansThe following hooks are defined in
172*088b5ad3SKyle Evans.Nm :
173*088b5ad3SKyle Evans.Bl -tag -width "config.reloaded" -offset indent
174*088b5ad3SKyle Evans.It config.loaded
175*088b5ad3SKyle Evans.It config.reloaded
176*088b5ad3SKyle Evans.El
177*088b5ad3SKyle Evans.Sh SEE ALSO
178*088b5ad3SKyle Evans.Xr loader.conf 5 ,
179*088b5ad3SKyle Evans.Xr loader 8 ,
180*088b5ad3SKyle Evans.Xr menu.lua 8 ,
181*088b5ad3SKyle Evans.Xr nextboot 8
182*088b5ad3SKyle Evans.Sh AUTHORS
183*088b5ad3SKyle EvansThe
184*088b5ad3SKyle Evans.Nm
185*088b5ad3SKyle Evansfile was originally written by
186*088b5ad3SKyle Evans.An Pedro Souza Aq Mt pedrosouza@FreeBSD.org .
187*088b5ad3SKyle EvansLater work and this manual page was done by
188*088b5ad3SKyle Evans.An Kyle Evans Aq Mt kevans@FreeBSD.org .
189