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