#!/bin/sh
#
# Copyright (c) 2002 Red Hat, Inc. All rights reserved.
#
# This software may be freely redistributed under the terms of the
# GNU General Public License.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Component of: Red Hat Database Administrator
#
# Simple wrapper for rhdb-admin
#
# Authors: Liam Stewart <liams@redhat.com> & Neil Padgett <npadgett@redhat.com>

cmd=./rhdb-admin.tcl
workdir=/usr/share/rhdb-admin
logfile=/dev/null
logstdout=no

while getopts ":l:" option
do
	case $option in
		l)
			if [ "$OPTARG" = "-" ];
			then
				logstdout=yes
			else
				logfile=`python -c "from os.path import abspath; print abspath(\"$OPTARG\")"`
			fi
			;;
		*)
			echo "Invalid option: -$OPTARG"
			exit 1
			;;
	esac
done

pushd ${workdir} > /dev/null

if [ "$logstdout" = "yes" ];
then
	${cmd} 2>&1
else
	${cmd} > ${logfile} 2>&1
fi

popd > /dev/null
