#! /bin/sh

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

if [ ! -d "$MULE_BASE/apps/mule-example-stockquote" ]
then
    echo "This example requires you to build it before running it.  Please follow the instructions in the README.txt file."
    exit 1
fi         

echo "(make sure you have configured your HTTP proxy if behind a firewall - see README.txt)"
echo
echo "The Stock Quote example is available in three variations:"
echo "  1. REST"
echo "  2. WSDL"
echo "  3. SOAP"
echo "Select the one you wish to execute and press Enter..."
read i

if [ 1 = $i ]
then
    exec "$MULE_BASE/bin/mule" -config "$MULE_BASE/apps/mule-example-stockquote/stockquote-rest-config.xml,$MULE_BASE/apps/mule-example-stockquote/stdio-config.xml"
elif [ 2 = $i ]
then
    exec "$MULE_BASE/bin/mule" -config "$MULE_BASE/apps/mule-example-stockquote/stockquote-wsdl-config.xml,$MULE_BASE/apps/mule-example-stockquote/stdio-config.xml"
elif [ 3 = $i ]
then
    exec "$MULE_BASE/bin/mule" -config "$MULE_BASE/apps/mule-example-stockquote/stockquote-soap-config.xml,$MULE_BASE/apps/mule-example-stockquote/stdio-config.xml"
fi
