HOOK.LUA(8)
πΈ NAME πΈ
hook.lua β bootloader hook module. Welcome to HOOK.LUA(8) from the System Managerβs Manual, bestie π
π¦ DESCRIPTION π¦
Okay so hook.lua contains functionality for defining hook types and attaching hooks. Hooks are functions used to attach custom behaviors at pre-defined points in loader execution. Those pre-defined points are what we refer to as βhook typesβ. Hooks may also take an optional data parameter, which may or may not be populated by the caller. No cap.
Before using the functionality provided by hook.lua, it must be included with a statement such as the following:
local hook = require("hook")
π«Ά Exported functions π«Ά
The following functions are exported from hook.lua β iconic lineup, honestly:
hook.registerType(hooktype)β Addshooktypeas a recognized hook type. This allows functions to be added to run when hooks of this type are invoked usinghook.runAll(hooktype).hook.register(hooktype, hookfunc)β Registerhookfuncto be run when hooks of typehooktypeare invoked.hook.runAll(hooktype)β Invoke all hooks registered for typehooktype. Hooks are invoked in the order in which they are registered.
π Hook Naming Guidelines π
Hook names should consist of the name of the module they are defined in, as well as a verb describing when the hook is executed, separated by a period. For example, config.reloaded is defined in the config.lua(8) module and run when the configuration is reloaded. Thatβs the whole naming vibe: module name + dot + verb β¨
π₯ EXAMPLES π₯
To register a hook to be run when configuration is reloaded, youβd do this:
local hook = require("hook")
local function configuration_was_reloaded()
print("Configuration was reloaded!")
end
hook.register("config.reloaded", configuration_was_reloaded)
Thatβs it. Chefβs kiss. π
π AUTHORS π
The hook.lua file was originally written by Kyle Evans <kevans@FreeBSD.org>. Legend behavior, fr fr π
Okay bestie, thatβs the whole page! This little icon is from Debian, dated March 29, 2025, and you just finished HOOK.LUA(8). Slay and stay hooked π
β¨
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms