Go to main content

Developing System Services in Oracle® Solaris 11.3

Exit Print View

Updated: September 2018
 
 

Converting a Run Control Script to an SMF Service

This section describes how to replace a run control script with an SMF service manifest so that the run control service can be managed by SMF.

How to Convert a Run Control Script to an SMF Service

This procedure describes how to use the rc-script property with the svcbundle command to convert a run control script to an SMF service.

  1. Determine the service model.

    By default, svcbundle creates a transient service. Determine whether this run control script starts any long-running daemon and therefore this service is a contract service. See Service Models in Managing System Services in Oracle Solaris 11.3, the model property in the svcbundle(1M) man page, and the startd/duration property in the svc.startd(1M) man page for information about service models.

  2. Create an initial manifest.

    To convert a run control script, use the rc-script property name with the -s option of the svcbundle command. See the rc-script property in the svcbundle(1M) man page for more information or enter svcbundle help rc-script.

    In this example, the service name is ex_con and is a contract service that runs at level 2. The run level is specified after a colon after the script name in the rc-script property value.

    $ svcbundle -o /tmp/ex_con.xml -s service-name=ex_con
          -s rc-script=/etc/init.d/ex_con:2 -s model=contract
  3. Make any necessary changes to the manifest.

    Verify that the content of the /tmp/ex_con.xml manifest is what you need. You might need to add a dependency or adjust the method timeout, for example. Add comments to describe what the service does and how the properties of the service are used.

  4. Verify that the manifest is valid.

    Use the svccfg validate command to ensure the service manifest is valid.

    $ svccfg validate /tmp/ex_con.xml
  5. Copy the manifest to the standard directory.
    $ cp /tmp/ex_con.xml /lib/svc/manifest/site/ex_con.xml
  6. Stop the existing service.
    $ /etc/init.d/ex_con stop
  7. Disable the run control script.

    Remove any links to the run control script from the appropriate rcn.d directories.

  8. Import the manifest and start the service.
    $ svcadm restart manifest-import
  9. List the new service.

    Verify that the new service exists and is in the expected state.

    $ svcs ex-con