1*f875b4ebSrica#!/sbin/sh 2*f875b4ebSrica# 3*f875b4ebSrica# CDDL HEADER START 4*f875b4ebSrica# 5*f875b4ebSrica# The contents of this file are subject to the terms of the 6*f875b4ebSrica# Common Development and Distribution License (the "License"). 7*f875b4ebSrica# You may not use this file except in compliance with the License. 8*f875b4ebSrica# 9*f875b4ebSrica# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*f875b4ebSrica# or http://www.opensolaris.org/os/licensing. 11*f875b4ebSrica# See the License for the specific language governing permissions 12*f875b4ebSrica# and limitations under the License. 13*f875b4ebSrica# 14*f875b4ebSrica# When distributing Covered Code, include this CDDL HEADER in each 15*f875b4ebSrica# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*f875b4ebSrica# If applicable, add the following below this CDDL HEADER, with the 17*f875b4ebSrica# fields enclosed by brackets "[]" replaced with your own identifying 18*f875b4ebSrica# information: Portions Copyright [yyyy] [name of copyright owner] 19*f875b4ebSrica# 20*f875b4ebSrica# CDDL HEADER END 21*f875b4ebSrica# 22*f875b4ebSrica# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23*f875b4ebSrica# Use is subject to license terms. 24*f875b4ebSrica# 25*f875b4ebSrica#ident "%Z%%M% %I% %E% SMI" 26*f875b4ebSrica# 27*f875b4ebSrica# zoneunshare -- unshare zone resources 28*f875b4ebSrica 29*f875b4ebSrica# Processes the specified sharetab file and unshare 30*f875b4ebSrica# all entries shared by the specfied zone 31*f875b4ebSrica 32*f875b4ebSricaUSAGE="zoneunshare -z zonename [- | file]" 33*f875b4ebSricaset -- `getopt z: $*` 34*f875b4ebSricaif [ $? != 0 ] # invalid options 35*f875b4ebSrica then 36*f875b4ebSrica echo $USAGE >&2 37*f875b4ebSrica exit 1 38*f875b4ebSricafi 39*f875b4ebSricafor i in $* # pick up the options 40*f875b4ebSricado 41*f875b4ebSrica case $i in 42*f875b4ebSrica -z) zonename=$2; shift 2;; 43*f875b4ebSrica --) shift; break;; 44*f875b4ebSrica esac 45*f875b4ebSricadone 46*f875b4ebSrica 47*f875b4ebSricazoneattr=`/usr/sbin/zoneadm -z $zonename list -p 2> /dev/null` 48*f875b4ebSricaif [ $? -ne 0 ] # invalid zone 49*f875b4ebSrica then 50*f875b4ebSrica echo $USAGE >&2 51*f875b4ebSrica exit 1 52*f875b4ebSricafi 53*f875b4ebSrica 54*f875b4ebSricaprefix=`echo $zoneattr | cut -d ":" -f4` 55*f875b4ebSricarootpath=$prefix/root 56*f875b4ebSrica 57*f875b4ebSricaif [ $# -gt 1 ] # accept only one argument 58*f875b4ebSricathen 59*f875b4ebSrica echo $USAGE >&2 60*f875b4ebSrica exit 1 61*f875b4ebSricaelif [ $# = 1 ] 62*f875b4ebSricathen 63*f875b4ebSrica case $1 in 64*f875b4ebSrica -) infile=;; # use stdin 65*f875b4ebSrica *) infile=$1;; # use a given source file 66*f875b4ebSrica esac 67*f875b4ebSricaelse 68*f875b4ebSrica infile=/etc/dfs/sharetab # default 69*f875b4ebSricafi 70*f875b4ebSrica 71*f875b4ebSrica# Run unshare for each resource in its own shell 72*f875b4ebSrica 73*f875b4ebSricawhile read line # get complete lines 74*f875b4ebSricado 75*f875b4ebSrica echo $line 76*f875b4ebSricadone < $infile | 77*f875b4ebSrica `egrep "^$rootpath"|nawk '{ print "/usr/sbin/unshare " $1 ";" }'|/sbin/sh` 78