-
Notifications
You must be signed in to change notification settings - Fork 0
/
parsvt.sh
1190 lines (1190 loc) · 50.4 KB
/
parsvt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
# #########################################
# Program: ParsVT CRM Installation Script
# Developer: Hamid Rabiei, Mohammad Hadadpour
# Release: 1397-12-10
# Update: 1403-07-17
# #########################################
set -e
shecanProDNS1="178.22.122.101"
shecanProDNS2="185.51.200.1"
shecanDNS1="178.22.122.100"
shecanDNS2="185.51.200.2"
googleDNS1="8.8.8.8"
googleDNS2="8.8.4.4"
cloudflareDNS1="1.1.1.1"
cloudflareDNS2="1.0.0.1"
Color_Off="\e[0m"
Red="\e[0;31m"
Green="\e[0;32m"
Yellow="\e[0;33m"
Blue="\e[0;34m"
Purple="\e[0;35m"
Cyan="\e[0;36m"
primarySite="aweb.co"
secondarySite="files.aweb.asia"
ETH_DEV="127.0.0.1"
IP=$(ifconfig eth0 2>/dev/null | awk '/inet addr:/ {print $2}' | sed 's/addr://')
INSTALLTYPE="Fresh"
DBHOST="localhost"
DBUSER="root"
DBNAME="parsvt"
SETUPDIR="/var/www/html/"
SETUPDIR2="/var/www/html"
backupdirectory="/home/backup"
counter=0
LICENSEKEY=""
app_dir=""
adminPWD="123456789"
mysqlPWD="123456789"
INTERNET_STATUS="DOWN"
installationType="Install"
output() {
echo -e "$1"
}
startInstallation() {
echo -e "\nPlease enter the item number you want to use:"
echo -e "[${Cyan}1${Color_Off}] ${Cyan}Install ParsVT CRM${Color_Off}"
echo -e "[${Cyan}2${Color_Off}] ${Cyan}Repair server configurations${Color_Off}"
echo -e "[${Cyan}3${Color_Off}] ${Cyan}Update ionCube loader${Color_Off}"
echo -e "[${Cyan}4${Color_Off}] ${Cyan}Install ClamAV (not recommended for low end servers)${Color_Off}"
echo -e "[${Yellow}5${Color_Off}] ${Yellow}Cancel installation${Color_Off}\n"
read -p "Please select an action (1-5): " run
if [ "$run" == "1" ]; then
installationType="Install"
elif [ "$run" == "2" ]; then
installationType="Repair"
elif [ "$run" == "3" ]; then
installationType="ionCube"
elif [ "$run" == "4" ]; then
installationType="clamAV"
elif [ "$run" == "5" ]; then
echo -e "\n${Red}The operation aborted!${Color_Off}"
echo -e "${Yellow}www.parsvt.com${Color_Off}\n"
exit
else
startInstallation
fi
}
checkInternetConnection() {
TIMESTAMP=$(date +%s)
set +e
ping -c 1 -W 1 8.8.8.8 >/dev/null 2>&1
set -e
if [ $(($(date +%s) - $TIMESTAMP)) -eq 0 ]; then
echo -e "\n${Green}Internet connection is UP - $(date +%Y-%m-%d_%H:%M:%S_%Z) - $(($(date +%s) - $TIMESTAMP))${Color_Off}"
INTERNET_STATUS="UP"
else
echo -e "\n${Red}Internet connection is DOWN - $(date +%Y-%m-%d_%H:%M:%S_%Z) - $(($(date +%s) - $TIMESTAMP))${Color_Off}"
INTERNET_STATUS="DOWN"
output "Please check the server's internet connection and DNS settings and run the installer again."
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
exit
fi
}
setDNS() {
echo -e "\nPlease enter the item number you want to use as DNS during installation:\n"
if [ "$installationType" = "Install" ]; then
echo -e "[${Cyan}1${Color_Off}] Shecan Pro (recommended)"
else
echo -e "[${Cyan}1${Color_Off}] Shecan (recommended)"
fi
echo -e "[${Cyan}2${Color_Off}] Google"
echo -e "[${Cyan}3${Color_Off}] Cloudflare"
echo -e "[${Yellow}4${Color_Off}] Continue without changing DNS\n"
read -p "Please select an item (1-4): " rundns
if [ "$rundns" == "1" ]; then
if [ "$installationType" = "Install" ]; then
shecanURI=$(echo -n "${RESPONSES[3]}" | base64 --decode)
curl -s -o /dev/null "${shecanURI}"
mv -n /etc/resolv.conf /etc/resolv.conf.parsvt
echo -e "nameserver ${shecanProDNS1}\nnameserver ${shecanProDNS2}\n" >/etc/resolv.conf
curl -s -o /dev/null "${shecanURI}"
else
mv -n /etc/resolv.conf /etc/resolv.conf.parsvt
echo -e "nameserver ${shecanDNS1}\nnameserver ${shecanDNS2}\n" >/etc/resolv.conf
fi
elif [ "$rundns" == "2" ]; then
mv -n /etc/resolv.conf /etc/resolv.conf.parsvt
echo -e "nameserver ${googleDNS1}\nnameserver ${googleDNS2}\n" >/etc/resolv.conf
elif [ "$rundns" == "3" ]; then
mv -n /etc/resolv.conf /etc/resolv.conf.parsvt
echo -e "nameserver ${cloudflareDNS1}\nnameserver ${cloudflareDNS2}\n" >/etc/resolv.conf
elif [ "$rundns" == "4" ]; then
echo -e "${Green}Done!${Color_Off}"
else
setDNS
fi
}
restoreDNS() {
if [ -e /etc/resolv.conf.parsvt ]; then
mv /etc/resolv.conf.parsvt /etc/resolv.conf
fi
}
getLicense() {
read -p "Please enter your ParsVT CRM license key: " LICENSEKEY
LICENSEKEY=${LICENSEKEY//[[:blank:]]/}
}
precheckLicense() {
chrlen=${#LICENSEKEY}
if [[ $chrlen -ne 26 ]] && [[ $chrlen -ne 25 ]]; then
echo -e "${Red}The license key is invalid!${Color_Off}"
checkLicense
fi
if [[ ${LICENSEKEY:0:6} != \ParsVT ]] && [[ ${LICENSEKEY:0:5} != \Cloud ]]; then
echo -e "${Red}The license key is invalid!${Color_Off}"
checkLicense
fi
}
checkLicense() {
if [[ $counter -gt 3 ]]; then
echo -e "\n${Red}The number of incorrect entries exceeded!${Color_Off}"
echo -e "\n${Red}The operation aborted!${Color_Off}"
echo -e "${Yellow}www.parsvt.com${Color_Off}\n"
exit
fi
counter=$((counter + 1))
getLicense
precheckLicense
}
setAdminPassword() {
adminPWD=$(date +%s | sha256sum | base64 | head -c 32)
adminPWD=${adminPWD:0:15}
mysqlPWD=$(php -r "echo crypt('$adminPWD', 'ad');")
}
removeMySQL() {
MYSQLFOLDER="/var/lib/mysql"
if [ -f "$MYSQLFOLDER" ]; then
dt=$(date '+%d-%m-%Y_%H-%M-%S')
mv /var/lib/mysql /var/lib/old_backup_mysql_"$dt"
fi
}
getPHPConfigPath() {
PHPINI="/etc/php.ini"
if [ ! -f "$PHPINI" ]; then
PHPINI=$(php -r 'print php_ini_loaded_file();')
fi
}
restartApache() {
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
systemctl restart httpd
set +e
systemctl restart php-fpm
set -e
else
service httpd restart
fi
}
restartDatabase() {
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
systemctl restart mariadb
else
service mariadb restart
fi
}
disableSELinux() {
output "\n${Cyan}Disabling SELinux...${Color_Off}"
STATUS=$(getenforce)
if [ "$STATUS" = "disabled" ] || [ "$STATUS" = "Disabled" ]; then
output "${Green}SELinux is already disabled!${Color_Off}"
else
setenforce 0
sed -i -e 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
sed -i -e 's/SELINUX=permissive/SELINUX=disabled/g' /etc/selinux/config
output "${Green}SELinux successfully disabled!${Color_Off}"
fi
}
updatePackage() {
if [ "$major" = "8" ] || [ "$major" = "9" ]; then
if grep -rnwq "/etc/redhat-release" -e "CentOS"; then
if ! grep -rnwq "/etc/redhat-release" -e "Stream"; then
output "\n${Cyan}Converting from CentOS Linux to CentOS Stream...${Color_Off}"
dnf --disablerepo '*' --enablerepo extras swap centos-linux-repos centos-stream-repos -y
dnf distro-sync -y
output "${Green}CentOS successfully converted!${Color_Off}\n"
output "${Cyan}Updating installed packages...${Color_Off}"
yum install dnf -y
dnf update -y
output "${Green}Installed packages successfully updated!${Color_Off}"
else
output "\n${Cyan}Updating installed packages...${Color_Off}"
yum install dnf -y
dnf update -y
output "${Green}Installed packages successfully updated!${Color_Off}"
fi
else
output "\n${Cyan}Updating installed packages...${Color_Off}"
yum install dnf -y
dnf update -y
output "${Green}Installed packages successfully updated!${Color_Off}"
fi
elif [ "$major" = "7" ]; then
output "\n${Cyan}Updating installed packages...${Color_Off}"
yum install dnf -y
dnf update -y
output "${Green}Installed packages successfully updated!${Color_Off}"
else
output "\n${Cyan}Updating installed packages...${Color_Off}"
yum update -y
output "${Green}Installed packages successfully updated!${Color_Off}"
fi
}
installPackage() {
output "\n${Cyan}Installing required packages...${Color_Off}"
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
dnf install wget curl expect psmisc net-tools yum-utils zip unzip tar crontabs tzdata -y
else
yum install wget curl expect psmisc net-tools yum-utils zip unzip tar crontabs tzdata -y
fi
if [ "$major" = "9" ]; then
dnf install initscripts -y
fi
output "${Green}Required packages successfully installed!${Color_Off}\n"
}
installNTP() {
file="/etc/ntp.conf"
if [ ! -f "$file" ]; then
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
output "${Cyan}Installing Chrony...${Color_Off}"
dnf install chrony -y
systemctl start chronyd
systemctl enable chronyd
output "${Green}Chrony successfully installed!${Color_Off}\n"
else
output "${Cyan}Installing NTP...${Color_Off}"
yum install ntp ntpdate ntp-doc -y
ntpdate pool.ntp.org
systemctl start ntpd
systemctl enable ntpd
output "${Green}NTP successfully installed!${Color_Off}\n"
fi
fi
}
installIonCube() {
cd /tmp
rm -rf ioncube_loaders_lin*.tar.gz*
if [ "$ARCH" = "x86_64" ]; then
wget http://$primarySite/modules/addons/easyservice/Installer/ioncube_loaders_lin_x86-64.tar.gz -O ioncube_loaders_lin_x86-64.tar.gz
else
wget http://$primarySite/modules/addons/easyservice/Installer/ioncube_loaders_lin_x86.tar.gz -O ioncube_loaders_lin_x86-64.tar.gz
fi
tar xfz ioncube_loaders_lin_x86-64.tar.gz
PHP_CONFD="/etc/php.d"
PHP_VERSION=$(php -r "echo PHP_MAJOR_VERSION.'.'.PHP_MINOR_VERSION;")
if [ "$major" = "8" ] || [ "$major" = "9" ]; then
PHP_EXT_DIR=$(php -r "echo ini_get('extension_dir');")
else
PHP_EXT_DIR=$(php-config --extension-dir)
fi
cp "ioncube/ioncube_loader_lin_${PHP_VERSION}.so" $PHP_EXT_DIR
echo "zend_extension = ${PHP_EXT_DIR}/ioncube_loader_lin_${PHP_VERSION}.so" >"${PHP_CONFD}/00-ioncube.ini"
rm -rf ./ioncube
rm -rf ioncube_loaders_lin*.tar.gz*
cd /root
restartApache
}
installJava() {
if java -version 2>&1 >/dev/null | grep -q "java version"; then
output "${Green}Java libraries are already installed!${Color_Off}\n"
else
output "${Cyan}Installing Java libraries...${Color_Off}"
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
if [ "$ARCH" = "x86_64" ]; then
dnf install http://$secondarySite/JAVA/jdk-8u421-linux-x64.rpm -y
dnf install http://$secondarySite/JAVA/jre-8u421-linux-x64.rpm -y
else
dnf install http://$secondarySite/JAVA/jdk-8u421-linux-i586.rpm -y
dnf install http://$secondarySite/JAVA/jre-8u421-linux-i586.rpm -y
fi
else
if [ "$ARCH" = "x86_64" ]; then
yum install http://$secondarySite/JAVA/jdk-8u421-linux-x64.rpm -y
yum install http://$secondarySite/JAVA/jre-8u421-linux-x64.rpm -y
else
yum install http://$secondarySite/JAVA/jdk-8u421-linux-i586.rpm -y
yum install http://$secondarySite/JAVA/jre-8u421-linux-i586.rpm -y
fi
fi
output "${Green}Java libraries successfully installed!${Color_Off}\n"
fi
}
openPorts() {
output "${Cyan}Opening required firewall ports...${Color_Off}"
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
systemctl enable firewalld
systemctl restart firewalld
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https
firewall-cmd --zone=public --permanent --add-service=imaps
firewall-cmd --zone=public --permanent --add-service=ssh
firewall-cmd --zone=public --permanent --add-service=smtp
firewall-cmd --zone=public --permanent --add-port=80/tcp
firewall-cmd --zone=public --permanent --add-port=443/tcp
firewall-cmd --zone=public --permanent --add-port=143/tcp
firewall-cmd --zone=public --permanent --add-port=993/tcp
firewall-cmd --zone=public --permanent --add-port=110/tcp
firewall-cmd --zone=public --permanent --add-port=995/tcp
firewall-cmd --zone=public --permanent --add-port=22/tcp
firewall-cmd --zone=public --permanent --add-port=25/tcp
firewall-cmd --zone=public --permanent --add-port=2525/tcp
firewall-cmd --zone=public --permanent --add-port=587/tcp
firewall-cmd --zone=public --permanent --add-port=465/tcp
firewall-cmd --zone=public --permanent --add-port=3306/tcp
firewall-cmd --zone=public --permanent --add-port=5038/tcp
firewall-cmd --zone=public --permanent --add-port=9999/tcp
firewall-cmd --zone=public --permanent --add-port=7777/tcp
firewall-cmd --zone=public --permanent --add-port=2222/tcp
firewall-cmd --zone=public --permanent --add-port=8080/tcp
firewall-cmd --zone=public --permanent --add-port=8081/tcp
firewall-cmd --zone=public --permanent --add-port=10000/tcp
firewall-cmd --reload
else
iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 143 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 993 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 995 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 2525 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 587 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 465 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 5038 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 9999 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 7777 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 2222 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8081 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT
service iptables save
fi
output "${Green}Required firewall ports successfully opened!${Color_Off}"
}
mysqlConnection() {
read -p "Enter your MySQL hostname (default: $(tput bold)localhost$(tput sgr0)): " mysql_db_host
DBHOST="${mysql_db_host:=localhost}"
read -p "Enter your MySQL username (default: $(tput bold)root$(tput sgr0)): " mysql_root_name
DBUSER="${mysql_root_name:=root}"
read -p "Enter your MySQL password: " DBPassword
read -p "Enter your new MySQL database (default: $(tput bold)parsvt$(tput sgr0)): " mysql_db_name
DBNAME="${mysql_db_name:=parsvt}"
COMMAND="error_reporting(0); \$conn = new mysqli(\""$DBHOST"\", \""$DBUSER"\", \""$DBPassword"\"); if (\$conn->connect_error) { die(\"Connection failed: \" . \$conn->connect_error);} die(\"Connected\");"
mysqlresult=$(php -r "$COMMAND")
if [ "$mysqlresult" = "Connected" ]; then
output "${Green}Connection successfully established!${Color_Off}\n"
output "Database information:"
output "Database hostname: ${Yellow}${DBHOST}${Color_Off}"
output "Database username: ${Yellow}${DBUSER}${Color_Off}"
output "Database password: ${Yellow}${DBPassword}${Color_Off}"
output "Database name: ${Yellow}${DBNAME}${Color_Off}\n"
output "Setting up your new database..."
mysql -h ${DBHOST} -u ${DBUSER} -p${DBPassword} --default-character-set=utf8mb4 --silent -e "CREATE DATABASE IF NOT EXISTS ${DBNAME} CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';"
output "${Green}Database successfully created!${Color_Off}\n"
else
output "${Red}$mysqlresult${Color_Off}"
mysqlConnection
fi
}
function string_replace {
echo "${1/\/\//$2}"
}
echo -e "\n${Yellow}██████ █████ ██████ ███████ ██ ██ ████████"
echo -e "██ ██ ██ ██ ██ ██ ██ ██ ██ ██ "
echo -e "██████ ███████ ██████ ███████ ██ ██ ██ "
echo -e "██ ██ ██ ██ ██ ██ ██ ██ ██ "
echo -e "██ ██ ██ ██ ██ ███████ ████ ██ \n"
echo -e "Shell script to install ParsVT CRM on Linux."
echo -e "Please run as root. if you are not, enter '5' now and enter 'sudo su' before running the script.${Color_Off}"
startInstallation
restoreDNS
if [ "$installationType" = "Install" ]; then
if [ -e /var/www/html/config.inc.php ]; then
output "\n${Red}VtigerCRM already exists!${Color_Off}"
output "Press Ctrl+C within the next 10 seconds to cancel the installation."
output "Otherwise, wait until the installation continues, but it will destroy the existing data!"
INSTALLTYPE="Exist"
sleep 10
fi
checkInternetConnection
if [ ! -f "/etc/redhat-release" ]; then
output "\n${Red}Operating system is not supported!${Color_Off}"
output "ParsVT installer only installs on CentOS and RHEL-based Linuxes."
output "You have to install Apache, PHP and MySQL manually."
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
exit
else
fullname=$(cat /etc/redhat-release)
major=$(cat /etc/redhat-release | tr -dc '0-9.' | cut -d \. -f1)
ARCH=$(uname -m)
output "\n${Green}${fullname} ${ARCH}${Color_Off}"
IPS=$(hostname --all-ip-addresses)
ipsarray=($IPS)
if [ -n "$ipsarray" ]; then
ipnums=${#ipsarray[@]}
if (($ipnums > 1)); then
output "\nThe following ethernet devices found! Please enter the item number you want to use: "
COUNT=0
for i in "${ipsarray[@]}"; do
:
output "# $COUNT - $i"
COUNT=$(($COUNT + 1))
done
read -p "Please select an IP address: " DEVS
if [ -z "${ipsarray[$DEVS]}" ]; then
output "${Red}Invalid ethernet adapter!${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
exit
fi
ETH_DEV=${ipsarray[$DEVS]}
else
ETH_DEV=${ipsarray[0]}
fi
else
output "${Red}Your ethernet device not found!${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
exit
fi
output "\nParsVT CRM will be installed on ${Green}${ETH_DEV}${Color_Off}\n"
checkLicense
RESPONSE=$(curl -fs -d "licenseid=$LICENSEKEY&serverip=$ETH_DEV" -H "Content-Type: application/x-www-form-urlencoded" -X POST "http://$primarySite/modules/addons/easyservice/Installer/check.php")
IFS=';' read -ra RESPONSES <<<"$RESPONSE"
if [ "${RESPONSES[0]}" != "Active" ] || [ "${#RESPONSES[2]}" == 0 ]; then
output "\nLicense key status: ${Red}${RESPONSES[0]}!${Color_Off}"
output "\n${Red}${RESPONSES[1]}${Color_Off}"
output "For more information, please contact us."
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
exit
fi
output "\n${Green}${LICENSEKEY}${Color_Off} will be used as the license key."
setDNS
disableSELinux
updatePackage
installPackage
wgetfile="/usr/bin/wget"
curlfile="/usr/bin/curl"
if [ ! -f "$wgetfile" ] || [ ! -f "$curlfile" ]; then
output "${Red}required packages failed to install!${Color_Off}"
output "Please check the server's internet connection and DNS settings and run the installer again."
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
fi
installNTP
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
output "${Cyan}Installing Remi repository...${Color_Off}"
file="/etc/yum.repos.d/remi.repo"
if [ ! -f "$file" ]; then
dnf install http://$primarySite/modules/addons/easyservice/Installer/epel-release-latest-$major.noarch.rpm -y
if [ "$major" = "9" ]; then
set +e
dnf install http://$primarySite/modules/addons/easyservice/Installer/epel-next-release-latest-$major.noarch.rpm -y
set -e
fi
dnf install http://$primarySite/modules/addons/easyservice/Installer/remi-release-$major.rpm -y
fi
else
output "${Cyan}Installing Remi repository...${Color_Off}"
file="/etc/yum.repos.d/remi.repo"
if [ ! -f "$file" ]; then
yum install http://$primarySite/modules/addons/easyservice/Installer/epel-release-latest-$major.noarch.rpm -y
yum install http://$primarySite/modules/addons/easyservice/Installer/remi-release-$major.rpm -y
fi
fi
if [ "$major" = "8" ]; then
dnf config-manager --set-enabled powertools
dnf --enablerepo=remi,powertools install epel-release perl perl-Net-SSLeay openssl perl-IO-Tty perl-Encode-Detect htop iotop perl-Digest-MD5 perl-Digest-SHA -y
set +e
dnf --enablerepo=remi,powertools install epel-next-release -y
set -e
elif [ "$major" = "9" ]; then
dnf config-manager --set-enabled crb
dnf --enablerepo=remi,crb install epel-release perl perl-Net-SSLeay openssl perl-IO-Tty perl-Encode-Detect htop iotop perl-Digest-MD5 perl-Digest-SHA -y
set +e
dnf --enablerepo=remi,crb install epel-next-release -y
set -e
else
yum --enablerepo=remi install epel-release perl perl-Net-SSLeay openssl perl-IO-Tty perl-Encode-Detect htop iotop perl-Digest-MD5 perl-Digest-SHA -y
fi
output "${Green}Remi repository successfully installed!${Color_Off}\n"
file="/etc/yum.repos.d/remi.repo"
if [ ! -f "$file" ]; then
output "${Red}Remi repository failed to install!${Color_Off}"
output "Please check the server's internet connection and DNS settings and run the installer again."
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
fi
if ! command -v "php" &>/dev/null; then
if [ "$major" = "7" ]; then
output "${Cyan}Installing Apache and PHP...${Color_Off}"
dnf install --enablerepo=remi,remi-php74 --skip-broken httpd httpd-devel mod_ssl python-certbot-apache certbot php php-common php-zip php-gd php-mbstring php-mcrypt php-devel php-bcmath php-xml php-odbc php-pear php-imap php-ldap php-openssl php-intl php-xmlrpc php-soap php-mysql php-mysqlnd php-sqlsrv php-xz php-fpm php-pdo curl-devel -y
elif [ "$major" = "8" ] || [ "$major" = "9" ]; then
output "${Cyan}Installing Apache and PHP...${Color_Off}"
dnf module reset php -y
dnf module install php:remi-7.4 -y
dnf install --enablerepo=remi --skip-broken httpd httpd-devel mod_ssl python-certbot-apache certbot php php-common php-zip php-gd php-mbstring php-mcrypt php-devel php-bcmath php-xml php-odbc php-pear php-imap php-ldap php-openssl php-intl php-xmlrpc php-soap php-mysql php-mysqlnd php-sqlsrv php-xz php-fpm php-pdo curl-devel -y
else
output "${Cyan}Installing Apache and PHP...${Color_Off}"
yum install --enablerepo=remi,remi-php72 --skip-broken httpd httpd-devel mod_ssl python-certbot-apache certbot php php-common php-zip php-gd php-mbstring php-mcrypt php-devel php-bcmath php-xml php-odbc php-pear php-imap php-ldap php-openssl php-intl php-xmlrpc php-soap php-mysql curl-devel -y
fi
if [ "$major" = "6" ]; then
chkconfig httpd on
iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
service iptables save
else
systemctl enable httpd
fi
output "${Green}Apache and PHP successfully installed!${Color_Off}\n"
output "${Cyan}Installing ionCube loader...${Color_Off}"
installIonCube
output "${Green}ionCube loader successfully installed!${Color_Off}\n"
else
output "${Green}PHP is already installed!${Color_Off}\n"
if ! command -v "httpd" &>/dev/null; then
output "${Cyan}Installing Apache...${Color_Off}"
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
dnf install --skip-broken httpd httpd-devel mod_ssl python-certbot-apache certbot -y
else
yum install --enablerepo=remi,remi-php72 --skip-broken httpd httpd-devel mod_ssl python-certbot-apache certbot -y
fi
if [ "$major" = "6" ]; then
chkconfig httpd on
iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
service iptables save
else
systemctl enable httpd
fi
output "${Green}Apache successfully installed!${Color_Off}\n"
fi
output "Checking the PHP version..."
PHP_VER=$(php -r "if (version_compare(PHP_VERSION,'5.6.0','>')) echo 'Ok'; else echo 'Failed';")
PHP_VERSION=$(php -r "echo PHP_VERSION;")
if [ "$PHP_VER" = "Ok" ]; then
cd /root
output "Current PHP version: ${Green}${PHP_VERSION}${Color_Off}\n"
output "Checking the ionCube loader version..."
wget -q http://$primarySite/modules/addons/easyservice/Installer/ic.txt -O /root/IC.php
set +e
IONCUBE_VER=$(php -f /root/IC.php)
IONCUBE_VERSION=$(php -r "error_reporting(0); echo ioncube_loader_version();")
set -e
rm -rf /root/IC.php*
if [ "$IONCUBE_VER" = "Ok" ]; then
output "Current ionCube loader version: ${Green}${IONCUBE_VERSION}${Color_Off}\n"
read -p "Enter the directory path of your application (default: $(tput bold)${SETUPDIR}$(tput sgr0)): " app_dir
SETUPDIR="/var/www/html/$app_dir"
SETUPDIR=$(string_replace "$SETUPDIR" "/")
SETUPDIR=$(string_replace "$SETUPDIR" "/")
mkdir -p "$SETUPDIR"
rm -rf $SETUPDIR/*
output "\nYour application will be installed in ${Yellow}${SETUPDIR}${Color_Off}.\n"
elif [ "$IONCUBE_VER" = "Upgrade" ]; then
output "Current ionCube loader version: ${Red}${IONCUBE_VERSION}${Color_Off}"
output "\n${Cyan}Updating ionCube loader...${Color_Off}"
installIonCube
output "${Green}ionCube loader successfully updated!${Color_Off}\n"
elif [ "$IONCUBE_VER" = "Failed" ]; then
output "Current ionCube loader version: ${Red}${IONCUBE_VERSION}${Color_Off}"
output "${Red}ionCube loader version must be greater than 10.0.0${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
else
output "ionCube loader is not installed!"
output "\n${Cyan}Installing ionCube loader...${Color_Off}"
installIonCube
output "${Green}ionCube loader successfully installed!${Color_Off}\n"
fi
else
output "Current PHP version: ${Red}${PHP_VER}${Color_Off}"
output "${Red}PHP version must be greater than 5.5${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
fi
fi
output "${Cyan}Installing timezonedb extension...${Color_Off}"
cd /root
mkdir -p timezonedb
cd timezonedb
getPHPConfigPath
wget http://$primarySite/modules/addons/easyservice/Installer/timezonedb-2024.2.tgz -O timezonedb-2024.2.tgz
pear install timezonedb-2024.2.tgz
if ! grep -rnwq "$PHPINI" -e "extension=timezonedb.so"; then
echo "extension=timezonedb.so" >>"$PHPINI"
fi
restartApache
date
hwclock
rm -rf /root/timezonedb*
cd /root
output "${Green}timezonedb extension successfully installed!${Color_Off}\n"
output "${Cyan}Setting ParsVT requirements...${Color_Off}"
getPHPConfigPath
sed -i -e 's/max_execution_time = 30/max_execution_time = 600/g' $PHPINI
sed -i -e 's/memory_limit = 128M/memory_limit = 512M/g' $PHPINI
sed -i -e 's/allow_call_time_pass_reference = Off/allow_call_time_pass_reference = On/g' $PHPINI
sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' $PHPINI
sed -i -e 's/;max_input_vars = 1000/max_input_vars = 10000/g' $PHPINI
sed -i -e 's/; max_input_vars = 1000/max_input_vars = 10000/g' $PHPINI
sed -i -e 's/log_errors = On/log_errors = Off/g' $PHPINI
sed -i -e 's/display_errors = Off/display_errors = On/g' $PHPINI
sed -i -e 's/error_reporting = E_ALL \& ~E_DEPRECATED \& ~E_STRICT/error_reporting = E_ALL \& ~E_NOTICE \& ~E_WARNING \& ~E_DEPRECATED \& ~E_STRICT/g' $PHPINI
sed -i -e 's/output_buffering = Off/output_buffering = 4096/g' $PHPINI
sed -i -e 's/file_uploads = Off/file_uploads = On/g' $PHPINI
sed -i -e 's/post_max_size = 8M/post_max_size = 128M/g' $PHPINI
sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 128M/g' $PHPINI
sed -i -e 's/max_input_time = 60/max_input_time = 600/g' $PHPINI
sed -i -e 's/zlib.output_compression = On/zlib.output_compression = Off/g' $PHPINI
sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 21600/g' $PHPINI
sed -i -e 's/session.gc_divisor = 500/session.gc_divisor = 1000/g' $PHPINI
sed -i -e 's/session.gc_probability = 0/session.gc_probability = 1/g' $PHPINI
sed -i -e 's/default_socket_timeout = 60/default_socket_timeout = 600/g' $PHPINI
sed -i -e 's/session.use_strict_mode = 0/session.use_strict_mode = 1/g' $PHPINI
sed -i -e 's/session.cookie_httponly =/session.cookie_httponly = 1/g' $PHPINI
sed -i -e 's/session.cookie_secure = 1/;session.cookie_secure =/g' $PHPINI
sed -i -e 's/expose_php = On/expose_php = Off/g' $PHPINI
sed -i -e 's/;date.timezone =/date.timezone = "Asia\/Tehran"/g' $PHPINI
sed -i -e 's/CustomLog "logs\/access_log" combined/#CustomLog "logs\/access_log" combined/g' /etc/httpd/conf/httpd.conf
sed -i -e 's/CustomLog logs\/ssl_request_log/#CustomLog logs\/ssl_request_log/g' /etc/httpd/conf.d/ssl.conf
sed -i -e 's/php_admin_value\[error_log\] = \/var\/log\/php-fpm\/www-error.log/;php_admin_value\[error_log\] = \/var\/log\/php-fpm\/www-error.log/g' /etc/php-fpm.d/www.conf
sed -i -e 's/php_admin_flag\[log_errors\] = on/;php_admin_flag\[log_errors\] = on/g' /etc/php-fpm.d/www.conf
sed -i '/<Directory "\/var\/www\/html">/,/<\/Directory>/ s/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
restartApache
output "${Green}ParsVT requirements have been set!${Color_Off}\n"
if type mysql >/dev/null 2>&1; then
output "${Green}MySQL is already installed!${Color_Off}\n"
mysqlConnection
else
removeMySQL
output "${Cyan}Installing MySQL/MariaDB...${Color_Off}"
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
dnf install --enablerepo=remi --skip-broken mariadb mariadb-server mariadb-backup mariadb-common mariadb-devel galera php-mysql php-mysqlnd phpMyAdmin -y
else
yum install --enablerepo=remi,remi-php72 --skip-broken mariadb mariadb-server mariadb-backup mariadb-common mariadb-devel galera php-mysql php-mysqlnd phpMyAdmin -y
fi
wget -q http://$primarySite/modules/addons/easyservice/Installer/pma.txt -O /etc/httpd/conf.d/phpMyAdmin.conf
DBPassword=$(date +%s | sha256sum | base64 | head -c 20)
output "MySQL Username: ${DBUSER}\nMySQL Password: ${DBPassword}" >/root/mysql.txt
restartDatabase
restartApache
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
systemctl enable mariadb
else
chkconfig mariadb on
fi
mysqladmin -uroot create $DBNAME
if [ "$major" = "9" ]; then
SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root (enter for none):\"
send \"\r\"
expect \"Switch to unix_socket authentication\"
send \"n\r\"
expect \"Change the root password?\"
send \"y\r\"
expect \"New password:\"
send \"$DBPassword\r\"
expect \"Re-enter new password:\"
send \"$DBPassword\r\"
expect \"Remove anonymous users?\"
send \"y\r\"
expect \"Disallow root login remotely?\"
send \"y\r\"
expect \"Remove test database and access to it?\"
send \"y\r\"
expect \"Reload privilege tables now?\"
send \"y\r\"
expect eof
")
else
SECURE_MYSQL=$(expect -c "
set timeout 10
spawn mysql_secure_installation
expect \"Enter current password for root (enter for none):\"
send \"\r\"
expect \"Set root password?\"
send \"y\r\"
expect \"New password:\"
send \"$DBPassword\r\"
expect \"Re-enter new password:\"
send \"$DBPassword\r\"
expect \"Remove anonymous users?\"
send \"y\r\"
expect \"Disallow root login remotely?\"
send \"y\r\"
expect \"Remove test database and access to it?\"
send \"y\r\"
expect \"Reload privilege tables now?\"
send \"y\r\"
expect eof
")
fi
echo "$SECURE_MYSQL"
wget -q http://$primarySite/modules/addons/easyservice/Installer/sqlconf.txt -O /etc/my.cnf.d/disable_mysql_strict_mode.cnf
restartDatabase
output "${Green}MySQL/MariaDB successfully installed!${Color_Off}\n"
output "${Cyan}Creating database...${Color_Off}"
mysql -u ${DBUSER} -p${DBPassword} --default-character-set=utf8mb4 --silent -e "CREATE DATABASE IF NOT EXISTS ${DBNAME} CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';"
mysql -u ${DBUSER} -p${DBPassword} --default-character-set=utf8mb4 --silent -e "ALTER DATABASE ${DBNAME} CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';"
output "${Green}Database successfully created!${Color_Off}\n"
fi
restartDatabase
output "${Cyan}Installing ParsVT CRM package...${Color_Off}"
file="$SETUPDIR/latest.zip"
if [ ! -f "$file" ]; then
wget -q http://$primarySite/modules/addons/easyservice/Installer/download.php -O "$SETUPDIR"/latest.zip
fi
unzip -q -o $SETUPDIR/latest.zip -d $SETUPDIR
mkdir -p "$SETUPDIR/test/data/modules/"
file="$SETUPDIR/extensions.zip"
if [ ! -f "$file" ]; then
wget -q "${RESPONSES[2]}" -O "$SETUPDIR"/extensions.zip
fi
unzip -q -o $SETUPDIR/extensions.zip -d $SETUPDIR
chown -R apache:apache $SETUPDIR
cd $SETUPDIR
find -type d -exec chmod 755 {} \;
find -type f -exec chmod 644 {} \;
cd /root
rm -rf $SETUPDIR/latest.zip*
rm -rf $SETUPDIR/extensions.zip*
if [ "$INSTALLTYPE" = "Exist" ]; then
(
echo 'SET foreign_key_checks = 0;'
(mysqldump -u $DBUSER -p$DBPassword --add-drop-table --no-data $DBNAME | grep ^DROP)
echo 'SET foreign_key_checks = 1;'
) |
mysql -u $DBUSER -p$DBPassword -b $DBNAME --default-character-set=utf8mb4 --silent
fi
mysql -h $DBHOST -u $DBUSER -p$DBPassword $DBNAME --default-character-set=utf8mb4 --silent -e "SET NAMES 'utf8mb4';"
mysql -h $DBHOST -u $DBUSER -p$DBPassword $DBNAME --default-character-set=utf8mb4 --silent <$SETUPDIR/test/data/tmp/database.sql
setAdminPassword
mysql -h $DBHOST -u $DBUSER -p$DBPassword $DBNAME --default-character-set=utf8mb4 --silent -e "UPDATE vtiger_users SET user_password = '$mysqlPWD', crypt_type = '' WHERE id = '1';"
mysql -h $DBHOST -u $DBUSER -p$DBPassword $DBNAME --default-character-set=utf8mb4 --silent -e "UPDATE vtiger_users SET accesskey = UPPER(SUBSTRING(MD5(RAND()) FROM 1 FOR 16)) WHERE id = 1;"
mysql -h $DBHOST -u $DBUSER -p$DBPassword $DBNAME --default-character-set=utf8mb4 --silent -e "TRUNCATE vtiger_crmsetup;"
mysql -h $DBHOST -u $DBUSER -p$DBPassword $DBNAME --default-character-set=utf8mb4 --silent -e "TRUNCATE vtiger_loginhistory;"
CRMURL="$ETH_DEV/$app_dir"
CRMURL=$(string_replace "$CRMURL" "/")
wget -q -o /dev/null -O /dev/null "http://$CRMURL/_install.php?db_hostname=$DBHOST&db_name=$DBNAME&db_username=$DBUSER&db_password=$DBPassword"
wget -q -o /dev/null -O /dev/null "http://$CRMURL/_extensions.php?token=${RESPONSES[1]}"
grep "http://$CRMURL/vtigercron.php" /var/spool/cron/root || echo "*/15 * * * * wget --spider \"http://$CRMURL/vtigercron.php\" >/dev/null 2>&1" >>/var/spool/cron/root
rm -rf $SETUPDIR/_install*
rm -rf $SETUPDIR/_extensions*
output "${Green}ParsVT CRM package successfully installed!${Color_Off}\n"
installJava
output "${Cyan}Setting backup directory...${Color_Off}"
if [ -f "/home/backup-$DBNAME.sh" ]; then
rm -rf "/home/backup-$DBNAME.sh"
fi
output "#!/bin/bash\n delfile=\$(date --date='-7 day' +'%Y-%d-%m')\n yest=\$(date --date='today' +'%Y-%d-%m')\n backupdirectory='$SETUPDIR2'\n storagedirectory='$backupdirectory'\n mysqldump --user=$DBUSER --password=$DBPassword --host=$DBHOST $DBNAME | gzip -c > \$storagedirectory/$DBNAME-\$yest.sql.gz\n tar -czf \$storagedirectory/$DBNAME-\$yest.tar.gz \$backupdirectory\n rm -rf \$storagedirectory/$DBNAME-\$delfile.sql.gz*\n rm -rf \$storagedirectory/$DBNAME-\$delfile.tar.gz*" >/home/backup-$DBNAME.sh
if [ ! -d $backupdirectory ]; then
mkdir -p $backupdirectory
fi
chmod +x /home/backup-$DBNAME.sh
grep "sh /home/backup-$DBNAME.sh" /var/spool/cron/root || echo "0 22 * * * sh /home/backup-$DBNAME.sh >/dev/null 2>&1" >>/var/spool/cron/root
output "${Green}Backup directory successfully set!${Color_Off}\n"
output "${Cyan}Installing Webmin...${Color_Off}"
if [ "$major" = "7" ] || [ "$major" = "8" ] || [ "$major" = "9" ]; then
dnf install http://$primarySite/modules/addons/easyservice/Installer/webmin-2.202-1.noarch.rpm -y
dnf install webmin -y
else
yum install http://$primarySite/modules/addons/easyservice/Installer/webmin-2.202-1.noarch.rpm -y
yum install webmin -y
fi
output "${Green}Webmin successfully installed!${Color_Off}\n"
openPorts
output "\n${Yellow} ___ __ _______ "
output "| _ \__ _ _ _ __\ \ / /_ _|__ ___ _ __ "
output "| _/ _\` | '_(_-<\ V / | |_/ _/ _ \ ' \ "
output "|_| \__,_|_| /__/ \_/ |_(_)__\___/_|_|_|${Color_Off}\n"
output "${Green}ParsVT installation successfully completed!${Color_Off}\n"
output "Webmin Information:"
output " Webmin URL: ${Yellow}http://$ETH_DEV:10000${Color_Off}"
output " Webmin Username: ${Yellow}$USER${Color_Off}"
output " Webmin Password: ${Yellow}$USER SSH Password${Color_Off}\n"
output "MySQL Information:"
output " Database Hostname: ${Yellow}$DBHOST${Color_Off}"
output " Database Username: ${Yellow}$DBUSER${Color_Off}"
output " Database Password: ${Yellow}$DBPassword${Color_Off}"
output " Database Name: ${Yellow}$DBNAME${Color_Off}\n"
output "CRM URL: http://$CRMURL\nCRM Username: admin\nCRM Password: $adminPWD" >/root/crm.txt
output "Vtiger Information:"
output " CRM URL: ${Yellow}http://$CRMURL${Color_Off}"
output " CRM Username: ${Yellow}admin${Color_Off}"
output " CRM Password: ${Yellow}$adminPWD${Color_Off}\n"
output "For more information, visit: www.parsvt.com\n"
fi
fi
if [ "$installationType" = "Repair" ]; then
if [ ! -f "/var/www/html/config.inc.php" ]; then
output "\n${Red}VtigerCRM is not installed!${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
exit
fi
checkInternetConnection
if [ ! -f "/etc/redhat-release" ]; then
output "\n${Red}Operating system is not supported!${Color_Off}"
output "ParsVT repair script only works on CentOS and RHEL-based Linuxes."
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
exit
else
fullname=$(cat /etc/redhat-release)
major=$(cat /etc/redhat-release | tr -dc '0-9.' | cut -d \. -f1)
ARCH=$(uname -m)
output "\n${Green}${fullname} ${ARCH}${Color_Off}"
setDNS
disableSELinux
set +e
updatePackage
installPackage
set -e
wgetfile="/usr/bin/wget"
curlfile="/usr/bin/curl"
if [ ! -f "$wgetfile" ] || [ ! -f "$curlfile" ]; then
output "${Red}required packages failed to install!${Color_Off}"
output "Please check the server's internet connection and DNS settings and run the script again."
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
fi
set +e
installNTP
set -e
file="/etc/yum.repos.d/remi.repo"
if [ ! -f "$file" ]; then
output "${Red}Remi repository is not installed!${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
else
output "${Green}Remi repository is already installed!${Color_Off}\n"
fi
if ! command -v "php" &>/dev/null; then
output "${Red}PHP is not installed!${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
else
output "${Green}PHP is already installed!${Color_Off}\n"
output "Checking the PHP version..."
PHP_VER=$(php -r "if (version_compare(PHP_VERSION,'5.6.0','>')) echo 'Ok'; else echo 'Failed';")
PHP_VERSION=$(php -r "echo PHP_VERSION;")
if [ "$PHP_VER" = "Ok" ]; then
cd /root
output "Current PHP version: ${Green}${PHP_VERSION}${Color_Off}\n"
output "Checking the ionCube loader version..."
wget -q http://$primarySite/modules/addons/easyservice/Installer/ic.txt -O /root/IC.php
set +e
IONCUBE_VER=$(php -f /root/IC.php)
IONCUBE_VERSION=$(php -r "error_reporting(0); echo ioncube_loader_version();")
set -e
rm -rf /root/IC.php*
if [ "$IONCUBE_VER" = "Ok" ]; then
output "Current ionCube loader version: ${Green}${IONCUBE_VERSION}${Color_Off}\n"
elif [ "$IONCUBE_VER" = "Upgrade" ]; then
output "Current ionCube loader version: ${Red}${IONCUBE_VERSION}${Color_Off}"
output "\n${Cyan}Updating ionCube loader...${Color_Off}"
installIonCube
output "${Green}ionCube loader successfully updated!${Color_Off}\n"
elif [ "$IONCUBE_VER" = "Failed" ]; then
output "Current ionCube loader version: ${Red}${IONCUBE_VERSION}${Color_Off}"
output "${Red}ionCube loader version must be greater than 10.0.0${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
else
output "ionCube loader is not installed!"
output "\n${Cyan}Installing ionCube loader...${Color_Off}"
installIonCube
output "${Green}ionCube loader successfully installed!${Color_Off}\n"
fi
else
output "Current PHP version: ${Red}${PHP_VER}${Color_Off}"
output "${Red}PHP version must be greater than 5.5${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
fi
fi
if ! command -v "httpd" &>/dev/null; then
output "${Red}Apache is not installed!${Color_Off}"
output "\n${Red}The operation aborted!${Color_Off}"
output "${Yellow}www.parsvt.com${Color_Off}\n"
if [ "$rundns" != "5" ]; then
restoreDNS
fi
exit
else
output "${Green}Apache is already installed!${Color_Off}\n"
fi
output "${Cyan}Installing timezonedb extension...${Color_Off}"
cd /root
mkdir -p timezonedb
cd timezonedb
getPHPConfigPath
set +e
wget http://$primarySite/modules/addons/easyservice/Installer/timezonedb-2024.2.tgz -O timezonedb-2024.2.tgz
pear install -f timezonedb-2024.2.tgz
if ! grep -rnwq "$PHPINI" -e "extension=timezonedb.so"; then
echo "extension=timezonedb.so" >>"$PHPINI"
fi
set -e
restartApache
date
hwclock
rm -rf /root/timezonedb*
cd /root
output "${Green}timezonedb extension successfully installed!${Color_Off}\n"
output "${Cyan}Setting ParsVT requirements...${Color_Off}"
getPHPConfigPath
sed -i -e 's/max_execution_time = 30/max_execution_time = 600/g' $PHPINI
sed -i -e 's/memory_limit = 128M/memory_limit = 512M/g' $PHPINI
sed -i -e 's/allow_call_time_pass_reference = Off/allow_call_time_pass_reference = On/g' $PHPINI
sed -i -e 's/short_open_tag = Off/short_open_tag = On/g' $PHPINI
sed -i -e 's/;max_input_vars = 1000/max_input_vars = 10000/g' $PHPINI
sed -i -e 's/; max_input_vars = 1000/max_input_vars = 10000/g' $PHPINI
sed -i -e 's/log_errors = On/log_errors = Off/g' $PHPINI
sed -i -e 's/display_errors = Off/display_errors = On/g' $PHPINI
sed -i -e 's/error_reporting = E_ALL \& ~E_DEPRECATED \& ~E_STRICT/error_reporting = E_ALL \& ~E_NOTICE \& ~E_WARNING \& ~E_DEPRECATED \& ~E_STRICT/g' $PHPINI
sed -i -e 's/output_buffering = Off/output_buffering = 4096/g' $PHPINI
sed -i -e 's/file_uploads = Off/file_uploads = On/g' $PHPINI
sed -i -e 's/post_max_size = 8M/post_max_size = 128M/g' $PHPINI
sed -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 128M/g' $PHPINI
sed -i -e 's/max_input_time = 60 /max_input_time = 600/g' $PHPINI
sed -i -e 's/zlib.output_compression = On/zlib.output_compression = Off/g' $PHPINI
sed -i -e 's/session.gc_maxlifetime = 1440/session.gc_maxlifetime = 21600/g' $PHPINI
sed -i -e 's/session.gc_divisor = 500/session.gc_divisor = 1000/g' $PHPINI
sed -i -e 's/session.gc_probability = 0/session.gc_probability = 1/g' $PHPINI
sed -i -e 's/default_socket_timeout = 60 /default_socket_timeout = 600/g' $PHPINI
sed -i -e 's/session.use_strict_mode = 0/session.use_strict_mode = 1/g' $PHPINI
sed -i -e 's/session.cookie_httponly =/session.cookie_httponly = 1/g' $PHPINI
sed -i -e 's/session.cookie_secure = 1/;session.cookie_secure =/g' $PHPINI
sed -i -e 's/expose_php = On/expose_php = Off/g' $PHPINI