#! /bin/bash
################################################################################
# Filename: ./src/base/sbin/qrm-admin
# 
# The contents of this file are subject to the Qlusters Public License
# Version 1.1 (the License); you may not use this file except in compliance
# with the License.
# You may obtain a copy of the License at
# http://www.openqrm.org/content/view/33/69/.
# 
# Software distributed under the License is distributed on an AS IS basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
# the specific language governing rights and limitations under the License.
# 
# The Original Code is openQRM.
# 
# The Initial Developer of the Original Code is Qlusters Corporation. Portions
# created by Qlusters Corporation are Copyright (C) 2003-2005. All Rights
# Reserved.
# 
# Contributor(s):
# 
# Description:
# 
# Comments:
################################################################################

BASE_DIR=`dirname $0`
export QRM_SERVER_BASE_DIR=${QRM_SERVER_BASE_DIR:-`pushd $BASE_DIR/../.. > /dev/null; echo $PWD; popd > /dev/null`}
. $QRM_SERVER_BASE_DIR/qrm/include/qrm-functions
. $QRM_SERVER_BASE_DIR/qrm/include/qrm-server-functions
ADMIN_SCRIPTS_DIR=${BASE_DIR}/admin


function usage() {
	local rc=$1
	shift

	echo "Available commands: "
	ls --indicator-style=none ${ADMIN_SCRIPTS_DIR}
	exit $rc
}


COMMAND=$1
shift

if [ -z "$COMMAND" ]; then 
	usage 0
fi

case $COMMAND in
	-h|--help)
		usage 0
		;;
	*)
		if [ -f ${ADMIN_SCRIPTS_DIR}/${COMMAND} ]; then
			${ADMIN_SCRIPTS_DIR}/${COMMAND} "$@"
		else 
			echo "Command ${COMMAND} not found" 1>&2
			usage 1
		fi
esac

