This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall.sh
1489 lines (1129 loc) · 47.9 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# Tested on Debian Stretch / Debian Buster - amd64
# Use at your own risk
#####################################################################################################################
#
# Default software source list
#
#####################################################################################################################
jemalloc_address_default="https://github.com/jemalloc/jemalloc/archive/5.2.1.tar.gz"
cmake_address_default="https://github.com/Kitware/CMake/releases/download/v3.18.0/cmake-3.18.0.tar.gz"
openssl_address_default="https://www.openssl.org/source/openssl-1.1.1g.tar.gz"
python_address_default="https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz"
python3_address_default="https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz"
zlib_address_default="http://www.zlib.net/zlib-1.2.11.tar.gz"
lz4_address_default="https://github.com/lz4/lz4/archive/v1.9.2.tar.gz"
libzip_address_default="https://libzip.org/download/libzip-1.7.3.tar.gz"
libssh2_address_default="https://www.libssh2.org/download/libssh2-1.9.0.tar.gz"
nghttp2_address_default="https://github.com/nghttp2/nghttp2/releases/download/v1.41.0/nghttp2-1.41.0.tar.gz"
curl_address_default="https://curl.haxx.se/download/curl-7.71.1.tar.gz"
libcrack2_address_default="https://github.com/cracklib/cracklib/archive/v2.9.7.tar.gz"
libXML2_address_default="http://xmlsoft.org/sources/libxml2-2.9.10.tar.gz"
libxslt_address_default="http://xmlsoft.org/sources/libxslt-1.1.34.tar.gz"
php_address_default="https://github.com/php/php-src/archive/php-7.4.8.tar.gz"
nginx_address_default="https://nginx.org/download/nginx-1.19.1.tar.gz"
psol_url="https://www.modpagespeed.com/release_archive/1.13.35.2/psol-1.13.35.2-x64.tar.gz"
#####################################################################################################################
#
# Environment Variables
#
#####################################################################################################################
DEBIAN_VERSION=`cat /etc/debian_version | cut -d . -f 1`
if (( $DEBIAN_VERSION < 9 )); then
echo "Cancelled: Only run in Debian >= 9"
fi
BASEDIR="$PWD"
MACHINE_TYPE=`uname -m`
TRAVISFOLDNAME=/tmp/.travis_fold_name
NUMCPUS=`nproc`
NUMJOBS=`expr $NUMCPUS + 1`
alias make="make -j${NUMJOBS}"
if [ "$MACHINE_TYPE" == "i386" ]; then
export CPPFLAGS="-I/usr/local/include -I/usr/include/i386-linux-gnu"
fi
if [ "$MACHINE_TYPE" == "x86_64" ]; then
export CPPFLAGS="-I/usr/local/include -I/usr/include/x86_64-linux-gnu"
fi
export CFLAGS="-march=native -O2 -ftree-vectorize -pipe"
export CXXFLAGS="${CFLAGS}"
export LDFLAGS="-L/usr/local/lib -Wl,-rpath,/usr/local/lib"
export LDCONFIG=-L/usr/local/lib
export LIBS="-ldl"
source /etc/profile
#####################################################################################################################
#
# Functions
#
#####################################################################################################################
travis_fold() {
local action=$1
local name=$2
echo -en "travis_fold:${action}:${name}\r"
}
travis_fold_start() {
travis_fold start $1
echo $1
echo -n $1 > $TRAVISFOLDNAME
}
travis_fold_end() {
travis_fold end "$(cat ${TRAVISFOLDNAME})"
}
function wgetAndDecompress() {
local dirTmp=$1
local folderTmp=$2
local downloadAddress=$3
if [ -z $dirTmp ] || [ -z $folderTmp ] || [ -z $downloadAddress ]
then
read -n 1 -s -p "Critical error in wgetAndDecompress() - create directories" && echo -e "\n"
exit 1
fi
# tar.gz or tar.xz -> .tar
mkdir -p $dirTmp
wget --no-check-certificate -O $dirTmp/$folderTmp.tar $downloadAddress
if [ ! -f $dirTmp/$folderTmp.tar ]
then
read -n 1 -s -p "Critical error in wgetAndDecompress() - file download" && echo -e "\n"
exit 1
fi
mkdir -p $dirTmp/$folderTmp
rm -Rf ${dirTmp:?}/$folderTmp/*
tar -xvf $dirTmp/$folderTmp.tar -C $dirTmp/$folderTmp --strip-components=1 > /dev/null
cd $dirTmp/$folderTmp || exit 1
}
function pauseToContinue() {
if [ "$DefaultOption" != "Y" ]
then
read -n 1 -s -p "Press any key to continue" && echo -e "\n"
fi
}
# use: askOption question defaultOption skipQuestion
function askOption() {
local question="$1"
local defaultOption="$2"
local skipQuestion="$3"
returnOption="$defaultOption"
if [ "$skipQuestion" != "Y" ]
then
returnOption="$defaultOption"
read -e -i "$defaultOption" -p "$question" userOption
returnOption="${userOption:-$defaultOption}"
fi
echo "$returnOption"
}
function service_stop() {
# Func askOption (question, defaultOption, skipQuestion)
input_install_service_stop="$(askOption "Stop All Services? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_service_stop == "Y" ] || [ $input_install_service_stop == "y" ]
then
service nginx stop
service php7-fpm stop
fi
}
function clear_compile() {
# Func askOption (question, defaultOption, skipQuestion)
input_install_clear_compile="$(askOption "Clear Compile ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_clear_compile == "Y" ] || [ $input_install_clear_compile == "y" ]
then
rm -rf /var/tmp/*_build
ccache -C
apt-get -y remove --auto-remove libxau-dev libxdmcp-dev xorg-sgml-doctools \
xsltproc docbook-xsl docbook-xml needrestart autoconf autogen autopoint \
automake m4 bison build-essential g++ pkg-config \
autotools-dev libtool expect \
libcunit1-dev x11proto-core-dev file \
libenchant-dev gnu-standards \
autoconf-archive g++-multilib gcc-multilib \
valgrind valgrind-mpi \
valkyrie flex tk-dev ccache
# Only run in Debian 9.x
DEBIAN_VERSION=`cat /etc/debian_version | cut -d . -f 1`
if (( $DEBIAN_VERSION < 10 )); then
apt-get -y remove --auto-remove libstdc++-6-dev gcc-6-locales g++-6-multilib gcj-jdk
fi
apt-get -y remove --auto-remove golang
apt-get -y remove --auto-remove binutils
apt-get -y remove --auto-remove qt4-qmake
apt-get -y autoremove
apt-get clean
fi
}
function essential_install() {
#####################################################################################################################
#
# Install Essential
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_delete_build="$(askOption "Delete building directories ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_delete_build == "Y" ] || [ $input_delete_build == "y" ]
then
rm -rf /var/tmp/*_build
fi
# Func askOption (question, defaultOption, skipQuestion)
input_install_essential="$(askOption "Install Essential ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_essential == "Y" ] || [ $input_install_essential == "y" ]
then
# Build Essential
sed -i '/^#\sdeb-src /s/^#//' "/etc/apt/sources.list"
apt-get -y update
apt-get install -y --no-install-recommends apt-utils
chmod 666 /etc/environment
truncate -s 0 /etc/environment
echo -e "LC_ALL=en_US.UTF-8\n" >> /etc/environment
echo -e "LC_CTYPE=UTF-8\n" >> /etc/environment
echo -e "LANG=en_US.UTF-8\n" >> /etc/environment
chmod 644 /etc/environment
apt-get -y install locales
sed -i 's/^# *\(en_US.UTF-8\)/\1/' /etc/locale.gen && locale-gen
apt-get -y upgrade
apt-get -y dist-upgrade
# TODO: check this: Packages that can be deleted after the script is finished.
apt-get -y install libxau-dev libxdmcp-dev xorg-sgml-doctools \
xsltproc docbook-xsl docbook-xml needrestart autoconf autogen autopoint \
automake m4 bison build-essential g++ pkg-config \
autotools-dev libtool expect \
libcunit1-dev x11proto-core-dev file \
libenchant-dev gnu-standards \
autoconf-archive g++-multilib gcc-multilib \
valgrind valgrind-mpi \
valkyrie flex tk-dev golang binutils ccache \
qt4-qmake
# Only run in Debian 9.x
DEBIAN_VERSION=`cat /etc/debian_version | cut -d . -f 1`
if (( $DEBIAN_VERSION < 10 )); then
apt-get -y install libstdc++-6-dev gcc-6-locales g++-6-multilib gcj-jdk
fi
# TODO: check this: Important packages that must be installed.
apt-get -y install coreutils uuid-dev wget \
mcrypt perl libpcre3 bzip2 \
trousers libidn2-0 libtiffxx5 libexpat1-dev \
libc-dbg gettext debian-keyring liblinear-tools \
libdbi-perl rsync net-tools libdbd-mysql-perl re2c \
libc-ares-dev libpcre3-dev libxml2-dev libxslt1-dev \
libfreetype6-dev libfontconfig1-dev \
libjpeg62-turbo-dev libjpeg-dev libpng-dev \
libbz2-dev zlib1g-dev libzip-dev liblzma-dev \
libjansson-dev libmcrypt-dev \
libgmp-dev libev-dev libevent-dev \
libsqlite3-dev libgdbm-dev libdb-dev \
libsystemd-dev libspdylay-dev \
libaio-dev libncurses5-dev libncursesw5-dev libboost-all-dev \
libunistring-dev libunbound-dev libqt4-dev \
libicu-dev libltdl-dev libreadline-dev \
libaspell-dev libpspell-dev \
libc6-dev libpam0g-dev libmsgpack-dev libstemmer-dev libbsd-dev \
liblinear-dev libssl-dev libboost-dev libboost-thread-dev \
libffi-dev unzip git libonig-dev
if [ -f /usr/lib/ccache ]; then
export PATH=/usr/lib/ccache:$PATH
echo "export PATH=$PATH" >> /etc/profile
source /etc/profile
fi
apt-get -y upgrade
apt-get -y autoremove
apt-get -y remove --purge --auto-remove curl
apt-get -y remove --purge --auto-remove cmake*
apt-get -y remove --purge --auto-remove python*
apt-get -y build-dep curl
apt-get -y build-dep zlib
apt-get -y build-dep openssl
apt-get -y build-dep python3.7
apt-get -y upgrade
apt-get -y autoremove
apt-get clean
if [ "$ProgramName" != "travis" ] && [ "$ProgramName" != "packer" ]
then
tzselect
dpkg-reconfigure tzdata
fi
pauseToContinue
# Func askOption (question, defaultOption, skipQuestion)
input_install_reboot="$(askOption "Reboot ? [y/N]: " "N" $DefaultOption)"
if [ $input_install_reboot == "Y" ] || [ $input_install_reboot == "y" ]
then
reboot
exit 0
fi
fi
}
function jemalloc_install() {
#####################################################################################################################
#
# INSTALL jemalloc
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_jemalloc="$(askOption "Install jemalloc ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_jemalloc == "Y" ] || [ $input_install_jemalloc == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
jemalloc_address="$(askOption "Enter the download address for jemalloc (tar.gz): " $jemalloc_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
jemalloc_install_tmp_dir="$(askOption "Enter temporary directory for jemalloc compilation: " "/var/tmp/jemalloc_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $jemalloc_install_tmp_dir jemalloc_src $jemalloc_address
./autogen.sh
./configure --prefix=/usr/local --with-xslroot=/usr/share/xml/docbook/stylesheet/docbook-xsl/
make
make dist
make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig
pauseToContinue
fi
}
function cmake_install() {
#####################################################################################################################
#
# INSTALL cmake
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_cmake="$(askOption "Install cmake ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_cmake == "Y" ] || [ $input_install_cmake == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
cmake_address="$(askOption "Enter the download address for cmake (tar.gz): " $cmake_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
cmake_install_tmp_dir="$(askOption "Enter temporary directory for cmake compilation: " "/var/tmp/cmake_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $cmake_install_tmp_dir "cmake_src" $cmake_address
./bootstrap
make
make install
ldconfig
cmake --version
pauseToContinue
fi
}
function openssl_install() {
#####################################################################################################################
#
# INSTALL OpenSSL
# config file: /usr/local/ssl/openssl.cnf
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_openssl="$(askOption "Install OpenSSL ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_openssl == "Y" ] || [ $input_install_openssl == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
openssl_address="$(askOption "Enter the download address for OpenSSL (tar.gz): " $openssl_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
openssl_install_tmp_dir="$(askOption "Enter temporary directory for OpenSSL compilation: " "/var/tmp/openssl_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $openssl_install_tmp_dir "openssl_src" $openssl_address
./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)' no-comp no-zlib no-zlib-dynamic enable-ec_nistp_64_gcc_128 enable-tls1_3 shared
make
make test
make MANSUFFIX=ssl install
echo "export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt" >> /etc/profile
echo "export SSL_CERT_DIR=/etc/ssl/certs/" >> /etc/profile
source /etc/profile
update-ca-certificates
ldconfig
ldconfig -p | grep libcrypto
whereis openssl
openssl version -v
pauseToContinue
needrestart -r l
fi
}
function python2_install() {
#####################################################################################################################
#
# INSTALL Python (deprecated)
#
#####################################################################################################################
input_install_python="$(askOption "Install Python2 ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_python == "Y" ] || [ $input_install_python == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
python_address="$(askOption "Enter the download address for Python2 (tar.gz): " $python_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
python_install_tmp_dir="$(askOption "Enter temporary directory for Python2 compilation: " "/var/tmp/python_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $python_install_tmp_dir "python_src" $python_address
if [ "$ProgramName" != "travis" ]
then
./configure --prefix=/usr/local --enable-shared --enable-optimizations
else
./configure --prefix=/usr/local --enable-shared
fi
make
make install
python --version
wget https://bootstrap.pypa.io/get-pip.py
chmod +x get-pip.py
python get-pip.py
pip install --upgrade pip
pip install --upgrade setuptools wheel virtualenv pyopenssl
pip -V
fi
}
function python3_install() {
#####################################################################################################################
#
# INSTALL Python 3
#
#####################################################################################################################
input_install_python="$(askOption "Install Python3 ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_python == "Y" ] || [ $input_install_python == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
python_address="$(askOption "Enter the download address for Python3 (tar.gz): " $python3_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
python_install_tmp_dir="$(askOption "Enter temporary directory for Python3 compilation: " "/var/tmp/python3_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $python_install_tmp_dir "python3_src" $python_address
if [ "$ProgramName" != "travis" ]
then
./configure --prefix=/usr/local --enable-shared --enable-optimizations
else
./configure --prefix=/usr/local --enable-shared
fi
make
make install
apt remove -y --auto-remove python3.*
rm /usr/bin/python3
ln -s /usr/local/bin/python3 /usr/bin/python3
alias python=python3
python3 --version
wget https://bootstrap.pypa.io/get-pip.py
chmod +x get-pip.py
python3 get-pip.py
pip3 install --upgrade pip
pip3 install --upgrade setuptools wheel virtualenv pyopenssl
pip3 -V
fi
}
function zlib_install() {
#####################################################################################################################
#
# INSTALL zlib
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_zlib="$(askOption "Install zlib ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_zlib == "Y" ] || [ $input_install_zlib == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
zlib_address="$(askOption "Enter the download address for zlib (tar.gz): " $zlib_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
zlib_install_tmp_dir="$(askOption "Enter temporary directory for zlib compilation: " "/var/tmp/zlib_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $zlib_install_tmp_dir "zlib_src" $zlib_address
./configure --shared
make
make install
ldconfig
pauseToContinue
fi
}
function lz4_install() {
#####################################################################################################################
#
# INSTALL LZ4
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_lz4="$(askOption "Install lz4 ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_lz4 == "Y" ] || [ $input_install_lz4 == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
lz4_address="$(askOption "Enter the download address for lz4 (tar.gz): " $lz4_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
lz4_install_tmp_dir="$(askOption "Enter temporary directory for lz4 compilation: " "/var/tmp/lz4_build" $DefaultOption)"
wgetAndDecompress $lz4_install_tmp_dir "lz4_src" $lz4_address
make
make install
ldconfig
lz4 -V
pauseToContinue
fi
}
function libzip_install() {
#####################################################################################################################
#
# INSTALL libzip
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_libzip="$(askOption "Install libzip ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_libzip == "Y" ] || [ $input_install_libzip == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
libzip_address="$(askOption "Enter the download address for libzip (tar.gz): " $libzip_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
libzip_install_tmp_dir="$(askOption "Enter temporary directory for libzip compilation: " "/var/tmp/libzip_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $libzip_install_tmp_dir "libzip_src" $libzip_address
mkdir build
cd build
cmake ..
make
make test
make install
ldconfig
pauseToContinue
fi
}
function libssh2_install() {
#####################################################################################################################
#
# INSTALL libssh2
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_libssh2="$(askOption "Install libssh2 ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_libssh2 == "Y" ] || [ $input_install_libssh2 == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
libssh2_address="$(askOption "Enter the download address for libssh2 (tar.gz): " $libssh2_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
libssh2_install_tmp_dir="$(askOption "Enter temporary directory for libssh2 compilation: " "/var/tmp/libssh2_build" $DefaultOption)"
wgetAndDecompress $libssh2_install_tmp_dir "libssh2_src" $libssh2_address
./configure --with-crypto=openssl --with-libssl-prefix=/usr/local --with-libz --with-libz-prefix=/usr/local
make
make install
ldconfig
pauseToContinue
fi
}
function nghttp2_install() {
#####################################################################################################################
#
# INSTALL Nghttp2: HTTP/2 C Library
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_nghttp2="$(askOption "Install Nghttp2 ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_nghttp2 == "Y" ] || [ $input_install_nghttp2 == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
nghttp2_address="$(askOption "Enter the download address for Nghttp2 (tar.gz): " $nghttp2_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
nghttp2_install_tmp_dir="$(askOption "Enter temporary directory for Nghttp2 compilation: " "/var/tmp/nghttp2_build" $DefaultOption)"
wgetAndDecompress $nghttp2_install_tmp_dir "nghttp2_src" $nghttp2_address
./configure
make
make install
ldconfig
pauseToContinue
fi
}
function curl_install() {
#####################################################################################################################
#
# INSTALL curl
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_curl="$(askOption "Install curl ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_curl == "Y" ] || [ $input_install_curl == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
curl_address="$(askOption "Enter the download address for CURL (tar.gz) ? [Y/n]: " $curl_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
curl_install_tmp_dir="$(askOption "Enter temporary directory for CURL compilation: " "/var/tmp/curl_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $curl_install_tmp_dir "curl_src" $curl_address
./buildconf
./configure --enable-versioned-symbols --enable-threaded-resolver --with-libssl-prefix=/usr/local --with-ca-path=/etc/ssl/certs --with-ssl --with-zlib --with-nghttp2 --with-libssh2
make
make install
ldconfig
curl -V
pauseToContinue
fi
}
function libcrack2_install() {
#####################################################################################################################
#
# INSTALL libcrack2
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_libcrack2="$(askOption "Install libcrack2 ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_libcrack2 == "Y" ] || [ $input_install_libcrack2 == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
libcrack2_address="$(askOption "Enter the download address for libcrack2 (tar.gz): " $libcrack2_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
libcrack2_install_tmp_dir="$(askOption "Enter temporary directory for libcrack2 compilation: " "/var/tmp/libcrack2_build" $DefaultOption)"
wgetAndDecompress $libcrack2_install_tmp_dir "libcrack2_src" $libcrack2_address
cd ./src || exit 1
sed -i '/skipping/d' util/packer.c
mkdir -p /usr/local/lib/cracklib/pw_dict
./autogen.sh
./configure --prefix=/usr/local
make
make install
make installcheck
ldconfig
pauseToContinue
cd ../words || exit 1
make all
install -v -m644 -D ./cracklib-words.gz /usr/share/dict/cracklib-words.gz
gunzip -v /usr/share/dict/cracklib-words.gz
ln -v -sf cracklib-words /usr/share/dict/words
install -v -m755 -d /usr/local/lib/cracklib
#create-cracklib-dict /usr/share/dict/cracklib-words /usr/share/dict/cracklib-extra-words
create-cracklib-dict /usr/share/dict/cracklib-words
pauseToContinue
fi
}
function libxml2_install() {
#####################################################################################################################
#
# INSTALL LibXML2
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_libXML2="$(askOption "Install LibXML2 ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_libXML2 == "Y" ] || [ $input_install_libXML2 == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
libXML2_address="$(askOption "Enter the download address for LibXML2 (tar.gz): " $libXML2_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
libXML2_install_tmp_dir="$(askOption "Enter temporary directory for LibXML2 compilation: " "/var/tmp/libXML2_build" $DefaultOption)"
wgetAndDecompress $libXML2_install_tmp_dir "libXML2_src" $libXML2_address
./configure --prefix=/usr/local --with-history --with-python=/usr/local/bin/python3
make
make install
ldconfig
pauseToContinue
fi
}
function libxslt_install() {
#####################################################################################################################
#
# INSTALL libxslt
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_libxslt="$(askOption "Install libxslt ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_libxslt == "Y" ] || [ $input_install_libxslt == "y" ]
then
# Func askOption (question, defaultOption, skipQuestion)
libxslt_address="$(askOption "Enter the download address for libxslt (tar.gz): " $libxslt_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
libxslt_install_tmp_dir="$(askOption "Enter temporary directory for libxslt compilation: " "/var/tmp/libxslt_build" $DefaultOption)"
wgetAndDecompress $libxslt_install_tmp_dir "libxslt_src" $libxslt_address
sed -i s/3000/5000/ libxslt/transform.c doc/xsltproc.{1,xml}
./configure --prefix=/usr/local
make
make install
ldconfig
pauseToContinue
fi
}
function mariadb_install() {
#
# -- This function is little tested by the main developer. --
#
#####################################################################################################################
#
# INSTALL MariaDB 10.4 - http://espejito.fder.edu.uy/mariadb/repo/10.4/debian stretch main
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_mariadb="$(askOption "Install MariaDB Client? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_mariadb == "Y" ] || [ $input_install_mariadb == "y" ]
then
apt-get -y install software-properties-common dirmngr
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://espejito.fder.edu.uy/mariadb/repo/10.4/debian stretch main'
apt-get -y update
apt-get -y install libmariadb-dev mariadb-client
ln -s /usr/bin/mariadb_config /usr/bin/mysql_config
pauseToContinue
fi
}
function php_install() {
#####################################################################################################################
#
# INSTALL PHP
#
#####################################################################################################################
# Func askOption (question, defaultOption, skipQuestion)
input_install_php="$(askOption "Install PHP ? [Y/n]: " "Y" $DefaultOption)"
if [ $input_install_php == "Y" ] || [ $input_install_php == "y" ]
then
adduser --system --no-create-home --disabled-login --disabled-password --group www-data
# Func askOption (question, defaultOption, skipQuestion)
php_address="$(askOption "Enter the download address for PHP 7 (tar.gz): " $php_address_default $DefaultOption)"
# Func askOption (question, defaultOption, skipQuestion)
php_install_tmp_dir="$(askOption "Enter temporary directory for php compilation: " "/var/tmp/php_build" $DefaultOption)"
# Func wgetAndDecompress (dirTmp, folderTmp, downloadAddress)
wgetAndDecompress $php_install_tmp_dir "php_src" $php_address
mkdir -p /usr/local/php7
./buildconf --force
CONFIGURE_STRING="--prefix=/usr/local/php7 \
--enable-huge-code-pages \
--with-config-file-scan-dir=/usr/local/php7/etc/conf.d \
--without-pear \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--enable-intl \
--enable-exif \
--enable-dba \
--enable-ftp \
--with-gettext \
--enable-gd \
--with-jpeg \
--enable-mbstring \
--with-mhash \
--enable-mysqlnd=shared \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-openssl \
--enable-pcntl \
--with-pspell \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--with-zlib \
--with-readline \
--with-curl \
--enable-simplexml \
--enable-xmlreader \
--enable-xmlwriter \
--enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--with-libxml=/usr/local \
--disable-rpath \
--enable-inline-optimization \
--enable-mbregex \
--with-xsl \
--enable-opcache \
--enable-static"
./configure $CONFIGURE_STRING
make
make install
# Socket
mkdir -p /run/php
# Create a dir for storing PHP module conf
mkdir /usr/local/php7/etc/conf.d
# Symlink php-fpm to php7-fpm
ln -s /usr/local/php7/sbin/php-fpm /usr/local/php7/sbin/php7-fpm
# Generate backup configuration file php.ini
cp php.ini-production /usr/local/php7/lib/php.ini-production
cp php.ini-development /usr/local/php7/lib/php.ini-development
# PHP configuration file
cp php.ini-production /usr/local/php7/lib/php.ini
# Enable PDO extension for mysql and extension mysqli, mysqlnd
echo -e 'extension=mysqlnd.so\n' >> /usr/local/php7/lib/php.ini
echo -e 'extension=mysqli.so\n' >> /usr/local/php7/lib/php.ini
echo -e 'extension=pdo_mysql.so\n' >> /usr/local/php7/lib/php.ini
echo -e 'openssl.cafile=/etc/ssl/certs/ca-certificates.crt\n' >> /usr/local/php7/lib/php.ini
echo -e 'curl.cainfo=/etc/ssl/certs/ca-certificates.crt\n' >> /usr/local/php7/lib/php.ini
# It is important that we prevent Nginx from passing requests to the PHP-FPM backend if the file does not exists
sed -ie 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php7/lib/php.ini
cp ${BASEDIR}/files/php7/etc/php-fpm.d/www.conf /usr/local/php7/etc/php-fpm.d/www.conf
cp ${BASEDIR}/files/php7/etc/php-fpm.conf /usr/local/php7/etc/php-fpm.conf
cp ${BASEDIR}/files/php7/etc/conf.d/modules.ini /usr/local/php7/etc/conf.d/modules.ini
# Add the init script