mirror of https://github.com/apache/nifi.git
NIFI-1710 - Resolve path name to nifi.sh script
This closes #1137. Signed-off-by: Andy LoPresto <alopresto@apache.org>
This commit is contained in:
parent
27dba60f27
commit
3914141c45
|
@ -17,12 +17,36 @@
|
||||||
|
|
||||||
# Script structure inspired from Apache Karaf and other Apache projects with similar startup approaches
|
# Script structure inspired from Apache Karaf and other Apache projects with similar startup approaches
|
||||||
|
|
||||||
SCRIPT_DIR=$(dirname "$0")
|
# Discover the path of the file
|
||||||
SCRIPT_NAME=$(basename "$0")
|
|
||||||
|
|
||||||
|
# Since MacOS X, FreeBSD and some other systems lack gnu readlink, we use a more portable
|
||||||
|
# approach based on following StackOverflow comment http://stackoverflow.com/a/1116890/888876
|
||||||
|
|
||||||
|
TARGET_FILE=$0
|
||||||
|
|
||||||
|
cd $(dirname $TARGET_FILE)
|
||||||
|
TARGET_FILE=$(basename $TARGET_FILE)
|
||||||
|
|
||||||
|
# Iterate down a (possible) chain of symlinks
|
||||||
|
while [ -L "$TARGET_FILE" ]
|
||||||
|
do
|
||||||
|
TARGET_FILE=$(readlink $TARGET_FILE)
|
||||||
|
cd $(dirname $TARGET_FILE)
|
||||||
|
TARGET_FILE=$(basename $TARGET_FILE)
|
||||||
|
done
|
||||||
|
|
||||||
|
# Compute the canonicalized name by finding the physical path
|
||||||
|
# for the directory we're in and appending the target file.
|
||||||
|
PHYS_DIR=`pwd -P`
|
||||||
|
|
||||||
|
SCRIPT_DIR=$PHYS_DIR
|
||||||
PROGNAME=$(basename "$0")
|
PROGNAME=$(basename "$0")
|
||||||
|
|
||||||
. "$SCRIPT_DIR"/nifi-env.sh
|
. "$SCRIPT_DIR"/nifi-env.sh
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
warn() {
|
warn() {
|
||||||
echo "${PROGNAME}: $*"
|
echo "${PROGNAME}: $*"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue