buyingyi | 98e9a9b | 2013-03-10 21:24:35 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # ---------------------------------------------------------------------------- |
| 3 | # Copyright 2001-2006 The Apache Software Foundation. |
| 4 | # |
| 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 at |
| 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 | # Copyright (c) 2001-2006 The Apache Software Foundation. All rights |
| 19 | # reserved. |
| 20 | |
| 21 | |
| 22 | # resolve links - $0 may be a softlink |
| 23 | PRG="$0" |
| 24 | |
| 25 | while [ -h "$PRG" ]; do |
| 26 | ls=`ls -ld "$PRG"` |
| 27 | link=`expr "$ls" : '.*-> \(.*\)$'` |
| 28 | if expr "$link" : '/.*' > /dev/null; then |
| 29 | PRG="$link" |
| 30 | else |
| 31 | PRG=`dirname "$PRG"`/"$link" |
| 32 | fi |
| 33 | done |
| 34 | |
| 35 | PRGDIR=`dirname "$PRG"` |
| 36 | BASEDIR=`cd "$PRGDIR/.." >/dev/null; pwd` |
| 37 | |
| 38 | |
| 39 | |
| 40 | # OS specific support. $var _must_ be set to either true or false. |
| 41 | cygwin=false; |
| 42 | darwin=false; |
| 43 | case "`uname`" in |
| 44 | CYGWIN*) cygwin=true ;; |
| 45 | Darwin*) darwin=true |
| 46 | if [ -z "$JAVA_VERSION" ] ; then |
| 47 | JAVA_VERSION="CurrentJDK" |
| 48 | else |
| 49 | echo "Using Java version: $JAVA_VERSION" |
| 50 | fi |
| 51 | if [ -z "$JAVA_HOME" ] ; then |
| 52 | JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home |
| 53 | fi |
| 54 | ;; |
| 55 | esac |
| 56 | |
| 57 | if [ -z "$JAVA_HOME" ] ; then |
| 58 | if [ -r /etc/gentoo-release ] ; then |
| 59 | JAVA_HOME=`java-config --jre-home` |
| 60 | fi |
| 61 | fi |
| 62 | |
| 63 | # For Cygwin, ensure paths are in UNIX format before anything is touched |
| 64 | if $cygwin ; then |
| 65 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` |
| 66 | [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` |
| 67 | fi |
| 68 | |
| 69 | # If a specific java binary isn't specified search for the standard 'java' binary |
| 70 | if [ -z "$JAVACMD" ] ; then |
| 71 | if [ -n "$JAVA_HOME" ] ; then |
| 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then |
| 73 | # IBM's JDK on AIX uses strange locations for the executables |
| 74 | JAVACMD="$JAVA_HOME/jre/sh/java" |
| 75 | else |
| 76 | JAVACMD="$JAVA_HOME/bin/java" |
| 77 | fi |
| 78 | else |
| 79 | JAVACMD=`which java` |
| 80 | fi |
| 81 | fi |
| 82 | |
| 83 | if [ ! -x "$JAVACMD" ] ; then |
| 84 | echo "Error: JAVA_HOME is not defined correctly." 1>&2 |
| 85 | echo " We cannot execute $JAVACMD" 1>&2 |
| 86 | exit 1 |
| 87 | fi |
| 88 | |
| 89 | if [ -z "$REPO" ] |
| 90 | then |
| 91 | REPO="$BASEDIR"/lib |
| 92 | fi |
| 93 | |
| 94 | CLASSPATH=$CLASSPATH_PREFIX:"$HADOOP_HOME"/conf:"$BASEDIR"/etc:$1 |
| 95 | |
| 96 | # For Cygwin, switch paths to Windows format before running java |
| 97 | if $cygwin; then |
| 98 | [ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"` |
| 99 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` |
| 100 | [ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"` |
| 101 | [ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"` |
| 102 | [ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"` |
| 103 | fi |
| 104 | |
| 105 | exec "$JAVACMD" $JAVA_OPTS \ |
| 106 | -classpath "$CLASSPATH" \ |
| 107 | -Dapp.name="pregelix" \ |
| 108 | -Dapp.pid="$$" \ |
| 109 | -Dapp.repo="$REPO" \ |
| 110 | -Dapp.home="$BASEDIR" \ |
| 111 | -Dbasedir="$BASEDIR" \ |
| 112 | org.apache.hadoop.util.RunJar \ |
| 113 | "$@" |