forked from jessfraz/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.sh
executable file
·230 lines (199 loc) · 4.57 KB
/
bootstrap.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/usr/bin/env bash
set -e
set -o pipefail
# TODO: need to create a rule with powertop --auto-tune
base() {
apt update
apt -y upgrade
apt install -y --no-install-recommends \
alsa-utils \
arandr \
cmatrix \
compton \
curl \
feh \
git \
help2man \
i3 \
icdiff \
jq \
make \
neofetch \
neovim \
network-manager \
openvpn \
powertop \
rofi \
s3cmd \
scrot \
shellcheck \
terminator \
tig \
tlp \
tlp-rdw \
ttf-ancient-fonts \
wicd \
wicd-curses
apt autoremove
apt autoclean
apt clean
}
# installs docker master
install_docker() {
groupadd docker
gpasswd -a $USER docker
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
# zesty because artful (17.10) is no good for now
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
zesty \
stable"
apt update
apt install -y docker-ce
apt autoremove
apt autoclean
apt clean
}
install_docker_compose() {
local binary=/usr/local/bin/docker-compose
local version=1.18.0
curl -L https://github.com/docker/compose/releases/download/${version}/docker-compose-`uname -s`-`uname -m` -o ${binary}
chmod +x ${binary}
}
# install go from gophers repo
install_golang() {
export GO_VERSION
GO_VERSION=$(curl -sSL "https://golang.org/VERSION?m=text")
export GO_SRC=/usr/local/go
# if we are passing the version
if [[ ! -z "$1" ]]; then
GO_VERSION=$1
fi
# purge old src
if [[ -d "$GO_SRC" ]]; then
sudo rm -rf "$GO_SRC"
sudo rm -rf "$GOPATH"
fi
GO_VERSION=${GO_VERSION#go}
# subshell
(
curl -sSL "https://storage.googleapis.com/golang/go${GO_VERSION}.linux-amd64.tar.gz" | sudo tar -v -C /usr/local -xz
local user="$USER"
# rebuild stdlib for faster builds
sudo chown -R "${user}" /usr/local/go/pkg
CGO_ENABLED=0 $GO_SRC/bin/go install -a -installsuffix cgo std
ln -s $GO_SRC/bin/go /usr/local/bin/go
)
}
install_spotify() {
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DF731E45CE24F27EEEB1450EFDC8610341D9410
echo deb http://repository.spotify.com stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list
apt update
apt install -y spotify-client
}
# install custom scripts/binaries
install_scripts() {
# install speedtest
(
curl -sSL https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py > /usr/local/bin/speedtest
chmod +x /usr/local/bin/speedtest
)
# install lolcat
(
curl -sSL https://raw.githubusercontent.com/tehmaze/lolcat/master/lolcat > /usr/local/bin/lolcat
chmod +x /usr/local/bin/lolcat
)
# install light (need help2man which is installed in base)
(
git clone https://github.com/haikarainen/light.git /opt/light/
cd /opt/light
make && make install
)
}
install_kubectl() {
KUBERNETES_VERSION=$(curl -sSL https://storage.googleapis.com/kubernetes-release/release/stable.txt)
curl -sSL "https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl" > /usr/local/bin/kubectl
chmod +x /usr/local/bin/kubectl
}
install_vscode() {
local tmp_file=$(mktemp)
curl https://go.microsoft.com/fwlink/?LinkID=760868 -L --output $tmp_file
dpkg -i $tmp_file
rm $tmp_file
}
# symlink all the things
symlinks() {
ln -s ~/.dotfiles/.wallpaper ~/.wallpaper
}
die() { echo "$@" && exit 1}
check_is_sudo() { [ "$EUID" -ne 0 ] && die "please run as root"}
usage() {
echo -e "install.sh\\n\\tThis script installs my basic setup for a Ubuntu Minimal 17.10 laptop\\n"
echo "Usage:"
echo " all - do all of the things"
echo " base - install all the pkgs from apt"
echo " code - install vs code"
echo " docker - install docker"
echo " go - install golang"
echo " kube - install kubernetes things"
echo " scripts - install some cool scripts"
echo " spotify - install spotify"
echo " symlinks - link the config files"
}
main() {
local cmd=$1
if [[ -z "$cmd" ]]; then
usage
exit 1
fi
case $cmd in
all)
base
install_docker
install_golang
install_kubectl
install_scripts
install_spotify
symlinks
echo "Reboot and yipee kay yay!"
;;
base)
base
;;
code)
install_vscode
;;
docker)
install_docker
;;
docker-compose)
install_docker_compose
;;
go)
install_golang
;;
kube)
install_kubectl
;;
scripts)
install_scripts
;;
spotify)
install_spotify
;;
symlinks)
symlinks
;;
*)
usage
;;
esac
}
# must run this with sudo to do the thing with the thing
check_is_sudo
main "$@"