blob: 7232ccc72364f7c15de9a3ba541aafa1a183c9b7 [file] [log] [blame]
buyingyi1341a162013-06-05 15:07:52 -07001#!/bin/sh
2#
3#------------------------------------------------------------------------
4# Copyright 2009-2013 by The Regents of the University of California
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# you may obtain a copy of the License from
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# ------------------------------------------------------------------------
17#
18
19
20# resolve links - $0 may be a softlink
21PRG="$0"
22
23while [ -h "$PRG" ]; do
24 ls=`ls -ld "$PRG"`
25 link=`expr "$ls" : '.*-> \(.*\)$'`
26 if expr "$link" : '/.*' > /dev/null; then
27 PRG="$link"
28 else
29 PRG=`dirname "$PRG"`/"$link"
30 fi
31done
32
33PRGDIR=`dirname "$PRG"`
34BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd`
35
36
37
38# OS specific support. $var _must_ be set to either true or false.
39cygwin=false;
40darwin=false;
41case "`uname`" in
42 CYGWIN*) cygwin=true ;;
43 Darwin*) darwin=true
44 if [ -z "$JAVA_VERSION" ] ; then
45 JAVA_VERSION="CurrentJDK"
46 else
47 echo "Using Java version: $JAVA_VERSION"
48 fi
49 if [ -z "$JAVA_HOME" ] ; then
50 JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
51 fi
52 ;;
53esac
54
55if [ -z "$JAVA_HOME" ] ; then
56 if [ -r /etc/gentoo-release ] ; then
57 JAVA_HOME=`java-config --jre-home`
58 fi
59fi
60
61# For Cygwin, ensure paths are in UNIX format before anything is touched
62if $cygwin ; then
63 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
64 [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
65fi
66
67# If a specific java binary isn't specified search for the standard 'java' binary
68if [ -z "$JAVACMD" ] ; then
69 if [ -n "$JAVA_HOME" ] ; then
70 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
71 # IBM's JDK on AIX uses strange locations for the executables
72 JAVACMD="$JAVA_HOME/jre/sh/java"
73 else
74 JAVACMD="$JAVA_HOME/bin/java"
75 fi
76 else
77 JAVACMD=`which java`
78 fi
79fi
80
81if [ ! -x "$JAVACMD" ] ; then
82 echo "Error: JAVA_HOME is not defined correctly." 1>&2
83 echo " We cannot execute $JAVACMD" 1>&2
84 exit 1
85fi
86
87if [ -z "$REPO" ]
88then
89 REPO="$BASEDIR"/lib
90fi
91
92CLASSPATH=$CLASSPATH_PREFIX:"$HADOOP_HOME"/conf:/etc/hadoop/conf:"$BASEDIR"/etc:$1
93
94# For Cygwin, switch paths to Windows format before running java
95if $cygwin; then
96 [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
97 [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
98 [ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
99 [ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
100 [ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
101fi
102
103exec "$JAVACMD" $JAVA_OPTS \
104 -classpath "$CLASSPATH" \
105 -Dapp.name="pregelix" \
106 -Dapp.pid="$$" \
107 -Dapp.repo="$REPO" \
108 -Dapp.home="$BASEDIR" \
109 -Dbasedir="$BASEDIR" \
110 org.apache.hadoop.util.RunJar \
111 "$@"