-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·71 lines (64 loc) · 1.25 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
68
69
70
71
#!/usr/bin/env bash
# error codes
# 0 - exited without problems
# 1 - OS or ARCH not supported by this script
set -e
# detect OS
OS="$(uname)"
case $OS in
Linux)
OS='linux'
;;
Darwin)
OS='darwin'
;;
*)
echo 'OS not supported'
exit 1
;;
esac
# detect ARCH
ARCH="$(uname -m)"
case "$ARCH" in
x86_64 | amd64)
ARCH='amd64'
;;
aarch64 | arm64)
ARCH='arm64'
;;
*)
echo 'ARCH not supported'
exit 1
;;
esac
# download
download_link="https://static.nextbillion.io/tools/gsg/latest/${OS}-${ARCH}/gsg?$(date +%s)"
echo downloading from "$download_link"
curl "$download_link" >gsg
# mounting to environment
case "$OS" in
'linux')
downlod_path="/usr/bin/gsg"
mv -f gsg "$downlod_path"
chmod 755 "$downlod_path"
chown root:root "$downlod_path"
gsg version
;;
'darwin')
downlod_path="$HOME/.gsg/bin/gsg"
mkdir -p "$HOME/.gsg/bin"
mv -f gsg "$downlod_path"
chmod 755 "$downlod_path"
printf "\nPlease add:\n"
printf "export PATH=\"\$HOME/.gsg/bin:\$PATH\""
printf "\ninto your bash profile, e.g., .bash_profile/.zshrc, etc.\n"
;;
*)
echo 'OS not supported'
exit 1
;;
esac
# display instructions of installation
printf "\nSuccessfully installed!\n"
printf 'Remember to set GOOGLE_APPLICATION_CREDENTIALS env to use gsg.\n\n'
exit 0