#!/bin/ksh
#
# Component: tools
#
# Description:
#  Control script of component tools
#
# Last Updated     : $Author$
# Update Date Time : $Date$
# RCS File Name    : $RCSfile$
# RCS Revision     : $Revision$
# Locked by        : $Locker$
# Symbolic name    : $Name$
# State            : $State$

#--- INIT ------------------------------
#needs $HOME
. $HOME/etc/ctrl.main.shi

[ -f $HOME/etc/setenv.sh ] && . $HOME/etc/setenv.sh

#--- FUNC ------------------------------
do_shell_()
{
	cat <<-EndOfInlineData
		TOOLS_HOME=$HOME/component/tools
	EndOfInlineData

} #do_shell_()

do_start_()
{
	# check if tools/cfg/bashrc is included to .bashrc
	if ! grep -q "${TOOLS_HOME}/cfg/bashrc" $HOME/.bashrc ; then
		cat <<-EOFBASHRC >> $HOME/.bashrc


			# Include eRAD PACS server related settings
			[ -f "${TOOLS_HOME}/cfg/bashrc" ] && . "${TOOLS_HOME}/cfg/bashrc"
		EOFBASHRC
	fi


	if [ ! -e ${TOOLS_HOME}/mysqltuner.sh -a -f ${MYSQL_HOME}/tools/mysqltuner.sh ] ; then
		ln -s ${MYSQL_HOME}/tools/mysqltuner.sh ${TOOLS_HOME}/mysqltuner.sh
	fi
}

#--- MAIN ------------------------------

check_action_ $1
if [ 0 = $? ]; then
	do_$1_

else
	echo "--- Component tools [ctrl $$]: Bad command: $1" >&2
	exit 1

fi
