Installing Oracle® Solaris 11.2 Systems

Exit Print View

Updated: July 2014

How to Ensure One Run at First Boot

  1. Create a service to run the script.

    These easiest way to create this simple service is to use the svcbundle command as shown in Using the Manifest Creation Tool.

  2. Set a script completion flag before the script runs.

    Define a Boolean completion property in the service manifest, and set its value to false. See the completed property in the manifest in Example 13–3.

  3. Set the script completion flag at the end of the script.

    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 13–1.

  4. Disable the service if the script completed.

    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 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