#! /bin/sh

# There is no need to call this if you set the MULE_HOME in your environment
if [ -z "$MULE_HOME" ] ; then
  # find the name of the real MULE_HOME which is two levels up
  MULE_HOME=`pwd`
  MULE_HOME=`dirname "$MULE_HOME"`
  MULE_HOME=`dirname "$MULE_HOME"`
  export MULE_HOME
fi

# If MULE_BASE is not set, make it MULE_HOME
if [ -z "$MULE_BASE" ] ; then
  MULE_BASE="$MULE_HOME"
  export MULE_BASE
fi

# Any changes to the files in ./conf will take precedence over those deployed to $MULE_HOME/lib/user
MULE_LIB=./conf
export MULE_LIB

ACTIVEMQ=activemq-core-4.1.0-incubator.jar

if [ -f "$MULE_BASE/lib/user/${ACTIVEMQ}" ]; then
    exec "$MULE_BASE/bin/mule" -config ./conf/error-config.xml
elif [ -f "$MULE_HOME/lib/user/${ACTIVEMQ}" ]; then
    exec "$MULE_BASE/bin/mule" -config ./conf/error-config.xml
else
    echo "This example requires additional libraries which need to be downloaded by the build script.  Please follow the instructions in the README.txt file."
fi
