osi-tools/Documentation/module-interface.md

52 lines
1.3 KiB
Markdown
Raw Normal View History

2023-10-25 18:22:37 +00:00
# Module interface:
2023-12-13 03:23:30 +00:00
<!--
Copyright (C) 2023 Umorpha Systems
SPDX-License-Identifier: AGPL-3.0-or-later
-->
2023-10-25 18:22:37 +00:00
May call the functions:
- `load_module ${mod_filename}` to depend on another module
May adjust the variables:
- `packages` (array of depspecs) packages to download and install
- `cache_packages` (array of depspecs) packages to download but not
install
- `pre_install` (array of `uint:funcname` pairs) functions to call
after `${packages[@]}` and `${cache_packages[@]}` are downloaded,
but before `${packages[@]}` are installed. The listed functions
are called in numeric order of the provided number. Each function
is called with the image mountpoint as an argument.
2023-10-25 18:22:37 +00:00
You are encouraged to prefix your function names with `modulename:`
to avoid naming conflicts. Typical use looks like:
2023-10-25 18:22:37 +00:00
```bash
pre_install+=(99:mymodule:last_thing)
mymodule:last_thing() {
local arg_mountpoint=$2
# function body here
}
```
- `post_install` (array of `uint:funcname` pairs) like `pre_install`,
functions to call but called after `${packages[@]}` are installed.
All built-in hooks are in the ranges:
- 10-19
- 45-54
- 80-89
Which means that if you rely on running before or after them, your
safe ranges are:
- 00-09 # 10
- 20-44 # 25
- 55-79 # 25
- 90-99 # 10