#! /bin/sh
#
# Put this file in your PATH and/or invoke it directly.
#
# - Enables full debugging (note!  Privacy concerns!)
# - Enables core dumps (ulimit)
# - Creates a new log directory for this instance of Evo
# - Cd's there to keep everything related to this run together
#
# You should clean out those log directories occasionally.

prefix='/opt/evo'

# Set up debugging.  Remember EVERYTHING!
#E2K_DEBUG=5
#CAMEL_DEBUG=all
#MALLOC_CHECK_=2

export E2K_DEBUG CAMEL_DEBUG MALLOC_CHECK_ 

#export LD_LIBRARY_PATH=/usr/lib/debug:/usr/lib/debug:/usr/lib/debug/lib/tls/i686/cmov

## issue 595389
export CAMEL_SQLITE_DEFAULT_CACHE_SIZE=2000

# Allow for core dumps.
ulimit -c unlimited

# All our email is dumped with debugging, so set restrictive permissions
umask 0077

# Create a directory just for this run
logdir="$prefix/log/`date '+%Y%m%d.%H%M%S'`"
mkdir -p "$logdir"
cd "$logdir" || exit 1

# Run it
i=0
while [ -e "$logdir/evo.log.$i" ]; do
   i=`expr $i + 1`
done

#killall bonobo-activation-server
#/opt/evo/bin/evolution --force-shutdown

echo $@

#exec "$prefix/bin/evolution-env" "gdb" -x "$prefix/.gdbinit"  "$prefix/bin/evolution" "$@"

exec "$prefix/bin/evolution-env" "$prefix/bin/evolution" "$@"
