#!/bin/sh
# $Header: vxss_db_paths.sh,v 1.1 2003/09/30 19:04:31 $

#***************************************************************************
#* $VRTScprght: Copyright 1993 - 2005 VERITAS Software Corporation, All Rights Reserved $
#***************************************************************************

at_conf="VRTSat.conf"
az=0
az_conf=""
az_install_dir=""

if [ $# -ne 1 ] ; then
	echo "
USAGE:  ${0} [-at | -az]"
	exit 1
elif [ "${1}" != "-at" -a "${1}" != "-az" ] ; then
	echo "
USAGE:  ${0} [-at | -az]"
	exit 1
elif [ "${1}" = "-az" ] ; then
	az=1
	az_conf="VRTSaz.conf"
	vss_command="\${az_install_dir}/bin/vssaz"
else
	vss_command="\${at_install_dir}/bin/vssat"
fi

#
#  Always need to check for the at conf file and get its install
#  location since az also needs it.  Only check for az if requested.
#

for file in ${at_conf} ${az_conf}
do
	if [ ! -f /etc/vx/vss/${file} ] ; then
		echo "File /etc/vx/vss/${file} is not found."
		exit 1
	fi
done

at_install_dir=`grep InstallDir < /etc/vx/vss/${at_conf} | cut -f4 -d'"'`
if [ ${az} -eq 1 ] ; then
	az_install_dir=`grep InstallDir < /etc/vx/vss/${az_conf} | cut -f4 -d'"'`
fi

for dir in ${at_install_dir} ${az_install_dir}
do
	if [ ! -d ${dir} ] ; then
		echo "Directory ${dir} does not exist."
		exit 1
	fi
done

if eval [ ! -f ${vss_command} ] ; then
	eval echo "File ${vss_command} is not found."
	exit 1
else
	if [ ${az} -eq 1 ] ; then
		eval ${vss_command} login --domain localhost: > /dev/null 2>&1
		stat=$?
		if [ ${stat} -ne 0 ] ; then
			eval echo "${vss_command} login failed."
			exit ${stat}
		fi
	fi
	eval ${vss_command} showbackuplist
fi
