Boot & shutdown hooks

Run your own scripts at defined points in the device lifecycle.

Hooks let you run your own scripts at defined points in the device lifecycle — for example to prepare hardware, mount a special device, or clean up on shutdown. They are the supported way to extend device behavior without modifying the read-only system image.

Available hooks

You can provide a script for each of these points:

HookScriptRuns
On boot/isodevice/config/hooks/on-bootEarly in startup, before the device agent starts.
After the agent starts/isodevice/config/hooks/after-dropletOnce the device agent is up.
On shutdown/isodevice/config/hooks/on-shutdownWhen the device is shutting down or rebooting.

How to provide a hook

Place your script at the path for the point you want to act on, and make it executable — a script that is not executable is skipped silently:

sudo install -m 755 my-script /isodevice/config/hooks/on-boot

Because /isodevice/config is configuration storage, the script persists across reboots and OS upgrades, and runs automatically at the corresponding point.

Guidelines

  • Keep hooks fast and resilient. The on-boot and after-agent hooks are allowed five minutes each before they time out, and a slow boot hook delays startup. Make hooks idempotent and have them exit cleanly.
  • Do not rely on modifying the system image. Use hooks to act on configuration and data, not to patch the OS — image changes do not persist.
  • Log from your hook so you can see what it did via logging.
  • Test on one device first before distributing a hook to a fleet.