JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Packaging and Delivering Software With the Image Packaging System in Oracle® Solaris 11.2
Oracle Technology Network
Print View
search filter icon
search icon

Document Information

Using This Documentation

Chapter 1 IPS Design Goals, Concepts, and Terminology

Chapter 2 Packaging Software With IPS

Chapter 3 Installing, Removing, and Updating Software Packages

Chapter 4 Specifying Package Dependencies

Chapter 5 Allowing Variations

Chapter 6 Modifying Package Manifests Programmatically

Chapter 7 Automating System Change as Part of Package Installation

Specifying System Changes on Package Actions

Delivering an SMF Service

Delivering a Service that Runs Once

Assembling a Custom File from Fragment Files

Chapter 8 Advanced Topics For Package Updating

Chapter 9 Signing IPS Packages

Chapter 10 Handling Non-Global Zones

Chapter 11 Modifying Published Packages

Appendix A Classifying Packages

Appendix B How IPS Is Used To Package the Oracle Solaris OS

Delivering a Service that Runs Once

This section shows an example of a package that delivers an SMF service that performs a one-time configuration.

The following package manifest delivers the run-once service:

set name=pkg.fmri value=myapp-run-once@1.0
set name=pkg.summary value="Deliver a service that runs once"
set name=pkg.description \
    value="This example package delivers a service that runs once. The service
is marked with a flag so that it will not run again."
set name=org.opensolaris.smf.fmri value=svc:/site/myapplication-run-once \
set name=variant.arch value=i386
file lib/svc/manifest/site/myapplication-run-once.xml \
    path=lib/svc/manifest/site/myapplication-run-once.xml owner=root group=sys \
mode=0444 restart_fmri=svc:/system/manifest-import:default
file lib/svc/method/ \
    path=lib/svc/method/ owner=root group=bin \
depend fmri=pkg:/shell/ksh93@ type=require
depend fmri=pkg:/system/core-os@0.5.11- type=require

The following script does the configuration work of the service. This method script uses a property, config/ran, that has been set in the service to ensure that the script runs only once. The property is set to one value in the service manifest and to another value in the method script. The comment in the exit call will be displayed by the svcs command.


# Load SMF shell support definitions
. /lib/svc/share/

# If nothing to do, exit with temporary disable.
ran=$(/usr/bin/svcprop -p config/ran $SMF_FMRI)
if [ "$ran" == "true" ] ; then
    smf_method_exit $SMF_EXIT_TEMP_DISABLE done "service ran"

# Do the configuration work.

# Record that this run-once service has done its work.
svccfg -s $SMF_FMRI setprop config/ran = true
svccfg -s $SMF_FMRI refresh

smf_method_exit $SMF_EXIT_TEMP_DISABLE done "service ran"

The following listing shows the SMF service manifest for this example. Some features of this manifest are described following the listing.

<?xml version="1.0" ?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type="manifest" name="myapplication-run-once">
            <service_fmri value='svc:/system/filesystem/local:default' />
        <service_fmri value='svc:/milestone/self-assembly-complete' />
    <instance enabled='true' name='default'>
        <property_group name='startd' type='framework'>
            <propval name='duration' type='astring' value='transient' />
        <property_group name='config' type='application'>
            <propval name='ran' type='boolean' value='false' />
             <loctext xml:lang='C'>
                 Run-once service
             <loctext xml:lang='C'>
                 This service checks and sets a property so that it runs
                 only once. This service is a dependency of the
                 self-assembly-complete milestone.

Be sure to include a comment in the method script exit and a service name and description in the service template data to help users understand why this service runs only one time.

Make sure the service manifest is valid:

$ svccfg validate proto/lib/svc/manifest/site/myapplication-run-once.xml

Publish your package as described in Publish the Package.

Run pkg verify before and after installing the package. Compare the output of each run to ensure that the script does not attempt to modify any files that are not marked as editable.

After you install the package, check the following output:

If you enable the service, you see that the “Rereading configuration” line is absent from the log file, and the service exited without re-doing the configuration work.