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
Using the Manifest Creation Tool
Customizing the Generated Manifest
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
To know what source you can use for your script, you need to know what tools are installed on the client system at first boot. The solaris-large-server package is installed by default. If you installed that group package, you have Python, bash, ksh, and other tools available to you at first boot. For a complete list of packages that are included in the solaris-large-server group package, use the pkg contents command as described in Listing All Installable Packages in a Group Package in Adding and Updating Oracle Solaris 11.1 Software Packages. If you want to use a source for your script that is not available in the solaris-large-server package, identify the package you need and specify it in the AI manifest. For information about how to find the names of other packages that you might want to install, see Adding and Updating Oracle Solaris 11.1 Software Packages.
Tip -
Use only one first-boot script to avoid having different commands in different scripts that collide with one another.
Do not reboot in the first-boot script.
Example 13-1 Template First-Boot Script
This example shows operations that should be done in any first-boot script.
A first-boot script must load /lib/svc/share/smf_include.sh in order to use definitions such as SMF method exit codes.
The script should test whether it already ran in a prior boot. If the completed property is already set to true, then exit the start method and temporarily disable the service.
The following line in the script gets the value of the completed property in the config property group in the site/first-boot-script-svc:default service instance and assigns that value to the local completed variable.
completed=`svcprop -p config/completed site/first-boot-script-svc:default`
The following line in the script sends the SMF_EXIT_TEMP_DISABLE exit code to the service start method, with method_completed as the short reason for the exit and "Configuration completed" as the longer description of the reason for the exit.
smf_method_exit $SMF_EXIT_TEMP_DISABLE script_completed "Configuration completed"
A first-boot script should save a copy of the boot environment (BE) that was just created by the AI installation. Saving a copy of the BE before the first-boot script modifies it enables you to easily recover from any problems introduced by the script by booting into the saved BE.
When the script has finished its work, the script must set the value of the completed property to true, refresh the service with the new property value, and exit the start method and temporarily disable the service. Use the svccfg command to set the completed property to true, and use the svcadm command to refresh the service.
Remember that by default, sh is ksh93.
#!/bin/sh # Load SMF shell support definitions . /lib/svc/share/smf_include.sh # If nothing to do, exit with temporary disable completed=`svcprop -p config/completed site/first-boot-script-svc:default` [ "${completed}" = "true" ] && \ smf_method_exit $SMF_EXIT_TEMP_DISABLE completed "Configuration completed" # Obtain the active BE name from beadm: The active BE on reboot has an R in # the third column of 'beadm list' output. Its name is in column one. bename=`beadm list -Hd|nawk -F ';' '$3 ~ /R/ {print $1}'` beadm create ${bename}.orig echo "Original boot environment saved as ${bename}.orig" # Place your one-time configuration tasks here # Record that this script's work is done svccfg -s site/first-boot-script-svc:default setprop config/completed = true svcadm refresh site/first-boot-script-svc:default smf_method_exit $SMF_EXIT_TEMP_DISABLE method_completed "Configuration completed"
Example 13-2 First-Boot Script that Configures Multiple IP Interfaces
This example shows a first-boot script named first-boot-script.sh that configures addresses on two IP interfaces and adds a default route.
#!/bin/sh # Load SMF shell support definitions . /lib/svc/share/smf_include.sh # If nothing to do, exit with temporary disable completed=`svcprop -p config/completed site/first-boot-script-svc:default` [ "${completed}" = "true" ] && \ smf_method_exit $SMF_EXIT_TEMP_DISABLE completed "Configuration completed" # Obtain the active BE name from beadm: The active BE on reboot has an R in # the third column of 'beadm list' output. Its name is in column one. bename=`beadm list -Hd|nawk -F ';' '$3 ~ /R/ {print $1}'` beadm create ${bename}.orig echo "Original boot environment saved as ${bename}.orig" # Create and configure addresses on two IP interfaces /usr/sbin/ipadm create-ip net0 /usr/sbin/ipadm create-ip net1 /usr/sbin/ipadm create-addr -a 10.153.125.222/24 net0 /usr/sbin/ipadm create-addr -a 169.254.182.77/24 net1 # Add a default route with net0 as the gateway /usr/sbin/route add default 10.153.125.1 -ifp net0 # Record that this script's work is done svccfg -s site/first-boot-script-svc:default setprop config/completed = true svcadm refresh site/first-boot-script-svc:default smf_method_exit $SMF_EXIT_TEMP_DISABLE method_completed "Configuration completed"