Repository: incubator-sentry
Updated Branches:
  refs/heads/master 1e5826f85 -> 7a2b21852


SENTRY-430: Sentry Service does not use correct classpath when HIVE_HOME 
environment var is defined (Prasad Mujumdar reviewed by Lenni Kuff, Sravya 
Tirukkovalur)


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/7a2b2185
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/7a2b2185
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/7a2b2185

Branch: refs/heads/master
Commit: 7a2b218527aed314db64865265550b3d809bae11
Parents: 1e5826f
Author: Prasad Mujumdar <[email protected]>
Authored: Thu Sep 18 22:51:41 2014 -0700
Committer: Prasad Mujumdar <[email protected]>
Committed: Thu Sep 18 22:51:41 2014 -0700

----------------------------------------------------------------------
 bin/config_tool | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 bin/sentry      | 29 +++++++++++----------------
 2 files changed, 68 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/7a2b2185/bin/config_tool
----------------------------------------------------------------------
diff --git a/bin/config_tool b/bin/config_tool
new file mode 100755
index 0000000..4da8567
--- /dev/null
+++ b/bin/config_tool
@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if [ "${RUN_CONFIG_TOOL}" != "1" ]
+then
+  echo "ERROR: $0 must be invoked via sentry script"
+  exit 1
+fi
+
+args=()
+while [ $# -gt 0 ]; do    # Until you run out of parameters . . .
+  case "$1" in
+    --hive-config)
+      shift
+      confdir=$1
+      shift
+      export HIVE_CONF_DIR=$confdir
+      echo Using hive-conf-dir $HIVE_CONF_DIR
+      ;;
+    --hive-home)
+      shift
+      homedir=$1
+      shift
+      export HIVE_HOME=$homedir
+      echo Using hive-home $HIVE_HOME
+      ;;
+    *)
+      args+=" $1"
+      shift
+      ;;
+  esac
+done
+
+if [[ -z "$HIVE_HOME" ]]
+then
+  echo "Cannot find hive installation: \$HIVE_HOME or hive must be in the 
path";
+  exit 5;
+fi
+  
+_HIVE_CMD=${HIVE_HOME}/bin/hive
+${_HIVE_CMD} --service jar ${SENTRY_HOME}/lib/${_CMD_JAR} 
org.apache.sentry.SentryMain ${args[@]}
+

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/7a2b2185/bin/sentry
----------------------------------------------------------------------
diff --git a/bin/sentry b/bin/sentry
index 2990ef4..0b98049 100755
--- a/bin/sentry
+++ b/bin/sentry
@@ -17,6 +17,7 @@
 
 bin=`dirname "$0"`
 myhome=`cd "$bin/.."; pwd`
+RUN_CONFIG_TOOL=0
 
 # the root of the Hive installation
 if [[ -z $SENTRY_HOME ]] ; then
@@ -41,23 +42,17 @@ if [ ! -f ${HADOOP} ]; then
   exit 4;
 fi
 
-#check to see if the hive conf dir is given as an optional argument
+# If we are running config-tool then invoke it via separate script. It needs 
Hive classpatch and config
 args=()
 while [ $# -gt 0 ]; do    # Until you run out of parameters . . .
   case "$1" in
-    --hive-config)
-      shift
-      confdir=$1
-      shift
-      export HIVE_CONF_DIR=$confdir
-      echo Using hive-conf-dir $HIVE_CONF_DIR
-      ;;
-    --hive-home)
-      shift
-      homedir=$1
+    --command)
+      if [ "$2" = "config-tool" ]
+      then
+        RUN_CONFIG_TOOL=1
+      fi
+      args+=" $1"
       shift
-      export HIVE_HOME=$homedir
-      echo Using hive-home $HIVE_HOME
       ;;
     *)
       args+=" $1"
@@ -66,19 +61,19 @@ while [ $# -gt 0 ]; do    # Until you run out of parameters 
. . .
   esac
 done
 
-_CMD_JAR=sentry-core-common-*.jar
+export _CMD_JAR=sentry-core-common-*.jar
 for f in ${SENTRY_HOME}/lib/*.jar; do
   HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:${f}
 done
 export HADOOP_CLASSPATH
-if [[ -z "$HIVE_HOME" ]]
+export RUN_CONFIG_TOOL
+if [ "${RUN_CONFIG_TOOL}" = "0" ]
 then
   for f in ${SENTRY_HOME}/lib/server/*.jar; do
     HADOOP_CLASSPATH=${HADOOP_CLASSPATH}:${f}
   done
   exec $HADOOP jar ${SENTRY_HOME}/lib/${_CMD_JAR} org.apache.sentry.SentryMain 
${args[@]}
 else
-  _HIVE_CMD=${HIVE_HOME}/bin/hive
-  ${_HIVE_CMD} --service jar ${SENTRY_HOME}/lib/${_CMD_JAR} 
org.apache.sentry.SentryMain ${args[@]}
+  exec ${SENTRY_HOME}/bin/config_tool ${args[@]}
 fi
 

Reply via email to