-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
86 lines (72 loc) · 1.87 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
GOO_PATH="${HOME}/.goo"
abort() {
printf "%s \n" "$@"
exit 1
}
MkDirIfNotExist() {
for d in "$@"; do
if [ ! -d "$d" ]; then
mkdir -p "$d"
fi
done
}
Download() {
GOO_DOWNLOAD_URL="$(curl -H "Accept: application/vnd.github.v3+json" -s https://api.github.com/repos/goo-app/cli/releases/latest | grep "browser_download_url.*${GOO_NAME}" | cut -d : -f 2,3 | tr -d \")"
curl -o "${GOO_PATH}/apps/goo/current/goo" "$GOO_DOWNLOAD_URL"
}
Prepare() {
if [ -d "$GOO_PATH" ]; then
abort "Goo is already installed"
fi
MkDirIfNotExist "$GOO_PATH" "$GOO_PATH/bin" "$GOO_PATH/apps/goo/current" "$GOO_PATH/tmp" "$GOO_PATH/repos"
}
Install() {
Download
cd "${HOME}/.goo/bin" || ln -s "../apps/goo/current/goo" goo
PATH="${HOME}/.goo/bin:$PATH"
goo init
}
InstallLinux() {
Prepare
UNAME_MACHINE="$(uname -m)"
if [[ "${UNAME_MACHINE}" == "arm64" ]]; then
GOO_NAME="goo_linux_arm64"
elif [[ "${UNAME_MACHINE}" == "x86_64" ]]; then
GOO_NAME="goo_linux_amd64"
elif [[ "${UNAME_MACHINE}" == "i386" ]]; then
GOO_NAME="goo_linux_386"
else
abort "Unsupported architecture: ${UNAME_MACHINE}"
fi
Install
echo "export GOO_PATH=\${HOME}/.goo" >> ~/.bashrc
echo "export PATH=\${GOO_PATH}/bin:\$PATH" >> ~/.bashrc
}
InstallDarwin() {
Prepare
UNAME_MACHINE="$(uname -m)"
if [[ "${UNAME_MACHINE}" == "arm64" ]]; then
GOO_NAME="goo_darwin_arm64"
else
GOO_NAME="goo_darwin_amd64"
fi
Install
echo "export GOO_PATH=\${HOME}/.goo" >> ~/.zshrc
echo "export PATH=\${GOO_PATH}/bin:\$PATH" >> ~/.zshrc
}
if [ -z "${BASH_VERSION:-}" ]; then
abort "Bash is required to interpret this script"
fi
if [[ ! -t 0 || -n "${CI-}" ]]
then
NONINTERACTIVE=1
fi
OS="$(uname)"
if [[ "${OS}" == "Linux" ]]; then
InstallLinux
elif [[ "${OS}" == "Darwin" ]]; then
InstallDarwin
else
abort "Goo supports only macOS, Linux and Windows!"
fi