#! /bin/sh

# The variable is not actually needed to run the example, but it is needed to 
# build the example, and if you haven't built the example, you can't run it. 
if [ -z "$MULE_HOME" ] ; then
  echo "You must set the environment variable MULE_HOME to the location of your Mule install in order to run this example." 
  exit 1
fi

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

# This extends the classpath to include the configuration directory.
# 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.2.jar

if [ -f "$MULE_BASE/lib/user/${ACTIVEMQ}" ]; then
    exec "$MULE_BASE/bin/mule" -config error-config.xml
elif [ -f "$MULE_HOME/lib/user/${ACTIVEMQ}" ]; then
    exec "$MULE_BASE/bin/mule" -config 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
