-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·548 lines (505 loc) · 20.5 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
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
#!/bin/bash
#
# install-ubuntu-dev.sh - Tux4Ubuntu Installer
#
# Copyright (C) 2017 Tux4Ubuntu Initiative <http://tux4ubuntu.blogspot.com>
#
# Permission is hereby granted, free of charge,
# to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to
# deal in the Software without restriction, including
# without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom
# the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice
# shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Written and designed by: Tuxedo Joe <http://github.com/tuxedojoe>
# for The Tux4Ubuntu Initiative <http://tux4ubuntu.blogspot.com>
#
# For CREDITS AND ATTRIBUTION see README
# Change directory to same as script is running in
cd "$(dirname "$0")"
# Adds error handling by exiting at first error
set -e
# Cleans the screen
printf "\033c"
# Set global values
STEPCOUNTER=false # Sets to true if user choose to install Tux Everywhere
OS_VERSION="";
# Here we check if OS is supported
# More info on other OSes regarding plymouth: http://brej.org/blog/?p=158
YELLOW='\033[1;33m'
LIGHT_GREEN='\033[1;32m'
LIGHT_RED='\033[1;31m'
NC='\033[0m' # No Color
function install_chromium {
printf "\033c"
package_name="Chrome/Chromium"
header "Installing ${package_name^^}" "$1"
if ask_install "Chrome (Chromium is up next)"; then
check_sudo
sudo apt-get install libxss1 libappindicator1 libindicator7
wget -P /tmp/chrome-install/ https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i /tmp/chrome-install/google-chrome*.deb
echo ""
printf "${LIGHT_GREEN}Successfully installed Chrome${NC}\n"
fi
if ask_install "Chromium"; then
check_sudo
install_if_not_found "chromium-browser"
sudo update-alternatives --config x-www-browser
printf "${LIGHT_GREEN}Successfully installed $package_name${NC}\n"
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function install_vsc {
printf "\033c"
package_name="Visual Studio Code"
header "Installing ${package_name^^}" "$1"
if ask_install "$package_name"; then
check_sudo
install_if_not_found "curl"
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /tmp/microsoft.gpg
sudo mv /tmp/microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update || true
sudo apt-get install code # or code-insiders
printf "${LIGHT_GREEN}Successfully installed $package_name${NC}\n"
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function install_gimp {
printf "\033c"
package_name="GIMP Edge"
header "Installing ${package_name^^}" "$1"
if ask_install "$package_name"; then
check_sudo
sudo add-apt-repository ppa:otto-kesselgulasch/gimp-edge
echo "Updating package list..."
sudo apt update || true
install_if_not_found "gimp gimp-gmic"
printf "${LIGHT_GREEN}Successfully installed $package_name${NC}\n"
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function install_git_and_ssh_keys {
printf "\033c"
package_name="GIT + SSH keys"
header "Installing ${package_name^^}" "$1"
if ask_install "$package_name"; then
check_sudo
install_if_not_found "git xclip"
echo "Enter your GIT username:"
read username
git config --global user.name "$username"
echo "To set up GIT you need to enter a username and an email adress (preferably yours, but not necessarily)."
echo "Enter your GIT e-mail:"
read email_id
git config --global user.email "$email_id"
if [ ! -f ~/.ssh/id_rsa ]; then
echo -ne '\n' | ssh-keygen || true
else
echo "~/.ssh/id_rsa already exists. Will use that one."
fi
ssh-add ~/.ssh/id_rsa || true
ssh -T git@github.com || true
xclip -sel clip < ~/.ssh/id_rsa.pub || true
printf "${LIGHT_GREEN}Successfully installed $package_name${NC}\n"
echo "Successfully installed GIT and ssh keys."
echo ""
echo "Your public ssh key is now copied to your clipboard."
echo "Paste it (Ctrl + V) to your bitbucket/github account for ssh connection."
echo ""
echo "Once you done that, run: "
echo " - 'ssh -T git@github.com' to add github to known hosts"
echo " - 'ssh -T git@bitbucket.org' to add bitbucket to known hosts."
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function install_amazon_cli {
printf "\033c"
package_name="Amazon CLI"
header "Installing ${package_name^^}" "$1"
if ask_install "$package_name"; then
check_sudo
echo "Updating package list..."
sudo apt-get update || true
install_if_not_found "python3-pip"
sudo pip3 install --upgrade pip
sudo pip3 install --upgrade --user awscli
echo ""
printf "${LIGHT_GREEN}Successfully installed $package_name${NC}\n"
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function install_tilda {
printf "\033c"
package_name="Tilda (Drop-down terminal - F1)"
header "Installing ${package_name^^}" "$1"
if ask_install "$package_name"; then
check_sudo
sudo apt install tilda
echo "Adding tilda to 'Startup applications'"
if [ ! -f ~/.config/autostart/tilda.desktop ]; then
mkdir ~/.config/autostart || true
sudo cp tilda.desktop ~/.config/autostart/tilda.desktop
else
echo "~/.config/autostart/tilda.desktop already exists. It will autostart."
fi
/usr/bin/tilda &
sleep 2
echo ""
printf "${LIGHT_GREEN}Successfully installed $package_name${NC}\n"
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function uninstall {
while :
do
clear
printf "\033c"
# Menu system as found here: http://stackoverflow.com/questions/20224862/bash-script-always-show-menu-after-loop-execution
printf "╔══════════════════════════════════════════════════════════════════════════════╗\n"
printf "║ ${LIGHT_RED}TUX DEVTOOLS - UNINSTALLER${NC} © 2018 Tux4Ubuntu ║\n"
printf "║ Let's Pause Tux a Bit https://tux4ubuntu.org ║\n"
printf "╠══════════════════════════════════════════════════════════════════════════════╣\n"
cat<<EOF
║ ║
║ What do you wanna uninstall? (Type in one of the following numbers) ║
║ ║
║ A) All of it - Uninstall all of the below ║
║ ------------------------------------------------------------------------ ║
║ 1) Chrome/Chromium ║
║ 2) Visual Studio Code ║
║ 3) GIMP Edge ║
║ 4) GIT + SSH keys ║
║ 5) Tilda ║
║ ------------------------------------------------------------------------ ║
║ I) Back to installing - Go back to installer ║
║ ------------------------------------------------------------------------ ║
║ Q) I'm done - Quit the installer (Ctrl+C) ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝
EOF
read -n1 -s
case "$REPLY" in
"A") # Uninstall everything
STEPCOUNTER=true
i=1
uninstall_chromium $i
((i++))
uninstall_vsc $i
((i++))
uninstall_gimp $i
((i++))
uninstall_git_and_ssh_keys $i
((i++))
# uninstall_amazon_cli $i
# ((i++))
uninstall_tilda $i
;;
"a") # Uninstall everything
STEPCOUNTER=true
i=1
uninstall_chromium $i
((i++))
uninstall_vsc $i
((i++))
uninstall_gimp $i
((i++))
uninstall_git_and_ssh_keys $i
((i++))
# uninstall_amazon_cli $i
# ((i++))
uninstall_tilda $i
;;
"1") uninstall_chromium ;;
"2") uninstall_vsc ;;
"3") uninstall_gimp ;;
"4") uninstall_git_and_ssh_keys;;
"5") uninstall_tilda ;;
"I") break ;;
"i") break ;;
"Q") exit ;;
"q") exit ;;
* ) echo "That's an invalid option. Try again." ;;
esac
sleep 1
done
}
function uninstall_chromium {
printf "\033c"
package_name="Chrome/Chromium"
header "Uninstalling ${package_name^^}" "$1"
if ask_uninstall "Chrome (Chromium is up next)"; then
check_sudo
sudo apt-get remove google-chrome-stable || true
sudo rm -r ~/.config/google-chrome || true
echo ""
printf "${LIGHT_GREEN}Successfully uninstalled Chrome${NC}\n"
fi
if ask_uninstall "Chromium"; then
check_sudo
uninstall_if_found "chromium-browser"
sudo rm -r ~/.config/chromium-browser || true
echo ""
printf "${LIGHT_GREEN}Successfully uninstalled Chromium${NC}\n"
sudo update-alternatives --config x-www-browser
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function uninstall_vsc {
printf "\033c"
package_name="Visual Studio Code"
header "Uninstalling ${package_name^^}" "$1"
if ask_uninstall "$package_name"; then
check_sudo
sudo apt-get purge code || true
echo ""
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function uninstall_gimp {
printf "\033c"
package_name="GIMP Edge"
header "Uninstalling ${package_name^^}" "$1"
if ask_uninstall "$package_name"; then
check_sudo
install_if_not_found "ppa-purge"
sudo ppa-purge ppa:otto-kesselgulasch/gimp-edge || true
uninstall_if_found "gimp gimp-gmic"
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function uninstall_git_and_ssh_keys {
printf "\033c"
package_name="GIT + SSH keys"
header "Uninstalling ${package_name^^}" "$1"
if ask_uninstall "GIT (SSH keys is up next)"; then
uninstall_if_found "git"
fi
if ask_uninstall "SSH keys"; then
sudo rm ~/.ssh/id_rsa
sudo rm ~/.ssh/id_rsa.pub
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function uninstall_amazon_cli {
printf "\033c"
package_name="Amazon CLI"
header "Uninstalling ${package_name^^}" "$1"
if ask_uninstall "$package_name"; then
sudo pip3 uninstall awscli
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function uninstall_tilda {
printf "\033c"
package_name="Tilda (Drop-down terminal)"
header "Uninstalling ${package_name^^}" "$1"
if ask_uninstall "$package_name"; then
uninstall_if_found "tilda"
echo "Removing Tilda from 'Startup applications'"
sudo rm ~/.config/autostart/tilda.desktop || true
fi
echo ""
read -n1 -r -p "Press any key to continue..." key
}
function check_sudo {
if sudo -n true 2>/dev/null; then
:
else
echo "Oh, and Tux will need sudo rights to copy and install everything, so he'll ask"
echo "about that below."
echo ""
fi
}
function install_if_not_found {
# As found here: http://askubuntu.com/questions/319307/reliably-check-if-a-package-is-installed-or-not
for pkg in $1; do
if dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
echo -e "$pkg is already installed"
else
printf "${YELLOW}Installing $pkg.${NC}\n"
if sudo apt-get -qq --allow-unauthenticated install $pkg; then
printf "${YELLOW}Successfully installed $pkg${NC}\n"
else
printf "${LIGHT_RED}Error installing $pkg${NC}\n"
fi
fi
done
}
function uninstall_if_found {
# As found here: http://askubuntu.com/questions/319307/reliably-check-if-a-package-is-installed-or-not
for pkg in $1; do
if dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
echo "Uninstalling $pkg."
if sudo apt-get remove $pkg; then
printf "${YELLOW}Successfully uninstalled $pkg${NC}\n"
else
printf "${LIGHT_RED}Error uninstalling $pkg${NC}\n"
fi
else
printf "${LIGHT_RED}$pkg is not installed${NC}\n"
fi
done
}
function header {
var_size=${#1}
# 80 is a full width set by us (to work in the smallest standard terminal window)
if [ $STEPCOUNTER = false ]; then
# 80 - 2 - 1 = 77 to allow space for side lines and the first space after border.
len=$(expr 77 - $var_size)
else
# "Step X/X " is 9
# 80 - 2 - 1 - 9 = 68 to allow space for side lines and the first space after border.
len=$(expr 68 - $var_size)
fi
ch=' '
echo "╔══════════════════════════════════════════════════════════════════════════════╗"
printf "║"
printf " ${YELLOW}$1${NC}"
printf '%*s' "$len" | tr ' ' "$ch"
if [ $STEPCOUNTER = true ]; then
printf "Step "${LIGHT_GREEN}$2${NC}
printf "/5 "
fi
printf "║\n"
echo "╚══════════════════════════════════════════════════════════════════════════════╝"
echo ""
}
function ask_install {
printf "Just double checking, you want to install $1?\n\n"
echo "(Type 1 or 2, then press ENTER)"
select yn in "Yes" "No"; do
case $yn in
Yes )
return 0
break;;
No )
echo "Okay, skipping $1."
return 1
break;;
esac
done
}
function ask_uninstall {
printf "Do you really want to uninstall $1?\n\n"
echo "(Type 1 or 2, then press ENTER)"
select yn in "Yes" "No"; do
case $yn in
Yes )
return 0
break;;
No )
echo "Okay, leaving $1 as it is."
return 1
break;;
esac
done
}
function tux_installer {
# Local/Github folder (comment out the other one if you're working locally)
../tux-install-master/tux4ubuntu-menu.sh
#~/Projects/Tux4Ubuntu/src/tux-desktop-theme/install.sh $1
}
while :
do
clear
# Menu system as found here: http://stackoverflow.com/questions/20224862/bash-script-always-show-menu-after-loop-execution
printf "╔══════════════════════════════════════════════════════════════════════════════╗\n"
printf "║ ${YELLOW}TUX DEVTOOLS ver 1.2${NC} © 2018 Tux4Ubuntu ║\n"
printf "║ Let's Bring TUX's Tools to Ubuntu https://tux4ubuntu.org ║\n"
printf "╠══════════════════════════════════════════════════════════════════════════════╣\n"
cat<<EOF
║ ║
║ What TUX developer tools do you want installed? (Press its number) ║
║ ║
║ A) All of it - Install all of the below ║
║ ------------------------------------------------------------------------ ║
║ 1) Chrome/Chromium - Adds another browser ║
║ 2) Visual Studio Code - Great free editor ║
║ 3) GIMP Edge - Newest version of GIMP ║
║ 4) GIT + SSH keys - Version handling ║
║ 5) Tilda - Drop-down terminal (F1) ║
║ ------------------------------------------------------------------------ ║
║ U) Uninstall - Uninstall the above ║
║ ------------------------------------------------------------------------ ║
║ T) Tux4Ubuntu installer - TUXedo up your Ubuntu ║
║ ------------------------------------------------------------------------ ║
║ Q) I'm done - Quit the installer (Ctrl+C) ║
║ ║
╚══════════════════════════════════════════════════════════════════════════════╝
EOF
read -n1 -s
case "$REPLY" in
"A") # Install everything
STEPCOUNTER=true
i=1
install_chromium $i
((i++))
install_vsc $i
((i++))
install_gimp $i
((i++))
install_git_and_ssh_keys $i
((i++))
# install_amazon_cli $i
# ((i++))
install_tilda $i
;;
"a") # Install everything
STEPCOUNTER=true
i=1
install_chromium $i
((i++))
install_vsc $i
((i++))
install_gimp $i
((i++))
install_git_and_ssh_keys $i
((i++))
# install_amazon_cli $i
# ((i++))
install_tilda $i
;;
"1") install_chromium ;;
"2") install_vsc ;;
"3") install_gimp ;;
"4") install_git_and_ssh_keys;;
# "5") install_amazon_cli ;;
"5") install_tilda ;;
"7") get_the_tshirt ;;
"U") uninstall ;;
"u") uninstall ;;
"T") tux_installer ;;
"t") tux_installer ;;
"Q") break ;;
"q") break ;;
* ) echo "That's an invalid option. Try again." ;;
esac
sleep 1
done