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