#!/bin/ksh93 # # Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. # The default AI manifest is a Derived Manifest (DM) script. The # script creates a temp file from xml within the script, loads that # file in as the manifest, then replaces the release of Solaris to # install with the same release as that running on the AI client. SCRIPT_SUCCESS=0 SOLPKG="entire" TMPFILE=`/usr/bin/mktemp /tmp/default.xml.XXXXXX` # # create_xml_file # Create xml tmp file from here document. The contents of the # here document are inserted during installadm create-service. # function create_xml_file { # Create xml tmp file cat <<- EOF > $TMPFILE %(default_manifest_goes_here)s EOF } # # error_handler # Error handling function # function error_handler { exit $? } # # load_xml # Load the default manifest from previously created tmp file # function load_xml { # load the default manifest trap error_handler ERR /usr/bin/aimanifest load $TMPFILE trap - ERR } # # update_solaris_version # Update the manifest entry of the Solaris consolidation package # so that the release of Solaris being installed is the same as # that running on the client. # function update_solaris_version { # If $SI_SYSPKG is not set in the environment, then the Solaris # consolidation pkg was not found on the client. Return without # making modifications to the manifest, but not an error. if [ -z ${SI_SYSPKG} ]; then echo "'${SOLPKG}' package not found on system" echo "Unable to constrain Solaris version being installed." return fi # Get list of pkgs to install from the manifest pkgs=$(/usr/bin/aimanifest get -r \ /auto_install/ai_instance/software[@type="IPS"]/software_data[@action="install"]/name \ 2> /dev/null) # array will be formatted as: ... array=($(echo ${pkgs} | /usr/bin/nawk 'BEGIN{FS="\n"} {print $NF}')) # Find the Solaris consolidation package manifest entry and change # it to use the version specified by the environment variable, # $SI_SYSPKG idx=0 while [ $idx -lt ${#array[@]} ]; do pkgname=${array[$idx]} # check if pkgname is Solaris consolidation package echo $pkgname | /usr/bin/egrep -s \ "(^*/|^)${SOLPKG}($|@[a-zA-Z0-9.,:-]*$)" if [ $? -ne 0 ]; then # look at next pkg (( idx=idx+2 )) continue fi # Replace Solaris consolidation package entry with DM # $SI_SYSPKG variable, which resolves to a pkg entry # that is the same release of Solaris as that running # on the client if [ ${pkgname} == ${SI_SYSPKG} ]; then echo "Solaris consolidation manifest entry is" \ "$SI_SYSPKG" break fi echo "Replacing Solaris consolidation manifest entry" \ "'${pkgname}' with '${SI_SYSPKG}'" trap error_handler ERR /usr/bin/aimanifest set ${array[idx+1]} $SI_SYSPKG trap - ERR break done if [ $idx -ge ${#array[@]} ]; then echo "Warning: Manifest does not contain package, '$SOLPKG'" echo "Unable to constrain version of Solaris" fi } ######################################## # main ######################################## # Create xml tmp file, then use aimanifest(1M) to load the # file and update the Solaris version to install. if [ -z "$TMPFILE" ]; then echo "Error: Unable to create temporary manifest file" exit 1 fi create_xml_file load_xml update_solaris_version exit $SCRIPT_SUCCESS