-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoinstaller.sh
2459 lines (2283 loc) · 96.9 KB
/
autoinstaller.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
#!/usr/bin/env bash
#
# Coded by M.A.H
# ID Telegram : @DevAtom
# update system packages
if [[ $(command -v yum) ]]; then
yum update -y
for pkg in perl wget curl screen; do
if ! rpm -q "${pkg}" >/dev/null 2>&1; then
yum install "${pkg}" -y
fi
done
clear
fi
if [[ $(command -v apt) ]]; then
apt update -y ; apt upgrade -y ; apt autoremove -y
for pkg in perl wget curl screen; do
if ! dpkg -s "${pkg}" >/dev/null 2>&1; then
apt install "${pkg}" -y
fi
done
clear
fi
# function to validate user input for y/n choices
function validate_yn_input {
read -rp "$1 " INPUT
INPUT=$(echo "$INPUT" | tr '[:upper:]' '[:lower:]')
while [[ "$INPUT" != "y" && "$INPUT" != "n" ]]; do
echo "Invalid input. Please enter 'y' or 'n'"
read -rp "$1 (y/n) : " INPUT
INPUT=$(echo "$INPUT" | tr '[:upper:]' '[:lower:]')
done
if [ "$INPUT" = "n" ]; then
clear
return 1
fi
}
# function to validate user input for menu choices
function validate_menu_input {
read -rp "$1" INPUT
while ! [[ "$INPUT" =~ ^[0-9]+$ ]] || (( INPUT < $2 || INPUT > $3 )); do
echo "Invalid input. Please enter a number between $2 and $3"
read -rp "$1" INPUT
done
}
#function for text colors
BLUE='\033[0;34m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
GREEN='\033[0;32m'
NC='\033[0m'
# Function to print text in colors
print_b () {
echo -e "${BLUE}$1${NC}"
}
print_r () {
echo -e "${RED}$1${NC}"
}
print_y () {
echo -e "${YELLOW}$1${NC}"
}
print_g () {
echo -e "${GREEN}$1${NC}"
}
# Run hostnamectl and save the output to a variable
output=$(hostnamectl)
# Extract the desired information from the output using grep and sed
hostname=$(echo "$output" | grep "Static hostname:" | sed 's/Static hostname:\s*//')
virtualization=$(echo "$output" | grep "Virtualization:" | sed 's/Virtualization:\s*//')
os=$(echo "$output" | grep "Operating System:" | sed 's/Operating System:\s*//')
kernel=$(echo "$output" | grep "Kernel:" | sed 's/Kernel:\s*//')
architecture=$(echo "$output" | grep "Architecture:" | sed 's/Architecture:\s*//')
vendor=$(echo "$output" | grep "Hardware Vendor:" | sed 's/Hardware Vendor:\s*//')
model=$(echo "$output" | grep "Hardware Model:" | sed 's/Hardware Model:\s*//')
CPU_NAME=$(grep "model name" /proc/cpuinfo | head -n 1 | cut -d':' -f2 | sed 's/^[ \t]*//')
CPU_CORES=$(grep -c processor /proc/cpuinfo)
MEM_TOTAL=$(free -h | awk '/^Mem/ {print $2}')
HDD_TOTAL=$(df -h --total | tail -n 1 | awk '{print $2}')
IP_ADDRESS=$(hostname -I | awk '{print $1}')
# Print the extracted information
information () {
echo -e "\033[33m Static Hostname\033[0m :\033[34m${hostname}\033[0m"
echo -e "\033[33m Virtualization\033[0m :\033[34m${virtualization}\033[0m"
echo -e "\033[33m Operating System\033[0m : \033[34m${os}\033[0m"
echo -e "\033[33m Kernel\033[0m :\033[34m${kernel}\033[0m"
echo -e "\033[33m Architecture\033[0m :\033[34m${architecture}\033[0m"
echo -e "\033[33m Hardware Vendor\033[0m :\033[34m${vendor}\033[0m"
echo -e "\033[33m Hardware Model\033[0m :\033[34m${model}\033[0m"
echo -e "\033[33m CPU\033[0m : \033[34m${CPU_NAME} (${CPU_CORES} Cores)\033[0m"
echo -e "\033[33m Memory\033[0m : \033[34m${MEM_TOTAL}\033[0m"
echo -e "\033[33m Hard Disk\033[0m : \033[34m${HDD_TOTAL}\033[0m"
echo -e "\033[33m IP Address\033[0m : \033[34m${IP_ADDRESS}\033[0m"
}
# Banner
message='
/$$$$$$ /$$ /$$$$$$ /$$ /$$ /$$
/$$__ $$ | $$ |_ $$_/ | $$ | $$| $$
| $$ \ $$ /$$ /$$ /$$$$$$ /$$$$$$ | $$ /$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ | $$| $$ /$$$$$$ /$$$$$$
| $$$$$$$$| $$ | $$|_ $$_/ /$$__ $$ | $$ | $$__ $$ /$$_____/|_ $$_/ |____ $$| $$| $$ /$$__ $$ /$$__ $$
| $$__ $$| $$ | $$ | $$ | $$ \ $$ | $$ | $$ \ $$| $$$$$$ | $$ /$$$$$$$| $$| $$| $$$$$$$$| $$ \__/
| $$ | $$| $$ | $$ | $$ /$$| $$ | $$ | $$ | $$ | $$ \____ $$ | $$ /$$ /$$__ $$| $$| $$| $$_____/| $$
| $$ | $$| $$$$$$/ | $$$$/| $$$$$$/ /$$$$$$| $$ | $$ /$$$$$$$/ | $$$$/| $$$$$$$| $$| $$| $$$$$$$| $$
|__/ |__/ \______/ \___/ \______/ |______/|__/ |__/|_______/ \___/ \_______/|__/|__/ \_______/|__/
#Atom
@DevAtom
'
cPanel='
____ _
___| _ \ __ _ _ __ ___| |
/ __| |_) / _` | `_ \ / _ \ |
| (__| __/ (_| | | | | __/ |
\___|_| \__,_|_| |_|\___|_|
'
Plesk='
____ _ _
| _ \| | ___ ___| | __
| |_) | |/ _ \/ __| |/ /
| __/| | __/\__ \ <
|_| |_|\___||___/_|\_\
'
aaPanel='
____ _
__ _ __ _| _ \ __ _ _ __ ___| |
/ _` |/ _` | |_) / _` | `_ \ / _ \ |
| (_| | (_| | __/ (_| | | | | __/ |
\__,_|\__,_|_| \__,_|_| |_|\___|_|
'
InstallcPanel='
___ _ _ _ ____ _
|_ _|_ __ ___| |_ __ _| | | ___| _ \ __ _ ___ _ __ | |
| || `_ \/ __| __/ _` | | | / __| |_) / _` |/ _ \ `_ \| |
| || | | \__ \ || (_| | | | | (__| __/ (_| | __/ | | | |
|___|_| |_|___/\__\__,_|_|_| \___|_| \__,_|\___|_| |_|_|
'
InstallPlesk='
___ _ _ _ ____ _ _
|_ _|_ __ ___| |_ __ _| | | | _ \| | ___ ___| | __
| || `_ \/ __| __/ _` | | | | |_) | |/ _ \/ __| |/ /
| || | | \__ \ || (_| | | | | __/| | __/\__ \ <
|___|_| |_|___/\__\__,_|_|_| |_| |_|\___||___/_|\_\
'
InstallaaPanel='
___ _ _ _ ____ _
|_ _|_ __ ___| |_ __ _| | | __ _ __ _| _ \ __ _ _ __ ___| |
| || `_ \/ __| __/ _` | | | / _` |/ _` | |_) / _` | `_ \ / _ \ |
| || | | \__ \ || (_| | | | | (_| | (_| | __/ (_| | | | | __/ |
|___|_| |_|___/\__\__,_|_|_| \__,_|\__,_|_| \__,_|_| |_|\___|_|
'
Tools='
____ _____ _
/ ___| ___ _ ____ _____ _ __ |_ _|__ ___ | |___
\___ \ / _ \ `__\ \ / / _ \ `__| | |/ _ \ / _ \| / __|
___) | __/ | \ V / __/ | | | (_) | (_) | \__ \
|____/ \___|_| \_/ \___|_| |_|\___/ \___/|_|___/
'
CSF='
____ _ ____ ____ _____
/ ___| ___| |_ _ _ _ __ / ___/ ___|| ___|
\___ \ / _ \ __| | | | `_ \ | | \___ \| |_
___) | __/ |_| |_| | |_) | | |___ ___) | _|
|____/ \___|\__|\__,_| .__/ \____|____/|_|
|_|
'
Plugins='
___ _ _ _ ____ _ _
|_ _|_ __ ___| |_ __ _| | | | _ \| |_ _ __ _(_)_ __ ___
| || `_ \/ __| __/ _` | | | | |_) | | | | |/ _` | | `_ \/ __|
| || | | \__ \ || (_| | | | | __/| | |_| | (_| | | | | \__ \
|___|_| |_|___/\__\__,_|_|_| |_| |_|\__,_|\__, |_|_| |_|___/
|___/
'
CloudLinux='
____ _ ____ _ _ _ _
/ ___| ___| |_ _ _ _ __ / ___| | ___ _ _ __| | | (_)_ __ _ ___ __
\___ \ / _ \ __| | | | `_ \ | | | |/ _ \| | | |/ _` | | | | `_ \| | | \ \/ /
___) | __/ |_| |_| | |_) | | |___| | (_) | |_| | (_| | |___| | | | | |_| |> <
|____/ \___|\__|\__,_| .__/ \____|_|\___/ \__,_|\__,_|_____|_|_| |_|\__,_/_/\_\
|_|
'
Advanced='
_ _ _ _____ _
/ \ __| |_ ____ _ _ __ ___ ___ __| | |_ _|__ ___ | |___
/ _ \ / _` \ \ / / _` | `_ \ / __/ _ \/ _` | | |/ _ \ / _ \| / __|
/ ___ \ (_| |\ V / (_| | | | | (_| __/ (_| | | | (_) | (_) | \__ \
/_/ \_\__,_| \_/ \__,_|_| |_|\___\___|\__,_| |_|\___/ \___/|_|___/
'
FTP='
____ _ _____ _____ ____ ____
/ ___| ___| |_ _ _ _ __ | ___|_ _| _ \ / ___| ___ _ ____ _____ _ __
\___ \ / _ \ __| | | | `_ \ | |_ | | | |_) | \___ \ / _ \ `__\ \ / / _ \ `__|
___) | __/ |_| |_| | |_) | | _| | | | __/ ___) | __/ | \ V / __/ |
|____/ \___|\__|\__,_| .__/ |_| |_| |_| |____/ \___|_| \_/ \___|_|
|_|
'
Management='
____ _ __ __ _
/ ___| ___| |_ _ _ _ __ | \/ | __ _ _ __ __ _ __ _ ___ _ __ ___ ___ _ __ | |_
\___ \ / _ \ __| | | | `_ \ | |\/| |/ _` | `_ \ / _` |/ _` |/ _ \ `_ ` _ \ / _ \ `_ \| __|
___) | __/ |_| |_| | |_) | | | | | (_| | | | | (_| | (_| | __/ | | | | | __/ | | | |_
|____/ \___|\__|\__,_| .__/ |_| |_|\__,_|_| |_|\__,_|\__, |\___|_| |_| |_|\___|_| |_|\__|
|_| |___/
'
WebServer='
__ __ _ ____
\ \ / /__| |__/ ___| ___ _ ____ _____ _ __
\ \ /\ / / _ \ `_ \___ \ / _ \ `__\ \ / / _ \ `__|
\ V V / __/ |_) |__) | __/ | \ V / __/ |
\_/\_/ \___|_.__/____/ \___|_| \_/ \___|_|
'
Mysql='
____ _ __ __ _
/ ___| ___| |_ _ _ _ __ | \/ |_ _ ___ __ _| |
\___ \ / _ \ __| | | | `_ \ | |\/| | | | / __|/ _` | |
___) | __/ |_| |_| | |_) | | | | | |_| \__ \ (_| | |
|____/ \___|\__|\__,_| .__/ |_| |_|\__, |___/\__, |_|
|_| |___/ |_|
'
Redis='
____ _ ____ _ _
/ ___| ___| |_ _ _ _ __ | _ \ ___ __| (_)___
\___ \ / _ \ __| | | | `_ \ | |_) / _ \/ _` | / __|
___) | __/ |_| |_| | |_) | | _ < __/ (_| | \__ \
|____/ \___|\__|\__,_| .__/ |_| \_\___|\__,_|_|___/
|_|
'
Memcached='
____ _ __ __ _ _
/ ___| ___| |_ _ _ _ __ | \/ | ___ _ __ ___ ___ __ _ ___| |__ ___ __| |
\___ \ / _ \ __| | | | `_ \ | |\/| |/ _ \ `_ ` _ \ / __/ _` |/ __| `_ \ / _ \/ _` |
___) | __/ |_| |_| | |_) | | | | | __/ | | | | | (_| (_| | (__| | | | __/ (_| |
|____/ \___|\__|\__,_| .__/ |_| |_|\___|_| |_| |_|\___\__,_|\___|_| |_|\___|\__,_|
|_|
'
# main menu
while true; do
clear
echo -e "\033[0;32m${message}\033[0m"
echo -e "\033[34minformation Server\033[0m"
information
echo
print_y "Which control panel do you want to install?"
print_g "1) cPanel"
print_g "2) Plesk"
print_g "3) aaPanel"
print_g "4) Exit"
validate_menu_input "$(print_y 'Enter your choice (1-4) : ')" 1 4
CP_CHOICE=$INPUT
if [ $CP_CHOICE -eq 4 ]; then
clear
exit
fi
# sub-menu for cPanel
if [ $CP_CHOICE -eq 1 ]; then
clear
while true; do
echo -e "\033[0;32m${cPanel}\033[0m"
print_y "What do you want to do?"
print_g "1) Install cPanel"
print_g "2) Server Tools [4]"
print_g "3) Setup CSF [4]"
print_g "4) install Plugins [8]"
print_g "5) Setup CloudLinux [7]"
print_g "6) Setup FTP Server [3]"
print_g "7) Advanced Tools [4]"
print_g "8) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-8) : ')" 1 8
CP_ACTION=$INPUT
if [ $CP_ACTION -eq 8 ]; then
clear
break
fi
# Install cPanel
if [ $CP_ACTION -eq 1 ]; then
clear
echo -e "\033[0;32m${InstallcPanel}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Install cPanel?(y/n) :')"
if [ $INPUT = "y" ]; then
cd /home && curl -o latest -L https://securedownloads.cpanel.net/latest && sh latest
fi
fi
# Server Tools
if [ $CP_ACTION -eq 2 ]; then
clear
echo -e "\033[0;32m${Tools}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Server Tools?(y/n) :')"
if [ $INPUT = "y" ]; then
while true; do
print_g "1) Change Nameserver"
print_g "2) Change Hostname"
print_g "3) Change SSH Port"
print_g "4) Change Password (root)"
print_g "5) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-5) : ')" 1 5
ST_ACTION=$INPUT
# Change Nameserver
if [ $ST_ACTION -eq 1 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to change the Nameserver?(y/n) :')"
if [ $INPUT = "y" ]; then
read -p "Enter Primary Nameserver: " PRIMARY_NS
read -p "Enter Secondary Nameserver: " SECONDARY_NS
if [ -f /etc/resolv.conf ]; then
sed -i 's/^nameserver/#nameserver/g' /etc/resolv.conf
echo "nameserver $PRIMARY_NS" >> /etc/resolv.conf
echo "nameserver $SECONDARY_NS" >> /etc/resolv.conf
print_b "Nameserver Changed To -> [ "$PRIMARY_NS" - "$SECONDARY_NS" ]"
fi
fi
fi
# Change hostname
if [ $ST_ACTION -eq 2 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to change the Hostname?(y/n) :')"
if [ $INPUT = "y" ]; then
read -rp "Enter your Hostname : " HOSTNAME
hostnamectl set-hostname $HOSTNAME
print_b "Hostname Changed To -> "$HOSTNAME""
fi
fi
# Change SSH Port
if [ $ST_ACTION -eq 3 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Change SSH Port?(y/n) :')"
if [ $INPUT = "y" ]; then
read -rp "Enter new SSH port : " NEW_PORT
sudo sed -i "s/^#*Port 22/Port $NEW_PORT/" /etc/ssh/sshd_config
service sshd restart
print_b "SSH Port Changed To -> "$NEW_PORT""
fi
fi
# Change Password (root)
if [ $ST_ACTION -eq 4 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Change Password Server?(y/n) :')"
if [ $INPUT = "y" ]; then
if [ $(whoami) = "root" ]; then
passwd root
else
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && sudo systemctl restart ssh && sudo passwd
fi
print_b "Password Changed (root) Successfully"
fi
fi
if [ $ST_ACTION -eq 5 ]; then
clear
break
fi
done
fi
fi
# Setup CSF
if [ $CP_ACTION -eq 3 ]; then
clear
echo -e "\033[0;32m${CSF}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Setup CSF?(y/n) :')"
if [ $INPUT = "y" ]; then
while true; do
print_g "1) Install CSF"
print_g "2) CSF Configuration"
print_g "3) CSF Blocklists Configuration"
print_g "4) Unblock Telegram IPs"
print_g "5) Uninstall CSF"
print_g "6) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-6) : ')" 1 6
CSF_ACTION=$INPUT
# Install CSF
if [ $CSF_ACTION -eq 1 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install CSF?(y/n) :')"
if [ $INPUT = "y" ]; then
cd /usr/src ; rm -fv csf.tgz ; wget https://download.configserver.com/csf.tgz ; tar -xzf csf.tgz ; cd csf ; sh install.sh ; perl /usr/local/csf/bin/csftest.pl ; cd
print_g "ConfigServer Security & Firewall (CSF) Successfully Installed"
fi
fi
#CSF Configuration
if [ $CSF_ACTION -eq 2 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Configuration CSF?(y/n) :')"
if [ $INPUT = "y" ]; then
# Set the parameters
TESTING="0"
CT_LIMIT="100"
CT_INTERVAL="30"
CT_EMAIL_ALERT="1"
CT_PORTS="80,443,2083,2082,2087,20,21,25,110,113,123,465,993,995,22"
CT_BLOCK_TIME="3600"
CT_PERMANENT="1"
CONNLIMIT="22;5,443;20,80;20,20;20,21;20,25;20,110;20,113;20,123;20,465;20,993;20,995;20,2083;20,2082;20"
RESTRICT_SYSLOG="3"
DENY_IP_LIMIT="200"
PACKET_FILTER="1"
PORTFLOOD="1"
# Update the csf.conf file
sed -i "s/^TESTING=.*/TESTING=$TESTING/g" /etc/csf/csf.conf
sed -i "s/^CT_LIMIT=.*/CT_LIMIT=$CT_LIMIT/g" /etc/csf/csf.conf
sed -i "s/^CT_INTERVAL=.*/CT_INTERVAL=$CT_INTERVAL/g" /etc/csf/csf.conf
sed -i "s/^CT_EMAIL_ALERT=.*/CT_EMAIL_ALERT=$CT_EMAIL_ALERT/g" /etc/csf/csf.conf
sed -i "s/^CT_PORTS=.*/CT_PORTS=$CT_PORTS/g" /etc/csf/csf.conf
sed -i "s/^CT_BLOCK_TIME=.*/CT_BLOCK_TIME=$CT_BLOCK_TIME/g" /etc/csf/csf.conf
sed -i "s/^CT_PERMANENT=.*/CT_PERMANENT=$CT_PERMANENT/g" /etc/csf/csf.conf
sed -i "s/^CONNLIMIT=.*/CONNLIMIT=$CONNLIMIT/g" /etc/csf/csf.conf
sed -i "s/^RESTRICT_SYSLOG=.*/RESTRICT_SYSLOG=$RESTRICT_SYSLOG/g" /etc/csf/csf.conf
sed -i "s/^DENY_IP_LIMIT=.*/DENY_IP_LIMIT=$DENY_IP_LIMIT/g" /etc/csf/csf.conf
sed -i "s/^PACKET_FILTER=.*/PACKET_FILTER=$PACKET_FILTER/g" /etc/csf/csf.conf
sed -i "s/^PORTFLOOD=.*/PORTFLOOD=$PORTFLOOD/g" /etc/csf/csf.conf
print_b "CSF configuration is successfully."
fi
fi
# CSF Blocklists Configuration
if [ $CSF_ACTION -eq 3 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to CSF Blocklists Configuration?(y/n) :')"
if [ $INPUT = "y" ]; then
while read line; do
# Check if the line starts with #
if [[ $line == \#* ]]; then
# Skip comment lines
continue
fi
# Split the line by | character
IFS='|' read -ra arr <<< "$line"
done < /etc/csf/csf.blocklists | sed 's/# Split the line by | character//'
print_b "CSF Blocklists Configuration is Successfully."
fi
fi
# Unblock Telegram IPs
if [ $CSF_ACTION -eq 4 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Unblock Telegram IPs?(y/n) :')"
if [ $INPUT = "y" ]; then
csf -a 149.154.168.0/22 ; csf -a 149.154.164.0/22 ; csf -a 149.154.172.0/22 ; csf -a 149.154.160.0/22 ; csf -a 91.108.4.0/22 ; csf -a 91.108.56.0/22 ; csf -a 91.108.16.0/22 ; csf -a 91.108.12.0/22 ; csf -a 91.108.8.0/22
print_b "Unblock Telegram IPs is Successfully."
fi
fi
# uninstall CSF
if [ $CSF_ACTION -eq 5 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Uninstall CSF?(y/n) :')"
if [ $INPUT = "y" ]; then
cd /etc/csf ; sh uninstall.sh
print_b "Uninstall CSF is Successfully."
fi
fi
if [ $CSF_ACTION -eq 6 ]; then
clear
break
fi
done
fi
fi
# Install Plugins
if [ $CP_ACTION -eq 4 ]; then
clear
echo -e "\033[0;32m${Plugins}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Install Plugins?(y/n) :')"
if [ $INPUT = "y" ]; then
while true; do
print_g "1) Install LiteSpeed"
print_g "2) Install ImunifyAV"
print_g "3) Install SSL"
print_g "4) Install WHMReseller"
print_g "5) Install WP Toolkit"
print_g "6) Install PostgreSQL"
print_g "7) Install Softaculous"
print_g "8) Install SitePad"
print_g "9) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-9) : ')" 1 9
PG_ACTION=$INPUT
# Install LiteSpeed
if [ $PG_ACTION -eq 1 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install LiteSpeed?(y/n) :')"
if [ $INPUT = "y" ]; then
cd /usr/src ; wget http://www.litespeedtech.com/packages/cpanel/lsws_whm_plugin_install.sh ; chmod 700 lsws_whm_plugin_install.sh ; ./lsws_whm_plugin_install.sh ; rm -f lsws_whm_plugin_install.sh ; cd
print_b "LiteSpeed Successfully Installed"
fi
fi
# Install ImunifyAV
if [ $PG_ACTION -eq 2 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install ImunifyAV?(y/n) :')"
if [ $INPUT = "y" ]; then
wget https://repo.imunify360.cloudlinux.com/defence360/imav-deploy.sh ; bash imav-deploy.sh ; rm -rf /root/imav-deploy.sh
print_b "ImunifyAV Successfully Installed"
fi
fi
# Install SSL
if [ $PG_ACTION -eq 3 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install SSL?(y/n) :')"
if [ $INPUT = "y" ]; then
/usr/local/cpanel/bin/checkallsslcerts ; /scripts/install_lets_encrypt_autossl_provider
print_b "Let's Encrypt Autossl (SSL) Successfully Installed"
fi
fi
# Install WHMReseller
if [ $PG_ACTION -eq 4 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install WHMReseller?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"centos"* ]]; then
yum install gcc-c++ -y ; cd /usr/local/cpanel/whostmgr/docroot/cgi ; wget http://deasoft.com/install.cpp ; g++ install.cpp -o install ; chmod 700 install ; ./install ; cd
print_b "WHMReseller Successfully Installed"
else
print_r "WHMReseller installation is only supported on CentOS."
fi
fi
fi
# Install WP Toolkit
if [ $PG_ACTION -eq 5 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install WP Toolkit?(y/n) :')"
if [ $INPUT = "y" ]; then
if [ $WP_ACTION -eq 1 ]; then
sh <(curl https://wp-toolkit.plesk.com/cPanel/installer.sh || wget -O - https://wp-toolkit.plesk.com/cPanel/installer.sh)
print_b "WP Toolkit Successfully Installed"
fi
fi
fi
# Install PostgreSQL
if [ $PG_ACTION -eq 6 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install PostgreSQL?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"centos"* ]]; then
yum install postgresql-server -y ; systemctl enable postgresql.service ; systemctl start postgresql.service ; /usr/local/cpanel/scripts/installpostgres
print_b "PostgreSQL Successfully Installed"
else
print_r "PostgreSQL installation is only supported on CentOS."
fi
fi
fi
# Install Softaculous
if [ $PG_ACTION -eq 7 ]; then
clear
validate_yn_input "$(print_y 'Are you sure that ioncube is installed and active on your server?(y/n) :')"
if [ $INPUT = "y" ]; then
if php -m | grep -q ionCube ; then
wget -N http://files.softaculous.com/install.sh && chmod 755 install.sh && ./install.sh
print_b "Softaculous Successfully Installed"
else
print_r "Error: ionCube is not installed on your server.
Please go to this address to install and activate ionCube -> Home / Server Configuration / Tweak Settings -> PHP -> cPanel PHP loader"
fi
fi
fi
# Install SitePad
if [ $PG_ACTION -eq 8 ]; then
clear
validate_yn_input "$(print_y 'Are you sure that ioncube is installed and active on your server?(y/n) :')"
if [ $INPUT = "y" ]; then
if php -m | grep -q ionCube ; then
cd /usr/local/src/ ; rm -fv install.sh ; wget -N https://files.sitepad.com/install.sh ; chmod +x install.sh ; ./install.sh ; cd
print_b "SitePad Successfully Installed"
else
print_r "Error: ionCube is not installed on your server.
Please go to this address to install and activate ionCube -> Home / Server Configuration / Tweak Settings -> PHP -> cPanel PHP loader"
fi
fi
fi
if [ $PG_ACTION -eq 9 ]; then
clear
break
fi
done
fi
fi
# Setup CloudLinux
if [ $CP_ACTION -eq 5 ]; then
clear
echo -e "\033[0;32m${CloudLinux}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Setup CloudLinux?(y/n) :')"
if [ $INPUT = "y" ]; then
while true; do
print_g "1) Install CloudLinux"
print_g "2) Install CageFS"
print_g "3) Install alt-php"
print_g "4) Install ea-php"
print_g "5) install mod-lsapi"
print_g "6) Install Python"
print_g "7) Install Ruby"
print_g "8) Install NodeJS"
print_g "9) Install MySQL Governor (not recommended)"
print_g "10) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-10) : ')" 1 10
CL_ACTION=$INPUT
# Install CloudLinux
if [ $CL_ACTION -eq 1 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install CloudLinux?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"centos"* ]]; then
wget https://repo.cloudlinux.com/cloudlinux/sources/cln/cldeploy -O cldeploy.sh
print_g "Get a 30-day CloudLinux License : https://www.cloudlinux.com/trial"
validate_yn_input "$(print_y 'Do you use the free 30-day License?(y/n) :')"
if [ $INPUT = "y" ]; then
read -rp "Enter your License : " License
sh cldeploy.sh -k "$License"
print_b "CloudLinux Successfully Installed, Please Reboot Your System"
else
print_g "Use your installation and activation command"
fi
else
print_r "CloudLinux installation is only supported on CentOS."
fi
fi
fi
# Install CageFS
if [ $CL_ACTION -eq 2 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install CageFS?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"cloudlinux"* ]]; then
yum install cagefs -y ; /usr/sbin/cagefsctl --init ; /usr/sbin/cagefsctl --enable-all
print_b "CageFS Successfully Installed"
else
print_r "CageFS installation is only supported on CentOS with CloudLinux."
fi
fi
fi
# Install alt-php
if [ $CL_ACTION -eq 3 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install alt-php?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"cloudlinux"* ]]; then
yum groupinstall alt-php -y ; yum update cagefs lvemanager -y ; yum groupupdate alt-php -y
print_b "alt-php Successfully Installed"
else
print_r "alt-php installation is only supported on CentOS."
fi
fi
fi
# Install ea-php
if [ $CL_ACTION -eq 4 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install ea-php?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"cloudlinux"* ]]; then
yum install ea-php82 -y ; yum install ea-php81 -y ; yum install ea-php80 -y ; yum install ea-php74 -y ; yum install ea-php73 -y ; yum install ea-php72 -y ; yum install ea-php71 -y ; yum install ea-php70 -y ; yum install ea-php51 -y ; yum install ea-php52 -y ; yum install ea-php53 -y ; yum install ea-php54 -y ; yum install ea-php55 -y ; yum install ea-php56 -y ; yum update cagefs lvemanager
print_b "ea-php Successfully Installed"
else
print_r "ea-php installation is only supported on CentOS."
fi
fi
fi
# Install mod-lsapi
if [ $CL_ACTION -eq 5 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install mod-lsapi?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"cloudlinux"* ]]; then
yum install liblsapi liblsapi-devel ; yum install ea-apache24-mod_lsapi ; /usr/bin/switch_mod_lsapi --setup ; service httpd restart
print_b "mod-lsapi Successfully Installed"
else
print_r "mod-lsapi installation is only supported on CentOS."
fi
fi
fi
# Install Python
if [ $CL_ACTION -eq 6 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install Python?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"cloudlinux"* ]]; then
yum -y groupinstall "Development Tools"
yum -y install openssl-devel bzip2-devel libffi-devel
yum groupinstall alt-python -y
yum install lvemanager lve-utils alt-python-virtualenv
yum install lve-utils lvemanager alt-python-virtualenv alt-mod-passenger -y
yum install lvemanager alt-python-virtualenv
yum install alt-python27-devel -y
print_b "Python Successfully Installed"
else
print_r "Python installation is only supported on CentOS."
fi
fi
fi
# Install Ruby
if [ $CL_ACTION -eq 7 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install Ruby?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"cloudlinux"* ]]; then
yum grouplist | grep alt-ruby
yum groupinstall alt-ruby -y
yum install lvemanager alt-python-virtualenv
yum install ea-ruby24-mod_passenger -y
print_b "Ruby Successfully Installed"
else
print_r "Ruby installation is only supported on CentOS."
fi
fi
fi
# Install NodeJS
if [ $CL_ACTION -eq 8 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install NodeJS?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"cloudlinux"* ]]; then
yum groupinstall alt-nodejs -y
yum install lvemanager lve-utils -y
yum install lvemanager lve-utils alt-mod-passenger -y
print_b "NodeJS Successfully Installed"
else
print_r "NodeJS installation is only supported on CentOS."
fi
fi
fi
# Install MySQL Governor
if [ $CL_ACTION -eq 9 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Install MySQL Governor?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"cloudlinux"* ]]; then
yum remove db-governor db-governor-mysql
yum install governor-mysql -y
read -rp "Enter Mysql Version : " MysqlV
/usr/share/lve/dbgovernor/mysqlgovernor.py --mysql-version="$MysqlV"
/usr/share/lve/dbgovernor/mysqlgovernor.py --install --yes
/usr/share/lve/dbgovernor/mysqlgovernor.py --dbupdate
service db_governor restart
service db_governor start
print_b "MySQL Governor Successfully Installed"
else
print_r "MySQL Governor installation is only supported on CentOS."
fi
fi
fi
if [ $CL_ACTION -eq 10 ]; then
clear
break
fi
done
fi
fi
# Setup FTP Server
if [ $CP_ACTION -eq 6 ]; then
clear
echo -e "\033[0;32m${FTP}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Setup FTP Server?(y/n) :')"
if [ $INPUT = "y" ]; then
while true; do
print_g "1) Pure-FTPd FTP Server (recommended)"
print_g "2) ProFTP FTP Server"
print_g "3) Disable FTP Services"
print_g "4) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-4) : ')" 1 4
FTP_ACTION=$INPUT
if [ $FTP_ACTION -eq 1 ]; then
/usr/local/cpanel/scripts/setupftpserver pure-ftpd
print_b "Pure-FTPd Successfully Configured"
sleep 5s
clear
break
elif [ $FTP_ACTION -eq 2 ]; then
/usr/local/cpanel/scripts/setupftpserver proftpd
print_b "ProFTP Successfully Configured"
sleep 5s
clear
break
elif [ $FTP_ACTION -eq 3 ]; then
/usr/local/cpanel/scripts/setupftpserver disabled
print_b "FTP Services Successfully Disabled"
sleep 5s
clear
break
elif [ $FTP_ACTION -eq 4 ]; then
clear
break
fi
done
fi
fi
# Advanced Tools
if [ $CP_ACTION -eq 7 ]; then
clear
echo -e "\033[0;32m${Advanced}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Advanced Tools?(y/n) :')"
if [ $INPUT = "y" ]; then
while true; do
print_g "1) Restore Backup"
print_g "2) Clear RAM Cache"
print_g "3) Delete all error_log"
print_g "4) Clear /tmp"
print_g "5) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-5) : ')" 1 5
AT_ACTION=$INPUT
#Restore Backup
if [ $AT_ACTION -eq 1 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to restore the user backup?(y/n) :')"
if [ $INPUT = "y" ]; then
read -rp "Enter the location home Directory (by default /home) : " directory
if [ -z "$directory" ]; then
cd /home
read -rp "Enter Link Backup : " BackUP
print_g "Downloading the backup file..."
wget "$BackUP"
read -rp "Enter NameFile Backup : " FileBackup
print_g "Restoring the backup file..."
/usr/local/cpanel/scripts/restorepkg "$FileBackup"
else
cd "$directory"
read -rp "Enter Link Backup : " BackUP
print_g "Downloading the backup file..."
wget "$BackUP"
read -rp "Enter NameFile Backup : " FileBackup
print_g "Restoring the backup file..."
/usr/local/cpanel/scripts/restorepkg "$FileBackup"
fi
fi
fi
# Clear RAM Cache
if [ $AT_ACTION -eq 2 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Clear RAM Cache?(y/n) :')"
if [ $INPUT = "y" ]; then
sync; echo 1 > /proc/sys/vm/drop_caches ; sync; echo 2 > /proc/sys/vm/drop_caches ; sync; echo 3 > /proc/sys/vm/drop_caches ; swapoff -a ; swapon -a
print_b "RAM Cache Successfully Cleared"
fi
fi
# Delete all error_log
if [ $AT_ACTION -eq 3 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Clear RAM Cache?(y/n) :')"
if [ $INPUT = "y" ]; then
/usr/bin/find /root*/* -type f -name error_log -exec du -sh {} \;
/usr/bin/find /root*/* -type f -name error_log -exec rm -rf {} \;
/usr/bin/find /home*/*/public_html/*/* -type f -name error_log -exec du -sh {} \;
/usr/bin/find /home*/*/public_html/*/* -type f -name error_log -exec rm -rf {} \;
print_b "all error_log Successfully Delete"
fi
fi
# Clear /tmp
if [ $AT_ACTION -eq 4 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to Clear /tmp?(y/n) :')"
if [ $INPUT = "y" ]; then
if [[ $(cat /etc/os-release | grep -w "ID") == *"centos"* ]]; then
yum install tmpwatch -y ; /usr/sbin/tmpwatch --mtime --all 6 /tmp
print_b "/tmp Successfully Cleared"
elif [[ $(cat /etc/os-release | grep -w "ID") == *"ubuntu"* ]]; then
apt install tmpreaper -y ; /usr/sbin/tmpwatch --mtime --all 6 /tmp
print_b "/tmp Successfully Cleared"
fi
fi
fi
if [ $AT_ACTION -eq 5 ]; then
clear
break
fi
done
fi
fi
done
fi
# sub-menu for Plesk
if [ $CP_CHOICE -eq 2 ]; then
clear
while true; do
echo -e "\033[0;32m${Plesk}\033[0m"
print_y "What do you want to do?"
print_g "1) Install Plesk"
print_g "2) Server Tools [4]"
print_g "3) Setup CSF [4]"
print_g "4) install Plugins [4]"
print_g "5) Advanced Tools [4]"
print_g "6) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-6) : ')" 1 6
PK_ACTION=$INPUT
if [ $PK_ACTION -eq 6 ]; then
clear
break
fi
# Install Plesk
if [ $PK_ACTION -eq 1 ]; then
clear
echo -e "\033[0;32m${InstallPlesk}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Install Plesk?(y/n) :')"
if [ $INPUT = "y" ]; then
sh <(curl https://autoinstall.plesk.com/one-click-installer || wget -O - https://autoinstall.plesk.com/one-click-installer)
fi
fi
# Server Tools
if [ $PK_ACTION -eq 2 ]; then
clear
echo -e "\033[0;32m${Tools}\033[0m"
validate_yn_input "$(print_y 'Are you sure you want to Server Tools?(y/n) :')"
if [ $INPUT = "y" ]; then
while true; do
print_g "1) Change Nameserver"
print_g "2) Change Hostname"
print_g "3) Change SSH Port"
print_g "4) Change Password (root)"
print_g "5) Back to Menu"
validate_menu_input "$(print_y 'Enter your choice (1-5) : ')" 1 5
ST_ACTION=$INPUT
# Change Nameserver
if [ $ST_ACTION -eq 1 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to change the Nameserver?(y/n) :')"
if [ $INPUT = "y" ]; then
read -p "Enter Primary Nameserver: " PRIMARY_NS
read -p "Enter Secondary Nameserver: " SECONDARY_NS
if [ -f /etc/resolv.conf ]; then
sed -i 's/^nameserver/#nameserver/g' /etc/resolv.conf
echo "nameserver $PRIMARY_NS" >> /etc/resolv.conf
echo "nameserver $SECONDARY_NS" >> /etc/resolv.conf
print_b "Nameserver Changed To -> [ "$PRIMARY_NS" - "$SECONDARY_NS" ]"
fi
fi
fi
# Change hostname
if [ $ST_ACTION -eq 2 ]; then
clear
validate_yn_input "$(print_y 'Are you sure you want to change the Hostname?(y/n) :')"
if [ $INPUT = "y" ]; then
read -rp "Enter your Hostname : " HOSTNAME
hostnamectl set-hostname $HOSTNAME
print_b "Hostname Changed To -> "$HOSTNAME""
fi
fi
# Change SSH Port
if [ $ST_ACTION -eq 3 ]; then