-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·53 lines (44 loc) · 1.38 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
#!/usr/bin/env bash
set -e
get_arch() {
a=$(uname -m)
case ${a} in
"x86_64" | "amd64" )
echo "amd64"
;;
"i386" | "i486" | "i586")
echo "386"
;;
*)
echo ${NIL}
;;
esac
}
get_os(){
echo $(uname -s | awk '{print tolower($0)}')
}
main() {
local os=$(get_os)
local arch=$(get_arch)
local dest_file="${HOME}/g1.1.0.${os}-${arch}.tar.gz"
local url="https://github.com/voidint/g/releases/download/v1.1.0/g1.1.0.${os}-${arch}.tar.gz"
echo "[1/3] Download ${url}"
rm -f ${dest_file}
wget -q -P "${HOME}" "${url}"
chmod +x ${dest_file}
echo "[2/3] Install g to the ${HOME}/bin"
mkdir -p "${HOME}/bin"
tar -xz -f ${dest_file} -C ${HOME}/bin
chmod +x ${HOME}/bin/g
echo "[3/3] Set environment variables"
echo '# ===== set g environment variables =====' >> ${HOME}/.bashrc
echo 'export GOROOT="${HOME}/.g/go"' >> ${HOME}/.bashrc
echo 'export PATH="${HOME}/bin:${HOME}/.g/go/bin:$PATH"' >> ${HOME}/.bashrc
echo 'export G_MIRROR=https://golang.google.cn/dl/' >> ${HOME}/.bashrc
echo '# ===== set g environment variables =====' >> ${HOME}/.zshrc
echo 'export GOROOT="${HOME}/.g/go"' >> ${HOME}/.zshrc
echo 'export PATH="${HOME}/bin:${HOME}/.g/go/bin:$PATH"' >> ${HOME}/.zshrc
echo 'export G_MIRROR=https://golang.google.cn/dl/' >> ${HOME}/.zshrc
exit 0
}
main