Managing System Services in Oracle® Solaris 11.2

Exit Print View

Updated: July 2014

How to Create an SMF Service Using the Service Bundle Generator Tool

This procedure shows how to create a service that uses an existing custom script as the start method.

  1. Determine the service model.

    By default, svcbundle creates a transient service. Determine whether the start method script for this service starts any long running daemon and is a contract service. See Service Models and the svc.startd (1M) man page for information about service models.

  2. Copy the script to the standard location.

    In this example, the script that will be the start method script for this service is named ex_svc. Copy this script to /lib/svc/method/ex_svc.

  3. Create an initial manifest.

    In this example, the service name is site/ex_svc. This is a transient service and does not need a stop method.

    $ svcbundle -o /tmp/ex_svc.xml -s service-name=site/ex_svc \
          -s start-method=/lib/svc/method/ex_svc
  4. Make any necessary changes to the manifest.

    Verify that the content of the /tmp/ex_svc.xml manifest is what you need. Add comments as needed.

  5. Verify that the manifest is valid.

    Use the svccfg validate command to make sure the service manifest is valid.

  6. Copy the manifest to the standard directory.
    $ cp /tmp/ex_svc.xml /lib/svc/manifest/site/ex_svc.xml
  7. Import the manifest and start the service.
    $ svcadm restart manifest-import
Example 5-1  Automatically Installing a Generated Manifest

If you do not need to make any changes to the new service manifest, you can use the -i option to install the manifest as soon as it is created. The svcbundle command will write the manifest to /lib/svc/manifest/site and restart the manifest-import service. Any existing file with the same name in the /lib/svc/manifest/site directory will be overwritten.

# svcbundle -i -s service-name=site/ex_svc \
	-s start-method=/lib/svc/method/ex_svc