#
#	browserEnvironment.txt
#
#	example UCSC genome mirror site definition file
#
#	copy this entire product/scripts/ directory to some directory outside
#	of the kent source tree.  Edit this browserEnvironment.txt file
#	for your local site.  This file is used as an argument to the scripts 
#	for building the source tree and fetching /gbdb/ and goldenPath/ files
#	from UCSC and loading database tables.
#

set +u 

# MACHTYPE needs to be a simple string such as: i386 or ppc or x86_64
# see what your uname -m produces, make sure it has no - characters
export MACHTYPE=`uname -m`
#	KENTHOME - directory where you want the kent source tree and built
#	binaries to exist.  This is typically your $HOME/ directory
export KENTHOME="/root"
# Set KENTBIN to a directory where you want the results of the kent
#	source tree build.  *NOTE* This will also require a symlink
#	in your HOME directory: $HOME/bin/$MACHTYPE -> $KENTBIN/$MACHTYPE
#	as the source tree often places resulting binaries in
#	$HOME/bin/$MACHTYPE despite this directive (this deficiency
#		to be corrected in later versions of the source tree)
export KENTBIN="${KENTHOME}/bin"
export BINDIR="${KENTBIN}/$MACHTYPE"
# This SCRIPTS is a directory where scripts from the kent source tree build
#	will be placed
export SCRIPTS="${KENTHOME}/browserLogs/scripts"
#	kentSrc - location where you want your master kent source tree to live
export kentSrc="${KENTHOME}/kent"
#	LOGDIR - location to keep log files of script activities:
export LOGDIR="${KENTHOME}/browserLogs"
# GBDB - You will need a symlink /gbdb -> to this directory with gbdb downloads
export GBDB="/gbdb"
# BROWSERHOME - directory where cgi-bin/ trash/ and htdocs/ should exist
#   This is typically something like /var/www or /usr/local/apache
export BROWSERHOME="/usr/local/apache"
# DOCUMENTROOT - location of top level htdocs for downloading UCSC static html
#	file hierarchy
export DOCUMENTROOT="${BROWSERHOME}/htdocs"
#	GOLD - where to download goldenPath/database/ directories
export GOLD="${DOCUMENTROOT}/goldenPath"
#	TRASHDIR - the full path to your "trash" directory
#	*BEWARE* this TRASHDIR specification is used by the trashCleaner.sh
#	script to remove files in this directory.  It needs to be correct.
#	It must be an absolute path starting with / and it must end in /trash
export TRASHDIR="/data/trash"
#       USERDATA - location where the trash cleaner scripts move files to
#         from TRASHDIR/ct/ to save custom track data associated with
#         saved sessions
export USERDATA="${BROWSERHOME}/userdata"
# cgi-bin/ must be in the same directory as htdocs/ and trash/
export CGI_BIN="${BROWSERHOME}/cgi-bin"
# Adding these to your path will enable finding all the kent commands
export PATH="$KENTBIN/$MACHTYPE:$KENTBIN/:$PATH"
# where to find the hgsql command for database operations
export HGSQL="$KENTBIN/$MACHTYPE/hgsql"
# You will need to find out where your MySQL libs are.
#	see notes in: README.building.source about finding them
export MYSQLLIBS="/usr/lib64/mysql/libmysqlclient.a -lz"
export MYSQLINC="/usr/include/mysql"
# If your mysql is SSL enabled, use the -lssl:
# export MYSQLLIBS="/usr/lib64/mysql/libmysqlclient.a -lssl -lz"

# You may need to specify the location of your png library if
#	it is not in any of: /usr/lib/libpng.a /usr/lib64/libpng.a
#	and your compiler can't find it when specified as: -lpng
# export PNGLIB="/opt/local/lib/libpng.a"
# export PNGINCL"-I/opt/local/include/libpng12"

# Optional support of the BAM file format, see also:
#	http://genomewiki.ucsc.edu/index.php/Build_Environment_Variables
#	You will need to install the samtools library from
#	http://sourceforge.net/projects/samtools/files/samtools/
# export USE_BAM=1
# export KNETFILE_HOOKS=1
# export SAMDIR=${BROWSERHOME}/samtools-0.1.11
# export SAMINC=${SAMDIR}
# export SAMLIB=${SAMDIR}/libbam.a
# Optional support of the tabix compression and binary index format
#	(required for support of the VCF file format),
#	analogous to configuration of samtools above, see;
#	http://genomewiki.ucsc.edu/index.php/Build_Environment_Variables
#	You will need to install the tabix library from
#	http://sourceforge.net/projects/samtools/files/tabix/
# export USE_TABIX=1
# export KNETFILE_HOOKS=1
# export TABIXDIR=${BROWSERHOME}/tabix-0.2.3
# export TABIXINC=${TABIXDIR}
# export TABIXLIB=${TABIXDIR}/libtabix.a

export ENCODE_PIPELINE_BIN="${BINDIR}"
# protect these scripts by specifying the single machine on which they
#	should run and the single user name which should be running them.
# for the AUTH_MACHINE you may need to see what uname -n says
export AUTH_MACHINE="browserbox"
export AUTH_USER="root"

########################################################################
# probably no changes needed with these variables, they are just convenient
# global variables for all the scripts
#       rsync command used to fetch from hgdownload.soe.ucsc.edu
#	Note the explicit arguments for mirroring in an attempt to work-around
#	the UCSC permissions on directories and files which are not
#	consistent for 'group' rwx permissions.
export RSYNC="rsync -rltgoD"
#	rsync location at UCSC to fetch files, select one of these two servers:
export HGDOWNLOAD="rsync://hgdownload.soe.ucsc.edu"
#	alternate rsync location at UCSC to fetch files
#  export HGDOWNLOAD="rsync://hgdownload-sd.soe.ucsc.edu"
#
#   END OF CONFIGURATION VARIABLES
########################################################################

#	verify this machine and user are correct
export MACHINE_NAME=`uname -n | sed -e 's/\..*//'`
if [ "X${AUTH_MACHINE}Y" != "X${MACHINE_NAME}Y" ]; then
    echo "ERROR: must be run on ${AUTH_MACHINE}, this machine is: ${MACHINE_NAME}"
    exit 255;
fi

if [ -z "${LOGNAME}" ]; then
    echo "ERROR: not found, expected environment variable: LOGNAME"
    exit 255;
fi

#if [ -z "${USER}" ]; then
USER=${LOGNAME}
export USER
#fi

if [ "X${AUTH_USER}Y" != "X${USER}Y" ]; then
    echo "ERROR: must be run only by user ${AUTH_USER}, your are: ${USER}"
    exit 255;
fi
