summaryrefslogtreecommitdiff
path: root/scripts/rabbitmq-env
diff options
context:
space:
mode:
authorMichael Klishin <michael@novemberain.com>2015-04-10 21:24:34 +0300
committerMichael Klishin <michael@novemberain.com>2015-04-10 21:24:34 +0300
commitb7df4cdbfdb92f91371b14f97baa595bab1597cc (patch)
treef35af0fab1a75d123cf04132e3b5e89aebb29e06 /scripts/rabbitmq-env
parent58749727df061836f7808b934a549fe4b00b670b (diff)
parentdc6c9b0275ab5b8a9689b4730aeb9e7d0fd37875 (diff)
downloadrabbitmq-server-git-b7df4cdbfdb92f91371b14f97baa595bab1597cc.tar.gz
Merge pull request #103 from rabbitmq/rabbitmq-server-88
PR for rabbitmq/rabbitmq-server#88
Diffstat (limited to 'scripts/rabbitmq-env')
-rwxr-xr-xscripts/rabbitmq-env59
1 files changed, 34 insertions, 25 deletions
diff --git a/scripts/rabbitmq-env b/scripts/rabbitmq-env
index 8a1b4d6510..1b72c4d82c 100755
--- a/scripts/rabbitmq-env
+++ b/scripts/rabbitmq-env
@@ -15,33 +15,40 @@
## Copyright (c) 2007-2014 GoPivotal, Inc. All rights reserved.
##
-# We set +e here since since our test for "readlink -f" below needs to
-# be able to fail.
-set +e
-# Determine where this script is really located (if this script is
-# invoked from another script, this is the location of the caller)
-SCRIPT_PATH="$0"
-while [ -h "$SCRIPT_PATH" ] ; do
- # Determine if readlink -f is supported at all. TODO clean this up.
- FULL_PATH=`readlink -f $SCRIPT_PATH 2>/dev/null`
- if [ "$?" != "0" ]; then
- REL_PATH=`readlink $SCRIPT_PATH`
- if expr "$REL_PATH" : '/.*' > /dev/null; then
- SCRIPT_PATH="$REL_PATH"
- else
- SCRIPT_PATH="`dirname "$SCRIPT_PATH"`/$REL_PATH"
- fi
- else
- SCRIPT_PATH=$FULL_PATH
- fi
-done
-set -e
-
-SCRIPT_DIR=`dirname $SCRIPT_PATH`
-RABBITMQ_HOME="${SCRIPT_DIR}/.."
+if [ "$RABBITMQ_ENV_LOADED" = 1 ]; then
+ return 0;
+fi
+
+if [ -z "$RABBITMQ_SCRIPTS_DIR" ]; then
+ # We set +e here since since our test for "readlink -f" below needs to
+ # be able to fail.
+ set +e
+ # Determine where this script is really located (if this script is
+ # invoked from another script, this is the location of the caller)
+ SCRIPT_PATH="$0"
+ while [ -h "$SCRIPT_PATH" ] ; do
+ # Determine if readlink -f is supported at all. TODO clean this up.
+ FULL_PATH=`readlink -f $SCRIPT_PATH 2>/dev/null`
+ if [ "$?" != "0" ]; then
+ REL_PATH=`readlink $SCRIPT_PATH`
+ if expr "$REL_PATH" : '/.*' > /dev/null; then
+ SCRIPT_PATH="$REL_PATH"
+ else
+ SCRIPT_PATH="`dirname "$SCRIPT_PATH"`/$REL_PATH"
+ fi
+ else
+ SCRIPT_PATH=$FULL_PATH
+ fi
+ done
+ set -e
+
+ RABBITMQ_SCRIPTS_DIR=`dirname $SCRIPT_PATH`
+fi
+
+RABBITMQ_HOME="${RABBITMQ_SCRIPTS_DIR}/.."
## Set defaults
-. ${SCRIPT_DIR}/rabbitmq-defaults
+. ${RABBITMQ_SCRIPTS_DIR}/rabbitmq-defaults
## Common defaults
SERVER_ERL_ARGS="+K true +A30 +P 1048576 \
@@ -112,5 +119,7 @@ DEFAULT_NODE_PORT=5672
##--- End of overridden <var_name> variables
+RABBITMQ_ENV_LOADED=1
+
# Since we source this elsewhere, don't accidentally stop execution
true