Skip to main content
Version: 030-rc3

Pantavisor Hooks

Overview: Hooks explains what hooks are for, why they are part of the revision, and how to write one.

Hook directory

/usr/lib/pantavisor/pv/hooks/system.d/

The base path (/usr/lib/pantavisor/pv) is set at build time via CMAKE_INSTALL_FULL_LIBDIR and may differ per target.

RuleBehaviour
DiscoveryThe directory is re-scanned on every hook invocation
OrderAlphabetical by filename. Use a numeric prefix (10-my-hook, 50-notify) to control it
EligibilityRegular files with the owner-execute bit (S_IXUSR) set
SkippedDirectories, symlinks and non-executable files, silently
Missing directoryNot an error — no hooks run
Outputstdout and stderr are captured by the log server under the hook's filename

Hook points

The active hook point is passed to the script as PV_OP.

PV_OP valueWhen it firesBootloader backends
system-startEarly in Pantavisor initialization, before containers are startedall
system-before-install-updateBefore the incoming revision is written into the bootloader environmentuboot-ab, rpiab
system-after-install-updateAfter the incoming revision has been written into the bootloader environmentuboot-ab, rpiab
system-install-updateBoth of the above combined, for backends with no dedicated install stepuboot, grub
system-boot-doneAfter a new revision has been committed following a successful try-bootall
system-doneWhen all containers have reached their status goalall

Hook environment variables

Set before executing every hook, unset afterwards.

VariableValue
PV_OPThe hook point currently running
PV_REVID of the currently running revision
PV_TRYID of the revision being attempted for the next boot; the incoming revision for update hooks. Empty outside a try-boot, or once committed
PV_TRYBOOT"true" if booted into an uncommitted trial revision, "false" otherwise. Always "true" during system-boot-done
PV_OBJ_STORAGEAbsolute path to the object storage directory
PV_TRAILS_STORAGEAbsolute path to the trails directory for the current revision
PV_STATUSCurrent revision status from the progress JSON (e.g. DONE, TESTING). Empty if no progress file exists

Failure semantics

A non-zero exit aborts the remaining hooks in the directory. What happens next depends on the hook point:

PV_OPEffect of a non-zero exit
system-startFatal. Pantavisor exits, the device reboots, and the bootloader's tryboot counter decrements toward rollback
system-before-install-updateThe update install is aborted
system-after-install-updateThe update install is aborted
system-install-updateThe update install is aborted
system-boot-doneThe commit fails
system-doneLogged only. The platform still transitions to its running state