8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / fs.d / nfs / exportfs / exportfs.sh
blob321ceb13e0688ba41051dab998f9067078acf4f7
1 #!/sbin/sh
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
23 # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
24 # All Rights Reserved
27 #ident "%Z%%M% %I% %E% SMI"
28 #!/bin/sh
30 # exportfs: compatibility script for SunOs command.
33 USAGE="Usage: exportfs [-aviu] [-o options] directory"
34 DFSTAB=/etc/dfs/dfstab
35 OPTS="rw"
38 # Translate from exportfs opts to share opts
41 fixopts() {
42 IFS=, ; set - $OPTS ; IFS=" "
43 for i
44 do case $i in *access=* ) eval $i ;; esac ; done
45 if [ ! "$access" ] ; then return ; fi
47 OPTS=""
48 for i
50 case $i in
51 rw=* ) OPTS="$OPTS$i," ;;
52 ro | rw ) OPTS="${OPTS}$i=$access," ; ropt="true" ;;
53 access=* ) ;;
54 * ) OPTS="$OPTS$i," ;;
55 esac
56 done
57 if [ ! "$ropt" ] ; then OPTS="ro=$access,$OPTS" ; fi
58 OPTS=`echo $OPTS | sed 's/,$//'`
61 bad() {
62 echo $USAGE >&2
63 exit 1
66 PATH=/usr/sbin:/usr/bin:$PATH
67 export PATH
69 if set -- `getopt aviuo: $*` ; then : ; else bad ; fi
71 for i in $*
73 case $i in
74 -a ) aflg="true" ; shift ;; # share all nfs
75 -v ) vflg="true" ; shift ;; # verbose
76 -i ) iflg="true" ; shift ;; # ignore dfstab opts
77 -u ) uflg="true" ; shift ;; # unshare
78 -o ) oflg="true" ; OPTS=$2 ; shift 2 ;; # option string
79 -- ) shift ; break ;;
80 esac
81 done
83 if [ $aflg ] ; then
84 if [ "$DIR" -o "$iflg" -o "$oflg" ] ; then bad ; fi
85 if [ $uflg ] ; then
86 if [ $vflg ] ; then echo unshareall -F nfs ; fi
87 /usr/sbin/unshareall -F nfs
88 else
89 if [ $vflg ] ; then echo shareall -F nfs ; fi
90 /usr/sbin/shareall -F nfs
92 exit $?
95 case $# in
96 0 ) if [ "$iflg" -o "$uflg" -o "$oflg" ] ; then bad ; fi
97 if [ "$vflg" ] ; then echo share -F nfs ; fi
98 /usr/sbin/share -F nfs
99 exit $? ;;
101 1 ) DIR=$1 ;;
102 * ) bad ;;
103 esac
105 if [ $uflg ] ; then
106 if [ "$iflg" -o "$oflg" ] ; then bad ; fi
107 if [ $vflg ] ; then echo unshare -F nfs $DIR ; fi
108 /usr/sbin/unshare -F nfs $DIR
109 exit $?
112 if [ $iflg ] ; then
113 fixopts
114 if [ $vflg ] ; then echo share -F nfs -o $OPTS $DIR ; fi
115 /usr/sbin/share -F nfs -o $OPTS $DIR
116 else
117 CMD=`grep $DIR'[ ]*$' $DFSTAB`
118 if [ "$CMD" = "" ] ; then
119 echo "exportfs: no entry for $DIR in $DFSTAB" >&2
120 exit 1
122 if [ $oflg ] ; then
123 echo "exportfs: supplied options ignored" >&2
124 vflg="true"
126 if [ $vflg ] ; then echo $CMD ; fi
127 eval $CMD
129 exit $?