This repository was archived by the owner on Jul 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-hub.sh
executable file
·96 lines (73 loc) · 1.77 KB
/
install-hub.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
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
goto_temp_dir() {
if [ ! -d .pullquester-temp ]; then
mkdir .pullquester-temp
fi
pushd .pullquester-temp > /dev/null
}
cleanup_temp_dir() {
popd > /dev/null
rm -r .pullquester-temp
}
install_go() {
local GOVERSION=1.4.1
echo Installing Go v$GOVERSION
curl -s -o go.tar.gz "https://storage.googleapis.com/golang/go$GOVERSION.darwin-amd64-osx10.8.tar.gz"
tar -C . -xzf go.tar.gz
cp -r ./go/* $GOROOT
echo Done!
}
ensure_GoRoot_dir() {
if [ -z "$GOROOT" ]; then
export GOROOT=$HOME/go
fi
echo GOROOT=$GOROOT
if [ ! -d $GOROOT ]; then
mkdir -p $GOROOT > /dev/null
fi
}
ensure_GoPath_dir() {
if [ -z "$GOPATH" ]; then
export GOPATH=$GOROOT/packages
fi
echo GOPATH=$GOPATH
if [ ! -d $GOPATH ]; then
mkdir -p $GOPATH > /dev/null
fi
}
ensure_Go_paths() {
ensure_GoRoot_dir
ensure_GoPath_dir
}
install_hub() {
echo Installing hub...
go get github.com/github/hub
go install github.com/github/hub
echo Done!
}
add_env_vars_to_profile() {
echo GOROOT=$GOROOT
echo GOPATH=$GOPATH
echo PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin
if [ -z "$( grep 'GOROOT=' ~/.profile )"]; then
echo GOROOT=$GOROOT >> ~/.profile
fi
if [ -z "$( grep 'GOPATH=' ~/.profile )"]; then
echo GOPATH=$GOPATH >> ~/.profile
fi
if [ -z "$( grep '=\$PATH:\$GOROOT/bin:\$GOPATH/bin' ~/.profile )"]; then
echo PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin >> ~/.profile
fi
}
ensure_temp_dir
# check for go installation
ensure_Go_paths
if [ -z "$(which go)" ]; then
install_go
fi
#check for package storage location
ensure_GoPath_dir
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
install_hub
add_env_vars_to_profile
cleanup_temp_dir