PageRenderTime 27ms CodeModel.GetById 15ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.2.0-rc0/bin/hcat

#
#! | 79 lines | 67 code | 12 blank | 0 comment | 0 complexity | a395979b17ec8b38f9fa9e93a9e5e2c4 MD5 | raw file
 1#!/usr/bin/env bash
 2
 3# Licensed to the Apache Software Foundation (ASF) under one
 4# or more contributor license agreements.  See the NOTICE file
 5# distributed with this work for additional information
 6# regarding copyright ownership.  The ASF licenses this file
 7# to you under the Apache License, Version 2.0 (the
 8# "License"); you may not use this file except in compliance
 9# with the License.  You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18
19# Resolve our absolute path                                                      
20# resolve links - $0 may be a softlink                                           
21this="${BASH_SOURCE-$0}"                                                         
22while [ -h "$this" ]; do                                                         
23    ls=`ls -ld "$this"`                                                          
24    link=`expr "$ls" : '.*-> \(.*\)$'`                                           
25    if expr "$link" : '.*/.*' > /dev/null; then                                  
26        this="$link"                                                             
27    else                                                                         
28        this=`dirname "$this"`/"$link"                                           
29    fi                                                                           
30done                                                                             
31                                                                                 
32# convert relative path to absolute path                                         
33bin=`dirname "$this"`                                                            
34script=`basename "$this"`                                                        
35bin=`unset CDPATH; cd "$bin"; pwd`                                               
36this="$bin/$script"                                                              
37
38
39if [ -e "$bin/../libexec/hcat-config.sh" ]; then
40  . "$bin"/../libexec/hcat-config.sh
41else
42  . "$bin"/hcat-config.sh
43fi
44
45# filter debug command line parameter
46debug=false
47
48for f in $@; do
49     if [[ $f = "-secretDebugCmd" ]]; then
50        debug=true
51     else
52        remaining="${remaining} $f"
53     fi
54done
55
56# Find our hcatalog jar
57shopt -s extglob
58HCAT_JAR=$HCAT_PREFIX/share/hcatalog/hcatalog-!(*server-extensions*).jar
59
60# Add all of the other jars to our classpath
61for jar in $HCAT_PREFIX/share/hcatalog/lib/*.jar ; do
62	HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$jar
63done
64
65# Put our config file in the classpath
66HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:${HCAT_PREFIX}/etc/hcatalog
67
68export HADOOP_CLASSPATH=$HADOOP_CLASSPATH
69export HADOOP_OPTS=$HADOOP_OPTS
70# run it
71if [ "$debug" == "true" ]; then
72	echo "Would run:"
73	echo "exec $HADOOP_PREFIX/bin/hadoop jar $HCAT_JAR org.apache.hcatalog.cli.HCatCli $remaining"
74	echo "with HADOOP_CLASSPATH set to ($HADOOP_CLASSPATH)"
75	echo "and HADOOP_OPTS set to ($HADOOP_OPTS)"
76else
77	exec $HADOOP_PREFIX/bin/hadoop jar  $HCAT_JAR org.apache.hcatalog.cli.HCatCli "$@"
78fi
79