# source this file to set enstore environment

ENSTORE_DIR=`rpm -ql enstore | head -1`
PYTHON_DIR=`rpm -ql Python-enstore | head -1`
FTT_DIR=`rpm -ql ftt | head -1`
ENSTORE_HOME=/home/enstore
ENSTORE_OUT=/var/log/enstore

export ENSTORE_DIR
export PYTHON_DIR
export FTT_DIR
export ENSTORE_HOME
export ENSTORE_OUT

rpm -q swig-enstore > /dev/null
if [ $? -eq 0 ]; then
	SWIG_DIR=`rpm -ql swig-enstore | head -1`
	export SWIG_DIR
	export SWIG_LIB=$SWIG_DIR/swig_lib
	PATH=$SWIG_DIR:$PATH
fi

rpm -q aci > /dev/null
if [ $? -eq 0 ];
then
    ACI_DIR=`rpm -ql aci | head -1`
    export ACI_DIR
    PATH=$ACI_DIR/admin:$PATH
    export DAS_SERVER="192.168.89.56"
    export DAS_CLIENT=`hostname -s`p
fi


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`
        PATH=$PATH:$PNFS_DIR/tools
        export PNFS_DIR
fi

CVSROOT=hppccvs@cdcvs.fnal.gov:/cvs/hppc; export CVSROOT
unset CVS_RSH 2>//dev/null;

PYTHONINC=`ls -d $PYTHON_DIR/include/python*`; export PYTHONINC
PYTHONLIB=`ls -d $PYTHON_DIR/lib/python*`;export PYTHONLIB
PATH=$PYTHON_DIR/bin:$PATH
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

if [ ! -r $ENSTORE_DIR/bin/encp ]; then ln -s $ENSTORE_DIR/src/encp.py $ENSTORE_DIR/bin/encp;fi
if [ ! -r $ENSTORE_DIR/bin/enstore ]; then ln -s $ENSTORE_DIR/src/enstore_admin.py $ENSTORE_DIR/bin/enstore; fi

if [ ! -r $ENSTORE_DIR/bin/enmv ];          then ln -s $ENSTORE_DIR/src/enmv.py   $ENSTORE_DIR/bin/enmv; fi
if [ ! -r $ENSTORE_DIR/sbin/enstoreCut ];      then ln -s $ENSTORE_DIR/sbin/encpCut           $ENSTORE_DIR/sbin/enstoreCut; fi
if [ ! -r $ENSTORE_DIR/sbin/enstore_up_down ]; then ln -s $ENSTORE_DIR/src/enstore_up_down.py $ENSTORE_DIR/sbin/enstore_up_down; fi
if [ ! -r $ENSTORE_DIR/sbin/enmonitor ];       then ln -s $ENSTORE_DIR/src/monitor_client.py  $ENSTORE_DIR/sbin/enmonitor; fi
if [ ! -r $ENSTORE_DIR/bin/pnfs ];             then ln -s $ENSTORE_DIR/src/pnfs.py            $ENSTORE_DIR/bin/pnfs; fi
if [ ! -r $ENSTORE_DIR/bin/entv ];             then ln -s $ENSTORE_DIR/src/entv.py            $ENSTORE_DIR/bin/entv; fi
if [ ! -r $ENSTORE_DIR/bin/volume_assert ];    then ln -s $ENSTORE_DIR/src/volume_assert.py   $ENSTORE_DIR/bin/volume_assert; fi
if [ ! -r $ENSTORE_DIR/bin/ensync ];	       then ln -s $ENSTORE_DIR/src/ensync.py   $ENSTORE_DIR/bin/ensync; fi
if [ ! -r $ENSTORE_DIR/bin/get ];	       then ln -s $ENSTORE_DIR/src/get.py   $ENSTORE_DIR/bin/get; fi
if [ ! -r $ENSTORE_DIR/sbin/quickquota ];      then ln -s $ENSTORE_DIR/src/quickquota.py   $ENSTORE_DIR/sbin/quickquota; fi
if [ ! -r $ENSTORE_DIR/bin/migrate ];          then ln -s $ENSTORE_DIR/src/gmigrate.py   $ENSTORE_DIR/bin/migrate; fi
if [ ! -r $ENSTORE_DIR/bin/duplicate ];        then ln -s $ENSTORE_DIR/src/duplicate.py   $ENSTORE_DIR/bin/duplicate; fi
###
### Enstore server links.
###
if [ ! -r $ENSTORE_DIR/sbin/configuration_server ]; then ln -s $ENSTORE_DIR/src/configuration_server.py $ENSTORE_DIR/sbin/configuration_server; fi
if [ ! -r $ENSTORE_DIR/sbin/log_server ];  then ln -s $ENSTORE_DIR/src/log_server.py   $ENSTORE_DIR/sbin/log_server; fi
if [ ! -r $ENSTORE_DIR/sbin/alarm_server ]; then ln -s $ENSTORE_DIR/src/alarm_server.py   $ENSTORE_DIR/sbin/alarm_server; fi
if [ ! -r $ENSTORE_DIR/sbin/inquisitor ]; then ln -s $ENSTORE_DIR/src/inquisitor.py   $ENSTORE_DIR/sbin/inquisitor; fi
if [ ! -r $ENSTORE_DIR/sbin/ratekeeper ]; then ln -s $ENSTORE_DIR/src/ratekeeper.py   $ENSTORE_DIR/sbin/ratekeeper; fi
if [ ! -r $ENSTORE_DIR/sbin/event_relay ]; then ln -s $ENSTORE_DIR/src/event_relay.py   $ENSTORE_DIR/sbin/event_relay; fi
if [ ! -r $ENSTORE_DIR/sbin/info_server ]; then ln -s $ENSTORE_DIR/src/info_server.py   $ENSTORE_DIR/sbin/info_server; fi
if [ ! -r $ENSTORE_DIR/sbin/file_clerk ]; then ln -s $ENSTORE_DIR/src/file_clerk.py   $ENSTORE_DIR/sbin/file_clerk; fi
if [ ! -r $ENSTORE_DIR/sbin/volume_clerk ]; then ln -s $ENSTORE_DIR/src/volume_clerk.py   $ENSTORE_DIR/sbin/volume_clerk; fi
if [ ! -r $ENSTORE_DIR/sbin/accounting_server ]; then ln -s $ENSTORE_DIR/src/accounting_server.py   $ENSTORE_DIR/sbin/accounting_server; fi
if [ ! -r $ENSTORE_DIR/sbin/drivestat_server ]; then ln -s $ENSTORE_DIR/src/drivestat_server.py   $ENSTORE_DIR/sbin/drivestat_server; fi
if [ ! -r $ENSTORE_DIR/sbin/library_manager ];  then ln -s $ENSTORE_DIR/src/library_manager.py   $ENSTORE_DIR/sbin/library_manager; fi
if [ ! -r $ENSTORE_DIR/sbin/media_changer ];      then ln -s $ENSTORE_DIR/src/media_changer.py   $ENSTORE_DIR/sbin/media_changer; fi
if [ ! -r $ENSTORE_DIR/sbin/mover ];      then ln -s $ENSTORE_DIR/src/mover.py   $ENSTORE_DIR/sbin/mover; fi
if [ ! -r $ENSTORE_DIR/sbin/monitor_server ]; then ln -s $ENSTORE_DIR/src/monitor_server.py   $ENSTORE_DIR/sbin/monitor_server; fi

export ENSTORE_CONFIG_HOST=`$ENSTORE_DIR/ups/chooseConfig`
export ENSTORE_CONFIG_PORT=7500
export ENSTORE_CONFIG_FILE=$ENSTORE_DIR/etc/`$ENSTORE_DIR/ups/chooseConfig file`
export ENSTORE_MAIL=`$ENSTORE_DIR/ups/chooseConfig mail`
export FARMLETS_DIR=/usr/local/etc/farmlets
