Creating a Custom Oracle® Solaris 11.2 Installation Image

Exit Print View

Updated: July 2014
 
 

Creating and Using Custom Scripts

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. Any number of custom-script checkpoints may be specified.


Note - Support for scripts is limited to any unmodified default scripts that are supplied with the application packages. If you choose to customize these scripts, back up the original scripts first.

In addition, note that 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.


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

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

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

  3. Reference the new script by adding a checkpoint in the execution section of the appropriate manifest file.

    To decide where to a the new checkpoint, review the descriptions of the default checkpoints as described in Set Up Build Checkpoints.

    Be sure to specify the full path to your scripts. Checkpoints are executed in the order 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 this 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 instead of using numbers. If new scripts are added, the new checkpoints for those new scripts will disrupt a 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. (Optional)Specify a build parameter as part of the checkpoint as follows.

    Here {PKG_IMAGE_PATH} is specified as the build parameter in the arguments section.

    <checkpoint name="my-script"
            desc="my new script"
            mod_path="solaris_install/distro_const/checkpoints/my_script"
            checkpoint_class="CustomScript">
            <args>/tmp/myscript.sh {PKG_IMAGE_PATH}</args>
    </checkpoint>

    If included in the checkpoint, the values of {PKG_IMAGE_PATH} and {BOOT_ARCHIVE} are replaced by the distro_const utility with ZFS dataset/build_data/pkg_image and ZFS dataset/build_data/boot_archive, respectively.

  5. Build the image.

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

    For instructions, see Chapter 3, Building an Image.

  6. (Optional)After the build is complete, you can view a log file reporting on the build process.

    The build output displays the location of log files.