Clean up after yourself

This is a rather small change in one of the Solaris 11.4 SRUs. SMF had so far three methods. You could have a start method, which is as the name says meant to start the service. You could have a stop method, which is used of course to stop the service. A third method is the refresh one, which allows SMF to trigger the reload of the configuration of a service. Now there is a fourth once called cleanup. It’s a little bit special. It is only used then you transition from maintainance to disabled and that only happens if you use a svcadm disable</a> to a service in the maintainance state.

This restriction is very interesting from my point: You can integrate cleanup work that should be only used on manual intervention of the administrator. For example nuking cache directories or something similar. Something that you wouldn’t do on each restart. So if your operators have problems with the service (there must be a reason why the service went into maintaince) the often seen pattern of disabling/enabling a service (the equivalent of “Have to tried to restart the computer” or “Have to reset the Parameter RAM?”) to see if something changes can actually do something useful and helping.

Currently the script for the firewall at /lib/svc/method/firewall is using this fourth method.

                $PFCTL -dq

So when you want to integrate some cleanup work into your SMF service helping users to get it running again, you can now do it by having a similar section in your script with the SMF methods.