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
  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         RUN_CHECK mkdir -p $SHRDIR || exit 1
  53 
  54         # Check fs type on the server
  55         RUN_CHECK get_fstype $SHRDIR || exit 1 
  56 
  57         # share it
  58         RUN_CHECK sharemgr_share $SHRGRP $SHRDIR $SHROPT || exit 1
  59 
  60         RUN_CHECK chmod 777 $SHRDIR || exit 1
  61         ;;
  62 c)
  63         RUN_CHECK sharemgr_unshare $SHRGRP $SHRDIR || exit 1
  64         RUN_CHECK rm -rf $SHRDIR || exit 1
  65         ;;
  66 \?) 
  67         echo $Usage
  68         exit 99
  69         ;;
  70 esac
  71 
  72 exit 0