17c478bd9Sstevel@tonic-gate#!/sbin/sh 27c478bd9Sstevel@tonic-gate# 37c478bd9Sstevel@tonic-gate# CDDL HEADER START 47c478bd9Sstevel@tonic-gate# 57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*6185db85Sdougm# Common Development and Distribution License (the "License"). 7*6185db85Sdougm# You may not use this file except in compliance with the License. 87c478bd9Sstevel@tonic-gate# 97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate# and limitations under the License. 137c478bd9Sstevel@tonic-gate# 147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate# 207c478bd9Sstevel@tonic-gate# CDDL HEADER END 217c478bd9Sstevel@tonic-gate# 22*6185db85Sdougm# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 23*6185db85Sdougm# Use is subject to license terms. 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate#ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate# shareall -- share resources 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gateUSAGE="shareall [-F fsys[,fsys...]] [- | file]" 307c478bd9Sstevel@tonic-gatefsys= 317c478bd9Sstevel@tonic-gateset -- `getopt F: $*` 327c478bd9Sstevel@tonic-gateif [ $? != 0 ] # invalid options 337c478bd9Sstevel@tonic-gate then 347c478bd9Sstevel@tonic-gate echo $USAGE >&2 357c478bd9Sstevel@tonic-gate exit 1 367c478bd9Sstevel@tonic-gatefi 377c478bd9Sstevel@tonic-gatefor i in $* # pick up the options 387c478bd9Sstevel@tonic-gatedo 397c478bd9Sstevel@tonic-gate case $i in 407c478bd9Sstevel@tonic-gate -F) fsys=$2; shift 2;; 417c478bd9Sstevel@tonic-gate --) shift; break;; 427c478bd9Sstevel@tonic-gate esac 437c478bd9Sstevel@tonic-gatedone 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gateif [ $# -gt 1 ] # accept only one argument 467c478bd9Sstevel@tonic-gatethen 477c478bd9Sstevel@tonic-gate echo $USAGE >&2 487c478bd9Sstevel@tonic-gate exit 1 497c478bd9Sstevel@tonic-gateelif [ $# = 1 ] 507c478bd9Sstevel@tonic-gatethen 517c478bd9Sstevel@tonic-gate case $1 in 527c478bd9Sstevel@tonic-gate -) infile=;; # use stdin 537c478bd9Sstevel@tonic-gate *) infile=$1;; # use a given source file 547c478bd9Sstevel@tonic-gate esac 557c478bd9Sstevel@tonic-gateelse 567c478bd9Sstevel@tonic-gate infile=/etc/dfs/dfstab # default 577c478bd9Sstevel@tonic-gatefi 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gateif [ "$fsys" ] # for each file system ... 617c478bd9Sstevel@tonic-gatethen 62*6185db85Sdougm if [ "$infile" = "/etc/dfs/dfstab" ] 63*6185db85Sdougm then 64*6185db85Sdougm /usr/sbin/sharemgr start -P $fsys -a 65*6185db85Sdougm else 667c478bd9Sstevel@tonic-gate while read line # get complete lines 677c478bd9Sstevel@tonic-gate do 687c478bd9Sstevel@tonic-gate echo $line 697c478bd9Sstevel@tonic-gate done < $infile | 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate `egrep "^[^#]*[ ][ ]*-F[ ]*(\`echo $fsys|tr ',' '|'\`)" | 727c478bd9Sstevel@tonic-gate /sbin/sh` 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate fsys_file=/etc/dfs/fstypes 757c478bd9Sstevel@tonic-gate if [ -f $fsys_file ] # get default file system type 767c478bd9Sstevel@tonic-gate then 777c478bd9Sstevel@tonic-gate def_fs=`egrep '^[^#]' $fsys_file | awk '{print $1; exit}'` 787c478bd9Sstevel@tonic-gate if [ "$def_fs" = "$fsys" ] # if default is what we want ... 797c478bd9Sstevel@tonic-gate then # for every file system ... 807c478bd9Sstevel@tonic-gate while read line 817c478bd9Sstevel@tonic-gate do 827c478bd9Sstevel@tonic-gate echo $line 837c478bd9Sstevel@tonic-gate done < $infile | 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate # not a comment and no -F option 867c478bd9Sstevel@tonic-gate `egrep -v "(^[#]|-F)" | /sbin/sh` 877c478bd9Sstevel@tonic-gate fi 887c478bd9Sstevel@tonic-gate else 897c478bd9Sstevel@tonic-gate echo "shareall: can't open $fsys_file" 907c478bd9Sstevel@tonic-gate fi 91*6185db85Sdougm fi 927c478bd9Sstevel@tonic-gateelse # for every file system ... 93*6185db85Sdougm if [ "$infile" = "/etc/dfs/dfstab" ] 94*6185db85Sdougm then 95*6185db85Sdougm /usr/sbin/sharemgr start -a 96*6185db85Sdougm else 977c478bd9Sstevel@tonic-gate cat $infile|/sbin/sh 987c478bd9Sstevel@tonic-gate fi 99*6185db85Sdougmfi 100