Getting rwho to work under Solaris SMF

Solaris (10+) and OpenSolaris use a relatively new mechanism for starting daemons the SMF (Service Management Framework). Adding a new entry to a manifest is surprisingly easy. We use rwhod as an example.
The core of the SMF is a manifest which is an XML file that describes what a service is and how to start stop and reload it. Here is an example for rwhod (rwhod.xml):


<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="rwhod">
<service name="network/rwhod" type="service" version="4">
<create_default_instance enabled="false"/>
<single_instance/>
<!--
If there's no network, then there's no point in running
-->
<dependency
name="loopback"
grouping="require_all"
restart_on="error"
type="service">
<service_fmri value="svc:/network/loopback:default"/>
</dependency>
<dependency
name="physical"
grouping="require_all"
restart_on="error"
type="service">
<service_fmri value="svc:/network/physical:default"/>
</dependency>
<dependency
name="fs-local"
grouping="require_all"
restart_on="none"
type="service">
<service_fmri value="svc:/system/filesystem/local"/>
</dependency>
<exec_method
type="method"
name="start"
exec="/usr/sbin/in.rwhod"
timeout_seconds="60"/>
<exec_method
type="method"
name="stop"
exec=":kill"
timeout_seconds="60"/>
<stability value="Unstable"/>
<template>
<common_name>
<loctext xml:lang="C">RWho daemon</loctext>
</common_name>
<documentation>
<manpage title="in.rwho" section="1M"/>
</documentation>
</template>
</service>
</service_bundle>


This is a basic manifest that lists a set of preconditions that must be satisfied before starting and a set of methods for stopping and starting the service.

Once the manifest is created it is imported using the command:

   svccfg import rwhod.xml

And started with the command:

   svcadm enable sec:/network/rwho:default