Adding environment variables to an SMF service

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.

This article was posted by Matty on 2009-02-06 11:26:00 -0400 -0400