Boot & shutdown hooks
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.
Hooks are run by the SPEKTRA Edge OS lifecycle, so they are not available on
a device running the droplet agent installed from a .deb package. See
Install the droplet agent.
Available hooks
You can provide a script for each of these points:
| Hook | Script | Runs |
|---|---|---|
| On boot | /isodevice/config/hooks/on-boot | Early in startup, before the device agent starts. |
| After the agent starts | /isodevice/config/hooks/after-droplet | Once the device agent is up. |
| On shutdown | /isodevice/config/hooks/on-shutdown | When 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.
Hook scripts run with the privileges needed to administer the device. Treat them as trusted code and control who can place them on your devices.
Related
- How persistence works — the other settings supplied as files, and what survives an upgrade.
- Reboot, shutdown & recovery — when hooks run.
- Operations — the rest of this section.