Repository navigation
Expand file tree
/
Copy pathvesta_compile.sh
More file actions
1570 lines (1300 loc) · 57.7 KB
/
Copy pathvesta_compile.sh
File metadata and controls
1570 lines (1300 loc) · 57.7 KB
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
# Autocompile script for myVesta deb files - ver 1.1
# Autocompile script borrowed from HestiaCP, special thanks to Raphael Schneeberger
build_deb_package=1
add_deb_to_apt_repo=0
TARGET_DEB_NAME=$(grep '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2)
TARGET_DEB_VER=$(cat /etc/debian_version | tr "." "\n" | head -n1)
if [ $TARGET_DEB_VER = "8" ] && [ -z "$TARGET_DEB_NAME" ] ; then
TARGET_DEB_NAME="jessie"
fi
run_apt_update_and_install=1
wait_to_press_enter=1
###############
# Note: first run --apt before turning add_deb_to_apt_repo=1
if [ $# -gt 1 ]; then
TARGET_DEB_NAME=$2
fi
if [ $# -gt 2 ]; then
TARGET_DEB_VER=$3
fi
if [ $# -gt 3 ]; then
build_deb_package=$4
fi
if [ $# -gt 4 ]; then
add_deb_to_apt_repo=$5
fi
MAINTAINER_EMAIL='info@myvestacp.com'
TARGET_DEB_NAME_MAIN=$(grep '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2)
TARGET_DEB_VER_MAIN=$(cat /etc/debian_version | tr "." "\n" | head -n1)
if [ $TARGET_DEB_VER_MAIN = "8" ] && [ -z "$TARGET_DEB_NAME_MAIN" ] ; then
TARGET_DEB_NAME_MAIN="jessie"
fi
# Set compiling directory
BUILD_DIR="/usr/src/$TARGET_DEB_NAME"
BUILD_DIR_MAIN="/usr/src/$TARGET_DEB_NAME_MAIN"
INSTALL_DIR="/usr/local/vesta"
# Set git repository raw path
GIT_SRC='https://raw.githubusercontent.com/myvesta/vesta/master/src'
GIT_REP="$GIT_REP/deb"
C_WEB_ADDRESS="c.myvestacp.com"
WWW_FOLDER="/var/www"
PATH_OF_C_WEB_FOLDER_ROOT="$WWW_FOLDER/$C_WEB_ADDRESS/html"
PATH_OF_C_WEB_FOLDER="$PATH_OF_C_WEB_FOLDER_ROOT/debian/$TARGET_DEB_VER"
APT_WEB_ADDRESS="apt.myvestacp.com"
PATH_OF_APT_REPO_ROOT="$WWW_FOLDER/$APT_WEB_ADDRESS/html"
PATH_OF_APT_REPO="$PATH_OF_APT_REPO_ROOT/$TARGET_DEB_NAME"
VESTA_VER=$(curl -s https://raw.githubusercontent.com/myvesta/vesta/master/src/deb/latest.txt)
VESTA_VER=${VESTA_VER:6}
BUILD_DATE=$(date +"%d-%b-%Y")
# Set Version for compiling
VESTA_V=$VESTA_VER"_amd64"
NGINX_V='1.31.6'
PHP_V='8.5.10'
OPENSSL_V='1.1.1w'
PCRE_V='8.45'
ZLIB_V='1.3.2'
ONIG_V='6.9.10'
VESTA_NGINX_V="$NGINX_V"
VESTA_PHP_V="$PHP_V"
# Only for Debian 8 and 9
CURL_V='8.17.0'
LIBXML_V='2.12.10'
LIBXML="https://download.gnome.org/sources/libxml2/2.12/libxml2-$LIBXML_V.tar.xz"
# Generate Links for sourcecode
NGINX='https://nginx.org/download/nginx-'$NGINX_V'.tar.gz'
OPENSSL='https://www.openssl.org/source/openssl-'$OPENSSL_V'.tar.gz'
# PRCE got moved to sourceforce.net
# PRCE2 in the feature use
# PCRE='https://github.com/PCRE2Project/pcre2/releases/download/pcre2-'$PCRE_V'/pcre2-'$PCRE_V'.tar.gz'
PCRE='https://sourceforge.net/projects/pcre/files/pcre/'$PCRE_V'/pcre-'$PCRE_V'.tar.gz/download'
# Zlib moved archives to Github
ZLIB='https://github.com/madler/zlib/archive/refs/tags/v'$ZLIB_V'.tar.gz'
PHP='https://www.php.net/distributions/php-'$PHP_V'.tar.gz'
# Set package dependencies for compiling
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
if [ "$release" -lt 12 ]; then
SOFTWARE='build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config reprepro dpkg-sig git rsync xz-utils'
else
SOFTWARE='build-essential libxml2-dev libz-dev libcurl4-gnutls-dev unzip openssl libssl-dev pkg-config reprepro git rsync'
fi
function press_enter {
if [ $wait_to_press_enter -eq 1 ]; then
read -p "$1"
else
echo $1
fi
}
function make_deb_package {
if [ -z "$2" ]; then
VER=$VESTA_V
else
VER=$2
fi
press_enter "=== Press enter to build the package"
echo "=== Changing to build directory: $BUILD_DIR"
cd $BUILD_DIR
if [ -f "$1_$VER.deb" ]; then
echo "=== Removing existing deb file: $1_$VER.deb"
rm $1_$VER.deb
fi
echo "=== Building deb package: $1_$VER.deb"
dpkg-deb --build $1_$VER
echo "=== Building done."
echo "=== Your .deb package is here: $BUILD_DIR/$1_$VER.deb"
}
function add_to_repo {
if [ -z "$2" ]; then
VER=$VESTA_V
else
VER=$2
fi
press_enter "=== Press enter to sign the package ==============================================================================="
echo "=== Changing to build directory: $BUILD_DIR"
cd $BUILD_DIR
echo "=== Signing deb package: $1_$VER.deb"
export GPG_TTY=$(tty)
dpkg-sig --sign builder $1_$VER.deb
press_enter "=== Press enter to add to repo ==============================================================================="
echo "=== Creating apt repo directory: $PATH_OF_APT_REPO"
mkdir -p $PATH_OF_APT_REPO
echo "=== Changing to apt repo directory: $PATH_OF_APT_REPO"
cd $PATH_OF_APT_REPO
echo "=== Removing existing deb package: $1_$VER.deb from $TARGET_DEB_NAME"
reprepro --ask-passphrase -Vb . remove $TARGET_DEB_NAME $1
echo "=== Adding deb package: $1_$VER.deb to $TARGET_DEB_NAME"
reprepro --ask-passphrase -Vb . includedeb $TARGET_DEB_NAME $BUILD_DIR/$1_$VER.deb
echo "=== All done for adding to apt repo: $1_$VER.deb"
}
# Install needed software
if [ $run_apt_update_and_install -eq 1 ]; then
echo "Update system repository..."
apt-get -qq update
echo "Installing dependencies for compilation..."
apt-get -qq install -y $SOFTWARE
# Fix for Debian PHP Envroiment
if [ ! -e /usr/local/include/curl ] && [ ! -L /usr/local/include/curl ] && [ "$release" -lt 12 ]; then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
fi
if [ ! -e /usr/local/include/curl ] && [ ! -L /usr/local/include/curl ] && [ "$release" -eq 13 ]; then
ln -s /usr/include/x86_64-linux-gnu/curl /usr/local/include/curl
fi
press_enter "=== Press enter to continue ==============================================================================="
fi
# Set packages to compile
for arg; do
case "$1" in
--all)
NGINX_B='true'
PHP_B='true'
VESTA_B='true'
VESTAGIT_B='true'
CWEB_B='true'
APTWEB_B='true'
;;
--nginx)
NGINX_B='true'
;;
--php)
PHP_B='true'
;;
--vesta)
VESTA_B='true'
;;
--git)
VESTAGIT_B='true'
;;
--git)
VESTAGIT_B='true'
;;
--c)
CWEB_B='true'
;;
--apt)
APTWEB_B='true'
;;
*)
NOARGUMENT='true'
;;
esac
done
if [ $# -eq 0 ]; then
echo "!!! Please run with argument --vesta, --nginx, --php, --git, --c, --apt or --all"
exit 1
fi
if [ -d "$WWW_FOLDER" ]; then
if [ ! -d "/root/backup-www" ]; then
mkdir /root/backup-www
fi
echo "=== Making backup of $WWW_FOLDER"
rsync -a --delete $WWW_FOLDER/ /root/backup-www/
fi
if [ $build_deb_package -eq 1 ]; then
if [ "$APTWEB_B" = true ]; then
VESTAGIT_B='true'
fi
if [ "$CWEB_B" = true ]; then
VESTAGIT_B='true'
fi
if [ "$VESTA_B" = true ]; then
VESTAGIT_B='true'
fi
if [ "$PHP_B" = true ]; then
VESTAGIT_B='true'
fi
if [ "$NGINX_B" = true ]; then
VESTAGIT_B='true'
fi
if [ "$CWEB_B" = true ]; then
if [ $# -gt 1 ]; then
if [ $2 = "--nogit" ]; then
VESTAGIT_B='false'
fi
fi
fi
fi
if [ ! -d "$BUILD_DIR" ]; then
mkdir -p $BUILD_DIR
fi
#################################################################################
#
# Get latest vesta from git
#
#################################################################################
if [ "$VESTAGIT_B" = true ]; then
echo "======= Get latest vesta from git ======="
if [ -d "/root/vesta" ]; then
cd /root/vesta
git pull
if [ "$?" -ne 0 ]; then
cd /root
rm -rf vesta/
git clone https://github.com/myvesta/vesta.git
echo "=== Git cloning done"
fi
else
cd /root
git clone https://github.com/myvesta/vesta.git
fi
fi
#################################################################################
#
# Building c subdomain web folder
#
#################################################################################
if [ "$APTWEB_B" = true ]; then
echo "======= Building apt subdomain web folder ======="
mkdir -p $PATH_OF_APT_REPO
cd $PATH_OF_APT_REPO
mkdir conf && cd conf
cat <<EOF >distributions
Origin: $APT_WEB_ADDRESS
Label: myvesta apt repository
Codename: $TARGET_DEB_NAME
Architectures: amd64 source
Components: vesta
Description: myvesta debian package repo
SignWith: yes
Pull: $TARGET_DEB_NAME
EOF
if [ ! -d "/root/.gnupg" ]; then
gpg --full-gen-key
gpg --armor --export $MAINTAINER_EMAIL --output $MAINTAINER_EMAIL.gpg.key
press_enter "*** please copy above generated key to your clipboard and then paste it after pressing enter now ***"
vi $PATH_OF_APT_REPO_ROOT/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/13/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/12/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/11/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/10/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/9/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/8/deb_signing.key
cp $PATH_OF_APT_REPO_ROOT/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/debian/7/deb_signing.key
fi
echo "=== All done"
fi
#################################################################################
#
# Building c subdomain web folder
#
#################################################################################
if [ "$CWEB_B" = true ]; then
echo "======= Building c subdomain web folder ======="
echo "Removing: $PATH_OF_C_WEB_FOLDER_ROOT"
rm -rf $PATH_OF_C_WEB_FOLDER_ROOT
echo "=== Whole C folder removed"
echo "=== Making folder $PATH_OF_C_WEB_FOLDER_ROOT"
mkdir -p $PATH_OF_C_WEB_FOLDER_ROOT
cd $PATH_OF_C_WEB_FOLDER_ROOT
echo "=== Copying and extracting static files"
cp /root/vesta/src/static.tar.gz $PATH_OF_C_WEB_FOLDER_ROOT/static.tar.gz
tar -xzf static.tar.gz
rm static.tar.gz
echo "=== Copying files"
mkdir -p $PATH_OF_C_WEB_FOLDER
cp -rf /root/vesta/install/debian/* $PATH_OF_C_WEB_FOLDER_ROOT/debian
if [ ! -f "$PATH_OF_C_WEB_FOLDER_ROOT/deb_signing.key" ]; then
cp /root/vesta/install/debian/$TARGET_DEB_VER_MAIN/deb_signing.key $PATH_OF_C_WEB_FOLDER_ROOT/deb_signing.key
fi
cp /root/vesta/src/deb/latest.txt $PATH_OF_C_WEB_FOLDER_ROOT/latest.txt
echo "$BUILD_DATE" > $PATH_OF_C_WEB_FOLDER_ROOT/build_date.txt
if [ -f "/root/custom_callback.sh" ]; then
BUILD_RELEASE=$(</root/vesta/src/deb/latest.txt)
BUILD_RELEASE=${BUILD_RELEASE:6}
bash /root/custom_callback.sh "$BUILD_RELEASE" "$BUILD_DATE" "/root/vesta/Changelog.md"
fi
###########
cd $PATH_OF_C_WEB_FOLDER_ROOT/debian/8
if [ -f "packages.tar.gz" ]; then
rm packages.tar.gz
fi
tar -czf packages.tar.gz packages/
if [ -f "templates.tar.gz" ]; then
rm templates.tar.gz
fi
tar -czf templates.tar.gz templates/
if [ -f "firewall.tar.gz" ]; then
rm firewall.tar.gz
fi
tar -czf firewall.tar.gz firewall/
if [ -f "fail2ban.tar.gz" ]; then
rm fail2ban.tar.gz
fi
tar -czf fail2ban.tar.gz fail2ban/
if [ -f "dovecot.tar.gz" ]; then
rm dovecot.tar.gz
fi
tar -czf dovecot.tar.gz dovecot/
echo "=== All done for Debian8"
###########
cd $PATH_OF_C_WEB_FOLDER_ROOT/debian/9
if [ -f "packages.tar.gz" ]; then
rm packages.tar.gz
fi
tar -czf packages.tar.gz packages/
if [ -f "templates.tar.gz" ]; then
rm templates.tar.gz
fi
tar -czf templates.tar.gz templates/
if [ -f "firewall.tar.gz" ]; then
rm firewall.tar.gz
fi
tar -czf firewall.tar.gz firewall/
if [ -f "fail2ban.tar.gz" ]; then
rm fail2ban.tar.gz
fi
tar -czf fail2ban.tar.gz fail2ban/
if [ -f "dovecot.tar.gz" ]; then
rm dovecot.tar.gz
fi
tar -czf dovecot.tar.gz dovecot/
echo "=== All done for Debian9"
###########
cd $PATH_OF_C_WEB_FOLDER_ROOT/debian/10
if [ -f "packages.tar.gz" ]; then
rm packages.tar.gz
fi
tar -czf packages.tar.gz packages/
if [ -f "templates.tar.gz" ]; then
rm templates.tar.gz
fi
tar -czf templates.tar.gz templates/
if [ -f "firewall.tar.gz" ]; then
rm firewall.tar.gz
fi
tar -czf firewall.tar.gz firewall/
if [ -f "fail2ban.tar.gz" ]; then
rm fail2ban.tar.gz
fi
tar -czf fail2ban.tar.gz fail2ban/
if [ -f "dovecot.tar.gz" ]; then
rm dovecot.tar.gz
fi
tar -czf dovecot.tar.gz dovecot/
echo "=== All done for Debian10"
##########
cd $PATH_OF_C_WEB_FOLDER_ROOT/debian/11
if [ -f "packages.tar.gz" ]; then
rm packages.tar.gz
fi
tar -czf packages.tar.gz packages/
if [ -f "templates.tar.gz" ]; then
rm templates.tar.gz
fi
tar -czf templates.tar.gz templates/
if [ -f "firewall.tar.gz" ]; then
rm firewall.tar.gz
fi
tar -czf firewall.tar.gz firewall/
if [ -f "fail2ban.tar.gz" ]; then
rm fail2ban.tar.gz
fi
tar -czf fail2ban.tar.gz fail2ban/
if [ -f "dovecot.tar.gz" ]; then
rm dovecot.tar.gz
fi
tar -czf dovecot.tar.gz dovecot/
echo "=== All done for Debian11"
##########
cd $PATH_OF_C_WEB_FOLDER_ROOT/debian/12
if [ -f "packages.tar.gz" ]; then
rm packages.tar.gz
fi
tar -czf packages.tar.gz packages/
if [ -f "templates.tar.gz" ]; then
rm templates.tar.gz
fi
tar -czf templates.tar.gz templates/
if [ -f "firewall.tar.gz" ]; then
rm firewall.tar.gz
fi
tar -czf firewall.tar.gz firewall/
if [ -f "fail2ban.tar.gz" ]; then
rm fail2ban.tar.gz
fi
tar -czf fail2ban.tar.gz fail2ban/
if [ -f "dovecot.tar.gz" ]; then
rm dovecot.tar.gz
fi
tar -czf dovecot.tar.gz dovecot/
echo "=== All done for Debian12"
##########
cd $PATH_OF_C_WEB_FOLDER_ROOT/debian/13
if [ -f "packages.tar.gz" ]; then
rm packages.tar.gz
fi
tar -czf packages.tar.gz packages/
if [ -f "templates.tar.gz" ]; then
rm templates.tar.gz
fi
tar -czf templates.tar.gz templates/
if [ -f "firewall.tar.gz" ]; then
rm firewall.tar.gz
fi
tar -czf firewall.tar.gz firewall/
if [ -f "fail2ban.tar.gz" ]; then
rm fail2ban.tar.gz
fi
tar -czf fail2ban.tar.gz fail2ban/
if [ -f "dovecot.tar.gz" ]; then
rm dovecot.tar.gz
fi
tar -czf dovecot.tar.gz dovecot/
echo "=== All done for Debian13"
##########
cp /root/vesta/install/vst-install-debian.sh $PATH_OF_C_WEB_FOLDER_ROOT/vst-install-debian.sh
mkdir $PATH_OF_C_WEB_FOLDER_ROOT/tools
cp -rf /root/vesta/src/deb/for-download/tools/* $PATH_OF_C_WEB_FOLDER_ROOT/tools
echo "=== All done for c subdomain ==="
fi
#################################################################################
#
# Building vesta-nginx
#
#################################################################################
if [ "$NGINX_B" = true ]; then
if [ $build_deb_package -eq 1 ]; then
echo "======= Building vesta-nginx ======="
echo "=== Change to build directory: $BUILD_DIR"
cd $BUILD_DIR
BUILDING_NOW=0
# Check if target directory exist
if [ ! -d "$INSTALL_DIR/nginx" ] || [ ! -d "$BUILD_DIR/nginx-$NGINX_V" ]; then
BUILDING_NOW=1
press_enter "=== Press enter to download and unpack source files"
if [ -d "nginx-$NGINX_V" ]; then
echo "=== Removing existing nginx directory: nginx-$NGINX_V"
rm -rf nginx-$NGINX_V/
fi
if [ -d "openssl-$OPENSSL_V" ]; then
echo "=== Removing existing openssl directory: openssl-$OPENSSL_V"
rm -rf openssl-$OPENSSL_V/
fi
if [ -d "pcre-$PCRE_V" ]; then
echo "=== Removing existing pcre directory: pcre-$PCRE_V"
rm -rf pcre-$PCRE_V/
fi
if [ -d "zlib-$ZLIB_V" ]; then
echo "=== Removing existing zlib directory: zlib-$ZLIB_V"
rm -rf zlib-$ZLIB_V/
fi
if [ ! -f "nginx-$NGINX_V.tar.gz" ]; then
echo "=== Downloading nginx source files from $NGINX and extracting it"
wget -nv $NGINX -O nginx-$NGINX_V.tar.gz
fi
if [ ! -f "nginx-$NGINX_V.tar.gz" ]; then
echo "=== ERROR: nginx source files not found, exiting..."
exit 1
fi
tar xzf nginx-$NGINX_V.tar.gz
if [ ! -f "openssl-$OPENSSL_V.tar.gz" ]; then
echo "=== Downloading openssl source files from $OPENSSL and extracting it"
wget -nv $OPENSSL -O openssl-$OPENSSL_V.tar.gz
fi
if [ ! -f "openssl-$OPENSSL_V.tar.gz" ]; then
echo "=== ERROR: openssl source files not found, exiting..."
exit 1
fi
tar xzf openssl-$OPENSSL_V.tar.gz
if [ ! -f "pcre-$PCRE_V.tar.gz" ]; then
echo "=== Downloading pcre source files from $PCRE and extracting it"
wget -nv $PCRE -O pcre-$PCRE_V.tar.gz
fi
if [ ! -f "pcre-$PCRE_V.tar.gz" ]; then
echo "=== ERROR: pcre source files not found, exiting..."
exit 1
fi
tar xzf pcre-$PCRE_V.tar.gz
if [ ! -f "zlib-$ZLIB_V.tar.gz" ]; then
echo "=== Downloading zlib source files from $ZLIB and extracting it"
wget -nv $ZLIB -O zlib-$ZLIB_V.tar.gz
fi
if [ ! -f "zlib-$ZLIB_V.tar.gz" ]; then
echo "=== ERROR: zlib source files not found, exiting..."
exit 1
fi
tar xzf zlib-$ZLIB_V.tar.gz
echo "=== Change to nginx directory to: nginx-$NGINX_V"
cd nginx-$NGINX_V
press_enter "=== Press enter to configure nginx"
echo "=== Configuring nginx"
./configure --prefix=$INSTALL_DIR/nginx \
--with-http_ssl_module \
--with-openssl=../openssl-$OPENSSL_V \
--with-openssl-opt=enable-ec_nistp_64_gcc_128 \
--with-openssl-opt=no-nextprotoneg \
--with-openssl-opt=no-weak-ssl-ciphers \
--with-openssl-opt=no-ssl3 \
--with-pcre=../pcre-$PCRE_V \
--with-pcre-jit \
--with-zlib=../zlib-$ZLIB_V
# Check install directory and remove if exists
if [ -d "$INSTALL_DIR/nginx" ]; then
echo "=== Removing existing nginx directory: $INSTALL_DIR/nginx"
rm -rf $INSTALL_DIR/nginx
fi
press_enter "=== Press enter to make && make install"
echo "=== Making (building) nginx"
make && make install
echo "=== Stripping nginx binary"
strip --strip-unneeded $INSTALL_DIR/nginx/sbin/nginx
fi
press_enter "=== Press enter to Prepare Deb Package Folder Structure"
if [ -d "$BUILD_DIR/vesta-nginx_$VESTA_NGINX_V" ]; then
echo "=== Removing existing vesta-nginx directory: $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V"
rm -rf $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V
fi
echo "=== Creating directory: $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V"
mkdir $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V
echo "=== Changing to directory: $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V"
cd $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/
echo "=== Creating directories: usr/local/vesta/nginx etc/init.d and DEBIAN"
mkdir -p usr/local/vesta/nginx etc/init.d DEBIAN
press_enter "=== Press enter to Download control, postinst and postrm files"
echo "=== Copying control, preinst, postinst and postrm files to $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/DEBIAN"
# Copying control, postinst and postrm files
cp -rf /root/vesta/src/deb/nginx/* $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/DEBIAN
# Set version
echo "=== Setting version: $VESTA_NGINX_V in $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/DEBIAN/control"
sed -i "/Version: /c\Version: $VESTA_NGINX_V" $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/DEBIAN/control
# Set permission
echo "=== Setting permission: +x for $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/DEBIAN/preinst"
chmod +x $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/DEBIAN/preinst
echo "=== Setting permission: +x for $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/DEBIAN/postinst"
chmod +x $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/DEBIAN/postinst
echo "=== Copying $INSTALL_DIR/nginx/* files to usr/local/vesta/nginx"
cp -rf $INSTALL_DIR/nginx/* usr/local/vesta/nginx
echo "=== Changing to directory: $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/etc/init.d"
cd $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/etc/init.d
echo "=== Copying vesta service file to $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/etc/init.d/vesta"
cp /root/vesta/src/deb/for-download/nginx/vesta vesta
echo "=== Setting permission: +x for $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/etc/init.d/vesta"
chmod +x vesta
echo "=== Changing to directory: $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V"
cd $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V
# if [ "$release" -lt 10 ]; then
# echo "=== Copying /root/vesta/src/deb/for-download/nginx/nginx.conf to $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/usr/local/vesta/nginx/conf/nginx.conf"
# cp /root/vesta/src/deb/for-download/nginx/nginx.conf $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/usr/local/vesta/nginx/conf/nginx.conf
# else
echo "=== Copying /root/vesta/src/deb/for-download/nginx/nginx-deb12.conf to $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/usr/local/vesta/nginx/conf/nginx.conf"
cp /root/vesta/src/deb/for-download/nginx/nginx-deb12.conf $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/usr/local/vesta/nginx/conf/nginx.conf
# fi
# if [ $BUILDING_NOW -eq 1 ]; then
echo "=== Copying $INSTALL_DIR/nginx/sbin/nginx to $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/usr/local/vesta/nginx/sbin/vesta-nginx"
cp $INSTALL_DIR/nginx/sbin/nginx $BUILD_DIR/vesta-nginx_$VESTA_NGINX_V/usr/local/vesta/nginx/sbin/vesta-nginx
# fi
echo "=== Making deb package: vesta-nginx_$VESTA_NGINX_V"
make_deb_package "vesta-nginx" "$VESTA_NGINX_V"
fi
if [ $add_deb_to_apt_repo -eq 1 ]; then
echo "=== Adding deb to apt repo: vesta-nginx_$VESTA_NGINX_V"
add_to_repo "vesta-nginx" "$VESTA_NGINX_V"
fi
echo "=== All done for vesta-nginx_$VESTA_NGINX_V"
fi
#################################################################################
#
# Building vesta-php
#
#################################################################################
if [ "$PHP_B" = true ]; then
if [ $build_deb_package -eq 1 ]; then
echo "======= Building vesta-php package ======="
cd $BUILD_DIR
echo "=== Changing to directory: $BUILD_DIR"
BUILDING_NOW=0
if [ ! -d "onig-$ONIG_V" ]; then
press_enter "=== Press enter to download and extract Oniguruma source files"
BUILDING_NOW=1
if [ ! -f "onig-$ONIG_V.tar.gz" ]; then
echo "=== Downloading Oniguruma source files from https://github.com/kkos/oniguruma/releases/download/v$ONIG_V/onig-$ONIG_V.tar.gz"
wget "https://github.com/kkos/oniguruma/releases/download/v$ONIG_V/onig-$ONIG_V.tar.gz" -O onig-$ONIG_V.tar.gz
fi
if [ -d "onig-$ONIG_V" ]; then
echo "=== Removing existing oniguruma directory: onig-$ONIG_V"
rm -rf onig-$ONIG_V/
fi
echo "=== Extracting Oniguruma source files: onig-$ONIG_V.tar.gz"
tar xzf onig-$ONIG_V.tar.gz
echo "=== Changing to directory: onig-$ONIG_V"
cd onig-$ONIG_V
press_enter "=== Press enter to configure Oniguruma"
echo "=== Configuring Oniguruma"
CFLAGS="-O2 -fPIC" \
./configure \
--prefix=$BUILD_DIR/oniguruma-static \
--disable-shared \
--enable-static
echo "=== Making Oniguruma"
make -j"$(nproc)"
echo "=== Making and installing Oniguruma"
make install
echo "=== Changing to directory: .."
cd ..
fi
if [ ! -f "$BUILD_DIR/oniguruma-static/lib/libonig.a" ]; then
echo "=== ERROR: Oniguruma library not found, exiting..."
exit 1
else
echo "=== Oniguruma library found at $BUILD_DIR/oniguruma-static/lib/libonig.a"
export ONIG_CFLAGS="-I$BUILD_DIR/oniguruma-static/include"
export ONIG_LIBS="-L$BUILD_DIR/oniguruma-static/lib -l:libonig.a"
fi
press_enter "=== Press enter to continue ==============================================================================="
if [ "$TARGET_DEB_VER" -lt 10 ]; then
if [ ! -f "/opt/zlib-$ZLIB_V-static/lib/libz.a" ]; then
echo "=== Downloading zlib source files from $ZLIB and extracting it"
cd $BUILD_DIR
if [ ! -f "zlib-$ZLIB_V.tar.gz" ]; then
wget https://zlib.net/zlib-$ZLIB_V.tar.gz -O zlib-$ZLIB_V.tar.gz
fi
if [ -d "zlib-$ZLIB_V" ]; then
echo "=== Removing existing zlib directory: zlib-$ZLIB_V"
rm -rf zlib-$ZLIB_V/
fi
echo "=== Extracting zlib source files: zlib-$ZLIB_V.tar.gz"
tar xzf zlib-$ZLIB_V.tar.gz
echo "=== Changing to directory: zlib-$ZLIB_V"
cd zlib-$ZLIB_V
ZLIB_PREFIX="/opt/zlib-$ZLIB_V-static"
press_enter "=== Press enter to continue ==============================================================================="
echo "=== Configuring zlib"
ADDITIONAL_CFLAGS="-O2 -fPIC"
if [ $TARGET_DEB_VER -eq 8 ]; then
ADDITIONAL_CFLAGS="-O2 -fPIC -std=gnu99"
fi
echo "=== Value of ADDITIONAL_CFLAGS: $ADDITIONAL_CFLAGS"
CFLAGS="$ADDITIONAL_CFLAGS" ./configure \
--static \
--prefix="$ZLIB_PREFIX"
press_enter "=== Press enter to continue ==============================================================================="
make -j$(nproc)
press_enter "=== Press enter to continue ==============================================================================="
make test
press_enter "=== Press enter to continue ==============================================================================="
make install
press_enter "=== Press enter to continue ==============================================================================="
echo "=== Checking $ZLIB_PREFIX for libz* files (expecting: libz.a)"
find "$ZLIB_PREFIX" -maxdepth 2 -type f -name 'libz*' -ls
press_enter "=== Press enter to continue ==============================================================================="
echo "=== Checking zlib version (expecting: $ZLIB_V)"
PKG_CONFIG_PATH="$ZLIB_PREFIX/lib/pkgconfig" \
pkg-config --modversion zlib
press_enter "=== Press enter to continue ==============================================================================="
echo "=== Checking $ZLIB_PREFIX/lib/pkgconfig/zlib.pc file content"
cat "$ZLIB_PREFIX/lib/pkgconfig/zlib.pc"
press_enter "=== Press enter to continue ==============================================================================="
cd ..
echo "=== Changing to directory: .."
else
echo "=== zlib library found at /opt/zlib-$ZLIB_V-static/lib/libz.a"
fi
if [ "$TARGET_DEB_VER" -eq 8 ]; then
LIBXML_PREFIX="/opt/libxml2-$LIBXML_V-static"
if [ ! -f "$LIBXML_PREFIX/lib/libxml2.a" ]; then
cd "$BUILD_DIR"
if [ ! -f "libxml2-$LIBXML_V.tar.xz" ]; then
echo "=== Downloading libxml2 $LIBXML_V"
wget "$LIBXML" -O "libxml2-$LIBXML_V.tar.xz"
fi
if [ -d "libxml2-$LIBXML_V" ]; then
echo "=== Removing existing libxml2 directory: libxml2-$LIBXML_V"
rm -rf libxml2-$LIBXML_V/
fi
echo "=== Extracting libxml2 source files"
tar xJf "libxml2-$LIBXML_V.tar.xz"
echo "=== Changing to directory: libxml2-$LIBXML_V"
cd "libxml2-$LIBXML_V"
echo "=== Configuring static libxml2"
CFLAGS="-O2 -fPIC" \
CPPFLAGS="-I$ZLIB_PREFIX/include" \
LDFLAGS="-L$ZLIB_PREFIX/lib" \
PKG_CONFIG_PATH="$ZLIB_PREFIX/lib/pkgconfig" \
./configure \
--prefix="$LIBXML_PREFIX" \
--disable-shared \
--enable-static \
--without-python \
--without-lzma \
--with-zlib="$ZLIB_PREFIX"
if [ $? -ne 0 ]; then
echo "=== ERROR: libxml2 configuration failed, exiting..."
exit 1
fi
press_enter "=== Press enter to compile libxml2 ==============================================================================="
make -j$(nproc)
if [ $? -ne 0 ]; then
echo "=== ERROR: libxml2 compilation failed, exiting..."
exit 1
fi
press_enter "=== Press enter to install libxml2 ==============================================================================="
make install
if [ $? -ne 0 ]; then
echo "=== ERROR: libxml2 installation failed, exiting..."
exit 1
fi
echo "=== Checking static libxml2 library"
ls -lh "$LIBXML_PREFIX/lib/libxml2.a"
echo "=== Checking for shared libxml2 libraries; output should be empty:"
find "$LIBXML_PREFIX/lib" -maxdepth 1 -name 'libxml2.so*' -ls
echo "=== Checking libxml2 version (expecting: $LIBXML_V)"
PKG_CONFIG_PATH="$LIBXML_PREFIX/lib/pkgconfig" \
pkg-config --modversion libxml-2.0
echo "=== Static libxml2 libraries:"
PKG_CONFIG_PATH="$LIBXML_PREFIX/lib/pkgconfig:$ZLIB_PREFIX/lib/pkgconfig" \
pkg-config --static --libs libxml-2.0
press_enter "=== Press enter to continue ==============================================================================="
cd ..
else
echo "=== libxml2 static library found at $LIBXML_PREFIX/lib/libxml2.a"
fi
fi
OPENSSL_PREFIX="/opt/openssl-$OPENSSL_V-static"
if [ ! -f "$OPENSSL_PREFIX/lib/libssl.a" ] || [ ! -f "$OPENSSL_PREFIX/lib/libcrypto.a" ]; then
cd "$BUILD_DIR"
if [ ! -f "openssl-$OPENSSL_V.tar.gz" ]; then
echo "=== Downloading OpenSSL $OPENSSL_V"
wget "$OPENSSL" -O "openssl-$OPENSSL_V.tar.gz"
fi
if [ -d "openssl-$OPENSSL_V" ]; then
echo "=== Removing existing OpenSSL directory: openssl-$OPENSSL_V"
rm -rf openssl-$OPENSSL_V/
fi
echo "=== Extracting OpenSSL source files"
tar xzf "openssl-$OPENSSL_V.tar.gz"
echo "=== Changing to directory: openssl-$OPENSSL_V"
cd openssl-$OPENSSL_V
echo "=== Configuring static OpenSSL"
./config \
--prefix="$OPENSSL_PREFIX" \
--openssldir="$OPENSSL_PREFIX/ssl" \
no-shared \
no-tests \
-fPIC
press_enter "=== Press enter to compile OpenSSL ==============================================================================="
make -j$(nproc)
press_enter "=== Press enter to install OpenSSL ==============================================================================="
make install_sw
echo "=== Checking static OpenSSL libraries"
ls -lh "$OPENSSL_PREFIX/lib/libssl.a"
ls -lh "$OPENSSL_PREFIX/lib/libcrypto.a"
echo "=== Checking OpenSSL version"
"$OPENSSL_PREFIX/bin/openssl" version
press_enter "=== Press enter to continue ==============================================================================="
cd ..
else
echo "=== OpenSSL static libraries found:"
echo "$OPENSSL_PREFIX/lib/libssl.a"
echo "$OPENSSL_PREFIX/lib/libcrypto.a"
fi
if [ ! -f "/opt/curl-$CURL_V-static/lib/libcurl.a" ]; then
cd $BUILD_DIR
if [ ! -f "curl-$CURL_V.tar.gz" ]; then
echo "=== Downloading curl source files from https://curl.se/download/curl-$CURL_V.tar.gz and extracting it"
wget https://curl.se/download/curl-$CURL_V.tar.gz
fi
if [ -d "curl-$CURL_V" ]; then
echo "=== Removing existing curl directory: curl-$CURL_V"
rm -rf curl-$CURL_V/
fi
echo "=== Extracting curl source files: curl-$CURL_V.tar.gz"
tar xzf curl-$CURL_V.tar.gz
echo "=== Changing to directory: curl-$CURL_V"
cd curl-$CURL_V
CURL_PREFIX="/opt/curl-$CURL_V-static"
echo "=== Setting CURL_PREFIX: $CURL_PREFIX"
press_enter "=== Press enter to continue ==============================================================================="
echo "=== Configuring curl"
CFLAGS="-O2 -fPIC" \
CPPFLAGS="-I$OPENSSL_PREFIX/include -I$ZLIB_PREFIX/include" \
LDFLAGS="-L$OPENSSL_PREFIX/lib -L$ZLIB_PREFIX/lib" \
PKG_CONFIG_PATH="$OPENSSL_PREFIX/lib/pkgconfig:$ZLIB_PREFIX/lib/pkgconfig" \
./configure \
--prefix="$CURL_PREFIX" \
--disable-shared \
--enable-static \
--with-openssl="$OPENSSL_PREFIX" \
--with-zlib="$ZLIB_PREFIX" \
--without-brotli \
--without-zstd \
--without-libpsl \
--without-libidn2 \
--without-nghttp2 \
--without-libssh2 \
--without-librtmp \
--disable-ldap \
--disable-ldaps
echo "=== I hope you see above something like this:"
echo "SSL: enabled (OpenSSL)"
echo "zlib: enabled"
echo "Build libcurl: Shared=no, Static=yes"
press_enter "=== Press enter to continue ==============================================================================="