Skip Navigation Links | |
Exit Print View | |
Installing Oracle Solaris 11.1 Systems Oracle Solaris 11.1 Information Library |
Part I Oracle Solaris 11.1 Installation Options
1. Overview of Installation Options
Part II Installing Using Installation Media
2. Preparing for the Installation
5. Automated Installations That Boot From Media
6. Unconfiguring or Reconfiguring an Oracle Solaris instance
Part III Installing Using an Install Server
7. Automated Installation of Multiple Clients
8. Setting Up an Install Server
10. Provisioning the Client System
11. Configuring the Client System
12. Installing and Configuring Zones
13. Running a Custom Script During First Boot
Implementing Run Once at First Boot Controls
How to Ensure One Run at First Boot
Creating a Script to Run at First Boot
Creating an IPS Package for the Script and Service
How to Create and Publish the IPS Package
Installing the First-Boot Package on the AI Client
How to Install the IPS Package
Testing the First-Boot Service
How to Update the Script or Service
15. Troubleshooting Automated Installations
Part IV Performing Related Tasks
A. Working With Oracle Configuration Manager
Create an SMF manifest file that defines a service that executes a script.
The start method of the service executes the first-boot script.
This example specifies the multi-user dependency to make sure that the first-boot script executes late in the startup sequence after first boot. Depending on what your first-boot script does, you might not need such a dependency. If you do not specify such a dependency, your script might run before the system is adequately configured.
Tip - Evaluate your script's dependencies and construct the service to run the script after its dependencies are satisfied.
The completed property is defined with a value of false.
You can use the svcbundle command to generate a valid service manifest. In the following example, notice that by default, a manifest generated by the svcbundle command specifies a transient service and specifies the multi-user dependency.
Example 13-3 Generated SMF Service Manifest
In the following command, the name of the script shown in Creating a Script to Run at First Boot is specified as the value of start-method. The name of the script is specified as /opt/site/first-boot-script.sh because the package created in Creating an IPS Package for the Script and Service installs the first-boot-script.sh script into /opt/site/first-boot-script.sh.
In the following command, the completed property is specified by a colon-separated list of property group name, property name, property type, and initial property value.
$ svcbundle -s service-name=site/first-boot-script-svc \ -s start-method=/opt/site/first-boot-script.sh \ -s instance-property=config:completed:boolean:false \ > first-boot-script-svc-manifest.xml
In the generated service manifest shown below, the first-boot script, /opt/site/first-boot-script.sh, is the value of the exec attribute of the start method. The completed property is specified in the instance element that defines the default instance of this service, first-boot-script-svc:default.
<?xml version="1.0" ?> <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> <!-- Manifest created by svcbundle (2012-Jul-13 16:39:30-0700) --> <service_bundle type="manifest" name="site/first-boot-script-svc"> <service version="1" type="service" name="site/first-boot-script-svc"> <!-- The following dependency keeps us from starting until the multi-user milestone is reached. --> <dependency restart_on="none" type="service" name="multi_user_dependency" grouping="require_all"> <service_fmri value="svc:/milestone/multi-user"/> </dependency> <exec_method timeout_seconds="60" type="method" name="start" exec="/opt/site/first-boot-script.sh"/> <!-- The exec attribute below can be changed to a command that SMF should execute to stop the service. See smf_method(5) for more details. --> <exec_method timeout_seconds="60" type="method" name="stop" exec=":true"/> <!-- The exec attribute below can be changed to a command that SMF should execute when the service is refreshed. Services are typically refreshed when their properties are changed in the SMF repository. See smf_method(5) for more details. It is common to retain the value of :true which means that SMF will take no action when the service is refreshed. Alternatively, you may wish to provide a method to reread the SMF repository and act on any configuration changes. --> <exec_method timeout_seconds="60" type="method" name="refresh" exec=":true"/> <property_group type="framework" name="startd"> <propval type="astring" name="duration" value="transient"/> </property_group> <instance enabled="true" name="default"> <property_group type="application" name="config"> <propval type="boolean" name="completed" value="false"/> </property_group> </instance> <template> <common_name> <loctext xml:lang="C"> <!-- Replace this comment with a short name for the service. --> </loctext> </common_name> <description> <loctext xml:lang="C"> <!-- Replace this comment with a brief description of the service --> </loctext> </description> </template> </service> </service_bundle>
The service manifest generated with the svcbundle command might meet your needs with no modification necessary. The following example shows a modification of the service manifest.
If you modify a service manifest, use the svccfg validate command to ensure the manifest is still valid.
Example 13-4 Customized SMF Service Manifest
In the following copy of the generated service manifest, the default exec_method timeout of 60 seconds has been increased for the start method. Make sure the start method has adequate time to run the first-boot script.
<?xml version="1.0" ?> <!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> <!-- Manifest created by svcbundle (2012-Jul-13 16:39:30-0700) --> <service_bundle type="manifest" name="site/first-boot-script-svc"> <service version="1" type="service" name="site/first-boot-script-svc"> <!-- The following dependency keeps us from starting until the multi-user milestone is reached. --> <dependency restart_on="none" type="service" name="multi_user_dependency" grouping="require_all"> <service_fmri value="svc:/milestone/multi-user"/> </dependency> <!-- Make sure the start method has adequate time to run the script. --> <exec_method timeout_seconds="360" type="method" name="start" exec="/opt/site/first-boot-script.sh"/> <!-- The exec attribute below can be changed to a command that SMF should execute to stop the service. See smf_method(5) for more details. --> <exec_method timeout_seconds="60" type="method" name="stop" exec=":true"/> <!-- The exec attribute below can be changed to a command that SMF should execute when the service is refreshed. Services are typically refreshed when their properties are changed in the SMF repository. See smf_method(5) for more details. It is common to retain the value of :true which means that SMF will take no action when the service is refreshed. Alternatively, you may wish to provide a method to reread the SMF repository and act on any configuration changes. --> <exec_method timeout_seconds="60" type="method" name="refresh" exec=":true"/> <property_group type="framework" name="startd"> <propval type="astring" name="duration" value="transient"/> </property_group> <instance enabled="true" name="default"> <property_group type="application" name="config"> <propval type="boolean" name="completed" value="false"/> </property_group> </instance> <template> <common_name> <loctext xml:lang="C"> <!-- Replace this comment with a short name for the service. --> </loctext> </common_name> <description> <loctext xml:lang="C"> <!-- Replace this comment with a brief description of the service --> </loctext> </description> </template> </service> </service_bundle>
$ svccfg validate first-boot-script-svc-manifest.xml