#!/bin/ksh -p # # # # # # # # # # # # # # # # # # # # # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. # # # This postattach hook adds the service tag for the zone. # We need this in a postattach hook since the zone doesn't have # a UUID when the attach hook is run. # . /usr/lib/brand/solaris10/common.ksh install_media="-" f_sysunconfig=$(gettext "Error: sys-unconfig failed.") f_noscprofile=$(gettext "Unable to apply sysidcfg file to attached zone.") # If we weren't passed at least two arguments, exit now. (( $# < 2 )) && exit $ZONE_SUBPROC_OK ZONENAME="$1" ZONEPATH="$2" shift 2 noexecute=0 unset inst_type unset sc_sysidcfg # # This hook will see the same options as the attach hook, so make sure # we accept all of these. # while getopts "a:c:d:nr:x:" opt; do case $opt in a) inst_type="archive" install_media="$OPTARG" ;; c) sc_sysidcfg="$OPTARG" ;; d) inst_type="directory" install_media="$OPTARG" ;; n) noexecute=1 ;; r) inst_type="stdin" install_media="$OPTARG" ;; x) ;; # zoneadm only ?) error "$f_noscprofile" exit $ZONE_SUBPROC_OK ;; *) error "$f_noscprofile" exit $ZONE_SUBPROC_OK ;; esac done shift $((OPTIND-1)) [ $noexecute -eq 1 ] && exit $ZONE_SUBPROC_OK # Copy in sysidcfg file, boot zone, run sysunconfig and halt if [[ -n $sc_sysidcfg ]]; then /usr/sbin/zoneadm -z $ZONENAME boot -f -- -m milestone=none if (( $? != 0 )); then error "$e_badboot" fail_tryagain "$f_sysunconfig" fi sysunconfig_zone if (( $? != 0 )); then /usr/sbin/zoneadm -z $ZONENAME halt fail_tryagain "$f_sysunconfig" fi /usr/sbin/zoneadm -z $ZONENAME halt safe_copy $sc_sysidcfg $ZONEPATH/root/etc/sysidcfg fi [[ -z "$inst_type" ]] && inst_type="directory" # Add a service tag for this zone. add_svc_tag "$ZONENAME" "attach $inst_type `basename $install_media`" exit $ZONE_SUBPROC_OK