-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall_imposter.sh
executable file
·101 lines (86 loc) · 2.49 KB
/
install_imposter.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
# Copyright © 2021 Pete Cornish <[email protected]>
#
# 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.
# Imposter CLI installation
# See: https://github.com/imposter-project/imposter-cli
set -e
BASE_URL="https://github.com/imposter-project/imposter-cli/releases"
function unsupported_arch() {
echo "This OS/architecture is unsupported."
exit 1
}
function is_macos() {
case "$(uname -s)" in
*darwin* ) true ;;
*Darwin* ) true ;;
* ) false;;
esac
}
function is_linux() {
case "$(uname -s)" in
*Linux* ) true ;;
*linux* ) true ;;
* ) false;;
esac
}
function find_arch() {
if is_macos; then
case "$(uname -m)" in
*i386* ) IMPOSTER_ARCH="amd64" ;;
*x86_64* ) IMPOSTER_ARCH="amd64" ;;
*arm64* ) IMPOSTER_ARCH="arm64" ;;
* ) unsupported_arch;;
esac
else
case "$(uname -m)" in
*i686* ) IMPOSTER_ARCH="amd64" ;;
*x86_64* ) IMPOSTER_ARCH="amd64" ;;
*armv6* ) IMPOSTER_ARCH="arm" ;;
*armv7* ) IMPOSTER_ARCH="arm" ;;
*arm64* ) IMPOSTER_ARCH="arm64" ;;
*aarch64* ) IMPOSTER_ARCH="arm64" ;;
* ) unsupported_arch;;
esac
fi
}
function find_os() {
if is_macos; then
IMPOSTER_OS="darwin"
elif is_linux; then
IMPOSTER_OS="linux"
else
unsupported_arch
fi
}
function set_download_url() {
local BINARY_NAME="imposter-cli_${IMPOSTER_OS}_${IMPOSTER_ARCH}.tar.gz"
if [[ -z "${IMPOSTER_CLI_VERSION}" ]]; then
echo "Using latest version..."
DOWNLOAD_URL="${BASE_URL}/latest/download/${BINARY_NAME}"
else
echo "Using version: ${IMPOSTER_CLI_VERSION}"
DOWNLOAD_URL="${BASE_URL}/download/v${IMPOSTER_CLI_VERSION}/${BINARY_NAME}"
fi
}
find_os
find_arch
set_download_url
IMPOSTER_TEMP_DIR="$( mktemp -d /tmp/imposter-cli.XXXXXXX )"
cd "${IMPOSTER_TEMP_DIR}"
echo -e "\nDownloading from ${DOWNLOAD_URL}"
curl --fail -L -o imposter-cli.tar.gz "${DOWNLOAD_URL}"
tar xf imposter-cli.tar.gz
echo -e "\nInstalling to /usr/local/bin"
cp ./imposter /usr/local/bin/imposter
echo -e "\nDone"