#!/bin/ksh
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident	"@(#)mount_metadevices	1.5	01/05/03 SMI"
#
# This script creates and mounts a global filesystem on the metadevice.
# It check to see which metadevice it is resposnsible for making,
#	Invokes the metainit command to create the metadevice.
#	Newfs'es the metadevice
#	And mounts the metadevice.

ifile=/var/cluster/spm/metaset_db

if [[ ! -f $ifile ]]
then
	echo "This node is not responsible for mounting any global filesystems that reside on a metadevice."
else
	# Grab each of the metadevices and process it.
	metadevice_list=$(cat /var/cluster/spm/metadevice_db | awk -F'/' '{print $1}' | uniq)
	for md in $metadevice_list
	do
		# First invoke the metainit command to create the metadevice
		metainit -s $md -a
		# Second, newfs the metadevice
		newfs /dev/md/$md/rdsk/d0 </dev/null
		# Third, activate the mount
		mount /global/$md
	done
fi
