I create an SMF manifest last week for a new service, and needed two environment variables to be set prior to the services’ start method being invoked. After poking around the svccfg manual page, I came across the setenv subcommand, which can be used to set an environment variable:
$ svccfg -s tinydns setenv FOO bar
Since I was creating a manifest from scratch, I ran this against a temporary service and then used the svccfg “export” command to display the entry I needed to add to the manifest I was creating:
$ svccfg export tinydns
Here is the XML that was displayed for the environment variable addition:
<exec_method name=’start’ type=’method’ exec=’/lib/svc/method/tinydns start’ timeout_seconds=’60’>
<envvar name=’FOO’ value=’bar’/>
I like SMF, but sometimes wonder if it is over-engineered for what it actually needs to do. If you have opinions on this, please let me know by submitting a comment.