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