#!/sbin/sh
#	fs/xfs configuration script
#		checks for XFS filesystem and make sure it is mounted
#
# $Id: CONF,v 1.1 1994/08/03 22:14:54 tin Exp $

PATH=/sbin:$PATH

ENVFILE=/tmp/.envvars

# check to see if an XFS fs is mounted; only grab first one
XFSDEV=`mount | grep xfs | head -1| awk '{print $1;}'`
XFSDIR=`mount | grep xfs | head -1| awk '{print $3;}'`

# if not, grope in /etc/fstab for it
if [ -z "$XFSDEV" ]
then
	XFSDEV=`cat /etc/fstab | grep xfs | head -1 | awk '{print $1;}'`
	XFSDIR=`cat /etc/fstab | grep xfs | head -1 | awk '{print $2;}'`

	if [ -z "$XFSDEV" ]
	then
		# give up; can't do anything without XFS
		exit 1
	fi

	# we _HAVE_ to redirect xlv_assemble output to /dev/null
	# otherwise "bad" things happen... 6/23/94
	xlv_assemble >/dev/null 2>&1 || exit 1
	mount $XFSDIR || (echo Unable to mount $XFSDIR && exit 1)
fi

export XFSDEV XFSDIR

# for now we use a temp shell script to pass these env vars on

[ -f $ENVFILE ] && rm -f $ENVFILE

cat >$ENVFILE <<eof
#!/bin/sh
XFSDEV=$XFSDEV
XFSDIR=$XFSDIR
eof

chmod +x $ENVFILE || exit 1

exit 0
