Skip to content

Commit d42aa20

Browse files
authored
Merge pull request #584 from jekh/update-startup-script
Simplified startup script on unix OSes
2 parents f88c78f + af12cef commit d42aa20

File tree

2 files changed

+22
-99
lines changed

2 files changed

+22
-99
lines changed

browsermob-dist/assembly.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
2+
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
4+
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
55
<id>bin</id>
66
<formats>
77
<format>zip</format>
@@ -22,6 +22,7 @@
2222
<lineEnding>keep</lineEnding>
2323
<fileMode>0744</fileMode>
2424
<directoryMode>0755</directoryMode>
25+
<filtered>true</filtered>
2526
</fileSet>
2627
<fileSet>
2728
<directory>${project.basedir}/../browsermob-core/target</directory>
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,29 @@
11
#!/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-2002 The Apache Software Foundation. All rights
19-
# reserved.
202

213
BASEDIR=`dirname $0`/..
224
BASEDIR=`(cd "$BASEDIR"; pwd)`
235

24-
25-
26-
# OS specific support. $var _must_ be set to either true or false.
27-
cygwin=false;
28-
darwin=false;
29-
case "`uname`" in
30-
CYGWIN*) cygwin=true ;;
31-
Darwin*) darwin=true
32-
if [ -z "$JAVA_HOME" ] ; then
33-
JAVA_HOME=`/usr/libexec/java_home`
34-
fi
35-
if [ -z "$JAVA_HOME" ] ; then
36-
JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`
37-
fi
38-
if [ -z "$JAVA_HOME" ] ; then
39-
if [ -z "$JAVA_VERSION" ] ; then
40-
JAVA_VERSION="CurrentJDK"
41-
else
42-
echo "Using Java version: $JAVA_VERSION"
43-
fi
44-
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home
45-
fi
46-
JAVACMD="$JAVA_HOME/bin/java"
47-
;;
48-
esac
49-
50-
if [ -z "$JAVA_HOME" ] ; then
51-
if [ -r /etc/gentoo-release ] ; then
52-
JAVA_HOME=`java-config --jre-home`
53-
fi
54-
fi
55-
56-
# For Cygwin, ensure paths are in UNIX format before anything is touched
57-
if $cygwin ; then
58-
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
59-
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
60-
fi
61-
62-
# If a specific java binary isn't specified search for the standard 'java' binary
63-
if [ -z "$JAVACMD" ] ; then
64-
if [ -n "$JAVA_HOME" ] ; then
65-
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
66-
# IBM's JDK on AIX uses strange locations for the executables
67-
JAVACMD="$JAVA_HOME/jre/sh/java"
68-
else
69-
JAVACMD="$JAVA_HOME/bin/java"
70-
fi
71-
else
72-
JAVACMD=`which java`
73-
fi
74-
fi
75-
76-
if [ ! -x "$JAVACMD" ] ; then
77-
echo "Error: JAVA_HOME is not defined correctly."
78-
echo " We cannot execute $JAVACMD"
79-
exit 1
80-
fi
81-
82-
if [ -z "$REPO" ]
6+
# if user has not explicitly set a command to use to invoke java, use 'java' and assume it is on the path
7+
if [ -z "$JAVACMD" ]
838
then
84-
REPO="$BASEDIR"/lib
9+
JAVACMD="java"
8510
fi
8611

87-
CLASSPATH=$CLASSPATH_PREFIX:"$BASEDIR"/etc:"$REPO"/*
88-
EXTRA_JVM_ARGUMENTS=""
12+
"$JAVACMD" $JAVA_OPTS \
13+
-Dapp.name="browsermob-proxy" \
14+
-Dbasedir="$BASEDIR" \
15+
-jar "$BASEDIR/lib/browsermob-dist-${project.version}.jar" \
16+
"$@"
8917

90-
# For Cygwin, switch paths to Windows format before running java
91-
if $cygwin; then
92-
[ -n "$CLASSPATH" ] && CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
93-
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
94-
[ -n "$HOME" ] && HOME=`cygpath --path --windows "$HOME"`
95-
[ -n "$BASEDIR" ] && BASEDIR=`cygpath --path --windows "$BASEDIR"`
96-
[ -n "$REPO" ] && REPO=`cygpath --path --windows "$REPO"`
18+
# if we couldn't find java, print a helpful error message
19+
if [ $? -eq 127 ]
20+
then
21+
echo
22+
echo "Unable to run java using command: $JAVACMD"
23+
echo "Make sure java is installed and on the path, or set JAVACMD to the java executable before running this script."
24+
echo
25+
echo "Example:"
26+
echo
27+
echo " $ JAVACMD=/var/lib/jdk/bin/java ./browsermob-proxy"
28+
echo
9729
fi
98-
99-
exec "$JAVACMD" $JAVA_OPTS \
100-
$EXTRA_JVM_ARGUMENTS \
101-
-classpath "$CLASSPATH" \
102-
-Dapp.name="browsermob-proxy" \
103-
-Dapp.pid="$$" \
104-
-Dapp.repo="$REPO" \
105-
-Dbasedir="$BASEDIR" \
106-
net.lightbody.bmp.proxy.Main \
107-
"$@"

0 commit comments

Comments
 (0)