-
Notifications
You must be signed in to change notification settings - Fork 186
/
verify.sh
executable file
·70 lines (63 loc) · 2.42 KB
/
verify.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
#
# jmeter-ec2 - Install Script (Runs on remote ec2 server)
#
function install_jmeter_plugins() {
echo "Installing plugins..."
wget -q -O ~/JMeterPlugins-Extras.jar https://s3.amazonaws.com/jmeter-ec2/JMeterPlugins-Extras.jar
wget -q -O ~/JMeterPlugins-Standard.jar https://s3.amazonaws.com/jmeter-ec2/JMeterPlugins-Standard.jar
mv ~/JMeterPlugins*.jar ~/$JMETER_VERSION/lib/ext/
}
function install_java() {
echo "Updating apt-get..."
sudo apt-get -qqy update
echo "Installing java..."
sudo DEBIAN_FRONTEND=noninteractive apt-get -qqy install openjdk-7-jre
echo "Java installed"
}
function install_jmeter() {
# ------------------------------------------------
# Decide where to download jmeter from
#
# Order of preference:
# 1. S3, if we have a copy of the file
# 2. Mirror, if the desired version is current
# 3. Archive, as a backup
# ------------------------------------------------
if [ $(curl -sI https://s3.amazonaws.com/jmeter-ec2/$JMETER_VERSION.tgz | grep -c "403 Forbidden") -eq "0" ] ; then
# We have a copy on S3 so use that
echo "Downloading jmeter from S3..."
wget -q -O ~/$JMETER_VERSION.tgz https://s3.amazonaws.com/jmeter-ec2/$JMETER_VERSION.tgz
elif [ $(echo $(curl -s 'http://www.apache.org/dist/jmeter/binaries/') | grep -c "$JMETER_VERSION") -gt "0" ] ; then
# Nothing found on S3 but this is the current version of jmeter so use the preferred mirror to download
echo "downloading jmeter from a Mirror..."
wget -q -O ~/$JMETER_VERSION.tgz "http://www.apache.org/dyn/closer.cgi?filename=jmeter/binaries/$JMETER_VERSION.tgz&action=download"
else
# Fall back to the archive server
echo "Downloading jmeter from Apache Archive..."
wget -q -O ~/$JMETER_VERSION.tgz http://archive.apache.org/dist/jmeter/binaries/$JMETER_VERSION.tgz
fi
# Untar downloaded file
echo "Unpacking jmeter..."
tar -xf ~/$JMETER_VERSION.tgz
# install jmeter-plugins [http://code.google.com/p/jmeter-plugins/]
install_jmeter_plugins
echo "Jmeter installed"
}
JMETER_VERSION=$1
cd ~
# Java
if java -version 2>&1 >/dev/null | grep -q "java version" ; then
echo "Java is already installed"
else
install_java
fi
# JMeter
if [ ! -d "$JMETER_VERSION" ] ; then
# install jmeter
install_jmeter
else
echo "JMeter is already installed"
fi
# Done
echo "software installed"