diff --git a/bin/hbase b/bin/hbase index 3e569ba..c223cc3 100755 --- a/bin/hbase +++ b/bin/hbase @@ -205,6 +205,24 @@ function append_path() { JAVA_PLATFORM="" +#Try to guess HADOOP_HOME +if [ -z "$HADOOP_HOME" ]; then + PRG=$(which hadoop 2>/dev/null) + # This could be a symlink -- lets try to unroll it + while [ -h "${PRG}" ]; do + ls=`ls -ld "${PRG}"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "${PRG}"`/"$link" + fi + done + HADOOP_HOME="$(dirname $(dirname ${PRG}))" +fi + +echo $HADOOP_HOME + #If avail, add Hadoop to the CLASSPATH and to the JAVA_LIBRARY_PATH if [ ! -z $HADOOP_HOME ]; then HADOOPCPPATH=""