# source this file to set enstore environment
rpm -q enstore > /dev/null
if [ $? -eq 0 ]; then 
	ENSTORE_DIR=`rpm -ql enstore | head -1`
else
	echo "Enstore is not installed"
	exit 1
fi

PYTHON_DIR=$ENSTORE_DIR/Python
FTT_DIR=$ENSTORE_DIR/FTT
ENSTORE_HOME=/home/enstore
ENSTORE_OUT=/var/log/enstore

export ENSTORE_DIR
export PYTHON_DIR
export FTT_DIR
export ENSTORE_HOME
export ENSTORE_OUT
SWIG_DIR=$ENSTORE_DIR/SWIG
export SWIG_DIR
export SWIG_LIB=$SWIG_DIR/swig_lib
export QPID_DIR=$ENSTORE_DIR/qpid

# build PATH

# add directory to path only once thus this file can be sourced multiple times
pathmunge () { 
         if ! [[ $PATH =~ (^|:)$1($|:) ]] ; then 
             if [ "$2" = "after" ] ; then
                PATH=$PATH:$1;
             else
                PATH=$1:$PATH;
             fi
         fi
}

pathmunge $SWIG_DIR
pathmunge $QPID_DIR/bin
pathmunge $ENSTORE_DIR/tools
pathmunge $ENSTORE_DIR/bin
pathmunge $ENSTORE_DIR/sbin


PATH=$SWIG_DIR:$PATH

PATH=$ENSTORE_DIR/sbin:$ENSTORE_DIR/bin:$ENSTORE_DIR/tools:$PATH
rpm -q pnfs > /dev/null
if [ $? -eq 0 ]; then
        p_d=`rpm -ql pnfs | grep bin | head -1`
        PNFS_DIR=`dirname $p_d`
	pathmunge $PNFS_DIR/tools after
        export PNFS_DIR
fi

pathmunge $PYTHON_DIR/bin
# end build path

#unset CVS_RSH 2>/dev/null; # this is needed for PIC

PYTHONINC=`ls -d $PYTHON_DIR/include/python*`; export PYTHONINC
PYTHONLIB=`ls -d $PYTHON_DIR/lib/python*`;export PYTHONLIB
PYTHONPATH=$ENSTORE_DIR:$ENSTORE_DIR/src:$ENSTORE_DIR/modules:$ENSTORE_DIR/HTMLgen:$ENSTORE_DIR/PyGreSQL; export PYTHONPATH
PYTHONUNBUFFERED="x"; export PYTHONUNBUFFERED

# if using ssh for enstore node communications for discribution, upgade, and maintenance 
# uncomment the following lines
#export ENSSH=/usr/bin/ssh
#export ENSCP=/usr/bin/scp


GADFLY_GRAMMAR=$ENSTORE_DIR/gadfly; export GADFLY_GRAMMAR

$ENSTORE_DIR/external_distr/update_sym_links.sh -c


# if using ssh for enstore node communications for discribution, upgade, and maintenance 
# uncomment the following lines
#export ENSSH=/usr/bin/ssh
#export ENSCP=/usr/bin/scp


export ENSTORE_CONFIG_HOST=`$ENSTORE_DIR/ups/chooseConfig` # put config host name here
export ENSTORE_CONFIG_PORT=7500
export ENSTORE_CONFIG_FILE=$ENSTORE_DIR/etc/`$ENSTORE_DIR/ups/chooseConfig file` # put config file path here
export ENSTORE_MAIL=`$ENSTORE_DIR/ups/chooseConfig mail` # put enstore admin mail address here
export FARMLETS_DIR=/usr/local/etc/farmlets
