-
Notifications
You must be signed in to change notification settings - Fork 6
/
essentials.sh
executable file
·379 lines (342 loc) · 9.18 KB
/
essentials.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#!/bin/bash
# This script helps in installing the essential installation packages
# for majorly Ubuntu systems
#
# Download using curl:
# $ curl -fsSL https://bit.ly/ubuntu-essentials -o essentials.sh
#
# Download using wget:
# $ wget https://raw.githubusercontent.com/bhumijgupta/Install-Essentials/master/essentials.sh
#
# Running the script:
# $ bash essentials.sh
#
# Supported command line arguments
# --cli Show only CLI packages
# help Show help message
#
# ***************
# Utils
# ***************
print_colored() {
COLOR_PREFIX="\033[0;"
GREEN="32m"
RED="31m"
GREY="37m"
INFO="96m"
NO_COLOR="\033[0m"
if [ "$2" == "danger" ]; then
COLOR="${COLOR_PREFIX}${RED}"
elif [ "$2" == "success" ]; then
COLOR="${COLOR_PREFIX}${GREEN}"
elif [ "$2" == "debug" ]; then
COLOR="${COLOR_PREFIX}${GREY}"
elif [ "$2" == "info" ]; then
COLOR="${COLOR_PREFIX}${INFO}"
else
COLOR="${NO_COLOR}"
fi
printf "${COLOR}%b${NO_COLOR}\n" "$1"
}
show_help() {
print_colored "Invalid command-line argument" "danger"
print_colored "You can pass --cli flag to view only cli packages" "info"
exit 1
}
invalid_input(){
print_colored "Invalid input..." "danger"
}
APT_GET_DIR=$(which apt-get)
ONLY_CLI=false
if [ "$1" == "--cli" ]; then
ONLY_CLI=true
fi
if [ "$#" -gt 1 ] || [ "$1" != "--cli" ]; then
show_help
fi
sudo true
# ***************
# Check Compatibility
# ***************
print_colored "Checking Compatibility" ""
if [ -z "$APT_GET_DIR" ]; then
print_colored "Compatibility check failed. Cannot find apt-get." "danger"
print_colored "Exiting" "danger"
exit 1
else
print_colored "Compatibilty check passed" "success"
fi
# ***************
# Ask permissions
# ***************
read -r -p $'\nUpgrade existing packages? [Y/n] ' upgrade_packages
upgrade_packages=${upgrade_packages:-Y}
read -r -p $'\nInstall git? [Y/n] ' install_git
install_git=${install_git:-Y}
read -r -p $'\nInstall pip for python 3? [Y/n] ' install_pip3
install_pip3=${install_pip3:-Y}
read -r -p $'\nInstall C/C++ compiler? [Y/n] ' install_gcc
install_gcc=${install_gcc:-Y}
if [ "$ONLY_CLI" == false ]; then
read -r -p $'\nInstall Chrome? [Y/n] ' install_chrome
else
install_chrome=n
fi
install_chrome=${install_chrome:-Y}
if [ "$ONLY_CLI" == false ]; then
read -r -p $'\nInstall Spotify? [Y/n] ' install_spotify
else
install_spotify=n
fi
install_spotify=${install_spotify:-Y}
if [ "$ONLY_CLI" == false ]; then
read -r -p $'\nInstall VSCode? [Y/n] ' install_code
else
install_code=n
fi
install_code=${install_code:-Y}
if [ "$ONLY_CLI" == false ]; then
read -r -p $'\nInstall Postman? [Y/n] ' install_postman
else
install_postman=n
fi
install_postman=${install_postman:-Y}
read -r -p $'\nInstall MongoDB? [Y/n] ' install_mongodb
install_mongodb=${install_mongodb:-Y}
read -r -p $'\nInstall NodeJS? [Y/n] ' install_nodejs
install_nodejs=${install_nodejs:-Y}
if [ "$ONLY_CLI" == false ]; then
read -r -p $'\nInstall VLC? [Y/n] ' install_vlc
else
install_vlc=n
fi
install_vlc=${install_vlc:-Y}
read -r -p $'\nInstall Terminator? [Y/n] ' install_terminator
install_terminator=${install_terminator:-Y}
read -r -p $'\nInstall Docker? [Y/n] ' install_docker
install_docker=${install_docker:-Y}
read -r -p $'\nInstall Docker Compose? [Y/n] ' install_docker_compose
install_docker_compose=${install_docker_compose:-Y}
print_colored "Updating Package List" "success"
sudo apt update -y
case $upgrade_packages in
[yY][eE][sS]|[yY])
print_colored "Upgrading Packages" "success"
sudo apt install git -y
;;
[nN][oO]|[nN])
print_colored "Skipping package updation" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_git in
[yY][eE][sS]|[yY])
print_colored "Installing git" "success"
sudo apt install git -y
;;
[nN][oO]|[nN])
print_colored "Skipping git" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_pip3 in
[yY][eE][sS]|[yY])
print_colored "Installing pip3" "success"
sudo apt install python3-pip -y
;;
[nN][oO]|[nN])
print_colored "Skipping pip3" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_gcc in
[yY][eE][sS]|[yY])
print_colored "Installing C/C++ compiler" "success"
sudo apt install build-essential manpages-dev -y
;;
[nN][oO]|[nN])
print_colored "Skipping C/C++ compiler" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_chrome in
[yY][eE][sS]|[yY])
print_colored "Installing Chrome" "success"
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
print_colored "Cleaning up" "info"
rm google-chrome-stable_current_amd64.deb
;;
[nN][oO]|[nN])
print_colored "Skipping Chrome" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_spotify in
[yY][eE][sS]|[yY])
print_colored "Installing Spotify" "success"
sudo snap install spotify
;;
[nN][oO]|[nN])
print_colored "Skipping Spotify" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_code in
[yY][eE][sS]|[yY])
print_colored "Installing VSCode" "success"
sudo snap install --classic code
read -r -p $'\nInstall VSCode recommended extensions ? [Y/n] ' input
input=${input:-Y}
case $input in
[yY][eE][sS]|[yY])
print_colored "Installing extensions" "success"
code --install-extension christian-kohler.path-intellisense --user-data-dir="~/.vscode-root"
code --install-extension CoenraadS.bracket-pair-colorizer --user-data-dir="~/.vscode-root"
code --install-extension esbenp.prettier-vscode --user-data-dir="~/.vscode-root"
;;
[nN][oO]|[nN])
print_colored "Skipping extensions" "debug"
;;
*)
invalid_input
exit 1
;;
esac
;;
[nN][oO]|[nN])
print_colored "Skipping VSCode" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_postman in
[yY][eE][sS]|[yY])
print_colored "Installing Postman" "success"
sudo snap install postman
;;
[nN][oO]|[nN])
print_colored "Skipping Postman" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_mongodb in
[yY][eE][sS]|[yY])
print_colored "Installing MongoDB" "success"
sudo apt-get install gnupg -y
# TODO: find a way to stay at latest version
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -
printf "\ndeb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
print_colored "Starting MongoDB" "info"
sudo service mongod start
;;
[nN][oO]|[nN])
print_colored "Skipping MongoDB" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_nodejs in
[yY][eE][sS]|[yY])
print_colored "Installing NodeJS" "success"
sudo apt install curl -y
# TODO: find a way to stay at latest version
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt install nodejs -y
;;
[nN][oO]|[nN])
print_colored "Skipping NodeJS" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_vlc in
[yY][eE][sS]|[yY])
print_colored "Installing VLC" "success"
sudo snap install vlc
;;
[nN][oO]|[nN])
print_colored "Skipping VLC" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_terminator in
[yY][eE][sS]|[yY])
print_colored "Installing Terminator" "success"
sudo apt-get install terminator -y
;;
[nN][oO]|[nN])
print_colored "Skipping Terminator" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_docker in
[yY][eE][sS]|[yY])
print_colored "Installing Docker" "success"
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo usermod -aG docker "$USER"
print_colored "To use Docker as a non-root user, you will have to log out and back in." "success"
rm get-docker.sh
;;
[nN][oO]|[nN])
print_colored "Skipping Docker" "debug"
;;
*)
invalid_input
exit 1
;;
esac
case $install_docker_compose in
[yY][eE][sS]|[yY])
print_colored "Installing Docker Compose" "success"
# source: https://gist.github.com/wdullaer/f1af16bd7e970389bad3
COMPOSE_VERSION=$(git ls-remote https://github.com/docker/compose | grep refs/tags | grep -oE "[0-9]+\.[0-9][0-9]+\.[0-9]+$" | sort --version-sort | tail -n 1)
sudo curl -L "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo sh -c "curl -L https://raw.githubusercontent.com/docker/compose/${COMPOSE_VERSION}/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose"
;;
[nN][oO]|[nN])
print_colored "Skipping Docker Compose" "debug"
;;
*)
invalid_input
exit 1
;;
esac
# google-chrome https://www.mongodb.com/download-center/compass?jmp=docs