Configuring Big Brother as a Solaris 10 Service


Tags:

mkdir /var/svc/manifest/application/monitoring
create the /var/svc/manifest/application/monitoring/bigbrother.xml file.

contents of bigbrother.xml (change directories, user, group, and stop/start
                            script paths to fit your install):
---------------------------------------------------------------------------------

<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<!--
    bigbrother.xml : BigBrother manifest, Kyle Reynolds
    2006-07-02
-->

<service_bundle type='manifest' name='bigbrother'>
<service name='application/monitoring/bigbrother' type='service' version='1'>

   <single_instance />

   <dependency
      name='multi-user-server'
      grouping='require_any'
      restart_on='error'
      type='service'>
      <service_fmri value='svc:/milestone/multi-user-server:default' />
   </dependency>

   <exec_method
      type='method'
      name='start'
      exec='/u01/app/bb/bbc/runbb.sh start'
      timeout_seconds='120' >
      <method_context>
         <method_credential user='bbuser' group='bbgroup' />
      </method_context>
   </exec_method>

   <exec_method
      type='method'
      name='stop'
      exec='/u01/app/bb/bbc/runbb.sh stop'
      timeout_seconds='120' >
      <method_context>
         <method_credential user='bbuser' group='bbgroup' />
      </method_context>
   </exec_method>

   <instance name='default' enabled='false' />

   <stability value='Unstable' />

   <template>
      <common_name>
         <loctext xml:lang='C'>Big Brother</loctext>
      </common_name>
   </template>

</service>
</service_bundle>

---------------------------------------------------------------------------------

run:

svccfg validate /var/svc/manifest/application/monitoring/bigbrother.xml

   (this validates the syntax of the xml file.  If it returns the message:
   "svccfg: couldn't parse document", then try running:
   `xmllint /var/svc/manifest/application/monitoring/bigbrother.xml`
   for more detailed error messages).
 
svccfg import /var/svc/manifest/application/monitoring/bigbrother.xml

svcadm enable svc:/application/monitoring/bigbrother:default


(NOTE: Most Solaris 10 services consist of an xml file (like the one above) plus a
 start script (or method) that is stored under /lib/svc/method.  I chose not to 
 follow this standard for 2 reasons:  first, big brother comes with it's own start
 script; second, I have added this service initialization to a Solaris 10 package that
 is often installed in Solaris zones.  The way I typically create a zone gives read-only
 access to the /lib dir, so the package cannot move the method to the /lib dir unless I
 change the way I implement zones, so this way, the service is more self-contained and 
 works perfectly without my having to make changes to the zones.)