The release 2.27 of snapd introduced support for two new hooks: install and remove.
- The install hook can implement any custom initialization logic and it gets executed (if present in
meta/hooks/install
) when the snap is installed for the first time (contrary to configure hook, which gets executed every time a new revision of the snap gets installed). Install hook runs before any services shipped with the snap are started and before configure hook. This gives the snap a chance of doing any early initialization when installed for the first time.
Note: clearly install hook doesn’t help with snap updates (refreshes), this will be covered by another hook type which is coming with future snapd release. - The remove hook can implement any custom cleanup logic. It is executed (if present in
meta/hooks/remove
) when the last revision of the snap gets removed from the system. Remove hook runs after any services provided by the snap are stopped but before any data provided by the snap is cleaned up by snapd.
Both hooks run confined under the confinement of their snap (unless defined explicitely in snap.yaml
with specific plugs, in which case they may be granted extra permissions of these plugs as long as they’re auto-connected).