hook_install
hook_install
¶
OCI hook file generation and installation.
Writes the hook entrypoint script and JSON descriptors that tell podman
to invoke terok-shield at createRuntime and poststop. Two entry
points: :func:install_hooks for per-container setup during pre_start,
and :func:setup_global_hooks for one-time system-wide installation.
Pure file I/O — no runtime container interaction.
install_hooks(*, hook_entrypoint, hooks_dir)
¶
Write OCI hook entrypoint and JSON descriptors to a given directory.
WORKAROUND(hooks-dir-persist): currently only used for global hooks
(user or root) because podman does not persist per-container
--hooks-dir across stop/start. The per-container code path is
kept for near-future use.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hook_entrypoint
|
Path
|
Where to write the entrypoint script. |
required |
hooks_dir
|
Path
|
Directory for hook JSON descriptors. |
required |
Source code in src/terok_shield/core/hook_install.py
setup_global_hooks(target_dir, *, use_sudo=False)
¶
Install OCI hooks system-wide for restart persistence.
Called by the setup CLI command. When use_sudo is True, writes
to a temp directory first and copies via sudo cp — avoids needing
the Python process itself to run as root.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_dir
|
Path
|
Global hooks directory to install into. |
required |
use_sudo
|
bool
|
Copy files via |
False
|