-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall
executable file
·64 lines (52 loc) · 1.51 KB
/
install
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
#!/bin/sh
set -euo pipefail
PRERELEASE=${PRERELEASE:-}
get_download_file_name() {
os=$1
file_name=aws-profile-macos
if [ "${os}" = "Linux" ]; then
file_name=aws-profile-linux
fi
echo ${file_name}
}
get_download_url() {
file_name=$1
if [ -z "${PRERELEASE}" ]; then
curl -s https://api.github.com/repos/hpcsc/aws-profile/releases/latest | \
grep browser_download_url | \
grep ${file_name} | \
cut -d '"' -f 4
else
artifactory_latest_version=$(curl -s https://hpcsc.jfrog.io/artifactory/aws-profile/latest-version)
echo "https://hpcsc.jfrog.io/artifactory/aws-profile/${artifactory_latest_version}/${file_name}"
fi
}
OS=$(uname -s)
if [ "${OS}" != "Darwin" ] && [ "${OS}" != "Linux" ]; then
echo "${OS} is not supported"
exit 1
fi
TMP_DIR=$(mktemp -d /tmp/aws-profile.XXXXXX)
TARGET_FILE="/usr/local/bin/aws-profile"
DOWNLOAD_FILE_NAME=$(get_download_file_name ${OS})
URL="$(get_download_url ${DOWNLOAD_FILE_NAME})"
if [ -e "${TARGET_FILE}" ]; then
echo "aws-profile exists at ${TARGET_FILE}, install anyway? (n/Y)"
read confirm_install
confirm_install=${confirm_install:-y}
if [ "${confirm_install}" = "n" ] || [ "${confirm_install}" = "N" ]; then
exit 0
fi;
fi
(
cd "$TMP_DIR"
echo "Downloading from ${URL}..."
curl -fL "${URL}" -o ${DOWNLOAD_FILE_NAME}
echo "Download complete!"
)
(
mv -vf "${TMP_DIR}/${DOWNLOAD_FILE_NAME}" "${TARGET_FILE}"
chmod +x "${TARGET_FILE}"
)
rm -rf "$TMP_DIR"
echo "aws-profile is installed successfully 🎉"