#! /bin/sh

#change this line to the correct path of olex2.app
olex2_path=~/tmp

export PATH=~/bin:$PATH

export OLEX2_DIR="$olex2_path"/olex2.app/Contents/MacOS
export OLEX2_CCTBX_DIR="$olex2_path"/olex2.app/Contents/MacOS/cctbx

export BOOST_ADAPTBX_FPE_DEFAULT=1
export DYLD_LIBRARY_PATH=$OLEX2_CCTBX_DIR/cctbx_build/lib:"$olex2_path"/olex2.app/Contents/MacOS/Python26:$DYLD_LIBRARY_PATH

#fix the executable flags if got missing...

if [ ! -x "$olex2_path"/olex2.app/Contents/MacOS/unirun ]
then
  chmod +x "$olex2_path"/olex2.app/Contents/MacOS/unirun
fi

"$olex2_path"/olex2.app/Contents/MacOS/unirun "$olex2_path/olex2.app/Contents/MacOS"

if [ ! -x "$olex2_path"/olex2.app/Contents/MacOS/olex2 ]
then
  chmod +x "$olex2_path"/olex2.app/Contents/MacOS/olex2
fi

open "$olex2_path"/olex2.app
