ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 1 | # Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | # contributor license agreements. See the NOTICE file distributed with |
| 3 | # this work for additional information regarding copyright ownership. |
| 4 | # The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | # (the "License"); you may not use this file except in compliance with |
| 6 | # the License. You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | # included in all the hadoop scripts with source command |
| 17 | # should not be executable directly |
| 18 | # also should not be passed any arguments, since we need original $* |
| 19 | |
| 20 | # resolve links - $0 may be a softlink |
| 21 | |
| 22 | this="$0" |
| 23 | while [ -h "$this" ]; do |
| 24 | ls=`ls -ld "$this"` |
| 25 | link=`expr "$ls" : '.*-> \(.*\)$'` |
| 26 | if expr "$link" : '.*/.*' > /dev/null; then |
| 27 | this="$link" |
| 28 | else |
| 29 | this=`dirname "$this"`/"$link" |
| 30 | fi |
| 31 | done |
| 32 | |
| 33 | # convert relative path to absolute path |
| 34 | bin=`dirname "$this"` |
| 35 | script=`basename "$this"` |
| 36 | bin=`cd "$bin"; pwd` |
| 37 | this="$bin/$script" |
| 38 | |
| 39 | # the root of the Hadoop installation |
| 40 | export HADOOP_HOME=`dirname "$this"`/.. |
| 41 | |
| 42 | #check to see if the conf dir is given as an optional argument |
| 43 | if [ $# -gt 1 ] |
| 44 | then |
| 45 | if [ "--config" = "$1" ] |
| 46 | then |
| 47 | shift |
| 48 | confdir=$1 |
| 49 | shift |
| 50 | HADOOP_CONF_DIR=$confdir |
| 51 | fi |
| 52 | fi |
| 53 | |
| 54 | # Allow alternate conf dir location. |
| 55 | HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_HOME/conf}" |
| 56 | |
| 57 | #check to see it is specified whether to use the slaves or the |
| 58 | # masters file |
| 59 | if [ $# -gt 1 ] |
| 60 | then |
| 61 | if [ "--hosts" = "$1" ] |
| 62 | then |
| 63 | shift |
| 64 | slavesfile=$1 |
| 65 | shift |
| 66 | export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$slavesfile" |
| 67 | fi |
| 68 | fi |