#
# $Id: functions 2937 2012-05-30 18:17:09Z rdempsey $
#

prefix=/usr/local

USER=`whoami 2>/dev/null`

if [ $USER != "root" ]; then
	prefix=$HOME
fi

if [ $USER != "root" ]; then
	if [ -f $prefix/.bash_profile ]; then		
		profileFile=$prefix/.bash_profile
	elif [ -f $prefix/.profile ]; then		
		profileFile=$prefix/.profile
	else
		profileFile=$prefix/.bashrc
	fi
		
	. $profileFile
fi

# Source function library.
if [ -f /etc/init.d/functions ]; then
	. /etc/init.d/functions
fi

if [ -z "$COLUMNSTORE_INSTALL_DIR" ]; then
	COLUMNSTORE_INSTALL_DIR=/usr/local/mariadb/columnstore
fi

export COLUMNSTORE_INSTALL_DIR=$COLUMNSTORE_INSTALL_DIR

PATH=$COLUMNSTORE_INSTALL_DIR/bin:$PATH
export PATH

module_type()
{
(
	sed -r 's/[0-9]+$//' $COLUMNSTORE_INSTALL_DIR/local/module
) 2>/dev/null
}

firstboot()
{
	dbrmroot="`getConfig SystemConfig DBRMRoot`"
	dbrmdir="`dirname $dbrmroot`"
	test ! -f $dbrmdir/BRM_saves_current
}

oidbitmapfile()
{
	oidfile="`getConfig OIDManager OIDBitmapFile`"
	test ! -f $oidfile
}

module_name()
{
(
	cat $COLUMNSTORE_INSTALL_DIR/local/module
) 2>/dev/null
}

module_id()
{
(
	sed -r 's/[a-zA-Z]//g' $COLUMNSTORE_INSTALL_DIR/local/module
) 2>/dev/null
}
