blob: 1f9d52da79c4ecf469f1563fc1b89747e43bfcc9 [file] [log] [blame]
ramangrover29116eb972013-02-20 20:47:35 +00001# 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
22this="$0"
23while [ -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
31done
32
33# convert relative path to absolute path
34bin=`dirname "$this"`
35script=`basename "$this"`
36bin=`cd "$bin"; pwd`
37this="$bin/$script"
38
39# the root of the Hadoop installation
40export HADOOP_HOME=`dirname "$this"`/..
41
42#check to see if the conf dir is given as an optional argument
43if [ $# -gt 1 ]
44then
45 if [ "--config" = "$1" ]
46 then
47 shift
48 confdir=$1
49 shift
50 HADOOP_CONF_DIR=$confdir
51 fi
52fi
53
54# Allow alternate conf dir location.
55HADOOP_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
59if [ $# -gt 1 ]
60then
61 if [ "--hosts" = "$1" ]
62 then
63 shift
64 slavesfile=$1
65 shift
66 export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$slavesfile"
67 fi
68fi