forked from webmetrics/browsermob-proxy
-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplified startup script on unix OSes
- Loading branch information
Showing
2 changed files
with
22 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,29 @@ | ||
#!/bin/sh | ||
# ---------------------------------------------------------------------------- | ||
# Copyright 2001-2006 The Apache Software Foundation. | ||
# | ||
# Licensed 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. | ||
# ---------------------------------------------------------------------------- | ||
|
||
# Copyright (c) 2001-2002 The Apache Software Foundation. All rights | ||
# reserved. | ||
|
||
BASEDIR=`dirname $0`/.. | ||
BASEDIR=`(cd "$BASEDIR"; pwd)` | ||
|
||
|
||
|
||
# OS specific support. $var _must_ be set to either true or false. | ||
cygwin=false; | ||
darwin=false; | ||
case "`uname`" in | ||
CYGWIN*) cygwin=true ;; | ||
Darwin*) darwin=true | ||
if [ -z "$JAVA_HOME" ] ; then | ||
JAVA_HOME=`/usr/libexec/java_home` | ||
fi | ||
if [ -z "$JAVA_HOME" ] ; then | ||
JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home` | ||
fi | ||
if [ -z "$JAVA_HOME" ] ; then | ||
if [ -z "$JAVA_VERSION" ] ; then | ||
JAVA_VERSION="CurrentJDK" | ||
else | ||
echo "Using Java version: $JAVA_VERSION" | ||
fi | ||
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home | ||
fi | ||
JAVACMD="$JAVA_HOME/bin/java" | ||
;; | ||
esac | ||
|
||
if [ -z "$JAVA_HOME" ] ; then | ||
if [ -r /etc/gentoo-release ] ; then | ||
JAVA_HOME=`java-config --jre-home` | ||
fi | ||
fi | ||
|
||
# For Cygwin, ensure paths are in UNIX format before anything is touched | ||
if $cygwin ; then | ||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` | ||
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"` | ||
fi | ||
|
||
# If a specific java binary isn't specified search for the standard 'java' binary | ||
if [ -z "$JAVACMD" ] ; then | ||
if [ -n "$JAVA_HOME" ] ; then | ||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
# IBM's JDK on AIX uses strange locations for the executables | ||
JAVACMD="$JAVA_HOME/jre/sh/java" | ||
else | ||
JAVACMD="$JAVA_HOME/bin/java" | ||
fi | ||
else | ||
JAVACMD=`which java` | ||
fi | ||
fi | ||
|
||
if [ ! -x "$JAVACMD" ] ; then | ||
echo "Error: JAVA_HOME is not defined correctly." | ||
echo " We cannot execute $JAVACMD" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "$REPO" ] | ||
# if user has not explicitly set a command to use to invoke java, use 'java' and assume it is on the path | ||
if [ -z "$JAVACMD" ] | ||
then | ||
REPO="$BASEDIR"/lib | ||
JAVACMD="java" | ||
fi | ||
|
||
CLASSPATH=$CLASSPATH_PREFIX:"$BASEDIR"/etc:"$REPO"/* | ||
EXTRA_JVM_ARGUMENTS="" | ||
"$JAVACMD" $JAVA_OPTS \ | ||
-Dapp.name="browsermob-proxy" \ | ||
-Dbasedir="$BASEDIR" \ | ||
-jar "$BASEDIR/lib/browsermob-dist-${project.version}.jar" \ | ||
"$@" | ||
|
||
# For Cygwin, switch paths to Windows format before running java | ||
if $cygwin; then | ||
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"` | ||
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` | ||
[ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"` | ||
[ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"` | ||
[ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"` | ||
# if we couldn't find java, print a helpful error message | ||
if [ $? -eq 127 ] | ||
then | ||
echo | ||
echo "Unable to run java using command: $JAVACMD" | ||
echo "Make sure java is installed and on the path, or set JAVACMD to the java executable before running this script." | ||
echo | ||
echo "Example:" | ||
echo | ||
echo " $ JAVACMD=/var/lib/jdk/bin/java ./browsermob-proxy" | ||
echo | ||
fi | ||
|
||
exec "$JAVACMD" $JAVA_OPTS \ | ||
$EXTRA_JVM_ARGUMENTS \ | ||
-classpath "$CLASSPATH" \ | ||
-Dapp.name="browsermob-proxy" \ | ||
-Dapp.pid="$$" \ | ||
-Dapp.repo="$REPO" \ | ||
-Dbasedir="$BASEDIR" \ | ||
net.lightbody.bmp.proxy.Main \ | ||
"$@" |