1088b5ad3SKyle Evans.\" 2088b5ad3SKyle Evans.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3088b5ad3SKyle Evans.\" 4088b5ad3SKyle Evans.\" Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org> 5088b5ad3SKyle Evans.\" 6088b5ad3SKyle Evans.\" Redistribution and use in source and binary forms, with or without 7088b5ad3SKyle Evans.\" modification, are permitted provided that the following conditions 8088b5ad3SKyle Evans.\" are met: 9088b5ad3SKyle Evans.\" 1. Redistributions of source code must retain the above copyright 10088b5ad3SKyle Evans.\" notice, this list of conditions and the following disclaimer. 11088b5ad3SKyle Evans.\" 2. Redistributions in binary form must reproduce the above copyright 12088b5ad3SKyle Evans.\" notice, this list of conditions and the following disclaimer in the 13088b5ad3SKyle Evans.\" documentation and/or other materials provided with the distribution. 14088b5ad3SKyle Evans.\" 15088b5ad3SKyle Evans.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16088b5ad3SKyle Evans.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17088b5ad3SKyle Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18088b5ad3SKyle Evans.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19088b5ad3SKyle Evans.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20088b5ad3SKyle Evans.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21088b5ad3SKyle Evans.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22088b5ad3SKyle Evans.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23088b5ad3SKyle Evans.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24088b5ad3SKyle Evans.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25088b5ad3SKyle Evans.\" SUCH DAMAGE. 26088b5ad3SKyle Evans.\" 27088b5ad3SKyle Evans.\" $FreeBSD$ 28088b5ad3SKyle Evans.\" 297a5c6c8bSKyle Evans.Dd April 27, 2020 30088b5ad3SKyle Evans.Dt CONFIG.LUA 8 31088b5ad3SKyle Evans.Os 32088b5ad3SKyle Evans.Sh NAME 33088b5ad3SKyle Evans.Nm config.lua 34088b5ad3SKyle Evans.Nd FreeBSD config module 35088b5ad3SKyle Evans.Sh DESCRIPTION 36088b5ad3SKyle Evans.Nm 37088b5ad3SKyle Evanscontains configuration and module loading functionality. 38088b5ad3SKyle Evans.Pp 39088b5ad3SKyle EvansBefore hooking into or using the functionality provided by 40088b5ad3SKyle Evans.Nm , 41088b5ad3SKyle Evansit must be included with a statement such as the following: 42088b5ad3SKyle Evans.Pp 43088b5ad3SKyle Evans.Dl local config = require("config") 44088b5ad3SKyle Evans.Ss Exported functions 45088b5ad3SKyle EvansThe following functions are exported from 46088b5ad3SKyle Evans.Nm : 47088b5ad3SKyle Evans.Bl -tag -width "config.setCarouselIndex(id, idx)" -offset indent 48088b5ad3SKyle Evans.It Fn config.getCarouselIndex id 49088b5ad3SKyle EvansReturns the currently chosen index in the carousel menu entry described by 50088b5ad3SKyle Evans.Ev id . 51088b5ad3SKyle EvansSee the definition of 52088b5ad3SKyle Evans.Xr menu.lua 8 53088b5ad3SKyle Evansfor a more in-depth explanation of carousels. 54088b5ad3SKyle Evans.It Fn config.setCarouselIndex id idx 55088b5ad3SKyle EvansSet the chosen index for the carousel menu entry described by 56088b5ad3SKyle Evans.Ev id 57088b5ad3SKyle Evansto 58088b5ad3SKyle Evans.Ev idx . 59088b5ad3SKyle EvansA lookup will be done as needed to determine what value 60088b5ad3SKyle Evans.Ev idx 61088b5ad3SKyle Evansactually corresponds to. 627a5c6c8bSKyle Evans.It Fn config.readConfFiles files loaded_files 637a5c6c8bSKyle EvansProcess 647a5c6c8bSKyle Evans.Ev files 657a5c6c8bSKyle Evansas if it were 667a5c6c8bSKyle Evans.Ev loader_conf_files . 67aa3d34deSKyle EvansThe caller should pass in a table as the 687a5c6c8bSKyle Evans.Ev loaded_files 697a5c6c8bSKyle Evansargument, which uses filenames as keys and any non-nil value to indicate that 707a5c6c8bSKyle Evansthe file named by the key has been loaded. 71088b5ad3SKyle Evans.It Fn config.processFile name silent 72088b5ad3SKyle EvansProcess and parse 73088b5ad3SKyle Evans.Ev name 74088b5ad3SKyle Evansas a configuration file. 75088b5ad3SKyle EvansReturns true if 76088b5ad3SKyle Evans.Ev name 77088b5ad3SKyle Evansexists and parses without error, false otherwise. 78088b5ad3SKyle EvansIf 79088b5ad3SKyle Evans.Ev silent 80088b5ad3SKyle Evansis true, 81088b5ad3SKyle Evans.Fn config.processFile 82088b5ad3SKyle Evanswill not consider a failure to read the file as a failure. 83088b5ad3SKyle Evans.It Fn config.parse text 84088b5ad3SKyle EvansParse 85088b5ad3SKyle Evans.Ev text 86088b5ad3SKyle Evansas a configuration file. 87088b5ad3SKyle EvansThis is used internally by 88088b5ad3SKyle Evans.Fn config.processFile 89088b5ad3SKyle Evansto parse the contents of a configuration file. 90088b5ad3SKyle EvansReturns true if parsing succeeds without error, false if an error occurred. 91088b5ad3SKyle EvansA message is also printed to the console if an error is encountered. 92088b5ad3SKyle Evans.It Fn config.loadKernel other_kernel 93088b5ad3SKyle EvansAttempts to load 94088b5ad3SKyle Evans.Ev other_kernel 95088b5ad3SKyle Evansas a kernel. 96088b5ad3SKyle EvansIf 97088b5ad3SKyle Evans.Ev other_kernel 98088b5ad3SKyle Evansis unset 99088b5ad3SKyle Evans.Fn config.loadKernel 100088b5ad3SKyle Evanswill attempt to load 101088b5ad3SKyle Evans.Dq kernel . 102088b5ad3SKyle EvansOtherwise, it will try to load 103088b5ad3SKyle Evans.Dq kernel 104088b5ad3SKyle Evansfirst from 105088b5ad3SKyle Evans.Pa /boot/{other_kernel} , 106088b5ad3SKyle Evansthen from 107088b5ad3SKyle Evans.Pa {other_kernel} . 108088b5ad3SKyle Evans.Pp 109088b5ad3SKyle EvansThe latter is tried in case an absolute path has been specified to the kernel 110088b5ad3SKyle Evansto use. 111088b5ad3SKyle Evans.Ev module_path 112088b5ad3SKyle Evansis amended to include the directory the kernel was found in if either of these 113088b5ad3SKyle Evanspaths result in a loaded kernel. 114088b5ad3SKyle Evans.Pp 115088b5ad3SKyle EvansIf no kernel was loaded from either of these paths, 116088b5ad3SKyle Evans.Fn config.loadKernel 117088b5ad3SKyle Evanswill attempt to load a kernel named 118088b5ad3SKyle Evans.Dq {other_kernel} 119088b5ad3SKyle Evansfrom 120088b5ad3SKyle Evans.Ev module_path 121088b5ad3SKyle Evansinstead of attempting to load a kernel named 122088b5ad3SKyle Evans.Dq kernel . 123088b5ad3SKyle Evans.Pp 124088b5ad3SKyle EvansReturns true if a kernel was loaded, false if no kernel was loaded. 125088b5ad3SKyle Evans.It Fn config.selectKernel kernel 126088b5ad3SKyle EvansSet 127088b5ad3SKyle Evans.Ev kernel 128088b5ad3SKyle Evansto the kernel that will be loaded when either 129088b5ad3SKyle Evans.Ic autoboot 130088b5ad3SKyle Evansor 131088b5ad3SKyle Evans.Ic boot 132088b5ad3SKyle Evansare invoked. 133088b5ad3SKyle EvansThis is usually called by the menu system as the kernel selector carousel is 134088b5ad3SKyle Evanstoggled through. 135088b5ad3SKyle Evans.It Fn config.load file reload 136088b5ad3SKyle EvansLoads 137088b5ad3SKyle Evans.Ev file 138088b5ad3SKyle Evansas a configuration file. 139088b5ad3SKyle EvansIf 140088b5ad3SKyle Evans.Ev file 141088b5ad3SKyle Evansis not specified, 142088b5ad3SKyle Evans.Pa /boot/defaults/loader.conf 143088b5ad3SKyle Evansis used. 144088b5ad3SKyle Evans.Fn config.load 145088b5ad3SKyle Evanswill then silently attempt to process any files specified in 146088b5ad3SKyle Evans.Ev loader_conf_files 147088b5ad3SKyle Evansafter 148088b5ad3SKyle Evans.Ev file 149088b5ad3SKyle Evanshas been processed. 150088b5ad3SKyle Evans.Xr nextboot 8 151088b5ad3SKyle Evansconfiguration will also be checked as part of 152088b5ad3SKyle Evans.Fn config.load . 153088b5ad3SKyle EvansBefore returning, all 154088b5ad3SKyle Evans.Dq config.loaded 155088b5ad3SKyle Evanshooks will be run if 156088b5ad3SKyle Evans.Ev reload 157088b5ad3SKyle Evansis not set to true. 158088b5ad3SKyle Evans.It Fn config.reload file 159088b5ad3SKyle EvansReloads 160088b5ad3SKyle Evans.Ev file 161088b5ad3SKyle Evansas a configuration file. 162088b5ad3SKyle Evans.Fn config.reload 163088b5ad3SKyle Evanswill restore the environment to how it existed before the last config was 164088b5ad3SKyle Evansloaded, then it will invoke 165088b5ad3SKyle Evans.Fn config.load file . 166088b5ad3SKyle EvansBefore returning, all 167088b5ad3SKyle Evans.Dq config.reloaded 168088b5ad3SKyle Evanshooks will be run. 169088b5ad3SKyle Evans.It Fn config.loadelf 170088b5ad3SKyle EvansLoads all ELF objects, the selected kernel as well as any modules configured to 171088b5ad3SKyle Evansbe preloaded in 172088b5ad3SKyle Evans.Xr loader.conf 5 . 173088b5ad3SKyle EvansThis will be called by the Lua intercepted 174088b5ad3SKyle Evans.Ic autoboot 175088b5ad3SKyle Evansand 176088b5ad3SKyle Evans.Ic boot 177088b5ad3SKyle Evanscommands. 178088b5ad3SKyle Evans.El 179088b5ad3SKyle Evans.Ss Defined Hooks 180088b5ad3SKyle EvansThe following hooks are defined in 181088b5ad3SKyle Evans.Nm : 182088b5ad3SKyle Evans.Bl -tag -width "config.reloaded" -offset indent 183*60a2823cSKyle Evans.It Fn config.loaded 184*60a2823cSKyle Evans.It Fn config.reloaded 185*60a2823cSKyle Evans.It Fn kernel.loaded 186*60a2823cSKyle Evans.It Fn modules.loaded 187088b5ad3SKyle Evans.El 188088b5ad3SKyle Evans.Sh SEE ALSO 189088b5ad3SKyle Evans.Xr loader.conf 5 , 190088b5ad3SKyle Evans.Xr loader 8 , 191088b5ad3SKyle Evans.Xr menu.lua 8 , 192088b5ad3SKyle Evans.Xr nextboot 8 193088b5ad3SKyle Evans.Sh AUTHORS 194088b5ad3SKyle EvansThe 195088b5ad3SKyle Evans.Nm 196088b5ad3SKyle Evansfile was originally written by 197088b5ad3SKyle Evans.An Pedro Souza Aq Mt pedrosouza@FreeBSD.org . 198088b5ad3SKyle EvansLater work and this manual page was done by 199088b5ad3SKyle Evans.An Kyle Evans Aq Mt kevans@FreeBSD.org . 200