With some trepidation I set about porting a very simple rc script
to into smf.
It seems I should not have been overly concerned. The service in
question was a very small Postgres
database, which on Solaris 9 had been started from rc3.d. Moving the
rc script over to 10 worked but I wanted a fuller smf
experience so decided to create a manifest and import that into smf
on the zone running the database.
Starting with the start part of the rc script this became:
val=`svcprop -p $1 $FMRI`
[ -n "$val" ] && echo $val
exec /bin/su $u -c "postmaster -i -S -D $d"
It struck me that we are no longer confined to the bourne shell at
this point. As long as we depend on the files systems being mounted
we could use a more exotic shell, though never the
So all the possible options that postgres
uses are defined as properties. Then this manifest can be imported
and we are away:
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='postgres'>
<create_default_instance enabled='true' />
<service_fmri value='svc:/system/filesystem/autofs' />
<property_group name='postgres' type='application'>
<propval name='user' type='astring' value='postgres' />
<propval name='path' type='astring' value='/usr/local/pgsql/bin' />
<propval name='dbdir' type='astring' value='/var/pgsql' />
It depends on autofs so that if the binaries or the database files
are automounted it will be ready.
# svccfg import postgres.xml
and we are away. Clearly I did not manage to get this right first
time, and someone more knowledgeable in smf
will tell me I still have not, but this was easy to debug as the
output of the script when into
dredd 5 # svcs -l svc:/appl/postgres:default
dependency require_all/none svc:/system/filesystem/autofs (online)
dredd 6 #
Now killing postgres using
kill or pkill results in the database being restarted. Nice.
This was on a zone running build 67 so
things may appear different in the released version.