rpm -q enstore > /dev/null
if [ $? -eq 0 ]; then 
	ENSTORE_DIR=`rpm -ql enstore | head -1`
else
	ENSTORE_DIR=`rpm -ql enstore_sa | head -1`
fi

PYTHON_DIR=`rpm -ql Python-enstore2.6 | 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
#. $ENSTORE_DIR/sbin/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

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 
	rm -f  $ENSTORE_DIR/bin/encp;
	ln -s $ENSTORE_DIR/src/encp.py $ENSTORE_DIR/bin/encp;
fi
if [ ! -r $ENSTORE_DIR/bin/enstore ]; then 
	rm -f $ENSTORE_DIR/bin/enstore;
	ln -s $ENSTORE_DIR/src/enstore_admin.py $ENSTORE_DIR/bin/enstore; 
fi

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