2N/A#!/bin/ksh -p
2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
2N/A
2N/A#
2N/A# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A#
2N/A
2N/A#
2N/A# common shell script functions
2N/A#
2N/A. /usr/lib/brand/shared/common.ksh
2N/A. /usr/lib/brand/solaris10/common.ksh
2N/A. /usr/lib/brand/shared/uninstall.ksh
2N/A
2N/Atrap_exit() {
2N/A finish_log zone
2N/A exit $EXIT_CODE
2N/A}
2N/AEXIT_CODE=$ZONE_SUBPROC_USAGE
2N/A
2N/A#
2N/A# options processing
2N/A#
2N/A
2N/A# If we weren't passed at least two arguments, exit now.
2N/A(( $# < 2 )) && exit $ZONE_SUBPROC_USAGE
2N/A
2N/A# used by start_log()
2N/Aset -A save_args "$0" "$@"
2N/A
2N/Atypeset zone
2N/Ainit_zone zone "$1" "$2"
2N/Aeval $(bind_legacy_zone_globals zone)
2N/Ashift 2
2N/A
2N/Atrap trap_exit EXIT
2N/A
2N/Aoptions="FhHnvx:"
2N/Aoptions_repeat=""
2N/Aoptions_seen=""
2N/A
2N/Aopt_F=""
2N/Aopt_n=""
2N/Aopt_v=""
2N/A
2N/A# check for bad or duplicate options
2N/AOPTIND=1
2N/Awhile getopts $options OPT ; do
2N/Acase $OPT in
2N/A x) ;; # zoneadm only
2N/A \? ) uninstall_usage_err ;; # invalid argument
2N/A : ) uninstall_usage_err ;; # argument expected
2N/A * )
2N/A opt=`echo $OPT | sed 's/-\+//'`
2N/A if [ -n "$options_repeat" ]; then
2N/A echo $options_repeat | grep $opt >/dev/null
2N/A [ $? = 0 ] && break
2N/A fi
2N/A ( echo $options_seen | grep $opt >/dev/null ) &&
2N/A uninstall_usage_err
2N/A options_seen="${options_seen}${opt}"
2N/A ;;
2N/Aesac
2N/Adone
2N/A
2N/A# check for a help request
2N/AOPTIND=1
2N/Awhile getopts :$options OPT ; do
2N/Acase $OPT in
2N/A h|H ) uninstall_usage
2N/Aesac
2N/Adone
2N/A
2N/A# process options
2N/AOPTIND=1
2N/Awhile getopts :$options OPT ; do
2N/Acase $OPT in
2N/A F ) opt_F="-F" ;;
2N/A n ) opt_n="-n" ;;
2N/A v ) opt_v="-v" ;;
2N/Aesac
2N/Adone
2N/Ashift `expr $OPTIND - 1`
2N/A
2N/A[ $# -gt 0 ] && uninstall_usage_err
2N/A
2N/A#
2N/A# main
2N/A#
2N/Astart_log zone uninstall "${save_args[@]}"
2N/A
2N/Anop=""
2N/Aif [[ -n "$opt_n" ]]; then
2N/A nop="echo"
2N/A #
2N/A # in '-n' mode we should never return success (since we haven't
2N/A # actually done anything). so override ZONE_SUBPROC_OK here.
2N/A #
2N/A ZONE_SUBPROC_OK=$ZONE_SUBPROC_FATAL
2N/Afi
2N/A
2N/A
2N/Aif [[ -n "$ZONEPATH_DS" ]]; then
2N/A destroy_zone_datasets zone -a
2N/Afi
2N/A
2N/Afinish_log zone
2N/A# Set exit code for trap handler.
2N/AEXIT_CODE=$ZONE_SUBPROC_OK
2N/Aexit $ZONE_SUBPROC_OK