Repository: nifi Updated Branches: refs/heads/master 27dba60f2 -> 3914141c4
NIFI-1710 - Resolve path name to nifi.sh script This closes #1137. Signed-off-by: Andy LoPresto <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/3914141c Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/3914141c Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/3914141c Branch: refs/heads/master Commit: 3914141c45c574fb8d22a72af99165cb535f5f17 Parents: 27dba60 Author: Andre F de Miranda <[email protected]> Authored: Fri Oct 14 14:36:48 2016 +1100 Committer: Andy LoPresto <[email protected]> Committed: Tue Oct 18 16:43:03 2016 -0700 ---------------------------------------------------------------------- .../src/main/resources/bin/nifi.sh | 28 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/3914141c/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh index 79850ee..ff8addd 100755 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/bin/nifi.sh @@ -17,12 +17,36 @@ # Script structure inspired from Apache Karaf and other Apache projects with similar startup approaches -SCRIPT_DIR=$(dirname "$0") -SCRIPT_NAME=$(basename "$0") +# Discover the path of the file + + +# 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") . "$SCRIPT_DIR"/nifi-env.sh + + warn() { echo "${PROGNAME}: $*" }
