I feel obliged to point out that this blog post is roughly 5 years old. People change, opinions evolve. In just a few years, vast technological landscapes can shift. And don't get me started on config files. Please consider this text in the context of its time.

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 one called cleanup. It’s a little bit special. It is only used when you transition from maintenance to disabled and that only happens if you use svcadm disable on a service in the maintenance state.

This restriction is very interesting from my point of view: You can integrate cleanup work that should only be 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 maintenance) the often seen pattern of disabling/enabling a service (the equivalent of “Have you tried to restart the computer?” or “Have you reset the Parameter RAM?”) to see if something changes can actually do something useful and helpful.

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

        cleanup)
                $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.

Written by

Joerg Moellenkamp

Grey-haired, sometimes grey-bearded Windows dismissing Unix guy.