# ! /bin/sh
bin_dir=/work/distro/olex2-new

#modify the line below to point to a valid cctbx installtion to be used with olex2
export OLEX2_CCTBX_DIR=$bin_dir/cctbx
#this is necessary here as the cctbx sets signalf for FPE and does not handle them...
export BOOST_ADAPTBX_FPE_DEFAULT=1
export BOOST_ADAPTBX_SIGNALS_DEFAULT=1

#uncomment this on k/ubuntu to fix graphics...
#export OLEX2_GL_DEFAULT=True

#uncomment the line below to specify alternative location of olex2 GUI
#by default it is the $bin_dir
#export OLEX2_DIR=$bin_dir


# we need to set the correct update path, if the gui is not at the default location
#update_path="$bin_dir"

if [ $OLEX2_DIR ]
then
  update_path="$OLEX2_DIR"
  echo Setting the update path to: $update_path
fi

#set the dynamic library paths
export LD_LIBRARY_PATH=$bin_dir/lib:$bin_dir/Python26:$OLEX2_CCTBX_DIR/cctbx_build/lib:$LD_LIBRARY_PATH
export PYTHONHOME=$bin_dir/Python26
export PATH=$bin_dir/bin:$PATH

if [ ! -x $bin_dir/unirun ]
then
  chmod +x $bin_dir/unirun
fi

if [ -n update_path ]
then
  $bin_dir/unirun "$update_path"
else
  $bin_dir/unirun "$bin_dir"
fi

if [ ! -x $bin_dir/olex2 ]
then
  chmod +x $bin_dir/olex2
fi

$bin_dir/olex2 &
