forked from centminmod/centminmod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcentmin.sh
executable file
·2492 lines (2016 loc) · 80.3 KB
/
centmin.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/sh
EMAIL='' # Server notification email address enter only 1 address
PUSHOVER_EMAIL='' # Signup pushover.net push email notifications to mobile & tablets
ZONEINFO=Etc/UTC # Set Timezone
NGINX_IPV='n' #NGINX IPV6 compile support for unattended mode only
USEEDITOR='nano' # choice between nano or vim text editors for cmd shortcuts
CUSTOMSERVERNAME='y'
CUSTOMSERVERSTRING='nginx centminmod'
PHPFPMCONFDIR='/usr/local/nginx/conf/phpfpmd'
UNATTENDED='y' # please leave at 'y' for best compatibility as at .07 release
CMVERSION_CHECK='n'
#####################################################
DT=`date +"%d%m%y-%H%M%S"`
# for github support
branchname='123.08stable'
SCRIPT_MAJORVER='1.2.3'
SCRIPT_MINORVER='08'
SCRIPT_VERSION="${SCRIPT_MAJORVER}-eva2000.${SCRIPT_MINORVER}"
SCRIPT_DATE='31/07/2015'
SCRIPT_AUTHOR='eva2000 (vbtechsupport.com)'
SCRIPT_MODIFICATION_AUTHOR='eva2000 (vbtechsupport.com)'
SCRIPT_URL='http://centminmod.com'
COPYRIGHT="Copyright 2011-2015 CentminMod.com"
DISCLAIMER='This software is provided "as is" in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'
#####################################################
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version. See the included license.txt for futher details.
#
# PLEASE MODIFY VALUES BELOW THIS LINE ++++++++++++++++++++++++++++++++++++++
# Note: Please enter y for yes or n for no.
#####################################################
HN=$(uname -n)
# Pre-Checks to prevent screw ups
DIR_TMP='/svr-setup'
SCRIPT_DIR=$(readlink -f $(dirname ${BASH_SOURCE[0]}))
source "inc/memcheck.inc"
TMPFSLIMIT=2900000
if [ ! -d "$DIR_TMP" ]; then
if [[ "$TOTALMEM" -ge "$TMPFSLIMIT" ]]; then
TMPFSENABLED=1
RAMDISKTMPFS='y'
echo "setting up $DIR_TMP on tmpfs ramdisk for initial install"
mkdir -p $DIR_TMP
mount -t tmpfs -o size=2200M,mode=0755 tmpfs $DIR_TMP
df -hT
else
mkdir -p $DIR_TMP
fi
fi
if [[ -z $(cat /etc/resolv.conf) ]]; then
echo ""
echo "/etc/resolv.conf is empty. No nameserver resolvers detected !! "
echo "Please configure your /etc/resolv.conf correctly or you will not"
echo "be able to use the internet or download from your server."
echo "aborting script... please re-run centmin.sh"
echo ""
exit
fi
if [ ! -f /usr/bin/wget ]; then
echo "wget not found !! "
echo "installing wget"
yum -y -q install wget
echo "aborting script... please re-run centmin.sh"
exit
fi
if [ ! -f /usr/bin/lynx ]; then
echo "installing lynx..."
yum -y -q install lynx
fi
if [ ! -f /usr/bin/unzip ]; then
yum -y -q install unzip
fi
if [ ! -f /usr/bin/bc ]; then
echo "bc not found !! "
echo "installing bc"
yum -y -q install bc
echo "bc installed"
echo "aborting script... "
echo "please re-run centmin.sh again for install"
exit
fi
if [ ! -f /usr/bin/tee ]; then
#echo "tee not found !! "
#echo "installing tee"
yum -y -q install coreutils
fi
if [ -f /var/cpanel/cpanel.config ]; then
echo "WHM/Cpanel detected.. centmin mod NOT compatible"
echo "aborting script..."
exit
fi
if [ -f /etc/psa/.psa.shadow ]; then
echo "Plesk detected.. centmin mod NOT compatible"
echo "aborting script..."
exit
fi
if [ -f /etc/init.d/directadmin ]; then
echo "DirectAdmin detected.. centmin mod NOT compatible"
echo "aborting script..."
exit
fi
TESTEDCENTOSVER='7.9'
CENTOSVER=$(cat /etc/redhat-release | awk '{ print $3 }')
if [ "$CENTOSVER" == 'release' ]; then
CENTOSVER=$(cat /etc/redhat-release | awk '{ print $4 }' | cut -d . -f1,2)
if [[ "$(cat /etc/redhat-release | awk '{ print $4 }' | cut -d . -f1)" = '7' ]]; then
CENTOS_SEVEN='7'
fi
fi
if [[ "$(cat /etc/redhat-release | awk '{ print $3 }' | cut -d . -f1)" = '6' ]]; then
CENTOS_SIX='6'
fi
if [ "$CENTOSVER" == 'Enterprise' ]; then
CENTOSVER=$(cat /etc/redhat-release | awk '{ print $7 }')
OLS='y'
fi
source "inc/centos_seven.inc"
seven_function
cmservice() {
servicename=$1
action=$2
if [[ "$CENTOS_SEVEN" != '7' || "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' || "${servicename}" = 'memcached' || "${servicename}" = 'nsd' || "${servicename}" = 'csf' || "${servicename}" = 'lfd' ]]; then
echo "service ${servicename} $action"
if [[ "$CMSDEBUG" = [nN] ]]; then
service ${servicename} $action
fi
else
echo "systemctl $action ${servicename}.service"
if [[ "$CMSDEBUG" = [nN] ]]; then
systemctl $action ${servicename}.service
fi
fi
}
cmchkconfig() {
servicename=$1
status=$2
if [[ "$CENTOS_SEVEN" != '7' || "${servicename}" = 'php-fpm' || "${servicename}" = 'nginx' || "${servicename}" = 'memcached' || "${servicename}" = 'nsd' || "${servicename}" = 'csf' || "${servicename}" = 'lfd' ]]; then
echo "chkconfig ${servicename} $status"
if [[ "$CMSDEBUG" = [nN] ]]; then
chkconfig ${servicename} $status
fi
else
if [ "$status" = 'on' ]; then
status=enable
fi
if [ "$status" = 'off' ]; then
status=disable
fi
echo "systemctl $status ${servicename}.service"
if [[ "$CMSDEBUG" = [nN] ]]; then
systemctl $status ${servicename}.service
fi
fi
}
if [ -f /proc/user_beancounters ]; then
# CPUS='1'
# MAKETHREADS=" -j$CPUS"
# speed up make
CPUS=`cat "/proc/cpuinfo" | grep "processor"|wc -l`
CPUS=$(echo $CPUS+1 | bc)
MAKETHREADS=" -j$CPUS"
else
# speed up make
CPUS=`cat "/proc/cpuinfo" | grep "processor"|wc -l`
CPUS=$(echo $CPUS+1 | bc)
MAKETHREADS=" -j$CPUS"
fi
# configure .ini directory
CONFIGSCANBASE='/etc/centminmod'
CONFIGSCANDIR="${CONFIGSCANBASE}/php.d"
if [ ! -d "$CONFIGSCANBASE" ]; then
mkdir -p $CONFIGSCANBASE
fi
if [ ! -d "$CONFIGSCANDIR" ]; then
mkdir -p $CONFIGSCANDIR
if [ -d /root/centminmod/php.d/ ]; then
cp -a /root/centminmod/php.d/* ${CONFIGSCANDIR}/
fi
fi
# MySQL non-tmpfs based tmpdir for MySQL temp files
if [ ! -d "/home/mysqltmp" ]; then
mkdir -p /home/mysqltmp
chmod 1777 /home/mysqltmp
CHOWNMYSQL=y
fi
#####################################################
# Centmin Mod Git Repo URL - primary repo
# https://github.com/centminmod/centminmod
CMGIT='https://github.com/centminmod/centminmod.git'
# Gitlab backup repo
# https://gitlab.com/centminmod/centminmod
#CMGIT='https://gitlab.com/centminmod/centminmod.git'
#####################################################
# Timestamp Install
TS_INSTALL='y'
#####################################################
# Enable or disable menu mode
ENABLE_MENU='y'
#####################################################
# CentOS 7 specific
FIREWALLD_DISABLE='y'
#####################################################
# MariaDB Jemalloc
# doh forgot MariaDB already uses jemalloc by default
MARIADB_JEMALLOC='n'
#####################################################
# CCACHE Configuration
CCACHEINSTALL='y'
CCACHE_VER="3.2.2"
CCACHESIZE='2.2G'
#####################################################
# compiler related
CLANG='y' # Nginx and LibreSSL
CLANG_PHP='n' # PHP
CLANG_APC='n' # APC Cache
CLANG_MEMCACHED='n' # Memcached menu option 10 routine
# When set to =y, will disable those listed installed services
# by default. The service is still installed but disabled
# by default and can be re-enabled with commands:
# service servicename start; chkconfig servicename on
NSD_DISABLED=n # when set to =y, NSD disabled by default with chkconfig off
MEMCACHED_DISABLED=n # when set to =y, Memcached server disabled by default via chkconfig off
PHP_DISABLED=n # when set to =y, PHP-FPM disabled by default with chkconfig off
MYSQLSERVICE_DISABLED=n # when set to =y, MariaDB MySQL service disabled by default with chkconfig off
PUREFTPD_DISABLED=n # when set to =y, Pure-ftpd service disabled by default with chkconfig off
# General Configuration
NGINXUPGRADESLEEP='6'
NSD_INSTALL=y # Install NSD (DNS Server)
NSD_VERSION='3.2.18' # NSD Version
NTP_INSTALL=y # Install Network time protocol daemon
NGINXPATCH=y # Set to y to allow NGINXPATCH_DELAY seconds time before Nginx configure and patching Nginx
NGINXPATCH_DELAY='1' # Number of seconds to pause Nginx configure routine during Nginx upgrades
STRIPNGINX='y' # set 'y' to strip nginx binary to reduce size
NGINX_INSTALL=y # Install Nginx (Webserver)
NGINX_DEBUG=n # Enable & reinstall Nginx debug log nginx.org/en/docs/debugging_log.html & wiki.nginx.org/Debugging
NGINX_HTTP2=y # Nginx http/2 patch https://community.centminmod.com/threads/4127/
NGINX_GEOIP=y # Nginx GEOIP module install
NGINX_SPDY=n # Nginx SPDY support
NGINX_STREAM=y # http://nginx.org/en/docs/stream/ngx_stream_core_module.html
NGINX_RTMP=n # Nginx RTMP Module support https://github.com/arut/nginx-rtmp-module
NGINX_FLV=n # http://nginx.org/en/docs/http/ngx_http_flv_module.html
NGINX_MP4=n # Nginx MP4 Module http://nginx.org/en/docs/http/ngx_http_mp4_module.html
NGINX_AUTHREQ=n # http://nginx.org/en/docs/http/ngx_http_auth_request_module.html
NGINX_SECURELINK=y # http://nginx.org/en/docs/http/ngx_http_secure_link_module.html
NGINX_FANCYINDEX=y # http://wiki.nginx.org/NgxFancyIndex
NGINX_VHOSTSTATS=y # https://github.com/vozlt/nginx-module-vts
NGINX_PAGESPEED=y # Install ngx_pagespeed
NGINX_PAGESPEEDGITMASTER=n # Install ngx_pagespeed from official github master instead
NGXPGSPEED_VER='1.9.32.11-beta'
NGINX_PAGESPEEDPSOL_VER='1.9.32.11'
NGINX_PASSENGER='n' # Install Phusion Passenger requires installing addons/passenger.sh before hand
NGINX_WEBDAV=n # Nginx WebDAV and nginx-dav-ext-module
NGINX_EXTWEBDAVVER='0.0.3' # nginx-dav-ext-module version
NGINX_LIBATOMIC=y # Nginx configured with libatomic support
NGINX_HTTPREDIS=y # Nginx redis http://wiki.nginx.org/HttpRedisModule
NGINX_HTTPREDISVER='0.3.7' # Nginx redis version
NGINX_PCREJIT=y # Nginx configured with pcre & pcre-jit support
NGINX_PCREVER='8.37' # Version of PCRE used for pcre-jit support in Nginx
NGINX_HEADERSMORE='0.28'
NGINX_CACHEPURGEVER='2.3'
NGINX_STICKY='n' # nginx sticky module https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng
NGINX_STICKYVER='1.2.5'
NGINX_UPSTREAMCHECK='y' # nginx upstream check https://github.com/yaoweibin/nginx_upstream_check_module
NGINX_UPSTREAMCHECKVER='0.3.0'
NGINX_OPENRESTY='y' # Agentzh's openresty Nginx modules
ORESTY_MEMCVER='0.16' # openresty memc module https://github.com/openresty/memc-nginx-module
ORESTY_SRCCACHEVER='0.28' # openresty subrequest cache module https://github.com/openresty/srcache-nginx-module
ORESTY_DEVELKITVER='0.2.19' # openresty ngx_devel_kit module https://github.com/simpl/ngx_devel_kit
ORESTY_SETMISCVER='0.29' # openresty set-misc-nginx module https://github.com/openresty/set-misc-nginx-module
ORESTY_ECHOVER='0.58' # openresty set-misc-nginx module https://github.com/openresty/echo-nginx-module
ORESTY_REDISVER='0.12' # openresty redis2-nginx-module https://github.com/openresty/redis2-nginx-module
LUAJIT_GITINSTALL='y' # opt to install luajit 2.1 from dev branch http://repo.or.cz/w/luajit-2.0.git/shortlog/refs/heads/v2.1
LUAJIT_GITINSTALLVER='2.1' # branch version = v2.1 will override ORESTY_LUAGITVER if LUAJIT_GITINSTALL='y'
ORESTY_LUANGINX='y' # enable or disable or ORESTY_LUA* nginx modules below
ORESTY_LUANGINXVER='0.9.18' # openresty lua-nginx-module https://github.com/openresty/lua-nginx-module
ORESTY_LUAGITVER='2.0.4' # luagit http://luajit.org/
ORESTY_LUAMEMCACHEDVER='0.13' # openresty https://github.com/openresty/lua-resty-memcached
ORESTY_LUAMYSQLVER='0.15' # openresty https://github.com/openresty/lua-resty-mysql
ORESTY_LUAREDISVER='0.20' # openresty https://github.com/openresty/lua-resty-redis
ORESTY_LUADNSVER='0.14' # openresty https://github.com/openresty/lua-resty-dns
ORESTY_LUAUPLOADVER='0.09' # openresty https://github.com/openresty/lua-resty-upload
ORESTY_LUAWEBSOCKETVER='0.05' # openresty https://github.com/openresty/lua-resty-websocket
ORESTY_LUALOCKVER='0.04' # openresty https://github.com/openresty/lua-resty-lock
ORESTY_LUASTRINGVER='0.09' # openresty https://github.com/openresty/lua-resty-string
ORESTY_LUAREDISPARSERVER='0.10' # openresty https://github.com/openresty/lua-redis-parser
ORESTY_LUAUPSTREAMCHECKVER='0.03' # openresty https://github.com/openresty/lua-resty-upstream-healthcheck
ORESTY_LUALRUCACHEVER='0.04' # openresty https://github.com/openresty/lua-resty-lrucache
ORESTY_LUARESTYCOREVER='0.1.0' # openresty https://github.com/openresty/lua-resty-core
ORESTY_LUAUPSTREAMVER='0.04' # openresty https://github.com/openresty/lua-upstream-nginx-module
ORESTY_LUALOGGERSOCKETVER='0.1' # cloudflare openresty https://github.com/cloudflare/lua-resty-logger-socket
ORESTY_LUACOOKIEVER='master' # cloudflare openresty https://github.com/cloudflare/lua-resty-cookie
ORESTY_LUAUPSTREAMCACHEVER='0.1.1' # cloudflare openresty https://github.com/cloudflare/lua-upstream-cache-nginx-module
LUACJSONVER='2.1.0.2' # https://github.com/openresty/lua-cjson
STRIPPHP='y' # set 'y' to strip PHP binary to reduce size
PHP_INSTALL=y # Install PHP /w Fast Process Manager
PHPMAKETEST=n # set to y to enable make test after PHP make for diagnostic purposes
PHPDEBUGMODE=n # --enable-debug PHP compile flag
PHPFINFO=n # Disable or Enable PHP File Info extension
PHPPCNTL=y # Disable or Enable PHP Process Control extension
PHPINTL=y # Disable or Enable PHP intl extension
PHPRECODE=n # Disable or Enable PHP Recode extension
PHPSNMP=y # Disable or Enable PHP SNMP extension
SHORTCUTS=y # shortcuts
########################################################
# Choice of installing MariaDB 5.2 via RPM or via MariaDB 5.2 CentOS YUM Repo
# If MDB_YUMREPOINSTALL=y and MDB_INSTALL=n then MDB_VERONLY version
# number won't have any effect in determining version of MariaDB 5.2.x to install.
# YUM Repo will install whatever is latest MariaDB 5.2.x version available via the YUM REPO
MDB_INSTALL=n # Install via RPM MariaDB MySQL Server replacement (Not recommended for VPS with less than 256MB RAM!)
MDB_YUMREPOINSTALL=y # Install MariaDB 5.5 via CentOS YUM Repo
# Define current MariaDB version
MDB_VERONLY='5.2.14'
MDB_BUILD='122'
MDB_VERSION="${MDB_VERONLY}-${MDB_BUILD}" # Use this version of MariaDB ${MDB_VERONLY}
# Define previous MariaDB version for proper upgrade
MDB_PREVERONLY='5.2.12'
MDB_PREBUILD='115'
MDB_PREVERSION="${MDB_PREVERONLY}-${MDB_PREBUILD}" # Use this version of MariaDB ${MDB_VERONLY}
########################################################
# Optionally, if you want to install MariaDB instead of standard MySQL you can do.
# Set MDB_INSTALL=y and MYSQL_INSTALL=n
MYSQL_INSTALL=n # Install official Oracle MySQL Server (MariaDB alternative recommended)
SENDMAIL_INSTALL=n # Install Sendmail (and mailx) set to y and POSTFIX_INSTALL=n for sendmail
POSTFIX_INSTALL=y # Install Postfix (and mailx) set to n and SENDMAIL_INSTALL=y for sendmail
# Nginx
NGINX_VERSION='1.9.10' # Use this version of Nginx
NGINX_VHOSTSSL='y' # enable centmin.sh menu 2 prompt to create self signed SSL vhost 2nd vhost conf
NGINXBACKUP='y'
NGINXDIR='/usr/local/nginx'
NGINXCONFDIR="${NGINXDIR}/conf"
NGINXBACKUPDIR='/usr/local/nginxbackup'
##################################
## Nginx SSL options
# OpenSSL
NOSOURCEOPENSSL='y' # set to 'y' to disable OpenSSL source compile for system default YUM package setup
OPENSSL_VERSION='1.0.2f' # Use this version of OpenSSL http://openssl.org/
CLOUDFLARE_PATCHSSL='n' # set 'y' to implement Cloudflare's kill RC4 patch https://github.com/cloudflare/sslconfig
# LibreSSL
LIBRESSL_SWITCH='y' # if set to 'y' it overrides OpenSSL as the default static compiled option for Nginx server
LIBRESSL_VERSION='2.2.6' # Use this version of LibreSSL http://www.libressl.org/
##################################
# Choose whether to compile Nginx --with-google_perftools_module
# no longer used in Centmin Mod v1.2.3-eva2000.01 and higher
GPERFTOOLS_SOURCEINSTALL=n
LIBUNWIND_VERSION='0.99' # note google perftool specifically requies v0.99 and no other
GPERFTOOLS_VERSION='1.8.3' # Use this version of google-perftools
# Choose whether to compile PCRE from source. Note PHP 5.3.8 already includes PCRE v8.12
PCRE_SOURCEINSTALL=n
PCRE_VERSION='8.37' # NO longer used/ignored
# PHP and Cache/Acceleration
IMAGICKPHP_VER='3.4.0RC5' # PHP extension for imagick
MEMCACHED_INSTALL=y # Install Memcached
LIBEVENT_VERSION='2.0.22' # Use this version of Libevent
MEMCACHED_VERSION='1.4.25' # Use this version of Memcached server
MEMCACHE_VERSION='3.0.8' # Use this version of Memcache
MEMCACHEDPHP_VER='2.2.0' # Memcached PHP extension not server
LIBMEMCACHED_YUM='y' # switch to YUM install instead of source compile
LIBMEMCACHED_VER='1.0.18' # libmemcached version for source compile
TWEMPERF_VER='0.1.1'
PHPREDIS='y' # redis PHP extension install
REDISPHP_VER='2.2.7' # redis PHP version
PHPMONGODB='n' # MongoDB PHP extension install
MONGODBPHP_VER='1.6.9' # MongoDB PHP version
MONGODB_SASL='n' # SASL not working yet leave = n
FFMPEGVER='0.6.0'
SUHOSINVER='0.9.37.1'
PHP_VERSION='5.4.45' # Use this version of PHP
PHP_MIRRORURL='http://php.net'
PHPUPGRADE_MIRRORURL='http://php.net'
XCACHE_VERSION='3.2.0' # Use this version of Xcache
APCCACHE_VERSION='3.1.13' # Use this version of APC Cache
IGBINARY_VERSION='1.2.1'
IGBINARYGIT='y'
ZOPCACHEDFT='y'
ZOPCACHECACHE_VERSION='7.0.5' # for PHP <=5.4 http://pecl.php.net/package/ZendOpcache
ZOPCACHE_OVERRIDE='n' # =y will override PHP 5.5, 5.6, 7.0 inbuilt Zend OpCache version
# Python
PYTHON_VERSION='2.7.10' # Use this version of Python
SIEGE_VERSION='3.1.3'
WGETOPT='-cnv --no-dns-cache -4'
###############################################################
# experimental Intel compiled optimisations
# when auto detect Intel based processors
INTELOPT='n'
# experimental custom RPM compiled packages to replace source
# compiled versions for 64bit systems only
FPMRPM_LIBEVENT=n
FPMRPM_MEMCACHED=n
CENTALTREPO_DISABLE=y
RPMFORGEREPO_DISABLE=n
AXIVOREPO_DISABLE=n
REMIREPO_DISABLE=n
ATRPMSREPO_DISABLE=y
# custom curl/libcurl RPM for 7.46 and higher
# enable with CUSTOM_CURLRPM=y
# use at own risk as it can break the system
# info at http://mirror.city-fan.org/ftp/contrib/sysutils/Mirroring/
CUSTOM_CURLRPM=n
CUSTOM_CURLRPMVER='7.46.0-2.0' # custom curl/libcurl version
CUSTOM_CURLLIBSSHVER='1.6.0-3.0' # libssh2 version
CUSTOM_CURLRPMCARESVER='1.10.0-5.0' # c-ares version
CUSTOM_CURLRPMSYSURL='http://mirror.city-fan.org/ftp/contrib/sysutils/Mirroring'
CUSTOM_CURLRPMLIBURL='http://mirror.city-fan.org/ftp/contrib/libraries'
###############################################################
# Settings for centmin.sh menu option 2 and option 22 for
# the details of the self-signed SSL certificate that is auto
# generated. The default values where vhostname variable is
# auto added based on what you input for your site name
#
# -subj "/C=US/ST=California/L=Los Angeles/O=${vhostname}/OU=${vhostname}/CN=${vhostname}"
#
# You can only customise the first 5 variables for
# C = Country 2 digit code
# ST = state
# L = Location as in city
# 0 = organisation
# OU = organisational unit
#
# if left blank # defaults to same as vhostname that is your domain
# if set it overrides that
SELFSIGNEDSSL_C='US'
SELFSIGNEDSSL_ST='California'
SELFSIGNEDSSL_L='Los Angeles'
SELFSIGNEDSSL_O=''
SELFSIGNEDSSL_OU=''
###############################################################
MACHINE_TYPE=`uname -m` # Used to detect if OS is 64bit or not.
if [ "${ARCH_OVERRIDE}" != '' ]
then
ARCH=${ARCH_OVERRIDE}
else
if [ ${MACHINE_TYPE} == 'x86_64' ];
then
ARCH='x86_64'
MDB_ARCH='amd64'
else
ARCH='i386'
fi
fi
# ensure if ORESTY_LUANGINX is enabled, that the other required
# Openresty modules are enabled if folks forget to enable them
if [[ "$ORESTY_LUANGINX" = [yY] ]]; then
NGINX_OPENRESTY='y'
fi
# ensure clang alternative to gcc compiler is used only for 64bit OS
# if [[ "$(uname -m)" != 'x86_64' ]]; then
# CLANG='n'
# fi
# source "inc/mainmenu.inc"
# source "inc/mainmenu_cli.inc"
# source "inc/ramdisk.inc"
source "inc/customrpms.inc"
source "inc/pureftpd.inc"
source "inc/htpasswdsh.inc"
source "inc/gcc.inc"
source "inc/entropy.inc"
source "inc/cpucount.inc"
source "inc/motd.inc"
source "inc/cpcheck.inc"
source "inc/memcheck.inc"
source "inc/ccache.inc"
source "inc/bookmark.inc"
source "inc/centminlogs.inc"
source "inc/yumskip.inc"
source "inc/questions.inc"
source "inc/downloads_centosfive.inc"
source "inc/downloads_centossix.inc"
source "inc/downloads_centosseven.inc"
source "inc/downloadlinks.inc"
source "inc/downloads.inc"
source "inc/yumpriorities.inc"
source "inc/yuminstall.inc"
source "inc/centoscheck.inc"
source "inc/axelsetup.inc"
source "inc/phpfpmdir.inc"
source "inc/nginx_backup.inc"
source "inc/nsd_install.inc"
source "inc/nsdsetup.inc"
source "inc/nsd_reinstall.inc"
source "inc/logrotate_nginx.inc"
source "inc/logrotate_phpfpm.inc"
source "inc/nginx_mimetype.inc"
source "inc/openssl_install.inc"
source "inc/nginx_configure.inc"
# source "inc/nginx_configure_openresty.inc"
source "inc/geoip.inc"
source "inc/luajit.inc"
source "inc/nginx_patch.inc"
source "inc/nginx_install.inc"
source "inc/nginx_upgrade.inc"
source "inc/imagick_install.inc"
source "inc/memcached_install.inc"
source "inc/redis.inc"
source "inc/mongodb.inc"
source "inc/mysql_proclimit.inc"
source "inc/mysqltmp.inc"
source "inc/mariadb_install.inc"
source "inc/mysql_install.inc"
source "inc/mariadb_submenu.inc"
source "inc/zendopcache_tweaks.inc"
source "inc/php_extraopts.inc"
source "inc/php_configure.inc"
source "inc/phpng_download.inc"
source "inc/php_upgrade.inc"
source "inc/suhosin_setup.inc"
source "inc/nginx_pagespeed.inc"
source "inc/nginx_modules.inc"
source "inc/nginx_modules_openresty.inc"
source "inc/sshd.inc"
source "inc/openvz_stack.inc"
source "inc/siegeinstall.inc"
source "inc/python_install.inc"
source "inc/nginx_addvhost.inc"
source "inc/wpsetup.inc"
source "inc/mariadb_upgrade.inc"
source "inc/mariadb_upgrade53.inc"
source "inc/mariadb_upgrade55.inc"
source "inc/mariadb_upgrade10.inc"
source "inc/nginx_errorpage.inc"
source "inc/sendmail.inc"
source "inc/postfix.inc"
source "inc/compress.inc"
source "inc/diskalert.inc"
source "inc/phpsededit.inc"
source "inc/csfinstall.inc"
source "inc/csftweaks.inc"
source "inc/xcache_installask.inc"
source "inc/xcache_install.inc"
source "inc/xcache_reinstall.inc"
source "inc/igbinary.inc"
source "inc/apcprotect.inc"
source "inc/apcinstall.inc"
source "inc/apcreinstall.inc"
source "inc/zendopcache_55ini.inc"
source "inc/zendopcache_install.inc"
source "inc/zendopcache_upgrade.inc"
source "inc/zendopcache_reinstall.inc"
source "inc/zendopcache_submenu.inc"
source "inc/ffmpeginstall.inc"
source "inc/shortcuts_install.inc"
source "inc/memcacheadmin.inc"
source "inc/mysqlsecure.inc"
source "inc/updater_submenu.inc"
source "inc/centminfinish.inc"
checkcentosver
mysqltmpdir
cpcheck
if [ ! -f /etc/centminmod-release ];then
echo "$SCRIPT_VERSION" > /etc/centminmod-release
else
if [[ "$SCRIPT_VERSION" != "$(cat /etc/centminmod-release)" ]]; then
echo "$SCRIPT_VERSION" > /etc/centminmod-release
fi
fi
if [ -f /etc/centminmod-versionlog ];then
if [[ "$SCRIPT_VERSION" != "$(cat /etc/centminmod-versionlog)" ]]; then
echo "$SCRIPT_VERSION #`date`" >> /etc/centminmod-versionlog
fi
else
echo "$SCRIPT_VERSION #`date`" >> /etc/centminmod-versionlog
fi
if [ ! -f /usr/bin/cminfo_updater ]; then
setupdate
/usr/bin/cminfo_updater
else
setupdate
/usr/bin/cminfo_updater
fi
if [ ! -x /usr/bin/cminfo ]; then
chmod 0700 /usr/bin/cminfo
fi
###############################################################
# The default is stable, you can change this to development if you wish
#ARCH_OVERRIDE='i386'
# Uncomment the above line if you are running a 32bit Paravirtulized Xen VPS
# on a 64bit host node.
# YOU SHOULD NOT NEED TO MODIFY ANYTHING BELOW THIS LINE +++++++++++++++++++
# JUST RUN chmod +x ./centmin.sh && ./centmin.sh
#
###############################################################
KEYPRESS_PARAM='-s -n1 -p' # Read a keypress without hitting ENTER.
# -s means do not echo input.
# -n means accept only N characters of input.
# -p means echo the following prompt before reading input
ASKCMD="read $KEYPRESS_PARAM "
# MACHINE_TYPE=`uname -m` # Used to detect if OS is 64bit or not.
CUR_DIR=$SCRIPT_DIR # Get current directory.
CM_INSTALLDIR=$CUR_DIR
# echo "centmin.sh \${CUR_DIR} & \${CM_INSTALLDIR}"
# echo ${CUR_DIR}
# echo ${CM_INSTALLDIR}
if [ -f "${CM_INSTALLDIR}/inc/custom_config.inc" ]; then
source "inc/custom_config.inc"
fi
if [ -f "${CONFIGSCANBASE}/custom_config.inc" ]; then
# default is at /etc/centminmod/custom_config.inc
source "${CONFIGSCANBASE}/custom_config.inc"
fi
###############################################################
# FUNCTIONS
if [[ "$CENTOSVER" = '6.0' || "$CENTOSVER" = '6.1' || "$CENTOSVER" = '6.2' || "$CENTOSVER" = '6.3' || "$CENTOSVER" = '6.4' || "$CENTOSVER" = '6.5' || "$CENTOSVER" = '6.6' || "$CENTOSVER" = '6.7' || "$CENTOSVER" = '6.8' || "$CENTOSVER" = '6.9' || "$CENTOSVER" = '7.0' || "$CENTOSVER" = '7.1' || "$CENTOSVER" = '7.2' || "$CENTOSVER" = '7.3' || "$CENTOSVER" = '7.4' || "$CENTOSVER" = '7.5' || "$CENTOSVER" = '7.6' || "$CENTOSVER" = '7.7' ]]; then
DOWNLOADAPP="wget ${WGETOPT} --progress=bar"
WGETRETRY='--tries=3'
AXELPHPTARGZ="-O php-${PHP_VERSION}.tar.gz"
AXELPHPUPGRADETARGZ="-O php-${phpver}.tar.gz"
else
DOWNLOADAPP="wget ${WGETOPT} --progress=bar"
WGETRETRY='--tries=3'
AXELPHPTARGZ=''
AXELPHPUPGRADETARGZ=''
fi
# if [ "${ARCH_OVERRIDE}" != '' ]
# then
# ARCH=${ARCH_OVERRIDE}
# else
# if [ ${MACHINE_TYPE} == 'x86_64' ];
# then
# ARCH='x86_64'
# MDB_ARCH='amd64'
# else
# ARCH='i386'
# fi
# fi
ASK () {
keystroke=''
while [[ "$keystroke" != [yYnN] ]]
do
$ASKCMD "$1" keystroke
echo "$keystroke";
done
key=$(echo $keystroke)
}
# 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
}
###
unsetramdisk() {
if [[ "$RAMDISKTMPFS" = [yY] && "$TMPFSENABLED" = '1' ]]; then
echo
cecho "unmount $DIR_TMP tmpfs ramdisk & copy back to disk" $boldyellow
mkdir -p ${DIR_TMP}_disk
\cp -R ${DIR_TMP}/* ${DIR_TMP}_disk
# ls -lah ${DIR_TMP}_disk
# diff -qr ${DIR_TMP} ${DIR_TMP}_disk
cmservice nginx stop
cmservice php-fpm stop
cmservice memcached stop
sleep 4
# lsof | grep /svr-setup
umount -l ${DIR_TMP}
cmservice nginx start
cmservice php-fpm start
cmservice memcached start
\cp -R ${DIR_TMP}_disk/* ${DIR_TMP}
# ls -lahrt ${DIR_TMP}
df -hT
cecho "unmounted $DIR_TMP tmpfs ramdisk" $boldyellow
fi
}
###
function funct_centmininstall {
#check centmin install previously
run_once() {
# If OpenVZ user add user/group 500 - else various folders and devices will end up with an odd user/group name for some reason
if [ -f /proc/user_beancounters ];
then
groupadd 500
useradd -g 500 -s /sbin/nologin -M 500
fi
#ASK "Would you like to update any pre-installed software? (Recommended) [y/n] "
#if [[ "$key" = [yY] ]];
#then
# echo "Let's do that then..."
# yum${CACHESKIP} -q clean all
# yum${CACHESKIP} -y update glibc\*
# yum${CACHESKIP} -y update yum\* rpm\* python\*
# yum${CACHESKIP} -q clean all
# yum${CACHESKIP} -y update
#fi
if [ ${ARCH} == 'x86_64' ];
then
if [ "$UNATTENDED" == 'n' ]; then
ASK "Would you like to exclude installation of 32bit Yum packages? (Recommended for 64bit CentOS) [y/n] "
else
key='y'
fi #unattended
if [[ "$key" = [yY] ]];
then
\cp -f /etc/yum.conf /etc/yum.bak
echo "removing any i686 packages installed by default"
yum -y remove \*.i686
ex -s /etc/yum.conf << EOF
:/plugins=1/
:a
exclude=*.i386 *.i586 *.i686
.
:w
:q
EOF
echo "Your origional yum configuration has been backed up to /etc/yum.bak"
else
rm -rf $CUR_DIR/config/yum
fi
fi
if [ "$UNATTENDED" == 'n' ]; then
ASK "Would you like to secure /tmp and /var/tmp? (Highly recommended) [y/n] "
else
key='y'
fi #unattended
{
if [[ "$key" = [yY] ]]; then
echo "Centmin Mod secure /tmp # `date`"
echo "*************************************************"
cecho "* Secured /tmp and /var/tmp" $boldgreen
echo "*************************************************"
# centos 7 + openvz /tmp workaround
if [[ -f /proc/user_beancounters && "$CENTOS_SEVEN" = '7' ]]; then
echo "CentOS 7 Setup /tmp"
echo "CentOS 7 + OpenVZ virtualisation detected"
systemctl is-enabled tmp.mount
## leave CentOS 7 + OpenVZ systems /tmp mounted on disk in ##
## partition / ##
# systemctl enable tmp.mount
# systemctl is-enabled tmp.mount
## leave CentOS 7 + OpenVZ system's /tmp mounted in memory via
## tmpfs as CentOS 7 requires more memory installed, so most of
## the time, you would have sufficient memory at least for /tmp
## on ramdisk tmpfs unlike when CentOS 6 32bit systems can use
## 256MB to 512MB memory and end up with too small a ramdisk tmpfs
## /tmp mount
#
# rm -rf /tmp
# mkdir -p /tmp
# mount -t tmpfs -o rw,noexec,nosuid tmpfs /tmp
# chmod 1777 /tmp
# echo "tmpfs /tmp tmpfs rw,noexec,nosuid 0 0" >> /etc/fstab
# rm -rf /var/tmp
# ln -s /tmp /var/tmp
# mount -o remount /tmp
elif [[ ! -f /proc/user_beancounters && "$CENTOS_SEVEN" = '7' ]]; then
echo "CentOS 7 Setup /tmp"
echo "CentOS 7 + non-OpenVZ virtualisation detected"
systemctl is-enabled tmp.mount
elif [[ ! -f /proc/user_beancounters ]]; then
# TOTALMEM=$(cat /proc/meminfo | grep MemTotal | awk '{print $2}')
CURRENT_TMPSIZE=$(df /tmp | awk '/tmp/ {print $2}')
# only mount /tmp on tmpfs if CentOS system
# total memory size is greater than 8GB
# will give /tmp a size equal to 1/2 total memory
if [[ "$TOTALMEM" -ge '8100001' ]]; then
rm -rf /tmp
mkdir -p /tmp
mount -t tmpfs -o rw,noexec,nosuid tmpfs /tmp
chmod 1777 /tmp
echo "tmpfs /tmp tmpfs rw,noexec,nosuid 0 0" >> /etc/fstab
rm -rf /var/tmp
ln -s /tmp /var/tmp
elif [[ "$TOTALMEM" -ge '2050061' || "$TOTALMEM" -lt '8100000' ]]; then
# set on disk non-tmpfs /tmp to 4GB size
# if total memory is between 2GB and <8GB
rm -rf /tmp
dd if=/dev/zero of=/home/usertmp_donotdelete bs=1024 count=4000000
echo Y | mkfs.ext4 /home/usertmp_donotdelete
mkdir -p /tmp
mount -t ext4 -o loop,rw,noexec,nosuid /home/usertmp_donotdelete /tmp
chmod 1777 /tmp
echo "/home/usertmp_donotdelete /tmp ext4 loop,rw,noexec,nosuid 0 0" >> /etc/fstab
rm -rf /var/tmp
ln -s /tmp /var/tmp
elif [[ "$TOTALMEM" -ge '1153434' || "$TOTALMEM" -lt '2050060' ]]; then
# set on disk non-tmpfs /tmp to 2GB size
# if total memory is between 1.1-2GB
rm -rf /tmp
dd if=/dev/zero of=/home/usertmp_donotdelete bs=1024 count=2000000
echo Y | mkfs.ext4 /home/usertmp_donotdelete
mkdir -p /tmp
mount -t ext4 -o loop,rw,noexec,nosuid /home/usertmp_donotdelete /tmp
chmod 1777 /tmp
echo "/home/usertmp_donotdelete /tmp ext4 loop,rw,noexec,nosuid 0 0" >> /etc/fstab
rm -rf /var/tmp
ln -s /tmp /var/tmp
elif [[ "$TOTALMEM" -le '1153433' ]]; then
# set on disk non-tmpfs /tmp to 1GB size
# if total memory is <1.1GB
rm -rf /tmp
dd if=/dev/zero of=/home/usertmp_donotdelete bs=1024 count=1000000
echo Y | mkfs.ext4 /home/usertmp_donotdelete
mkdir -p /tmp
mount -t ext4 -o loop,rw,noexec,nosuid /home/usertmp_donotdelete /tmp
chmod 1777 /tmp
echo "/home/usertmp_donotdelete /tmp ext4 loop,rw,noexec,nosuid 0 0" >> /etc/fstab
rm -rf /var/tmp
ln -s /tmp /var/tmp
fi
fi # centos 7 + openvz /tmp workaround
fi
} 2>&1 | tee ${CENTMINLOGDIR}/securedtmp.log
#questions
#yuminstall
if [ "$UNATTENDED" == 'n' ]; then
ASK "Would you like to set the server localtime? [y/n] "
else
key='y'
fi #unattended
if [[ "$key" = [yY] ]];
then
echo "*************************************************"
cecho "* Setting preferred localtime for VPS" $boldgreen
echo "*************************************************"
rm -f /etc/localtime
ln -s /usr/share/zoneinfo/$ZONEINFO /etc/localtime
echo "Current date & time for the zone you selected is:"
date
fi
}
# END FUNCTIONS
################################################################
# SCRIPT START
#
clear
cecho "**********************************************************************" $boldyellow
cecho "* Centmin Mod Nginx, MariaDB MySQL, PHP & DNS Install script for CentOS" $boldgreen
cecho "* Version: $SCRIPT_VERSION - Date: $SCRIPT_DATE" $boldgreen
cecho "* $COPYRIGHT $SCRIPT_MODIFICATION_AUTHOR" $boldgreen
cecho "**********************************************************************" $boldyellow
echo " "
cecho "This software comes with no warranty of any kind. You are free to use" $boldyellow
cecho "it for both personal and commercial use as licensed under the GPL." $boldyellow
echo " "
cecho "Please read the included readme.txt before using this script." $boldmagenta
echo " "
if [ "$UNATTENDED" == 'n' ]; then
ASK "Would you like to continue? [y/n] "
if [[ "$key" = [nN] ]];
then
exit 0
fi
fi #unattended
# Set LIBDIR
if [ ${ARCH} == 'x86_64' ];
then
LIBDIR='lib64'
else
LIBDIR='lib'
fi
#DIR_TMP="/svr-setup"
#if [ -a "$DIR_TMP" ];
#then
# ASK "It seems that you have run this script before, would you like to start from after setting the timezone? [y/n] "
# if [[ "$key" = [nN] ]];
# then
# run_once
# fi
#else
# mkdir $DIR_TMP
# run_once
#fi
if [ ! -f "${DIR_TMP}/securedtmp.log" ]; then
run_once
fi
if [ -f /proc/user_beancounters ];
then
cecho "OpenVZ system detected, NTP not installed" $boldgreen
else
if [[ "$NTP_INSTALL" = [yY] ]];
then
echo "*************************************************"
cecho "* Installing NTP (and syncing time)" $boldgreen
echo "*************************************************"
if [ ! -f /usr/sbin/ntpd ]; then
yum${CACHESKIP} -y install ntp
fi
chkconfig --levels 235 ntpd on
ntpdate pool.ntp.org