-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·1502 lines (938 loc) · 40.5 KB
/
setup.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
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
############################# VARIABLES #############################
# BASH
# Bash Color
RED='\033[1;31m' # Light Red
GREEN='\033[1;32m' # Light Green
YELLOW='\033[1;33m' # Yellow
PURPLE='\033[1;35m' # Light Purple
CYAN='\033[1;36m' # Light Cyan
NC='\033[0m' # No Color
# Bash Text Style
BOLD=$(tput bold) # Bold text
NORMAL=$(tput sgr0) # Normal text
# ----------------------------------------------------------------- #
# LINUX
TIMEZONE="Asia/Jakarta"
NEW_USERNAME=""
DNS_NAMESERVER="208.67.222.222"
# ----------------------------------------------------------------- #
# EMAIL SETUP
FILE_TEMP="temp.txt"
FILE_CONFIG_POSTFIX_MAIN="/etc/postfix/main.cf"
FILE_CONFIG_POSTFIX_MASTER="/etc/postfix/master.cf"
FILE_CONFIG_ALIASES="/etc/aliases"
FILE_CONFIG_OPENDKIM="/etc/opendkim.conf"
FILE_CONFIG_OPENDKIM_SIGNINGTABLE="/etc/opendkim/signing.table"
FILE_CONFIG_OPENDKIM_KEYTABLE="/etc/opendkim/key.table"
FILE_CONFIG_OPENDKIM_TRUSTEDHOSTS="/etc/opendkim/trusted.hosts"
FILE_CONFIG_OPENDKIM_DEFAULT="/etc/default/opendkim"
# ----------------------------------------------------------------- #
# OTHERS
FILE_SETUP="setup.sh"
FILE_TMP="_tmp.txt"
ARG_CLOUD="cloud"
ARG_DESKTOP="desktop"
ARG_DO="do"
ARG_SERVER="server"
ARG_VBOX="vbox"
DEFAULT_NEW_SSH_PORT="11122"
################################ MAIN ###############################
main() {
# ./setup.sh
if [ "$0" == "./$FILE_SETUP" ] && [ "$1" == "" ]; then
check_sudo_user
if [ "$IS_SUDO_USER" = true ]; then ask_user_option; fi
# If the command is not valid, an error message will be shown
else
TEMP_PRINT="ERROR: Command is not valid"
printf "${RED}${TEMP_PRINT}...${NC}\n"
exit
fi
}
############################## FUNCTIONS ############################
# ============================== START ==============================
# Check if User is in sudo mode
check_sudo_user() {
if [ `whoami` != root ]; then
TEMP_PRINT="ERROR: Please run this script as root or using sudo"
printf "${RED}${TEMP_PRINT}...${NC}\n"
exit
else
IS_SUDO_USER=true
fi
}
# Ask the user option
ask_user_option() {
ask_user() {
TEMP_PRINT_A="${CYAN}Which set up will you do?${NC}\n"
TEMP_PRINT_1=" 1. VirtualBox (Desktop)\n"
TEMP_PRINT_2=" 2. VirtualBox (Server)\n"
TEMP_PRINT_3=" 3. Cloud (DigitalOcean/Hostwinds)\n"
TEMP_PRINT_4=" 4. Bare-metal (physical server)\n"
TEMP_PRINT_5=" 5. Email Server (${RED}required${NC} to set up ${YELLOW}at least${NC} 1 of option 1-4)\n"
printf "$TEMP_PRINT_A"
printf "$TEMP_PRINT_1"
printf "$TEMP_PRINT_2"
printf "$TEMP_PRINT_3"
printf "$TEMP_PRINT_4"
printf "$TEMP_PRINT_5"
TEMP_PRINT="Option: "
read -p "$TEMP_PRINT" USER_OPTION
if [ "$USER_OPTION" == "1" ]; then
setup_vbox_desktop
elif [ "$USER_OPTION" == "2" ]; then
setup_vbox_server
elif [ "$USER_OPTION" == "3" ]; then
setup_cloud_digitalocean
elif [ "$USER_OPTION" == "4" ]; then
setup_physical_server
elif [ "$USER_OPTION" == "5" ]; then
setup_email_server
else
TEMP_PRINT="ERROR: Wrong option"
printf "${RED}${TEMP_PRINT}...${NC}\n"
fi
}
ask_user
ARR_OPTIONS=(1 2 3 4 5)
while ! [[ ${ARR_OPTIONS[*]} =~ (^|[[:space:]])"$USER_OPTION"($|[[:space:]]) ]]; do
ask_user
done
}
# -------------------------------------------------------------------
# Setup for VBox (desktop)
setup_vbox_desktop() {
TEMP_PRINT="Setup for VBox (desktop)"
printf "${YELLOW}${TEMP_PRINT}...${NC}\n"
# Init Setup
basic_setup
# Install Required Apps
install_dev_tools
install_other_apps
# End Setup
end_setup
}
# Setup for VBox (server)
setup_vbox_server() {
TEMP_PRINT="Setup for VBox (server)"
printf "${YELLOW}${TEMP_PRINT}...${NC}\n"
# Init Setup
basic_setup
# Install Required Apps
install_other_apps
# End Setup
end_setup
}
# Setup for DigitalOcean
setup_cloud_digitalocean() {
TEMP_PRINT="Setup for server"
printf "${YELLOW}${TEMP_PRINT}...${NC}\n"
# Init Setup
create_user
ssh_settings
basic_setup
# Install Required Apps
install_other_apps
# (Optional) Install Email Server
setup_email_server
# End Setup
end_setup
}
# Setup for physical server
setup_physical_server() {
TEMP_PRINT="Setup for physical server"
printf "${YELLOW}${TEMP_PRINT}...${NC}\n"
# Init Setup
ssh_settings
basic_setup
# Install Required Apps
install_other_apps
# (Optional) Install Email Server
setup_email_server
# End Setup
end_setup
}
# =========================== INIT SETUP ============================
# Create User
create_user() {
# Check if User want to create new sudo user
ask_create_sudo_user() {
TEMP_PRINT="Create new sudo user? [Y/n] "
read -p "$TEMP_PRINT" user_option_create_user
if [ "$user_option_create_user" == "n" ] || [ "$user_option_create_user" == "N" ]; then
TEMP_PRINT="Sudo user will NOT be created"
printf "${RED}${TEMP_PRINT}...${NC}\n"
is_create_sudo_user=false
else
TEMP_PRINT="Sudo user WILL be created"
printf "${GREEN}${TEMP_PRINT}...${NC}\n"
is_create_sudo_user=true
fi
}
# Check if user exist
check_user_exist() {
id -u "$NEW_USERNAME" &> $FILE_TMP
temp1=$(cat $FILE_TMP | grep id)
if [ "$temp1" == "" ]; then
temp="User \"$NEW_USERNAME\" is exist"
printf "${RED}${temp}!${NC}\n"
IS_USER_EXIST=true
else
IS_USER_EXIST=false
IS_CONTINUE_CREATE_USER=false
fi
rm $FILE_TMP
}
# Create sudo user
create_sudo_user() {
temp="Create sudo user"
printf "${CYAN}${temp}:${NC}\n"
IS_CONTINUE_CREATE_USER=true
while [ $IS_CONTINUE_CREATE_USER = true ] || [ $IS_USER_EXIST = true ]; do
# Check new username
read -p "Enter username: " NEW_USERNAME
# Check if user exist
check_user_exist
done
# Create the user
sudo adduser $NEW_USERNAME
# Add to sudo group
sudo usermod -aG sudo $NEW_USERNAME
}
ask_create_sudo_user
if [ "$is_create_sudo_user" = true ]; then
# Create sudo user
create_sudo_user
# Copy SSH authorized keys
copy_ssh_authorized_keys
fi
}
# SSH settings
ssh_settings() {
TEMP_PRINT="SSH settings"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
TEMP_PRINT="Edit SSH settings? [Y/n] "
read -p "$TEMP_PRINT" USER_OPTION_SSH_SETTINGS
if [ "$USER_OPTION_SSH_SETTINGS" == "n" ] || [ "$USER_OPTION_SSH_SETTINGS" == "N" ]; then
TEMP_PRINT="SSH settings will NOT be edited"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
else
# Change the SSH Port
change_ssh_port
# Disable password authentication on SSH
disable_ssh_password_auth
# Disable root login on SSH
disable_ssh_root_login
# Check if user want to continue the process
ask_continue_process
fi
}
# Basic Setup
basic_setup() {
# Set timezone
set_timezone
# Update/upgrade packages
update_and_upgrade
}
# -------------------------------------------------------------------
# Copy SSH authorized keys
copy_ssh_authorized_keys() {
# Check if SSH authorized keys exist
check_ssh_authorized_keys_exist() {
TEMP_COMMAND=$(cat ~/.ssh/authorized_keys)
if [ "$TEMP_COMMAND" != "" ]; then
TEMP_PRINT="authorized_keys is exist"
printf "${GREEN}${TEMP_PRINT}...${NC}\n"
IS_AUTHORIZED_KEYS_EXIST=true
else
TEMP_PRINT="ERROR: authorized_keys is NOT available"
printf "${RED}${TEMP_PRINT}...${NC}\n"
IS_AUTHORIZED_KEYS_EXIST=false
fi
}
TEMP_PRINT_A="Copy SSH authorized keys"
printf "${CYAN}${TEMP_PRINT_A}:${NC}\n"
check_ssh_authorized_keys_exist
while [ $IS_AUTHORIZED_KEYS_EXIST = false ]; do
# Check if user want to continue the process
ask_continue_process
# Check if SSH authorized keys exist
check_ssh_authorized_keys_exist
done
mkdir /home/$NEW_USERNAME/.ssh
cp /root/.ssh/authorized_keys /home/$NEW_USERNAME/.ssh/
chown -R $NEW_USERNAME:$NEW_USERNAME /home/$NEW_USERNAME/.ssh/
printf "${TEMP_PRINT_A}...${NC} ${GREEN}OK${NC}\n"
}
# Set timezone
set_timezone() {
TEMP_PRINT="Set timezone"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
timedatectl set-timezone $TIMEZONE
printf "${TEMP_PRINT}...${NC} ${GREEN}OK${NC}\n"
}
# Update and upgrade the packages
update_and_upgrade() {
TEMP_PRINT="Update and upgrade the packages"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
# Update the package lists that need upgrading
TEMP_PRINT="Update the package lists that need upgrading"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt update
# Upgrade packages and its dependencies
TEMP_PRINT="Upgrade packages and its dependencies"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt dist-upgrade -y
}
# -------------------------------------------------------------------
# SSH
# Change the SSH Port
change_ssh_port() {
# Ask if user want to change the SSH port
ask_ssh_port() {
TEMP_PRINT="Change SSH default port? [Y/n] "
read -p "$TEMP_PRINT" USER_OPTION_SSH_PORT
if [ "$USER_OPTION_SSH_PORT" == "n" ] || [ "$USER_OPTION_SSH_PORT" == "N" ]; then
TEMP_PRINT="SSH port will NOT be changed"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
is_change_ssh_port=false
else
TEMP_PRINT="SSH port WILL be changed"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
is_change_ssh_port=true
fi
}
ask_ssh_port
if [ "$is_change_ssh_port" == true ]; then
read -p "Enter the new port [$DEFAULT_NEW_SSH_PORT] " USER_INPUT_NEW_SSH_PORT
TEMP_MESSAGE="Using default value"
TEMP_PRINT="${PURPLE}${TEMP_MESSAGE}...${NC}\n"
if [ "$USER_INPUT_NEW_SSH_PORT" == "" ]; then
printf "$TEMP_PRINT"
USER_INPUT_NEW_SSH_PORT="$DEFAULT_NEW_SSH_PORT"
fi
# Change the default value
TEMP_PRINT="Change the default value"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo sed -i "s/#Port 22/Port $USER_INPUT_NEW_SSH_PORT/g" /etc/ssh/sshd_config
sudo systemctl restart ssh
# Allow the new port in firewall
TEMP_PRINT="Allow the new port in firewall"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo ufw allow $USER_INPUT_NEW_SSH_PORT/tcp
fi
}
# Disable password authentication on SSH
disable_ssh_password_auth() {
# Ask if user want to disable password authentication on SSH
ask_disable_ssh_password_auth() {
TEMP_PRINT="Disable password authentication on SSH? [Y/n] "
read -p "$TEMP_PRINT" USER_OPTION_SSH_PASSWORD_AUTH
if [ "$USER_OPTION_SSH_PASSWORD_AUTH" == "n" ] || [ "$USER_OPTION_SSH_PASSWORD_AUTH" == "N" ]; then
TEMP_PRINT="Password authentication on SSH will NOT be disabled"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
is_disable_ssh_password_auth=false
else
TEMP_PRINT="Password authentication on SSH will be DISABLED"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
is_disable_ssh_password_auth=true
fi
}
# Ask if user already copy the Public Key to Authorized Keys
ask_copy_publickey_to_authorizedkey() {
TEMP_PRINT="Already copy the Public Key to Authorized Keys? [y/N] "
read -p "$TEMP_PRINT" USER_OPTION_COPY_PUBLICKEY
if [ "$USER_OPTION_COPY_PUBLICKEY" == "y" ] || [ "$USER_OPTION_COPY_PUBLICKEY" == "Y" ]; then
is_continue_disable_ssh_password_auth=true
else
TEMP_PRINT="Please copy the Public Key to Authorized Keys"
printf "${RED}${TEMP_PRINT}...${NC}\n"
exit
fi
}
ask_disable_ssh_password_auth
if [ "$is_disable_ssh_password_auth" == true ]; then ask_copy_publickey_to_authorizedkey; fi
if [ "$is_disable_ssh_password_auth" == true ] && [ "$is_continue_disable_ssh_password_auth" == true ]; then
# Change the default value
sudo sed -i "s/PasswordAuthentication yes/PasswordAuthentication no/g" /etc/ssh/sshd_config
sudo systemctl restart ssh
fi
}
# Disable root login on SSH
disable_ssh_root_login() {
# Ask if user want to disable root login on SSH
ask_disable_ssh_root_login() {
TEMP_PRINT="Disable root login on SSH? [Y/n] "
read -p "$TEMP_PRINT" USER_OPTION_SSH_ROOT_LOGIN
if [ "$USER_OPTION_SSH_ROOT_LOGIN" == "n" ] || [ "$USER_OPTION_SSH_ROOT_LOGIN" == "N" ]; then
TEMP_PRINT="Root login on SSH will NOT be disabled"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
is_disable_ssh_root_login=false
else
TEMP_PRINT="Root login on SSH will be DISABLED"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
is_disable_ssh_root_login=true
fi
}
ask_disable_ssh_root_login
if [ "$is_disable_ssh_root_login" == true ]; then
# Change the default value
sudo sed -i "s/PermitRootLogin yes/PermitRootLogin no/g" /etc/ssh/sshd_config
sudo sed -i "s/#PermitRootLogin prohibit-password/PermitRootLogin no/g" /etc/ssh/sshd_config
sudo systemctl restart ssh
fi
}
# ============================ DEV-TOOLS =============================
# Install developing apps
install_dev_tools() {
# Essential
install_vscode # Install Visual Studio Code
install_sqlitebrowser # Install SQLite Browser
install_mysqlworkbench # Install MySQL Workbench
install_postman # Install Postman
# Additional
install_filezilla # Install FileZilla
install_tree # Install tree
install_rename # Install rename
install_imagemagick # Install Imagemagick
}
# -------------------------------------------------------------------
# Install Visual Studio Code
install_vscode() {
TEMP_PRINT="Install Visual Studio Code"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
# Install the dependencies
TEMP_PRINT="Install the dependencies"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install software-properties-common apt-transport-https wget -y
# Import the Microsoft GPG key
TEMP_PRINT="Import the Microsoft GPG key"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
# Enable the repository and update the package index
TEMP_PRINT="Enable the repository and update the package index"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update
# Install the package
TEMP_PRINT="Install the package"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install code -y
}
# Install SQLite Browser
install_sqlitebrowser() {
# https://sqlitebrowser.org/dl/
TEMP_PRINT="Install SQLite Browser"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install sqlitebrowser -y
}
# Install MySQL Workbench
install_mysqlworkbench() {
TEMP_PRINT="Install MySQL Workbench"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
# Install the dependencies of MySQL Workbench
TEMP_PRINT="Install the dependencies of MySQL Workbench"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install libopengl0 libpcrecpp0v5 libproj15 libzip5 -y
# Download the installer
TEMP_PRINT="Download the installer"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
wget https://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-workbench-community_8.0.26-1ubuntu20.04_amd64.deb
# Install the MySQL Workbench
TEMP_PRINT="Install the MySQL Workbench"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo dpkg -i mysql-*
# Remove the installer after installation finish
TEMP_PRINT="Remove the installer after installation finish"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
rm mysql-*
}
# Install Postman
install_postman() {
# https://speedysense.com/install-postman-on-ubuntu-20-04/
TEMP_PRINT="Install Postman"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
# Download Postman installer
TEMP_PRINT="Download Postman installer"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
wget --content-disposition https://dl.pstmn.io/download/latest/linux
# Extract Postman package
TEMP_PRINT="Extract Postman package"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
tar -xzf Postman-linux-*
# Move the directory to `opt/` directory
TEMP_PRINT="Move the directory to \`opt/\` directory"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo mv Postman /opt
# Create a Symbolic Links
TEMP_PRINT="Create a Symbolic Links"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo ln -s /opt/Postman/Postman /usr/local/bin/postman
# Create a desktop file for Postman app
TEMP_PRINT="Create a desktop file for Postman app"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
DESKTOP_FILE="/usr/share/applications/postman.desktop"
echo "[Desktop Entry]" >> $DESKTOP_FILE
echo "Type=Application" >> $DESKTOP_FILE
echo "Name=Postman" >> $DESKTOP_FILE
echo "Icon=/opt/Postman/app/resources/app/assets/icon.png" >> $DESKTOP_FILE
echo "Exec=\"/opt/Postman/Postman\"" >> $DESKTOP_FILE
echo "Comment=Postman GUI" >> $DESKTOP_FILE
echo "Categories=Development;Code;" >> $DESKTOP_FILE
# Remove the installer after installation finish
TEMP_PRINT="Remove the installer after installation finish"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
rm Postman-linux-*
}
# -------------------------------------------------------------------
# Install FileZilla
install_filezilla() {
TEMP_PRINT="Install FileZilla"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install filezilla -y
}
# Install tree
install_tree() {
TEMP_PRINT="Install tree"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install tree -y
}
# Install rename
install_rename() {
TEMP_PRINT="Install rename"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install rename -y
}
# Install Imagemagick
install_imagemagick() {
TEMP_PRINT="Install Imagemagick"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install imagemagick -y
}
# ============================= OTHERS ===============================
# Install other apps
install_other_apps() {
install_openssh # Install OpenSSH
install_host # Install host
install_htop # Install htop
install_git # Install Git
install_nettools # Install net-tools
install_python_dependencies # Install Python dependencies
install_docker # Install Docker
install_nginx # Install NGINX
install_certbot # Install Certbot
install_redis # Install Redis
install_postgresql # Install PostgreSQL
}
# -------------------------------------------------------------------
# Install OpenSSH
install_openssh() {
TEMP_PRINT="Install OpenSSH"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install openssh-server -y
}
# Install host
install_host() {
TEMP_PRINT="Install host"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install host -y
}
# Install htop
install_htop() {
TEMP_PRINT="Install htop"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install htop -y
}
# Install Git
install_git() {
TEMP_PRINT="Install Git"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install git -y
}
# Install net-tools
install_nettools() {
TEMP_PRINT="Install net-tools"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install net-tools -y
}
# Install Python dependencies
install_python_dependencies() {
TEMP_PRINT="Install Python dependencies"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
# Install Python environment
TEMP_PRINT="Install Python environment"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install python3.8-venv -y
# Install PIP
TEMP_PRINT="Install PIP"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install python3-pip -y
# Install Django Admin
TEMP_PRINT="Install Django Admin"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install python3-django -y
}
# Install Docker
install_docker() {
TEMP_PRINT="Install Docker"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
# Install the dependencies of Docker
TEMP_PRINT="Install the dependencies of Docker"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release -y
# Add Docker’s official GPG key
TEMP_PRINT="Add Docker’s official GPG key"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
# Set up the stable repository of Docker and update the package index
TEMP_PRINT="Set up the stable repository of Docker and update the package index"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
# Install the latest version of Docker Engine and container
TEMP_PRINT="Install the latest version of Docker Engine and container"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install docker-ce docker-ce-cli containerd.io -y
# Install Docker Compose
TEMP_PRINT="Install Docker Compose"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo apt install docker-compose -y
# Adding user to the Docker group
TEMP_PRINT="Adding user to the Docker group"
printf "${PURPLE}${TEMP_PRINT}...${NC}\n"
sudo usermod -a -G docker $USER
}
# Install NGINX
install_nginx() {
TEMP_PRINT="Install NGINX"
printf "${CYAN}${TEMP_PRINT}:${NC}\n"
sudo apt install nginx -y