Skip to content

Commit

Permalink
Simplified startup script on unix OSes
Browse files Browse the repository at this point in the history
  • Loading branch information
jekh committed Dec 26, 2016
1 parent f88c78f commit af12cef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 99 deletions.
5 changes: 3 additions & 2 deletions browsermob-dist/assembly.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bin</id>
<formats>
<format>zip</format>
Expand All @@ -22,6 +22,7 @@
<lineEnding>keep</lineEnding>
<fileMode>0744</fileMode>
<directoryMode>0755</directoryMode>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>${project.basedir}/../browsermob-core/target</directory>
Expand Down
116 changes: 19 additions & 97 deletions browsermob-dist/src/main/scripts/browsermob-proxy
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 \
"$@"

0 comments on commit af12cef

Please sign in to comment.