I know that the
remove hook exists. Is there a best practice for performing tasks that need to run when the snap is being removed from a system, but before services have been shut down?
The specific case I have in mind is in MicroStack. It leaves an Open vSwitch bridge device behind. The bridge goes away on reboot, but I still want to be as tidy as possible when tearing the snap down, especially in the case where an operator might be uninstalling, then reinstalling the snap in a test environment or in preparation for a demo.
The correct command to remove the bridge is
microstack.ovsctl delbr br-ex. But that command only works while the Open vSwitch daemon is running. And it isn’t running by the time snapd executes the remove hook!
I’m thinking of simply writing and documenting a
microstack.uninstall script. But I’m curious as to whether there is something that integrates more neatly with the built in
snap remove microstack invocation.