1 #! /usr/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 DIR=$(dirname $0)
29 NAME=$(basename $0)
30
31 Usage="Usage: $NAME -s | -c \n
32 -s: to setup the server\n
33 -c: to cleanup the server\n
34 "
35 if (( $# < 1 )); then
36 echo $Usage
37 exit 99
38 fi
39
40 # Include common STC utility functions for SMF
41 . ${DIR}/srv_env.vars
42 . ${DIR}/nfs-util.kshlib
43
44 # Turn on debug info, if requested
45 export _NFS_STF_DEBUG=$_NFS_STF_DEBUG:$NFSGEN_DEBUG
46 [[ :$NFSGEN_DEBUG: = *:${NAME}:* || :${NFSGEN_DEBUG}: = *:all:* ]] \
47 && set -x
48
49 getopts sc opt
50 case $opt in
51 s)
52 # Create test group
53 groupdel $TGROUP >/dev/null 2>&1
54 RUN_CHECK groupadd -g $TGID $TGROUP || exit 1
55 # Create test user
56 userdel $TUSER01 >/dev/null 2>&1
57 RUN_CHECK useradd -u $TUID01 -g $TGROUP -d /tmp $TUSER01 || exit 1
58 userdel $TUSER02 >/dev/null 2>&1
59 RUN_CHECK useradd -u $TUID02 -g $TGROUP -d /tmp $TUSER02 || exit 1
60
61 # Set mapid domain
62 set_nfs_property NFSMAPID_DOMAIN $NFSMAPID_DOMAIN $DIR/mapid_backup \
63 || exit 1
64 # Set delegation
65 set_nfs_property NFS_SERVER_DELEGATION on $DIR/deleg_backup \
66 || exit 1
67 ;;
68 c)
69 # Delete test user and group
70 RUN_CHECK userdel $TUSER01 || exit 1
71 RUN_CHECK userdel $TUSER02 || exit 1
72 RUN_CHECK groupdel $TGROUP || exit 1
73
74 # Restore mapid domain
75 restore_nfs_property NFSMAPID_DOMAIN $DIR/mapid_backup || exit 1
76 # Restore delegation
77 restore_nfs_property NFS_SERVER_DELEGATION $DIR/deleg_backup || exit 1
78 ;;
79 \?)
80 echo $Usage
81 exit 99
82 ;;
83 esac
84
85 exit 0