-
-
Notifications
You must be signed in to change notification settings - Fork 161
/
installer81.sh
executable file
·2488 lines (2373 loc) · 111 KB
/
installer81.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
#
#######################################################
# some OS image templates are missing some locales that need to be installed
check_install_locale() {
if [[ ! "$(locale -a | grep -qi "en_US.UTF8")" ]]; then
local os_version=$(rpm -qa yum | grep -o 'el[0-9]*')
case "$os_version" in
el7)
yum install -y glibc-common
;;
el8|el9)
yum install -y glibc-langpack-en
;;
esac
fi
}
check_install_locale
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
# disable systemd pager so it doesn't pipe systemctl output to less
export SYSTEMD_PAGER=''
ARCH_CHECK="$(uname -m)"
DT=$(date +"%d%m%y-%H%M%S")
exec > >(tee -a installer_${DT}.log) 2>&1
if [[ "$ARCH_CHECK" = 'aarch64' ]]; then echo; echo -e "Centmin Mod supports x86_64 CPUs only.\nARM based aarch64 CPUs not supported yet."; echo; exit 1; fi
#######################################################
# check if Centmin Mod already installed
FIRSTYUM_FILE=""
# Only run the find command if the directory exists
if [[ -d /root/centminlogs/ ]]; then
FIRSTYUM_FILE=$(find /root/centminlogs/ -maxdepth 1 -type f -name "firstyum_installtime_*.log" | head -n 1)
fi
if [[ -f "$FIRSTYUM_FILE" ]] || [[ -f /usr/local/src/centminmod/centmin.sh && -f /usr/local/bin/php && -f /usr/local/sbin/nginx ]]; then
echo
echo "error: Detected that Centmin Mod has already been installed on this system"
echo " You are only meant to run initial installer once"
echo " If you want to reinstall Centmin Mod, you need to reinstall"
echo " your operating system first."
echo
exit
fi
mkdir -p /etc/centminmod
touch /etc/centminmod/custom_config.inc
#if [ ! "$(grep 'CENTOS_ALPHATEST' /etc/centminmod/custom_config.inc)" ]; then
# echo "CENTOS_ALPHATEST='y'" >> /etc/centminmod/custom_config.inc
#fi
CENTOS_ALPHATEST='y'
#######################################################
DNF_ENABLE='n'
DNF_COPR='y'
branchname='140.00beta01'
DOWNLOAD="${branchname}.zip"
LOCALCENTMINMOD_MIRROR='https://centminmod.com'
CPUS=$(nproc)
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.45'
ALTPCRELINKFILE="pcre-${ALTPCRE_VERSION}.tar.gz"
ALTPCRELINK="${LOCALCENTMINMOD_MIRROR}/centminmodparts/pcre/${ALTPCRELINKFILE}"
WGET_VERSION='1.20.3'
WGET_VERSION_SEVEN='1.20.3'
WGET_VERSION_EIGHT='1.21.4'
WGET_VERSION_NINE='1.21.4'
WGET_FILENAME="wget-${WGET_VERSION}.tar.gz"
WGET_LINK="${LOCALCENTMINMOD_MIRROR}/centminmodparts/wget/${WGET_FILENAME}"
OS_PRETTY_NAME=$(cat /etc/os-release | awk -F '=' '/PRETTY_NAME/ {print $2}' | sed -e 's| (| |g' -e 's|)| |g' -e 's| Core ||g' -e 's|"||g')
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
}
###########################################################
if [ "$(id -u)" != 0 ]; then
echo "script needs to be run as root user" >&2
if [ "$(id -Gn | grep -o wheel)" ]; then
echo "if using a sudo user, switch to full root first:" >&2
echo >&2
echo "sudo -i" >&2
fi
exit 1
fi
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
lets_dst_root_ca_fix() {
if [ "$(/usr/bin/openssl version | grep '1.0.2')" ] && [ ! -z "$(grep -i 'DST Root CA X3' /etc/pki/tls/certs/ca-bundle.crt)" ]; then
echo
echo "Update workaround to blacklist expiring Letsencrypt DST Root CA X3 certificate..."
echo "https://community.centminmod.com/threads/21965/"
echo
mkdir -p /root/tools/backup-ca-certs
if [ -f /etc/pki/tls/certs/ca-bundle.crt ]; then
\cp -f /etc/pki/tls/certs/ca-bundle.crt /root/tools/backup-ca-certs/ca-bundle.crt-backup
fi
if [[ ! -f /usr/bin/trust || ! -f /usr/bin/update-ca-trust ]]; then
yum -q -y install ca-certificates p11-kit-trust
fi
if [[ -f /usr/bin/trust && -f /usr/bin/update-ca-trust ]]; then
trust dump --filter "pkcs11:id=%c4%a7%b1%a4%7b%2c%71%fa%db%e1%4b%90%75%ff%c4%15%60%85%89%10" | openssl x509 > /etc/pki/ca-trust/source/blacklist/DST-Root-CA-X3.pem
update-ca-trust extract
diff /root/tools/backup-ca-certs/ca-bundle.crt-backup /etc/pki/tls/certs/ca-bundle.crt > /root/tools/backup-ca-certs/diff-ca-bundle.crt.diff
echo "Diff check file at /root/tools/backup-ca-certs/diff-ca-bundle.crt.diff"
echo
echo "Check to see if DST Root CA X3 is blacklisted"
echo "trust list | grep -C3 'DST Root CA X3' | grep -B1 'blacklisted'"
echo
trust list | grep -C3 'DST Root CA X3' | grep -B1 'blacklisted'
echo
echo "Update ca-certificates YUM package for permanent fix"
yum -q -y update ca-certificates
echo "Updated ca-certificates"
yum -q history list ca-certificates
fi
fi
}
lets_dst_root_ca_fix
# 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'
elif [[ "$(cat /etc/redhat-release | awk '{ print $4 }' | cut -d . -f1)" = '9' ]]; then
CENTOS_NINE='9'
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
# ensure only el8+ OS versions are being looked at for alma linux, rocky linux
# oracle linux, vzlinux, circle linux, navy linux, euro linux
EL_VERID=$(awk -F '=' '/VERSION_ID/ {print $2}' /etc/os-release | sed -e 's|"||g' | cut -d . -f1)
if [ -f /etc/almalinux-release ] && [[ "$EL_VERID" -eq 8 || "$EL_VERID" -eq 9 ]]; then
CENTOSVER=$(awk '{ print $3 }' /etc/almalinux-release | cut -d . -f1,2)
ALMALINUXVER=$(awk '{ print $3 }' /etc/almalinux-release | cut -d . -f1,2 | sed -e 's|\.|000|g')
if [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '8' ]]; then
CENTOS_EIGHT='8'
ALMALINUX_EIGHT='8'
elif [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '9' ]]; then
CENTOS_NINE='9'
ALMALINUX_NINE='9'
fi
elif [ -f /etc/rocky-release ] && [[ "$EL_VERID" -eq 8 || "$EL_VERID" -eq 9 ]]; then
CENTOSVER=$(awk '{ print $4 }' /etc/rocky-release | cut -d . -f1,2)
ROCKYLINUXVER=$(awk '{ print $3 }' /etc/rocky-release | cut -d . -f1,2 | sed -e 's|\.|000|g')
if [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '8' ]]; then
CENTOS_EIGHT='8'
ROCKYLINUX_EIGHT='8'
elif [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '9' ]]; then
CENTOS_NINE='9'
ROCKYLINUX_NINE='9'
fi
elif [ -f /etc/oracle-release ] && [[ "$EL_VERID" -eq 8 || "$EL_VERID" -eq 9 ]]; then
CENTOSVER=$(awk '{ print $5 }' /etc/oracle-release | cut -d . -f1,2)
if [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '8' ]]; then
CENTOS_EIGHT='8'
ORACLELINUX_EIGHT='8'
elif [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '9' ]]; then
CENTOS_NINE='9'
ORACLELINUX_NINE='9'
fi
elif [ -f /etc/vzlinux-release ] && [[ "$EL_VERID" -eq 8 || "$EL_VERID" -eq 9 ]]; then
CENTOSVER=$(awk '{ print $4 }' /etc/vzlinux-release | cut -d . -f1,2)
if [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '8' ]]; then
CENTOS_EIGHT='8'
VZLINUX_EIGHT='8'
elif [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '9' ]]; then
CENTOS_NINE='9'
VZLINUX_NINE='9'
fi
elif [ -f /etc/circle-release ] && [[ "$EL_VERID" -eq 8 || "$EL_VERID" -eq 9 ]]; then
CENTOSVER=$(awk '{ print $4 }' /etc/circle-release | cut -d . -f1,2)
if [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '8' ]]; then
CENTOS_EIGHT='8'
CIRCLELINUX_EIGHT='8'
elif [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '9' ]]; then
CENTOS_NINE='9'
CIRCLELINUX_NINE='9'
fi
elif [ -f /etc/navylinux-release ] && [[ "$EL_VERID" -eq 8 || "$EL_VERID" -eq 9 ]]; then
CENTOSVER=$(awk '{ print $5 }' /etc/navylinux-release | cut -d . -f1,2)
if [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '8' ]]; then
CENTOS_EIGHT='8'
NAVYLINUX_EIGHT='8'
elif [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '9' ]]; then
CENTOS_NINE='9'
NAVYLINUX_NINE='9'
fi
elif [ -f /etc/el-release ] && [[ "$EL_VERID" -eq 8 || "$EL_VERID" -eq 9 ]]; then
CENTOSVER=$(awk '{ print $3 }' /etc/el-release | cut -d . -f1,2)
if [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '8' ]]; then
CENTOS_EIGHT='8'
EUROLINUX_EIGHT='8'
elif [[ "$(echo $CENTOSVER | cut -d . -f1)" -eq '9' ]]; then
CENTOS_NINE='9'
EUROLINUX_NINE='9'
fi
fi
# Almalinux 8.8 changed GPG keys breaking YUM for <=8.7
# https://almalinux.org/blog/2023-12-20-almalinux-8-key-update/
if [[ "$ALMALINUXVER" -ge '80000' && "$ALMALINUXVER" -le '80007' ]]; then
rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux
fi
# If set to yes, will abort centmin mod installation if the memory requirements are not met
# you can override this setting by setting ABORTINSTALL='n' in which case centmin mod
# install may either install successfully but very very slowly or crap out
# and fail to successfully install.
ABORTINSTALL='y'
#############################################################
TOTALMEM=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
TOTALMEM_T=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
TOTALMEM_SWAP=$(awk '/SwapFree/ {print $2}' /proc/meminfo)
TOTALMEM_PHP=$(($TOTALMEM_T+$TOTALMEM_SWAP))
if [[ "$CENTOS_EIGHT" -eq '8' || "$CENTOS_NINE" -eq '9' ]]; then
if [[ "$ISMINMEM_OVERRIDE" = [yY] ]]; then
ISMINMEM='1500000' # 1.43GB in bytes
else
ISMINMEM='1730000' # 1.7GB in bytes
fi
if [[ "$ISMINSWAP_OVERRIDE" = [yY] ]]; then
ISMINSWAP='2097152' # 2.0GB in bytes
else
ISMINSWAP='3774873' # 3.6GB in bytes
fi
elif [[ "$CENTOS_SEVEN" -eq '7' ]]; then
ISMINMEM='922624' # 900MB in bytes
ISMINSWAP='2097152' # 2GB in bytes
else
ISMINMEM='262144' # 256MB in bytes
ISMINSWAP='524288' # 512MB in bytes
fi
#############################################################
# Formulas
if [[ "$(rpm -qa bc | grep -o 'bc')" != 'bc' ]]; then
yum -y -q install bc
fi
if [[ ! -f /.dockerenv ]]; then
if [[ ! -f /usr/bin/expr ]]; then
yum -y -q install coreutils
fi
else
if rpm -q coreutils-single >/dev/null 2>&1; then
echo "coreutils-single package is already installed. expr command should be available."
elif rpm -q coreutils >/dev/null 2>&1; then
echo "coreutils package is already installed. expr command should be available."
else
if [[ ! -f /usr/bin/expr ]]; then
if yum -y -q install coreutils-single >/dev/null 2>&1; then
echo "coreutils-single package installed successfully."
else
echo "Failed to install coreutils-single package. Attempting to install coreutils package..."
if yum -y -q install coreutils >/dev/null 2>&1; then
echo "coreutils package installed successfully."
else
echo "Failed to install coreutils package."
exit 1
fi
fi
fi
fi
fi
TOTALMEMMB=`echo "scale=0;$TOTALMEM/1024" | bc`
ISMINMEMMB=`echo "scale=0;$ISMINMEM/1024" | bc`
ISMINSWAPMB=`echo "scale=0;$ISMINSWAP/1024" | bc`
CHECKMINMEM=`expr $TOTALMEM_T \< $ISMINMEM`
#############################################################
lowmemcheck() {
# Check memory and swap threshold
if [ "$CHECKMINMEM" == "1" ]; then
if [ "$TOTALMEM_SWAP" -lt "$ISMINSWAP" ]; then
CPUS='1'
MAKETHREADS=" -j$CPUS"
echo ""
if [[ "$CENTOS_EIGHT" -eq '8' || "$CENTOS_NINE" -eq '9' ]]; then
echo "For EL8 and EL9 operating system the minimum and recommended memory requirements have increased"
echo "Minimum: 2GB memory with 4GB swap disk"
echo "Recommended: 4GB memory with 4GB swap disk"
fi
echo -e "Warning: physically installed memory and swap too low for Centmin Mod\\nInstallation [Installed: $TOTALMEMMB MB < $ISMINMEMMB MB memory and $ISMINSWAPMB MB < $ISMINSWAPMB MB swap (recommended minimum)]\\n"
if [ "$ABORTINSTALL" == 'y' ]; then
echo "aborting install..."
sleep 20
exit
fi
else
echo ""
echo -e "Ok: swap is sufficient for Centmin Mod installation despite low memory\\nInstallation [Installed: $TOTALMEMMB MB < $ISMINMEMMB MB memory, but $TOTALMEM_SWAP MB >= $ISMINSWAPMB MB swap]\\n"
fi
else
echo ""
echo -e "Ok: physically installed memory is sufficient for Centmin Mod\\nInstallation [Installed: $TOTALMEMMB MB >= $ISMINMEMMB MB memory]\\n"
fi
}
swap_setup() {
# swap file detection and setup routine add a 4GB swap file
# to servers without swap setup and non-openvz based as a
# precaution for low memory vps systems <2GB which require
# memory intensive initial install and running i.e. php fileinfo
# extension when enabled via PHPFINFO='y' need more memory ~2GB
# on <2GB systems this can be a problem without a swap file as
# an additional memory buffer
FINDSWAPSIZE=$(free -m | awk '/Swap: / {print $2}' | head -n1)
# if free -m output swap size = 0, create a 4GB swap file for
# non-openvz systems or if less than 2GB of memory and swap
# smaller than 4GB on non-openvz systems, create a 4GB additional
# swap file
if [[ "$CENTOS_EIGHT" -eq '8' || "$CENTOS_NINE" -eq '9' ]]; then
if [[ "$ISMINSWAP_OVERRIDE" = [yY] && "$FINDSWAPSIZE" -eq '0' && ! -f /proc/user_beancounters && "$CHECK_LXD" != [yY] && ! -f /swapfile ]] || [[ "$ISMINSWAP_OVERRIDE" = [yY] && "$(awk '/MemTotal/ {print $2}' /proc/meminfo)" -le '2097152' && "$FINDSWAPSIZE" -le '2047' && ! -f /proc/user_beancounters && "$CHECK_LXD" != [yY] && ! -f /swapfile ]]; then
{
echo
free -m
echo
if [[ "$ISMINSWAP_OVERRIDE" = [yY] ]]; then
echo "create 2GB swap file";
dd_size=2048
fallocate_size=2
else
echo "create 4GB swap file";
dd_size=4096
fallocate_size=4
fi
if [[ "$(df -hT | grep -w xfs)" || "$(virt-what | grep -o lxc)" = 'lxc' ]]; then
dd if=/dev/zero of=/swapfile bs=$dd_size count=1048576;
else
fallocate -l ${fallocate_size}G /swapfile
fi
ls -lah /swapfile;
mkswap /swapfile;
swapon /swapfile;
chown root:root /swapfile;
chmod 0600 /swapfile;
swapon -s;
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab;
mount -a;
free -m
echo
} 2>&1 | tee "${CENTMINLOGDIR}/centminmod_swapsetup_installer_${DT}.log"
elif [[ "$FINDSWAPSIZE" -eq '0' && ! -f /proc/user_beancounters && "$CHECK_LXD" != [yY] && ! -f /swapfile ]] || [[ "$(awk '/MemTotal/ {print $2}' /proc/meminfo)" -le '2097152' && "$FINDSWAPSIZE" -le '4096' && ! -f /proc/user_beancounters && "$CHECK_LXD" != [yY] && ! -f /swapfile ]]; then
{
echo
free -m
echo
if [[ "$ISMINSWAP_OVERRIDE" = [yY] ]]; then
echo "create 2GB swap file";
dd_size=2048
fallocate_size=2
else
echo "create 4GB swap file";
dd_size=4096
fallocate_size=4
fi
if [[ "$(df -hT | grep -w xfs)" || "$(virt-what | grep -o lxc)" = 'lxc' ]]; then
dd if=/dev/zero of=/swapfile bs=$dd_size count=1048576;
else
fallocate -l ${fallocate_size}G /swapfile
fi
ls -lah /swapfile;
mkswap /swapfile;
swapon /swapfile;
chown root:root /swapfile;
chmod 0600 /swapfile;
swapon -s;
echo "/swapfile swap swap defaults 0 0" >> /etc/fstab;
mount -a;
free -m
echo
} 2>&1 | tee "${CENTMINLOGDIR}/centminmod_swapsetup_installer_${DT}.log"
elif [[ "$FINDSWAPSIZE" -eq '0' && ! -f /proc/user_beancounters && "$CHECK_LXD" != [yY] && -f /swapfile && "$(grep '/swapfile' /etc/fstab)" ]] || [[ "$(awk '/MemTotal/ {print $2}' /proc/meminfo)" -le '2097152' && "$FINDSWAPSIZE" -le '4096' && ! -f /proc/user_beancounters && "$CHECK_LXD" != [yY] && -f /swapfile && "$(grep '/swapfile' /etc/fstab)" ]]; then
{
echo
free -mlt
echo
echo "re-create 4GB swap file";
swapoff -a
if [[ "$(df -hT | grep -w xfs)" || "$(virt-what | grep -o lxc)" = 'lxc' ]]; then
dd if=/dev/zero of=/swapfile bs=4096 count=1048576;
else
fallocate -l 4G /swapfile
fi
ls -lah /swapfile;
mkswap /swapfile;
swapon /swapfile;
chown root:root /swapfile;
chmod 0600 /swapfile;
swapon -s;
# echo "/swapfile swap swap defaults 0 0" >> /etc/fstab;
mount -a;
free -mlt
echo
} 2>&1 | tee "${CENTMINLOGDIR}/centminmod_swapsetup_installer_${DT}.log"
fi
elif [[ "$FINDSWAPSIZE" -eq '0' && ! -f /proc/user_beancounters && "$CHECK_LXD" != [yY] && -f /swapfile && "$(grep '/swapfile' /etc/fstab)" ]] || [[ "$(awk '/MemTotal/ {print $2}' /proc/meminfo)" -le '1048576' && "$FINDSWAPSIZE" -le '512' && ! -f /proc/user_beancounters && "$CHECK_LXD" != [yY] && -f /swapfile && "$(grep '/swapfile' /etc/fstab)" ]]; then
{
echo
free -mlt
echo
echo "re-create 1GB swap file";
swapoff -a
if [[ "$(df -hT | grep -w xfs)" || "$(virt-what | grep -o lxc)" = 'lxc' ]]; then
dd if=/dev/zero of=/swapfile bs=4096 count=1024k;
else
fallocate -l 4G /swapfile
fi
ls -lah /swapfile;
mkswap /swapfile;
swapon /swapfile;
chown root:root /swapfile;
chmod 0600 /swapfile;
swapon -s;
# echo "/swapfile swap swap defaults 0 0" >> /etc/fstab;
mount -a;
free -mlt
echo
} 2>&1 | tee "${CENTMINLOGDIR}/centminmod_swapsetup_installer_${DT}.log"
fi
}
swap_setup
lowmemcheck
if [ ! -f /usr/sbin/virt-what ]; then
yum -q -y install virt-what
fi
if [[ ! -f /proc/user_beancounters ]]; then
if [[ -f /usr/bin/systemd-detect-virt && "$(/usr/bin/systemd-detect-virt)" = 'lxc' ]]; then
CHECK_LXD='y'
elif [[ -f $(which virt-what) ]]; then
VIRT_WHAT_OUTPUT=$(virt-what | xargs)
if [[ $VIRT_WHAT_OUTPUT == *'openvz'* ]]; then
CHECK_LXD='n'
elif [[ $VIRT_WHAT_OUTPUT == *'lxc'* ]]; then
CHECK_LXD='y'
fi
fi
fi
# check for Docker environment to skip grub routines
if [[ ! -f /.dockerenv && "$CHECK_LXD" != 'y' ]]; then
# earlier selinux check for el9 systems
SELINUX_STATUS=$(getenforce)
if [ -f /etc/default/grub ]; then
SELINUX_STATUS_GRUB=$(grep 'selinux=0' /etc/default/grub)
else
SELINUX_STATUS_GRUB=""
fi
if [[ "$CENTOS_NINE" -eq '9' ]] && [[ -z "$SELINUX_STATUS_GRUB" ]]; then
echo "Detected SELinux NOT disabled for EL9"
echo "Adding selinux=0 to Kernel GRUB_CMDLINE_LINUX line in /etc/default/grub"
echo
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9/html/using_selinux/changing-selinux-states-and-modes_using-selinux#Enabling_and_Disabling_SELinux-Disabling_SELinux_changing-selinux-states-and-modes
if [ ! "$(rpm -qa grubby | grep grubby)" ]; then
yum -y install grubby
fi
echo "grubby --update-kernel ALL --args selinux=0"
grubby --update-kernel ALL --args selinux=0
echo
grep '^GRUB_CMDLINE_LINUX=' /etc/default/grub
echo
echo "Added selinux=0 to Kernel GRUB_CMDLINE_LINUX line in /etc/default/grub to disable SELinux"
echo "This is the right way to disable SELinux in future as other run-time methods deprecated"
echo "If you intend to use own custom Linux Kernels i.e. ELRepo, ensure you have selinux=0 set"
echo "Please reboot system to disable SELinux then install Centmin Mod"
exit
fi
if [[ "$CENTOS_EIGHT" -eq '8' ]] && [[ -z "$SELINUX_STATUS_GRUB" ]]; then
echo "Detected SELinux NOT disabled for EL8"
echo "Adding selinux=0 to Kernel GRUB_CMDLINE_LINUX line in /etc/default/grub"
if [ -f /etc/default/grub ]; then
sed -i '/^GRUB_CMDLINE_LINUX=/ s/"$/ selinux=0"/' /etc/default/grub
grep '^GRUB_CMDLINE_LINUX=' /etc/default/grub
fi
echo "Regenerating GRUB2 configuration"
if [ ! -f /usr/sbin/grub2-mkconfig ]; then
echo "/usr/sbin/grub2-mkconfig not found"
echo "installing grub2-tools"
yum -y install grub2-tools
fi
if [ -d /sys/firmware/efi ]; then
# UEFI-based systems
if [ -f /etc/almalinux-release ] && [ -f /boot/efi/EFI/almalinux/grub.cfg ]; then
# AlmaLinux OS
echo "grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg"
grub2-mkconfig -o /boot/efi/EFI/almalinux/grub.cfg
elif [ -f /etc/rocky-release ] && [ -f /boot/efi/EFI/rocky/grub.cfg ]; then
# Rocky Linux
echo "grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg"
grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg
elif [ -f /etc/oracle-release ] && [ -f /boot/efi/EFI/oracle/grub.cfg ]; then
# Oracle Linux
echo "grub2-mkconfig -o /boot/efi/EFI/oracle/grub.cfg"
grub2-mkconfig -o /boot/efi/EFI/oracle/grub.cfg
elif [ -f /etc/vzlinux-release ] && [ -f /boot/efi/EFI/vzlinux/grub.cfg ]; then
# VzLinux
echo "grub2-mkconfig -o /boot/efi/EFI/vzlinux/grub.cfg"
grub2-mkconfig -o /boot/efi/EFI/vzlinux/grub.cfg
elif [ -f /etc/circle-release ] && [ -f /boot/efi/EFI/circle/grub.cfg ]; then
# Circle Linux
echo "grub2-mkconfig -o /boot/efi/EFI/circle/grub.cfg"
grub2-mkconfig -o /boot/efi/EFI/circle/grub.cfg
elif [ -f /etc/navylinux-release ] && [ -f /boot/efi/EFI/navylinux/grub.cfg ]; then
# Navy Linux
echo "grub2-mkconfig -o /boot/efi/EFI/navylinux/grub.cfg"
grub2-mkconfig -o /boot/efi/EFI/navylinux/grub.cfg
elif [ -f /boot/efi/EFI/centos/grub.cfg ]; then
# CentOS Stream
echo "grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg"
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
else
echo "GRUB2 configuration file not found for your distribution. Please check the file paths and update the script accordingly."
exit 1
fi
else
# BIOS-based systems
if [ -f /boot/grub2/grub.cfg ]; then
echo "grub2-mkconfig -o /boot/grub2/grub.cfg"
grub2-mkconfig -o /boot/grub2/grub.cfg
else
echo "GRUB2 configuration file not found for your distribution. Please check the file paths and update the script accordingly."
exit 1
fi
fi
echo "Added selinux=0 to Kernel GRUB_CMDLINE_LINUX line in /etc/default/grub to disable SELinux"
echo "This is the right way to disable SELinux in future as other run-time methods deprecated"
echo "If you intend to use own custom Linux Kernels i.e. ELRepo, ensure you have selinux=0 set"
echo "Please reboot system to disable SELinux then install Centmin Mod"
exit
fi
fi
# set el9 to utf8mb4 charset for MariaDB 10.6
if [[ "$CENTOS_NINE" -eq '9' ]]; then
#echo "DEVTOOLSETTEN='n'" >> /etc/centminmod/custom_config.inc
#echo "DEVTOOLSETELEVEN='n'" >> /etc/centminmod/custom_config.inc
#echo "DEVTOOLSETTWELVE='y'" >> /etc/centminmod/custom_config.inc
echo "SET_DEFAULT_MYSQLCHARSET='utf8mb4'" >> /etc/centminmod/custom_config.inc
echo "SELFSIGNEDSSL_ECDSA='y'" >> /etc/centminmod/custom_config.inc
if [[ "$ISMINMEM_OVERRIDE" = [yY] && "$ISMINSWAP_OVERRIDE" = [yY] ]]; then
echo "PHPFINFO='n'" >> /etc/centminmod/custom_config.inc
else
echo "PHPFINFO='y'" >> /etc/centminmod/custom_config.inc
fi
echo "PHP_OVERWRITECONF='n'" >> /etc/centminmod/custom_config.inc
echo "PYTHON_INSTALL_ALTERNATIVES='y'" >> /etc/centminmod/custom_config.inc
fi
# set el8 defaults
if [[ "$CENTOS_EIGHT" -eq '8' ]]; then
#echo "DEVTOOLSETTEN='n'" >> /etc/centminmod/custom_config.inc
#echo "DEVTOOLSETELEVEN='n'" >> /etc/centminmod/custom_config.inc
#echo "DEVTOOLSETTWELVE='y'" >> /etc/centminmod/custom_config.inc
echo "SELFSIGNEDSSL_ECDSA='y'" >> /etc/centminmod/custom_config.inc
if [[ "$ISMINMEM_OVERRIDE" = [yY] && "$ISMINSWAP_OVERRIDE" = [yY] ]]; then
echo "PHPFINFO='n'" >> /etc/centminmod/custom_config.inc
else
echo "PHPFINFO='y'" >> /etc/centminmod/custom_config.inc
fi
echo "PHP_OVERWRITECONF='n'" >> /etc/centminmod/custom_config.inc
echo "PYTHON_INSTALL_ALTERNATIVES='y'" >> /etc/centminmod/custom_config.inc
fi
# set el7 defaults
if [[ "$CENTOS_SEVEN" -eq '7' ]]; then
echo "DEVTOOLSETTEN='n'" >> /etc/centminmod/custom_config.inc
echo "DEVTOOLSETELEVEN='y'" >> /etc/centminmod/custom_config.inc
echo "SELFSIGNEDSSL_ECDSA='y'" >> /etc/centminmod/custom_config.inc
echo "PHP_OVERWRITECONF='n'" >> /etc/centminmod/custom_config.inc
fi
# el8+ dnf/yum speed tweaks
if [[ -f /etc/dnf/dnf.conf && "$CPUS" -ge '2' ]]; then
echo "Optimizing /etc/dnf/dnf.conf settings"
if [[ "$CPUS" -eq '2' ]]; then
max_dnf_downloads=4
elif [[ "$CPUS" -eq '3' ]]; then
max_dnf_downloads=4
elif [[ "$CPUS" -eq '4' ]]; then
max_dnf_downloads=6
elif [[ "$CPUS" -eq '5' ]]; then
max_dnf_downloads=6
elif [[ "$CPUS" -eq '6' ]]; then
max_dnf_downloads=6
elif [[ "$CPUS" -eq '7' ]]; then
max_dnf_downloads=7
elif [[ "$CPUS" -eq '8' ]]; then
max_dnf_downloads=8
elif [[ "$CPUS" -eq '9' ]]; then
max_dnf_downloads=9
elif [[ "$CPUS" -ge '10' ]]; then
max_dnf_downloads=10
fi
if [[ ! "$(grep 'max_parallel_downloads' /etc/dnf/dnf.conf)" ]]; then
echo "max_parallel_downloads=$max_dnf_downloads" >> /etc/dnf/dnf.conf
elif [[ "$(grep 'max_parallel_downloads' /etc/dnf/dnf.conf)" ]]; then
sed -i "s|max_parallel_downloads=.*|max_parallel_downloads=$max_dnf_downloads|" /etc/dnf/dnf.conf
fi
if [[ ! "$(grep 'fastestmirror=' /etc/dnf/dnf.conf)" ]]; then
echo "fastestmirror=True" >> /etc/dnf/dnf.conf
elif [[ "$(grep 'fastestmirror=' /etc/dnf/dnf.conf)" ]]; then
sed -i "s|fastestmirror=.*|fastestmirror=True|" /etc/dnf/dnf.conf
fi
dnf -y update --refresh
elif [[ -f /etc/dnf/dnf.conf && "$CPUS" -eq '1' ]]; then
echo "Optimizing /etc/dnf/dnf.conf settings"
if [[ ! "$(grep 'fastestmirror=' /etc/dnf/dnf.conf)" ]]; then
echo "fastestmirror=True" >> /etc/dnf/dnf.conf
elif [[ "$(grep 'fastestmirror=' /etc/dnf/dnf.conf)" ]]; then
sed -i "s|fastestmirror=.*|fastestmirror=True|" /etc/dnf/dnf.conf
fi
dnf -y update --refresh
fi
if [[ "$CENTOS_ALPHATEST" != [yY] && "$CENTOS_NINE" -eq '9' ]] || [[ "$CENTOS_ALPHATEST" != [yY] && "$CENTOS_EIGHT" -eq '8' ]] || [[ "$CENTOS_ALPHATEST" != [yY] && "$CENTOS_NINE" -eq '9' ]]; then
if [[ "$ORACLELINUX_NINE" -eq '9' ]]; then
label_os=OracleLinux
label_os_ver=9
label_prefix='https://community.centminmod.com/forums/31/'
elif [[ "$ROCKYLINUX_NINE" -eq '9' ]]; then
label_os=RockyLinux
label_os_ver=9
label_prefix='https://community.centminmod.com/forums/31/?prefix_id=84'
elif [[ "$ALMALINUX_NINE" -eq '9' ]]; then
label_os=AlmaLinux
label_os_ver=9
label_prefix='https://community.centminmod.com/forums/31/?prefix_id=83'
elif [[ "$ORACLELINUX_EIGHT" -eq '8' ]]; then
label_os=OracleLinux
label_os_ver=8
label_prefix='https://community.centminmod.com/forums/31/'
elif [[ "$ROCKYLINUX_EIGHT" -eq '8' ]]; then
label_os=RockyLinux
label_os_ver=8
label_prefix='https://community.centminmod.com/forums/31/?prefix_id=84'
elif [[ "$ALMALINUX_EIGHT" -eq '8' ]]; then
label_os=AlmaLinux
label_os_ver=8
label_prefix='https://community.centminmod.com/forums/31/?prefix_id=83'
elif [[ "$CENTOS_NINE" = '9' ]]; then
label_os_ver=9
label_os=CentOS
label_prefix='https://community.centminmod.com/forums/31/?prefix_id=81'
elif [[ "$CENTOS_EIGHT" = '8' ]]; then
label_os_ver=8
label_os=CentOS
label_prefix='https://community.centminmod.com/forums/31/?prefix_id=81'
fi
echo
echo "$label_os ${label_os_ver} is currently not supported by Centmin Mod, please use CentOS 7.9+"
echo "To follow EL${label_os_ver} compatibility for CentOS ${label_os_ver} / AlmaLinux ${label_os_ver} read thread at:"
echo "https://community.centminmod.com/threads/18372/"
echo "You can read CentOS 8 specific discussions via prefix tag link at:"
echo "$label_prefix"
exit 1
echo
fi
if [[ "$CENTOS_SEVEN" -eq '7' ]]; then
WGET_VERSION=$WGET_VERSION_SEVEN
WGET_FILENAME="wget-${WGET_VERSION}.tar.gz"
WGET_LINK="${LOCALCENTMINMOD_MIRROR}/centminmodparts/wget/${WGET_FILENAME}"
fi
if [[ "$CENTOS_EIGHT" -eq '8' ]]; then
echo "EL${label_os_ver} Install Dependencies Start..."
WGET_VERSION=$WGET_VERSION_EIGHT
WGET_FILENAME="wget-${WGET_VERSION}.tar.gz"
WGET_LINK="${LOCALCENTMINMOD_MIRROR}/centminmodparts/wget/${WGET_FILENAME}"
# enable CentOS 8 PowerTools repo for -devel packages
if [ "$(yum repolist powertools | grep -ow 'powertools')" ]; then
reponame_powertools=powertools
elif [ "$(yum repolist all | grep -ow 'ol8_codeready_builder')" ]; then
reponame_powertools=ol8_codeready_builder
elif [ "$(yum repolist all | grep -ow 'ol9_codeready_builder')" ]; then
reponame_powertools=ol9_codeready_builder
else
reponame_powertools=PowerTools
fi
if [ ! -f /usr/bin/yum-config-manager ]; then
yum -q -y install yum-utils tar
yum-config-manager --enable $reponame_powertools
elif [ -f /usr/bin/yum-config-manager ]; then
yum-config-manager --enable $reponame_powertools
fi
# disable native CentOS 8 AppStream repo based nginx, php & oracle mysql packages
yum -q -y module disable nginx mariadb mysql php redis:5
# install missing dependencies specific to CentOS 8
# for csf firewall installs
# if [ ! -f /usr/share/perl5/vendor_perl/Math/BigInt.pm ]; then
# echo "EL8 CSF Firewall dependency"
# yum -q -y install perl-Math-BigInt
# fi
fi
if [[ "$CENTOS_NINE" -eq '9' ]]; then
echo "EL${label_os_ver} Install Dependencies Start..."
WGET_VERSION=$WGET_VERSION_NINE
WGET_FILENAME="wget-${WGET_VERSION}.tar.gz"
WGET_LINK="${LOCALCENTMINMOD_MIRROR}/centminmodparts/wget/${WGET_FILENAME}"
if [ "$(yum repolist all | grep -ow 'ol9_codeready_builder')" ]; then
# oracle linux 9
reponame_powertools=ol9_codeready_builder
else
# enable CentOS 9 crb repo for -devel packages
reponame_powertools=crb
fi
if [ ! -f /usr/bin/yum-config-manager ]; then
yum -q -y install yum-utils tar
yum-config-manager --enable $reponame_powertools
elif [ -f /usr/bin/yum-config-manager ]; then
yum-config-manager --enable $reponame_powertools
fi
# disable native CentOS 9 AppStream repo based nginx, php & oracle mysql packages
# yum -q -y module disable nginx mariadb mysql php redis:6
# install missing dependencies specific to CentOS 9
# for csf firewall installs
# if [ ! -f /usr/share/perl5/vendor_perl/Math/BigInt.pm ]; then
# echo "EL9 CSF Firewall dependency"
# 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
elif [[ "$(grep -o 'AMD EPYC 7272' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7272' ]]; then
# 7272 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7272
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7282' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7282' ]]; then
# 7282 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7282
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7302' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7302' ]]; then
# 7302 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7302
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7352' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7352' ]]; then
# 7352 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7352
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7402' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7402' ]]; then
# 7402 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7402
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7452' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7452' ]]; then
# 7452 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7452
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7502' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7502' ]]; then
# 7502 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7502
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7532' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7532' ]]; then
# 7532 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7532
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7542' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7542' ]]; then
# 7542 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7542
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7552' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7552' ]]; then
# 7552 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7552
CPUS=24
elif [[ "$(grep -o 'AMD EPYC 7642' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7642' ]]; then
# 7642 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7642
CPUS=24
elif [[ "$(grep -o 'AMD EPYC 7662' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7662' ]]; then
# 7662 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7662
CPUS=24
elif [[ "$(grep -o 'AMD EPYC 7702' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7702' ]]; then
# 7702 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7702
CPUS=24
elif [[ "$(grep -o 'AMD EPYC 7742' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7742' ]]; then
# 7742 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7742
CPUS=24
elif [[ "$(grep -o 'AMD EPYC 7H12' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7H12' ]]; then
# 7H12 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7H12
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7F52' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7F52' ]]; then
# 7F52 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7F52
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7F72' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7F72' ]]; then
# 7F72 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7F72
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7313' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7313' ]]; then
# 7313 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7313
CPUS=8
elif [[ "$(grep -o 'AMD EPYC 7413' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7413' ]]; then
# 7413 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7413
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7443' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7443' ]]; then
# 7443 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7443
CPUS=12
elif [[ "$(grep -o 'AMD EPYC 7453' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7453' ]]; then
# 7453 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7453
CPUS=14
elif [[ "$(grep -o 'AMD EPYC 7513' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7513' ]]; then
# 7513 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7513
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7543' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7543' ]]; then
# 7543 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7543
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7643' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7643' ]]; then
# 7643 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7643
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7663' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7663' ]]; then
# 7663 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7663
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7713' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7713' ]]; then
# 7713 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7713
CPUS=32
elif [[ "$(grep -o 'AMD EPYC 73F3' /proc/cpuinfo | sort -u)" = 'AMD EPYC 73F3' ]]; then
# 73F3 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/73F3
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 74F3' /proc/cpuinfo | sort -u)" = 'AMD EPYC 74F3' ]]; then
# 74F3 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/74F3
CPUS=24
elif [[ "$(grep -o 'AMD EPYC 75F3' /proc/cpuinfo | sort -u)" = 'AMD EPYC 75F3' ]]; then
# 75F3 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/75F3
CPUS=32
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
elif [[ "$(grep -o 'AMD EPYC 7272' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7272' ]]; then
# 7272 preferring higher clock frequency https://en.wikichip.org/wiki/amd/epyc/7272
CPUS=16
elif [[ "$(grep -o 'AMD EPYC 7282' /proc/cpuinfo | sort -u)" = 'AMD EPYC 7282' ]]; then