-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·67 lines (53 loc) · 1.92 KB
/
install.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
#!/bin/bash -e
function stderr() {
>&2 echo "$1"
}
function error() {
stderr "Error: $1"
exit 1
}
function info() {
stderr "Info: $1"
}
function main() {
info "Finding latest version..."
latest_version="$(curl --silent --header 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/isotoma/aws-sso-auth/releases | grep tag_name | head -n 1 | sed -e 's/.*:\s*//' -e 's/^"//' -e 's/",\?$//')"
platform_uname="$(uname -s)"
case "$platform_uname" in
Linux*)
platform=linux
;;
Darwin*)
platform=mac
;;
*)
error "Unknown platform: $platform_uname"
;;
esac
info "Downloading to temporary directory..."
download_url="https://github.com/isotoma/aws-sso-auth/releases/download/$latest_version/aws-sso-auth-$platform"
tmp_dir="$(mktemp -d -t aws-sso-auth-XXXXXXXX)"
tmp_download_path="$tmp_dir/aws-sso-auth"
curl --silent --location "$download_url" --output "$tmp_download_path"
target_directory_path="/usr/local/bin/aws-sso-auth"
info "Will install aws-sso-auth executable version=$latest_version, platform=$platform to $target_directory_path"
info " Downloaded from: $download_url"
info " MD5 checksum: $(md5sum $tmp_download_path || echo unknown)"
read -p "Are you sure (y/N)? " -r
if [[ ! $REPLY =~ ^(Y|y|yes)$ ]]
then
rm -rf "$tmp_dir"
error "Not confirmed, exiting"
fi
info "Installing..."
install -T "$tmp_download_path" "$target_directory_path" || {
info "Trying again with sudo..."
sudo install -T --owner=root --group=root "$tmp_download_path" "$target_directory_path"
}
rm -rf "$tmp_dir"
info "Installation succeeded, checking if on PATH using 'which aws-sso-auth'"
which aws-sso-auth
info "And checking installed version using 'aws-sso-auth version'"
aws-sso-auth version
}
main