The following procedure shows how to ensure that the script runs only at the first boot of the newly installed system, and that the script runs only one time.
Before You Begin
Ensure that your role has the appropriate rights profiles to perform this procedure. See Using Rights Profiles to Install Oracle Solaris.
These easiest way to create this simple service is to use the svcbundle command as shown in Using the Manifest Creation Tool to Create an SMF Manifest File Including a First-boot Script.
Define a Boolean completion property in the service manifest, and set its value to false. See the completed property in the manifest in Example 8, Generated SMF Service Manifest.
Use the svccfg command to set the completed property to true at the end of the script. Use the svcadm command to refresh the service with the new property value. See the end of the sample script in Example 7, Template First-Boot Script.
In the service manifest, the default service instance is created and enabled. The service is disabled in the script. When you exit your first-boot script, use the SMF_EXIT_TEMP_DISABLE exit code to exit the start method of the service and temporarily disable the service. The service is disabled, and the stop method of the service does not run.
Temporarily disabling the service is preferable to permanently disabling the service so that the service can be more easily re-enabled. In some situations, the script (and therefore the service) must be re-run to update configuration work that was done, such as zone cloning or migration. If the service is permanently disabled, the svcadm enable command must be run to re-enable the service.
Temporarily disabling the service is also preferable to leaving the service online. A service that is online might appear to be doing work on every reboot. In this example, the name of the service is site/first-boot-script-svc. After the AI client is booted, you can see the service is in the disabled state:
$ svcs first-boot-script-svc STATE STIME FMRI disabled 8:24:16 svc:/site/first-boot-script-svc:default