From af12cef9c0e66c26aded8ea052cdf684fe73df84 Mon Sep 17 00:00:00 2001 From: Jason Hoetger Date: Mon, 26 Dec 2016 11:19:07 -0800 Subject: [PATCH] Simplified startup script on unix OSes --- browsermob-dist/assembly.xml | 5 +- .../src/main/scripts/browsermob-proxy | 116 +++--------------- 2 files changed, 22 insertions(+), 99 deletions(-) diff --git a/browsermob-dist/assembly.xml b/browsermob-dist/assembly.xml index bca68a804..49ae27db3 100644 --- a/browsermob-dist/assembly.xml +++ b/browsermob-dist/assembly.xml @@ -1,7 +1,7 @@ - + xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> bin zip @@ -22,6 +22,7 @@ keep 0744 0755 + true ${project.basedir}/../browsermob-core/target diff --git a/browsermob-dist/src/main/scripts/browsermob-proxy b/browsermob-dist/src/main/scripts/browsermob-proxy index 0b437f5a0..dc8f66897 100755 --- a/browsermob-dist/src/main/scripts/browsermob-proxy +++ b/browsermob-dist/src/main/scripts/browsermob-proxy @@ -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 \ - "$@"