forked from centminmod/centminmod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer-latest.sh
executable file
·1490 lines (1399 loc) · 59 KB
/
installer-latest.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
#######################################################
# centminmod.com cli installer
#
#######################################################
export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
# set locale temporarily to english
# due to some non-english locale issues
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_CTYPE=en_US.UTF-8
#######################################################
DT=$(date +"%d%m%y-%H%M%S")
DNF_ENABLE='n'
DNF_COPR='y'
branchname=123.09beta01
DOWNLOAD="${branchname}.zip"
LOCALCENTMINMOD_MIRROR='https://centminmod.com'
FORCE_IPVFOUR='y' # curl/wget commands through script force IPv4
INSTALLDIR='/usr/local/src'
DIR_TMP='/svr-setup'
#CUR_DIR="/usr/local/src/centminmod-${branchname}"
#CM_INSTALLDIR=$CUR_DIR
#SCRIPT_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
#####################################################
# Centmin Mod Git Repo URL - primary repo
# https://github.com/centminmod/centminmod
GITINSTALLED='y'
CMGIT='https://github.com/centminmod/centminmod.git'
# Gitlab backup repo
# https://gitlab.com/centminmod/centminmod
#CMGIT='https://gitlab.com/centminmod/centminmod.git'
#####################################################
# wget renamed github
AXEL='n'
AXEL_VER='2.6'
AXEL_LINKFILE="axel-${AXEL_VER}.tar.gz"
AXEL_LINK="${LOCALCENTMINMOD_MIRROR}/centminmodparts/axel/v${AXEL_VER}.tar.gz"
AXEL_LINKLOCAL="https://github.com/axel-download-accelerator/axel/archive/v${AXEL_VER}.tar.gz"
#######################################################
ALTPCRE_VERSION='8.43'
ALTPCRELINKFILE="pcre-${ALTPCRE_VERSION}.tar.gz"
ALTPCRELINK="${LOCALCENTMINMOD_MIRROR}/centminmodparts/pcre/${ALTPCRELINKFILE}"
WGET_VERSION='1.20.3'
WGET_VERSION_SEVEN='1.20.3'
WGET_FILENAME="wget-${WGET_VERSION}.tar.gz"
WGET_LINK="https://centminmod.com/centminmodparts/wget/${WGET_FILENAME}"
CPUSPEED=$(awk -F: '/cpu MHz/{print $2}' /proc/cpuinfo | sort | uniq -c | sed -e s'| ||g' | xargs);
CPUMODEL=$(awk -F: '/model name/{print $2}' /proc/cpuinfo | sort | uniq -c | xargs);
###########################################################
# Setup Colours
black='\E[30;40m'
red='\E[31;40m'
green='\E[32;40m'
yellow='\E[33;40m'
blue='\E[34;40m'
magenta='\E[35;40m'
cyan='\E[36;40m'
white='\E[37;40m'
boldblack='\E[1;30;40m'
boldred='\E[1;31;40m'
boldgreen='\E[1;32;40m'
boldyellow='\E[1;33;40m'
boldblue='\E[1;34;40m'
boldmagenta='\E[1;35;40m'
boldcyan='\E[1;36;40m'
boldwhite='\E[1;37;40m'
Reset="tput sgr0" # Reset text attributes to normal
#+ without clearing screen.
cecho () # Coloured-echo.
# Argument $1 = message
# Argument $2 = color
{
message=$1
color=$2
echo -e "$color$message" ; $Reset
return
}
###########################################################
shopt -s expand_aliases
for g in "" e f; do
alias ${g}grep="LC_ALL=C ${g}grep" # speed-up grep, egrep, fgrep
done
CENTOSVER=$(awk '{ print $3 }' /etc/redhat-release)
CENTMINLOGDIR='/root/centminlogs'
if [ ! -d "$CENTMINLOGDIR" ]; then
mkdir -p $CENTMINLOGDIR
fi
# sudo adjustment
if [ -d /etc/sudoers.d ]; then
if [ ! -f /etc/sudoers.d/addpaths ]; then
touch /etc/sudoers.d/addpaths
if [[ "$(uname -m)" = 'x86_64' ]]; then
if [[ "$(grep '\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin:\/root\/bin' /etc/sudoers.d/addpaths >/dev/null; echo $?)" != '0' ]]; then
echo "Defaults secure_path = /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" > /etc/sudoers.d/addpaths
fi
else
if [[ "$(grep '\/usr\/local\/sbin:\/usr\/local\/bin:\/sbin:\/bin:\/usr\/sbin:\/usr\/bin:\/root\/bin' /etc/sudoers.d/addpaths >/dev/null; echo $?)" != '0' ]]; then
echo "Defaults secure_path = /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin" > /etc/sudoers.d/addpaths
fi
fi
fi
if [ -f /etc/sudoers.d/addpaths ]; then
chmod 0440 /etc/sudoers.d/addpaths
# visudo -c -q
fi
fi
if [ "$CENTOSVER" == 'release' ]; then
CENTOSVER=$(awk '{ print $4 }' /etc/redhat-release | cut -d . -f1,2)
if [[ "$(cat /etc/redhat-release | awk '{ print $4 }' | cut -d . -f1)" = '7' ]]; then
CENTOS_SEVEN='7'
elif [[ "$(cat /etc/redhat-release | awk '{ print $4 }' | cut -d . -f1)" = '8' ]]; then
CENTOS_EIGHT='8'
fi
fi
if [[ "$(cat /etc/redhat-release | awk '{ print $3 }' | cut -d . -f1)" = '6' ]]; then
CENTOS_SIX='6'
fi
# Check for Redhat Enterprise Linux 7.x
if [ "$CENTOSVER" == 'Enterprise' ]; then
CENTOSVER=$(awk '{ print $7 }' /etc/redhat-release)
if [[ "$(awk '{ print $1,$2 }' /etc/redhat-release)" = 'Red Hat' && "$(awk '{ print $7 }' /etc/redhat-release | cut -d . -f1)" = '7' ]]; then
CENTOS_SEVEN='7'
REDHAT_SEVEN='y'
fi
fi
if [[ -f /etc/system-release && "$(awk '{print $1,$2,$3}' /etc/system-release)" = 'Amazon Linux AMI' ]]; then
CENTOS_SIX='6'
fi
if [[ "$CENTOS_SEVEN" -eq '7' ]]; then
WGET_VERSION=$WGET_VERSION_SEVEN
fi
if [[ "$CENTOS_EIGHT" -eq '8' ]]; then
WGET_VERSION=$WGET_VERSION_SEVEN
# enable CentOS 8 PowerTools repo for -devel packages
if [ ! -f /usr/bin/yum-config-manager ]; then
yum -q -y install dnf-utils
yum-config-manager --enable PowerTools
elif [ -f /usr/bin/yum-config-manager ]; then
yum-config-manager --enable PowerTools
fi
# disable native CentOS 8 AppStream repo based nginx, php & oracle mysql packages
yum -q -y module disable nginx mysql php:7.2
# install missing dependencies specific to CentOS 8
# for csf firewall installs
if [ ! -f /usr/share/perl5/vendor_perl/Math/BigInt.pm ]; then
yum -q -y install perl-Math-BigInt
fi
fi
if [ -f /proc/user_beancounters ]; then
# CPUS='1'
# MAKETHREADS=" -j$CPUS"
# speed up make
CPUS=$(grep -c "processor" /proc/cpuinfo)
if [[ "$CPUS" -gt '8' ]]; then
if [[ "$(grep -o 'AMD EPYC 7601' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7601' ]]; then
# 7601 at 12 cpu cores has 3.20hz clock frequency https://en.wikichip.org/wiki/amd/epyc/7601
# while greater than 12 cpu cores downclocks to 2.70Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7551' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7551' ]]; then
# 7551P at 12 cpu cores has 3.0Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7551p
# while greater than 12 cpu cores downclocks to 2.55Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7501' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7501' ]]; then
# 7501P at 12 cpu cores has 3.0Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7501p
# while greater than 12 cpu cores downclocks to 2.6Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7451' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7451' ]]; then
# 7451 at 12 cpu cores has 3.2Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7451
# while greater than 12 cpu cores downclocks to 2.9Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7401' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7401' ]]; then
# 7401P at 12 cpu cores has 3.0Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7401p
# while greater than 12 cpu cores downclocks to 2.8Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7371' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7371' ]]; then
# 7371 at 8 cpu cores has 3.8Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7371
# while greater than 8 cpu cores downclocks to 3.6Ghz
CPUS=8
else
CPUS=$(echo $(($CPUS+2)))
fi
else
CPUS=$(echo $(($CPUS+1)))
fi
MAKETHREADS=" -j$CPUS"
else
# speed up make
CPUS=$(grep -c "processor" /proc/cpuinfo)
if [[ "$CPUS" -gt '8' ]]; then
if [[ "$(grep -o 'AMD EPYC 7601' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7601' ]]; then
# 7601 at 12 cpu cores has 3.20hz clock frequency https://en.wikichip.org/wiki/amd/epyc/7601
# while greater than 12 cpu cores downclocks to 2.70Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7551' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7551' ]]; then
# 7551P at 12 cpu cores has 3.0Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7551p
# while greater than 12 cpu cores downclocks to 2.55Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7501' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7501' ]]; then
# 7501P at 12 cpu cores has 3.0Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7501p
# while greater than 12 cpu cores downclocks to 2.6Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7451' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7451' ]]; then
# 7451 at 12 cpu cores has 3.2Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7451
# while greater than 12 cpu cores downclocks to 2.9Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7401' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7401' ]]; then
# 7401P at 12 cpu cores has 3.0Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7401p
# while greater than 12 cpu cores downclocks to 2.8Ghz
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7371' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7371' ]]; then
# 7371 at 8 cpu cores has 3.8Ghz clock frequency https://en.wikichip.org/wiki/amd/epyc/7371
# while greater than 8 cpu cores downclocks to 3.6Ghz
CPUS=8
else
CPUS=$(echo $(($CPUS+4)))
fi
elif [[ "$CPUS" -eq '8' ]]; then
CPUS=$(echo $(($CPUS+2)))
else
CPUS=$(echo $(($CPUS+1)))
fi
MAKETHREADS=" -j$CPUS"
fi
if [[ "$CENTOS_SEVEN" = '7' ]]; then
AXEL_VER='2.16.1'
AXEL_LINKFILE="axel-${AXEL_VER}.tar.gz"
AXEL_LINK="${LOCALCENTMINMOD_MIRROR}/centminmodparts/axel/v${AXEL_VER}.tar.gz"
AXEL_LINKLOCAL="https://github.com/axel-download-accelerator/axel/archive/v${AXEL_VER}.tar.gz"
fi
if [ -f /etc/centminmod/custom_config.inc ]; then
source /etc/centminmod/custom_config.inc
fi
if [[ "$FORCE_IPVFOUR" != [yY] ]]; then
ipv_forceopt=""
else
ipv_forceopt='4'
fi
if [[ ! -f /proc/user_beancounters && -f /usr/bin/systemd-detect-virt && "$(/usr/bin/systemd-detect-virt)" = 'lxc' ]] || [[ ! -f /proc/user_beancounters && -f $(which virt-what) && $(virt-what | xargs | grep -o lxc) = 'lxc' ]]; then
CHECK_LXD='y'
fi
if [[ "$(uname -m)" = 'x86_64' ]]; then
if [[ "$CENTOS_SIX" = '6' || "$CENTOS_SEVEN" = '7' ]] && [ ! "$(grep -w 'exclude' /etc/yum.conf)" ]; then
ex -s /etc/yum.conf << EOF
:/plugins=1/
:a
exclude=*.i386 *.i586 *.i686
.
:w
:q
EOF
elif [[ "$CENTOS_EIGHT" = '8' ]] && [ ! "$(grep -w 'exclude' /etc/yum.conf)" ]; then
ex -s /etc/yum.conf << EOF
:/best=True/
:a
exclude=*.i686
.
:w
:q
EOF
fi
fi
# some centos images don't even install tar by default !
if [[ "$CENTOS_EIGHT" = '8' && ! -f /usr/bin/tar ]]; then
yum -y -q install tar
elif [[ "$CENTOS_SEVEN" = '7' && ! -f /usr/bin/tar ]]; then
yum -y -q install tar
elif [[ "$CENTOS_SIX" = '6' && ! -f /bin/tar ]]; then
yum -y -q install tar
fi
if [[ "$CENTOS_SEVEN" = '7' && "$DNF_ENABLE" = [yY] ]]; then
if [[ $(rpm -q epel-release >/dev/null 2>&1; echo $?) != '0' ]]; then
yum -y -q install epel-release
yum clean all
fi
if [[ "$DNF_COPR" = [yY] ]]; then
cat > "/etc/yum.repos.d/dnf-centos.repo" <<EOF
[dnf-centos]
name=Copr repo for dnf-centos owned by @rpm-software-management
baseurl=https://copr-be.cloud.fedoraproject.org/results/@rpm-software-management/dnf-centos/epel-7-\$basearch/
skip_if_unavailable=True
gpgcheck=1
gpgkey=https://copr-be.cloud.fedoraproject.org/results/@rpm-software-management/dnf-centos/pubkey.gpg
enabled=1
enabled_metadata=1
EOF
fi
if [[ ! -f /usr/bin/dnf ]]; then
yum -y -q install dnf
dnf clean all
fi
if [ ! "$(grep -w 'exclude' /etc/dnf/dnf.conf)" ]; then
echo "excludepkgs=*.i386 *.i586 *.i686" >> /etc/dnf/dnf.conf
fi
if [ ! "$(grep -w 'fastestmirror=true' /etc/dnf/dnf.conf)" ]; then
echo "fastestmirror=true" >> /etc/dnf/dnf.conf
fi
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
sed -i 's|enabled .*|enabled = 0|g' /etc/yum.repos.d/rpmforge.repo
DISABLEREPO_DNF=' --disablerepo=rpmforge'
YUMDNFBIN="dnf${DISABLEREPO_DNF}"
else
DISABLEREPO_DNF=""
YUMDNFBIN='dnf'
fi
else
YUMDNFBIN='yum'
if [ -f /etc/yum.repos.d/rpmforge.repo ]; then
DISABLEREPO_DNF=' --disablerepo=rpmforge'
else
DISABLEREPO_DNF=""
fi
fi
if [ ! -f /usr/bin/sar ]; then
time $YUMDNFBIN -y -q install sysstat${DISABLEREPO_DNF}
if [[ "$(uname -m)" = 'x86_64' || "$(uname -m)" = 'aarch64' ]]; then
SARCALL='/usr/lib64/sa/sa1'
else
SARCALL='/usr/lib/sa/sa1'
fi
if [[ "$CENTOS_SIX" = '6' ]]; then
sed -i 's|10|5|g' /etc/cron.d/sysstat
if [ -d /etc/cron.d ]; then
echo '* * * * * root /usr/lib64/sa/sa1 1 1' > /etc/cron.d/cmsar
fi
service sysstat restart
chkconfig sysstat on
elif [[ "$CENTOS_SEVEN" = '7' ]]; then
sed -i 's|10|5|g' /etc/cron.d/sysstat
if [ -d /etc/cron.d ]; then
echo '* * * * * root /usr/lib64/sa/sa1 1 1' > /etc/cron.d/cmsar
fi
systemctl restart sysstat.service
systemctl enable sysstat.service
elif [[ "$CENTOS_EIGHT" = '8' ]]; then
sed -i 's|10|5|g' /usr/lib/systemd/system/sysstat-collect.timer
#if [ -d /etc/cron.d ]; then
# echo '* * * * * root /usr/lib64/sa/sa1 1 1' > /etc/cron.d/cmsar
#fi
systemctl daemon-reload
systemctl restart sysstat.service
systemctl enable sysstat.service
fi
elif [ -f /usr/bin/sar ]; then
if [[ "$(uname -m)" = 'x86_64' || "$(uname -m)" = 'aarch64' ]]; then
SARCALL='/usr/lib64/sa/sa1'
else
SARCALL='/usr/lib/sa/sa1'
fi
if [[ "$CENTOS_SIX" = '6' ]]; then
sed -i 's|10|5|g' /etc/cron.d/sysstat
if [ -d /etc/cron.d ]; then
echo '* * * * * root /usr/lib64/sa/sa1 1 1' > /etc/cron.d/cmsar
fi
service sysstat restart
chkconfig sysstat on
elif [[ "$CENTOS_SEVEN" = '7' ]]; then
sed -i 's|10|5|g' /etc/cron.d/sysstat
if [ -d /etc/cron.d ]; then
echo '* * * * * root /usr/lib64/sa/sa1 1 1' > /etc/cron.d/cmsar
fi
systemctl restart sysstat.service
systemctl enable sysstat.service
elif [[ "$CENTOS_EIGHT" = '8' ]]; then
sed -i 's|10|5|g' /usr/lib/systemd/system/sysstat-collect.timer
#if [ -d /etc/cron.d ]; then
# echo '* * * * * root /usr/lib64/sa/sa1 1 1' > /etc/cron.d/cmsar
#fi
systemctl daemon-reload
systemctl restart sysstat.service
systemctl enable sysstat.service
fi
fi
if [[ "$CENTOS_SEVEN" = '7' ]]; then
# set ld.gold linker as system default
/usr/sbin/alternatives --set ld /usr/bin/ld.gold
ld -v
fi
if [ -f /proc/user_beancounters ]; then
echo "OpenVZ system detected, NTP not installed"
elif [[ "$CHECK_LXD" = [yY] ]]; then
echo "LXC/LXD container system detected, NTP not installed"
else
if [[ "$CENTOS_EIGHT" = '8' ]]; then
echo
time $YUMDNFBIN -y install chrony
systemctl start chronyd
systemctl enable chronyd
systemctl status chronyd
echo "current chrony ntp servers"
chronyc sources
else
if [ ! -f /usr/sbin/ntpd ]; then
echo "*************************************************"
echo "* Installing NTP (and syncing time)"
echo "*************************************************"
echo "The date/time before was:"
date
echo
time $YUMDNFBIN -y install ntp
chkconfig ntpd on
if [ -f /etc/ntp.conf ]; then
if [[ -z "$(grep 'logfile' /etc/ntp.conf)" ]]; then
echo "logfile /var/log/ntpd.log" >> /etc/ntp.conf
ls -lahrt /var/log | grep 'ntpd.log'
fi
echo "current ntp servers"
NTPSERVERS=$(awk '/server / {print $2}' /etc/ntp.conf | grep ntp.org | sort -r)
for s in $NTPSERVERS; do
if [ -f /usr/bin/nc ]; then
echo -ne "\n$s test connectivity: "
if [[ "$(echo | nc -u -w1 $s 53 >/dev/null 2>&1 ;echo $?)" = '0' ]]; then
echo " ok"
else
echo " error"
fi
fi
ntpdate -q $s | tail -1
if [[ -f /etc/ntp/step-tickers && -z "$(grep $s /etc/ntp/step-tickers )" ]]; then
echo "$s" >> /etc/ntp/step-tickers
fi
done
if [ -f /etc/ntp/step-tickers ]; then
echo -e "\nsetup /etc/ntp/step-tickers server list\n"
cat /etc/ntp/step-tickers
fi
service ntpd restart >/dev/null 2>&1
echo -e "\ncheck ntpd peers list"
ntpdc -p
fi
fi
fi
echo "The date/time is now:"
date
fi
# only run for CentOS 6.x
if [[ "$CENTOS_SEVEN" != '7' ]]; then
echo ""
echo "Check for existing mysql-server packages"
OLDMYSQLSERVER=`rpm -qa | grep 'mysql-server' | head -n1`
if [[ ! -z "$OLDMYSQLSERVER" ]]; then
echo "rpm -e --nodeps $OLDMYSQLSERVER"
rpm -e --nodeps $OLDMYSQLSERVER
fi
fi # CENTOS_SEVEN != 7
# only run for CentOS 7.x
if [[ "$CENTOS_SEVEN" = '7' ]]; then
echo ""
echo "Check for existing mariadb packages"
OLDMYSQLSERVER=`rpm -qa | grep 'mariadb-server' | head -n1`
if [[ ! -z "$OLDMYSQLSERVER" ]]; then
echo "rpm -e --nodeps $OLDMYSQLSERVER"
rpm -e --nodeps $OLDMYSQLSERVER
fi
echo ""
echo "Check for existing mariadb-libs package"
OLDMYSQL_LIBS=`rpm -qa | grep 'mariadb-libs' | head -n1`
if [[ ! -z "$OLDMYSQL_LIBS" ]]; then
# echo "rpm -e --nodeps $OLDMYSQL_LIBS"
# rpm -e --nodeps $OLDMYSQL_LIBS
echo "yum -y remove mariadb-libs"
yum -y remove mariadb-libs
fi
echo ""
# Should not exist on CentOS 7 systems
echo "Check for existing MySQL-shared-compat"
OLDMYSQL_SHAREDCOMPAT=`rpm -qa | grep 'MySQL-shared-compat' | head -n1`
if [[ ! -z "$OLDMYSQL_SHAREDCOMPAT" ]]; then
echo "yum -y remove MySQL-shared-compat"
yum -y remove MySQL-shared-compat
fi
fi # CENTOS_SEVEN != 7
sar_call() {
$SARCALL 1 1
}
systemstats() {
if [ -d /root/centminlogs ]; then
sar -u > /root/centminlogs/sar-u-installstats.log
sar -q > /root/centminlogs/sar-q-installstats.log
sar -r > /root/centminlogs/sar-r-installstats.log
if [ ! -f /proc/user_beancounters ]; then
sar -d > /root/centminlogs/sar-d-installstats.log
fi
sar -b > /root/centminlogs/sar-b-installstats.log
if [[ "$(hostname -f 2>&1 | grep -w 'Unknown host')" || "$(hostname -f 2>&1 | grep -w 'service not known')" ]]; then
SERVERHOSTNAME=$(hostname)
else
SERVERHOSTNAME=$(hostname -f)
fi
sed -i "s|$SERVERHOSTNAME|hostname|" /root/centminlogs/sar-u-installstats.log
sed -i "s|$SERVERHOSTNAME|hostname|" /root/centminlogs/sar-q-installstats.log
sed -i "s|$SERVERHOSTNAME|hostname|" /root/centminlogs/sar-r-installstats.log
if [ ! -f /proc/user_beancounters ]; then
sed -i "s|$SERVERHOSTNAME|hostname|" /root/centminlogs/sar-d-installstats.log
fi
sed -i "s|$SERVERHOSTNAME|hostname|" /root/centminlogs/sar-b-installstats.log
if [[ "$CENTOS_SEVEN" = '7' ]]; then
if [[ "$(uname -m)" = 'x86_64' ]]; then
if [ -f /var/cache/yum/x86_64/7/timedhosts.txt ]; then
sort -k2 /var/cache/yum/x86_64/7/timedhosts.txt > /root/centminlogs/yum-timedhosts.txt
fi
fi
else
if [[ "$(uname -m)" = 'x86_64' ]]; then
if [ -f /var/cache/yum/timedhosts.txt ]; then
sort -k2 /var/cache/yum/timedhosts.txt > /root/centminlogs/yum-timedhosts.txt
fi
else
if [ -f /var/cache/yum/i386/6/timedhosts.txt ]; then
sort -k2 /var/cache/yum/i386/6/timedhosts.txt > /root/centminlogs/yum-timedhosts.txt
fi
fi
fi
fi
if [ -f /etc/cron.d/cmsar ]; then
rm -rf /etc/cron.d/cmsar
fi
}
scl_install() {
# if gcc version is less than 4.7 (407) install scl collection yum repo
if [[ "$CENTOS_SIX" = '6' ]]; then
# if devtoolset exists, enable it first before checking gcc versions
if [[ "$DEVTOOLSETSIX" = [yY] ]]; then
if [[ -f /opt/rh/devtoolset-6/root/usr/bin/gcc && -f /opt/rh/devtoolset-6/root/usr/bin/g++ ]]; then
source /opt/rh/devtoolset-6/enable
fi
else
if [[ -f /opt/rh/devtoolset-6/root/usr/bin/gcc && -f /opt/rh/devtoolset-6/root/usr/bin/g++ ]]; then
source /opt/rh/devtoolset-6/enable
fi
fi
if [[ "$(gcc --version | head -n1 | awk '{print $3}' | cut -d . -f1,2 | sed "s|\.|0|")" -lt '407' ]]; then
echo "install centos-release-scl for newer gcc and g++ versions"
if [[ -z "$(rpm -qa | grep rpmforge)" ]]; then
if [[ "$(rpm -ql centos-release-scl >/dev/null 2>&1; echo $?)" -ne '0' ]]; then
time $YUMDNFBIN -y -q install centos-release-scl
fi
sar_call
else
if [[ "$(rpm -ql centos-release-scl >/dev/null 2>&1; echo $?)" -ne '0' ]]; then
time $YUMDNFBIN -y -q install centos-release-scl --disablerepo=rpmforge
fi
sar_call
fi
if [[ "$DEVTOOLSETSIX" = [yY] ]]; then
if [[ -z "$(rpm -qa | grep rpmforge)" ]]; then
time $YUMDNFBIN -y -q install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils
sar_call
else
time $YUMDNFBIN -y -q install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils --disablerepo=rpmforge
sar_call
fi
echo
/opt/rh/devtoolset-6/root/usr/bin/gcc --version
/opt/rh/devtoolset-6/root/usr/bin/g++ --version
else
if [[ -z "$(rpm -qa | grep rpmforge)" ]]; then
time $YUMDNFBIN -y -q install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils
sar_call
else
time $YUMDNFBIN -y -q install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils --disablerepo=rpmforge
sar_call
fi
echo
/opt/rh/devtoolset-6/root/usr/bin/gcc --version
/opt/rh/devtoolset-6/root/usr/bin/g++ --version
fi
fi
elif [[ "$CENTOS_SEVEN" = '7' ]]; then
if [[ -z "$(rpm -qa | grep rpmforge)" ]]; then
if [[ "$(rpm -ql centos-release-scl >/dev/null 2>&1; echo $?)" -ne '0' ]]; then
time $YUMDNFBIN -y -q install centos-release-scl
fi
sar_call
else
if [[ "$(rpm -ql centos-release-scl >/dev/null 2>&1; echo $?)" -ne '0' ]]; then
time $YUMDNFBIN -y -q install centos-release-scl --disablerepo=rpmforge
fi
sar_call
fi
if [[ "$DEVTOOLSETSIX" = [yY] ]]; then
if [[ -z "$(rpm -qa | grep rpmforge)" ]]; then
time $YUMDNFBIN -y -q install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils
sar_call
else
time $YUMDNFBIN -y -q install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils --disablerepo=rpmforge
sar_call
fi
echo
/opt/rh/devtoolset-6/root/usr/bin/gcc --version
/opt/rh/devtoolset-6/root/usr/bin/g++ --version
else
if [[ -z "$(rpm -qa | grep rpmforge)" ]]; then
time $YUMDNFBIN -y -q install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils
sar_call
else
time $YUMDNFBIN -y -q install devtoolset-6-gcc devtoolset-6-gcc-c++ devtoolset-6-binutils --disablerepo=rpmforge
sar_call
fi
echo
/opt/rh/devtoolset-6/root/usr/bin/gcc --version
/opt/rh/devtoolset-6/root/usr/bin/g++ --version
fi
fi # centos 6 only needed
}
gccdevtools() {
if [[ ! -f /opt/rh/devtoolset-4/root/usr/bin/gcc || ! -f /opt/rh/devtoolset-4/root/usr/bin/g++ || ! -f /opt/rh/devtoolset-6/root/usr/bin/gcc || ! -f /opt/rh/devtoolset-6/root/usr/bin/g++ ]] && [[ "$CENTOS_SIX" = '6' ]]; then
scl_install
unset CC
unset CXX
if [[ "$DEVTOOLSETSIX" = [yY] ]]; then
export CC="/opt/rh/devtoolset-6/root/usr/bin/gcc"
export CXX="/opt/rh/devtoolset-6/root/usr/bin/g++"
else
export CC="/opt/rh/devtoolset-6/root/usr/bin/gcc"
export CXX="/opt/rh/devtoolset-6/root/usr/bin/g++"
fi
elif [[ "$DEVTOOLSETSIX" = [yY] && -f /opt/rh/devtoolset-6/root/usr/bin/gcc && -f /opt/rh/devtoolset-6/root/usr/bin/g++ ]] && [[ "$(gcc --version | head -n1 | awk '{print $3}' | cut -d . -f1,2 | sed "s|\.|0|")" -lt '407' ]]; then
unset CC
unset CXX
export CC="/opt/rh/devtoolset-6/root/usr/bin/gcc"
export CXX="/opt/rh/devtoolset-6/root/usr/bin/g++"
elif [[ -f /opt/rh/devtoolset-4/root/usr/bin/gcc && -f /opt/rh/devtoolset-4/root/usr/bin/g++ ]] && [[ "$(gcc --version | head -n1 | awk '{print $3}' | cut -d . -f1,2 | sed "s|\.|0|")" -lt '407' ]]; then
unset CC
unset CXX
export CC="/opt/rh/devtoolset-4/root/usr/bin/gcc"
export CXX="/opt/rh/devtoolset-4/root/usr/bin/g++"
fi
}
source_pcreinstall() {
if [[ "$(/usr/local/bin/pcre-config --version 2>&1 | grep -q ${ALTPCRE_VERSION} >/dev/null 2>&1; echo $?)" != '0' ]]; then
cd "$DIR_TMP"
cecho "Download $ALTPCRELINKFILE ..." $boldyellow
if [ -s "$ALTPCRELINKFILE" ]; then
cecho "$ALTPCRELINKFILE Archive found, skipping download..." $boldgreen
else
wget -c${ipv_forceopt} --progress=bar "$ALTPCRELINK" --tries=3
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
cecho "Error: $ALTPCRELINKFILE download failed." $boldgreen
exit #$ERROR
else
cecho "Download done." $boldyellow
fi
fi
tar xzf "$ALTPCRELINKFILE"
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
cecho "Error: $ALTPCRELINKFILE extraction failed." $boldgreen
exit #$ERROR
else
cecho "$ALTPCRELINKFILE valid file." $boldyellow
echo ""
fi
cd "pcre-${ALTPCRE_VERSION}"
./configure --enable-utf8 --enable-unicode-properties --enable-pcre16 --enable-pcre32 --enable-pcregrep-libz --enable-pcregrep-libbz2 --enable-pcretest-libreadline --enable-jit
sar_call
make${MAKETHREADS}
sar_call
make install
sar_call
/usr/local/bin/pcre-config --version
fi
}
source_wgetinstall() {
if [[ "$(/usr/local/bin/wget -V | head -n1 | awk '{print $3}' | grep -q ${WGET_VERSION} >/dev/null 2>&1; echo $?)" != '0' ]]; then
cd "$DIR_TMP"
cecho "Download $WGET_FILENAME ..." $boldyellow
if [ -s "$WGET_FILENAME" ]; then
cecho "$WGET_FILENAME Archive found, skipping download..." $boldgreen
else
wget -c${ipv_forceopt} --progress=bar "$WGET_LINK" -O "$WGET_FILENAME" --tries=3
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
cecho "Error: $WGET_FILENAME download failed." $boldgreen
exit #$ERROR
else
cecho "Download done." $boldyellow
fi
fi
tar xzf "$WGET_FILENAME"
ERROR=$?
if [[ "$ERROR" != '0' ]]; then
cecho "Error: $WGET_FILENAME extraction failed." $boldgreen
exit #$ERROR
else
cecho "$WGET_FILENAME valid file." $boldyellow
echo ""
fi
cd "wget-${WGET_VERSION}"
gccdevtools
make clean
if [[ "$(uname -m)" = 'x86_64' ]]; then
export CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic"
export PCRE_CFLAGS="-I /usr/local/include"
export PCRE_LIBS="-L /usr/local/lib -lpcre"
# ensure wget.sh installer utilises system openssl
export OPENSSL_CFLAGS="-I /usr/include"
export OPENSSL_LIBS="-L /usr/lib64 -lssl -lcrypto"
else
export CFLAGS="-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic"
export PCRE_CFLAGS="-I /usr/local/include"
export PCRE_LIBS="-L /usr/local/lib -lpcre"
if [ -f /root/.wgetrc ]; then
\cp -fp /root/.wgetrc /root/.wgetrc-bak
echo "ca_certificate=/etc/pki/tls/certs/ca-bundle.crt" > /root/.wgetrc
else
echo "ca_certificate=/etc/pki/tls/certs/ca-bundle.crt" > /root/.wgetrc
fi
fi
# ./configure --with-ssl=openssl PCRE_CFLAGS="-I /usr/local/include" PCRE_LIBS="-L /usr/local/lib -lpcre"
./configure --with-ssl=openssl
sar_call
make${MAKETHREADS}
sar_call
make install
sar_call
echo "/usr/local/lib/" > /etc/ld.so.conf.d/wget.conf
ldconfig
if [[ ! "$(grep '^alias wget' /root/.bashrc)" ]]; then
echo "alias wget='/usr/local/bin/wget'" >> /root/.bashrc
fi
. /root/.bashrc
if [[ "$(id -u)" -ne '0' ]]; then
if [[ ! "$(grep '^alias wget' $HOME/.bashrc)" ]]; then
echo "alias wget='/usr/local/bin/wget'" >> $HOME/.bashrc
fi
. $HOME/.bashrc
fi
echo
cecho "--------------------------------------------------------" $boldgreen
echo "ldconfig -p | grep libpcre.so.1"
ldconfig -p | grep libpcre.so.1
echo
echo "ldd $(which wget)"
ldd $(which wget)
cecho "--------------------------------------------------------" $boldgreen
cecho "wget -V" $boldyellow
wget -V
cecho "--------------------------------------------------------" $boldgreen
cecho "wget ${WGET_VERSION} installed at /usr/local/bin/wget" $boldyellow
cecho "--------------------------------------------------------" $boldgreen
unset CFLAGS
echo
fi
}
fileperm_fixes() {
if [ -f /usr/lib/udev/rules.d/60-net.rules ]; then
if [[ "$(lsattr /usr/lib/udev/rules.d/60-net.rules | cut -c5)" = 'i' ]]; then
# fix for some centos 7 vps templates on vps hosts setting chattr +i on
# /usr/lib/udev/rules.d/60-net.rules preventing yum updates for initscripts
# yum packages
chattr -i /usr/lib/udev/rules.d/60-net.rules
fi
fi
}
libc_fix() {
# https://community.centminmod.com/posts/52555/
if [[ "$CENTOS_SEVEN" -eq '7' && ! -f /etc/yum/pluginconf.d/versionlock.conf && "$(rpm -qa libc-client)" = 'libc-client-2007f-16.el7.x86_64' ]]; then
yum -y install yum-plugin-versionlock uw-imap-devel
yum versionlock libc-client uw-imap-devel
elif [[ "$CENTOS_SEVEN" -eq '7' && ! -f /etc/yum/pluginconf.d/versionlock.conf && "$(rpm -qa libc-client)" != 'libc-client-2007f-16.el7.x86_64' ]]; then
INIT_DIR=$(echo $PWD)
cd /svr-setup
wget https://centminmod.com/centminmodparts/uw-imap/libc-client-2007f-16.el7.x86_64.rpm
wget https://centminmod.com/centminmodparts/uw-imap/uw-imap-devel-2007f-16.el7.x86_64.rpm
yum -y remove libc-client
yum -y localinstall libc-client-2007f-16.el7.x86_64.rpm uw-imap-devel-2007f-16.el7.x86_64.rpm
yum -y install yum-plugin-versionlock
yum versionlock libc-client uw-imap-devel uw-imap-devel
cd "$INIT_DIR"
elif [[ "$CENTOS_SEVEN" -eq '7' && -f /etc/yum/pluginconf.d/versionlock.conf && "$(rpm -qa libc-client)" != 'libc-client-2007f-16.el7.x86_64' ]]; then
INIT_DIR=$(echo $PWD)
cd /svr-setup
wget https://centminmod.com/centminmodparts/uw-imap/libc-client-2007f-16.el7.x86_64.rpm
wget https://centminmod.com/centminmodparts/uw-imap/uw-imap-devel-2007f-16.el7.x86_64.rpm
yum versionlock delete libc-client uw-imap-devel
yum -y remove libc-client
yum -y localinstall libc-client-2007f-16.el7.x86_64.rpm uw-imap-devel-2007f-16.el7.x86_64.rpm
yum versionlock libc-client uw-imap-devel uw-imap-devel
cd "$INIT_DIR"
fi
}
opt_tcp() {
#######################################################
# check if custom open file descriptor limits already exist
LIMITSCONFCHECK=`grep '* hard nofile 524288' /etc/security/limits.conf`
if [[ -z $LIMITSCONFCHECK ]]; then
# Set VPS hard/soft limits
echo "* soft nofile 524288" >>/etc/security/limits.conf
echo "* hard nofile 524288" >>/etc/security/limits.conf
# https://community.centminmod.com/posts/52406/
if [[ "$CENTOS_SEVEN" = '7' && ! -f /etc/rc.d/rc.local ]]; then
cat > /usr/lib/systemd/system/rc-local.service <<EOF
# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.d/rc.local is executable.
[Unit]
Description=/etc/rc.d/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.d/rc.local start
TimeoutSec=0
RemainAfterExit=yes
EOF
cat > /etc/rc.d/rc.local <<EOF
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
EOF
# remove non-standard centos 7 service file if detected
if [ -f /etc/systemd/system/rc-local.service ]; then
echo "cat /etc/systemd/system/rc-local.service"
cat /etc/systemd/system/rc-local.service
echo
rm -rf /etc/systemd/system/rc-local.service
rm -rf /var/lock/subsys/local
systemctl daemon-reload
systemctl stop rc-local.service
fi
chmod +x /etc/rc.d/rc.local
pushd /etc; ln -s rc.d/rc.local /etc/rc.local; popd
systemctl daemon-reload
systemctl start rc-local.service
systemctl status rc-local.service
fi
ulimit -n 524288
echo "ulimit -n 524288" >> /etc/rc.local
if [[ ! "$(grep '/var/run/php-fpm' /etc/rc.local)" ]]; then
echo 'if [ ! -d /var/run/php-fpm/ ]; then mkdir -p /var/run/php-fpm/; fi' >> /etc/rc.local
fi
fi # check if custom open file descriptor limits already exist
if [[ "$CENTOS_SEVEN" = '7' ]]; then
# centos 7
if [[ -f /etc/security/limits.d/20-nproc.conf ]]; then
cat > "/etc/security/limits.d/20-nproc.conf" <<EOF
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 8192
* hard nproc 8192
nginx soft nproc 32278
nginx hard nproc 32278
root soft nproc unlimited
EOF
fi
else
# centos 6
if [[ -f /etc/security/limits.d/90-nproc.conf ]]; then
cat > "/etc/security/limits.d/90-nproc.conf" <<EOF
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 8192
* hard nproc 8192
nginx soft nproc 32278
nginx hard nproc 32278
root soft nproc unlimited
EOF
fi # raise user process limits
fi
if [[ ! -f /proc/user_beancounters ]]; then
if [[ "$CENTOS_SEVEN" = '7' ]]; then
if [ -d /etc/sysctl.d ]; then
# centos 7
touch /etc/sysctl.d/101-sysctl.conf
if [[ "$(grep 'centminmod added' /etc/sysctl.d/101-sysctl.conf >/dev/null 2>&1; echo $?)" != '0' ]]; then
# raise hashsize for conntrack entries
echo 65536 > /sys/module/nf_conntrack/parameters/hashsize
if [[ "$(grep 'hashsize' /etc/rc.local >/dev/null 2>&1; echo $?)" != '0' ]]; then
echo "echo 65536 > /sys/module/nf_conntrack/parameters/hashsize" >> /etc/rc.local
fi
cat >> "/etc/sysctl.d/101-sysctl.conf" <<EOF
# centminmod added
kernel.pid_max=65536
kernel.printk=4 1 1 7
fs.nr_open=12000000
fs.file-max=9000000
net.core.wmem_max=16777216
net.core.rmem_max=16777216
net.ipv4.tcp_rmem=8192 87380 16777216
net.ipv4.tcp_wmem=8192 65536 16777216
net.core.netdev_max_backlog=65536
net.core.somaxconn=65535
net.core.optmem_max=8192
net.ipv4.tcp_fin_timeout=10
net.ipv4.tcp_keepalive_intvl=30
net.ipv4.tcp_keepalive_probes=3
net.ipv4.tcp_keepalive_time=240
net.ipv4.tcp_max_syn_backlog=65536
net.ipv4.tcp_sack=1
net.ipv4.tcp_syn_retries=3
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 0
net.ipv4.tcp_max_tw_buckets = 1440000
vm.swappiness=10
vm.min_free_kbytes=65536
net.ipv4.ip_local_port_range=1024 65535
net.ipv4.tcp_slow_start_after_idle=0
net.ipv4.tcp_limit_output_bytes=65536
net.ipv4.tcp_rfc1337=1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.default.log_martians = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.netfilter.nf_conntrack_helper=0
net.nf_conntrack_max = 524288
net.netfilter.nf_conntrack_tcp_timeout_established = 28800
net.netfilter.nf_conntrack_generic_timeout = 60
net.ipv4.tcp_challenge_ack_limit = 999999999
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_base_mss = 1024
net.unix.max_dgram_qlen = 4096
EOF
if [[ "$(grep -o 'AMD EPYC' /proc/cpuinfo | sort -u)" = 'AMD EPYC' ]]; then
echo "kernel.watchdog_thresh = 20" >> /etc/sysctl.d/101-sysctl.conf
fi
/sbin/sysctl --system
fi
fi
else
# centos 6