Go to main content

Creating a Custom Oracle® Solaris 11.3 Installation Image

Exit Print View

Updated: December 2017
 
 

Creating and Using Custom Scripts When Creating an Installation Image

The distribution constructor enables you to specify additional scripts that can be used to make customizations during the image creation process based on the type of image you are building. The manifest files point to the scripts, and the scripts transform the generic image into a media-specific distribution. These scripts are referenced in the execution section of the manifest files. You can specify any number of custom-script checkpoints.

Often custom scripts are used to modify a configuration file or make some other change that can not be done using a manifest.

Scripts specified in the execution section of the manifest file are run during the image creation process. The execution section does not reference pre-install or post-install scripts.


Note -  Do not change scripts that are installed from packages. To prevent problems with future package updates, make any changes in a script you create.

    When you create your own custom scripts, note the following:

  • Scripts can be Python programs, shell scripts, or binaries.

  • Scripts are executed in the order in which they are listed in the execution section of the manifest file.

  • Standard output (stdout) and error output (stderr) of commands executed within the scripts (both shell and Python modules) are captured in log files that report on the completed or attempted build.

How to Create and Use a Custom Script When Creating an Installation Image

  1. Create a new script.
  2. Add the new script to your home directory or elsewhere on the system or network.

    Make sure that a user assuming the root role can execute the script.

  3. Modify the manifest.

    Add information referencing the new script in the execution section of the manifest. To decide where to add the new checkpoint, review Set Up Build Checkpoints.

    Be sure to specify the full path to your scripts. Checkpoints are executed in the order in which they are listed in the execution section of the manifest.

    When you add a reference for a new script in the execution section of a manifest file, you must specify a checkpoint name that can be used to pause the image build before or after the script performs its task. Optionally, you can include a custom message associated with the checkpoint name. If this message is omitted, the path of the script is used as the default checkpoint message. The checkpoint message displays when the checkpoint is run during the build process.


    Note -  Use meaningful names for checkpoint names rather than ordinal numbers. If you use numbers, adding new checkpoints for new scripts will disrupt the numbered checkpoint order.

    The following example checkpoint references a custom script named my-script.

    <checkpoint name="my-script"
            desc="my new script"
            mod_path="solaris_install/distro_const/checkpoints/custom_script"
            checkpoint_class="CustomScript">
            <args>/tmp/myscript.sh</args>
    </checkpoint>
  4. Build the image.

    You can build the image in one step or stop and restart the build at various checkpoints to check the status of the build.

    For instructions, see Building an Image.

  5. (Optional) After the build is complete, view the log file for the build process.

    The build output displays the location of the log files.

Example 4  Using Environment Variables in a Checkpoint

In the following example, the image directory path is used as an argument to myscript.sh.

<checkpoint name="my-script"
        desc="my new script"
        mod_path="solaris_install/distro_const/checkpoints/custom_script"
        checkpoint_class="CustomScript">
        <args>/tmp/myscript.sh {PKG_IMAGE_PATH}</args>
</checkpoint>
Example 5  Including a Short Script in a Custom DC Manifest

The following custom script prevents anyone from logging in as the user called jack. You could also change it to add a password, or remove the line. Note that this checkpoint was added at a specific place in the DC manifest. The script must run after the packages have been laid down, but before the boot_archive is created.

     <checkpoint name="set-ips-attributes"
         desc="Set post-install IPS attributes"
         mod_path="solaris_install/transfer/ips"
         checkpoint_class="TransferIPS"/>
     </checkpoint>
     <checkpoint name="lock-jack-account"
         desc="Lock the jack account from login"
         mod_path="solaris_install/distro_const/checkpoints/custom_script"
         checkpoint_class="CustomScript">
         <args>sed 's/jack:.[^:]*:/jack:*LK*:/g' {PKG_IMAGE_PATH}/etc/shadow
> {PKG_IMAGE_PATH}/etc/shadow.new; cp {PKG_IMAGE_PATH}/etc/shadow.new 
{PKG_IMAGE_PATH}/etc/shadow; rm {PKG_IMAGE_PATH}/etc/shadow.new</args>
     </checkpoint>
     <checkpoint name="pre-pkg-img-mod"

The following script will set the password for the solaris user which can be used to access an install client during the installation process.

     <checkpoint name="set-ips-attributes"
         desc="Set post-install IPS attributes"
         mod_path="solaris_install/transfer/ips"
         checkpoint_class="TransferIPS"/>
     </checkpoint>
     <checkpoint name="solaris-password"
         desc="Set the password for the solaris account used during the installation process"
         mod_path="solaris_install/distro_const/checkpoints/custom_script"
         checkpoint_class="CustomScript">
         <args>sed 's/solaris:.[^:]*:/solaris:string:/g' {PKG_IMAGE_PATH}/etc/shadow
> {PKG_IMAGE_PATH}/etc/shadow.new; cp {PKG_IMAGE_PATH}/etc/shadow.new 
{PKG_IMAGE_PATH}/etc/shadow; rm {PKG_IMAGE_PATH}/etc/shadow.new</args>
     </checkpoint>
     <checkpoint name="pre-pkg-img-mod"