| #!/usr/bin/env sh |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| |
| # a simple helper to get the current user |
| setCurrentUser(){ |
| CUSER="`whoami 2>/dev/null`" |
| # Solaris hack |
| if [ ! $? -eq 0 ]; then |
| CUSER="`/usr/ucb/whoami 2>/dev/null`" |
| fi |
| } |
| |
| # get a canonical path, macosx and slowlaris does not support radlink -f :-) |
| pathCanonical() { |
| local dst="${1}" |
| while [ -h "${dst}" ] ; do |
| ls=`ls -ld "${dst}"` |
| link=`expr "$ls" : '.*-> \(.*\)$'` |
| if expr "$link" : '/.*' > /dev/null; then |
| dst="$link" |
| else |
| dst="`dirname "${dst}"`/$link" |
| fi |
| done |
| local bas="`basename "${dst}"`" |
| local dir="`dirname "${dst}"`" |
| if [ "$bas" != "$dir" ]; then |
| dst="`pathCanonical "$dir"`/$bas" |
| fi |
| echo "${dst}" | sed -e 's#//#/#g' -e 's#/\./#/#g' -e 's#/[^/]*/\.\./#/#g' |
| } |
| |
| |
| # a simple helper to get the activemq installation dir |
| getActiveMQHome(){ |
| # get the real path to the binary |
| local REAL_BIN="`pathCanonical $0`" |
| local REAL_DIR="`dirname $REAL_BIN`/../" |
| REAL_DIR="`cd $REAL_DIR && pwd -P`" |
| if [ -z "$REAL_DIR" ];then |
| echo 'ERROR: unable to find real installtion path fo activemq, you have to define ACTIVEMQ_HOME manually in the config' >&2 |
| exit 1 |
| fi |
| echo "$REAL_DIR/" |
| |
| } |
| |
| # Active MQ installation dir |
| if [ -z "$ACTIVEMQ_HOME" ] ; then |
| ACTIVEMQ_HOME="`getActiveMQHome`" |
| fi |
| |
| # Active MQ base dir |
| if [ -z "$ACTIVEMQ_BASE" ] ; then |
| ACTIVEMQ_BASE="$ACTIVEMQ_HOME" |
| fi |
| |
| # Configure user specified classpath here or externally using this variable |
| if [ -z "$ACTIVEMQ_USER_CLASSPATH" ] ; then |
| ACTIVEMQ_USER_CLASSPATH="" |
| fi |
| |
| # ActiveMQ Classpath configuration |
| ACTIVEMQ_CLASSPATH="$ACTIVEMQ_BASE/lib/*:$ACTIVEMQ_BASE/conf/:$ACTIVEMQ_USER_CLASSPATH" |
| |
| ACTIVEMQ_DATA="$ACTIVEMQ_BASE/data/" |
| |
| |
| if [ -z "$JAVACMD" ] ; then |
| if [ -n "$JAVA_HOME" ] ; then |
| if [ -x "$JAVA_HOME/jre/sh/java" ] ; then |
| # IBM's JDK on AIX uses strange locations for the executables |
| JAVACMD="$JAVA_HOME/jre/sh/java" |
| else |
| JAVACMD="$JAVA_HOME/bin/java" |
| fi |
| else |
| JAVACMD=java |
| fi |
| fi |
| |
| |
| JAVA_ARGS= |
| |
| exec "$JAVACMD" \ |
| $JAVA_ARGS \ |
| -classpath "$ACTIVEMQ_CLASSPATH" \ |
| -Dactivemq.data=${ACTIVEMQ_DATA} \ |
| $DEBUG_ARGS \ |
| org.apache.activemq.cli.kahadb.exporter.Exporter "$@" |
| |