Skip to content

Commit 841d33e

Browse files
tommysitubenjih
authored andcommitted
Add error checking for get hoverfly script, remove hardcoded version, get latest release version
1 parent ee7c480 commit 841d33e

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

get_hoverfly.sh

Lines changed: 0 additions & 20 deletions
This file was deleted.

scripts/get_hoverfly_for_linux.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
HOVERFLY_VERSION=$(curl -s https://api.github.com/repos/spectolabs/hoverfly/releases/latest | grep tag_name | sed -n 's/.*"tag_name": "\(.*\)",/\1/p')
4+
if [[ $? == 1 ]]; then
5+
error_exit "Failed to get latest release version"
6+
fi
7+
8+
HOVERFLY_DOWNLOAD_URL=https://github.com/SpectoLabs/hoverfly/releases/download/${HOVERFLY_VERSION}
9+
10+
11+
# Download distribution package for Linux
12+
machine_type=$(uname -m)
13+
if [[ ${machine_type} == "x86_64" ]]; then
14+
asset_name=hoverfly_bundle_linux_amd64.zip
15+
else
16+
asset_name=hoverfly_bundle_linux_386.zip
17+
fi
18+
19+
wget -O /tmp/hoverfly.zip ${HOVERFLY_DOWNLOAD_URL}/${asset_name}
20+
if [[ $? == 1 ]]; then
21+
error_exit "Failed to download hoverfly release package"
22+
fi
23+
24+
# Unzip and copy to PATH
25+
unzip -d /tmp/hoverfly /tmp/hoverfly.zip
26+
sudo cp /tmp/hoverfly/hoverfly /usr/local/bin/
27+
sudo cp /tmp/hoverfly/hoverctl /usr/local/bin/
28+
29+
30+
# An error exit function
31+
function error_exit
32+
{
33+
echo "$1" 1>&2
34+
exit 1
35+
}

0 commit comments

Comments
 (0)