Print this page
XXX Remove nawk(1)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/tsol/zones/zoneshare.sh
+++ new/usr/src/cmd/tsol/zones/zoneshare.sh
1 1 #!/sbin/sh
2 2 #
3 3 # CDDL HEADER START
4 4 #
5 5 # The contents of this file are subject to the terms of the
6 6 # Common Development and Distribution License (the "License").
7 7 # You may not use this file except in compliance with the License.
8 8 #
9 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 # or http://www.opensolaris.org/os/licensing.
11 11 # See the License for the specific language governing permissions
12 12 # and limitations under the License.
13 13 #
14 14 # When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 # If applicable, add the following below this CDDL HEADER, with the
17 17 # fields enclosed by brackets "[]" replaced with your own identifying
18 18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 19 #
20 20 # CDDL HEADER END
21 21 #
22 22 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 23 # Use is subject to license terms.
24 24 #
25 -#ident "%Z%%M% %I% %E% SMI"
26 -#
27 25 # zoneshare -- share zone resources
28 26
29 27 # Processes a non-global zone's dfstab file after translating
30 28 # its zone-relative pathnames to global zone pathnames
31 29
32 30 USAGE="zoneshare -z zonename [- | file]"
33 31 set -- `getopt z: $*`
34 32 if [ $? != 0 ] # invalid options
35 33 then
36 34 echo $USAGE >&2
37 35 exit 1
38 36 fi
39 37 for i in $* # pick up the options
40 38 do
41 39 case $i in
42 40 -z) zonename=$2; shift 2;;
43 41 --) shift; break;;
44 42 esac
45 43 done
46 44
47 45 zoneattr=`/usr/sbin/zoneadm -z $zonename list -p 2> /dev/null`
48 46 if [ $? -ne 0 ] # invalid zone
49 47 then
50 48 echo $USAGE >&2
51 49 exit 1
52 50 fi
53 51
54 52 prefix=`echo $zoneattr | cut -d ":" -f4`
55 53 rootpath=$prefix/root
56 54
57 55 if [ $# -gt 1 ] # accept only one argument
58 56 then
59 57 echo $USAGE >&2
60 58 exit 1
61 59 elif [ $# = 1 ]
62 60 then
63 61 case $1 in
64 62 -) infile=;; # use stdin
65 63 *) infile=$1;; # use a given source file
66 64 esac
67 65 else
68 66 infile=$prefix/etc/dfs/dfstab # default
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
69 67 fi
70 68
71 69 # Prepend each exported pathname with the zone's rootpath
72 70 # Skip over comments and lines without a share command
73 71 # Run each share command in its own shell
74 72
75 73 while read line # get complete lines
76 74 do
77 75 echo $line
78 76 done < $infile |
79 - `egrep -v "(^[#])" | nawk -v rootpath=$rootpath \
77 + `egrep -v "(^[#])" | /usr/xpg4/bin/awk -v rootpath=$rootpath \
80 78 '/share/ { ORS = " "; for (i = 1; i < NF; i++) print $i ; \
81 79 print rootpath $NF ";" } ' | /sbin/sh`
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX