forked from oZONo32/EHCP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·845 lines (708 loc) · 26.7 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
#!/bin/bash
# ehcp - Easy Hosting Control Panel install/remove by [email protected] (actually, no remove yet)
# this is a basic (!) shell installer, real installation in install_lib.php, which is called by install_1.php, install_2.php
#
#
# please contact me if you made any modifications.. or you need help
# msn/email: [email protected]
# skype:ehcpanel
#
# Main Developer: [email protected]
# Marcel <[email protected]>
# - added initial support for yum (RedHat/CentOS) (not working now)
# - some code ordering, documentation and cleanup
#
# by [email protected] : many fixes,
# by [email protected] : many fixes,
# by [email protected] : quiet install,
# (Looking for other volunteer developers.. in future, maybe, we may have some budget... )
# last modified by ehcpdeveloper on 16.11.2016 (d-m-y)
ehcpversion="0.38.2.b"
emailenable=true # write true/false lowercase for bash..
echo
echo
#echo "Please Wait... initializing.a If something is very slow, please report on our site: ehcp.net"
echo
echo
chmod -Rf a+r *
for j in "noapt" "unattended" "light" ; # read some install parameters.
do
if [ "$1" == "$j" -o "$2" == "$j" -o "$3" == "$j" ] ; then
eval $j=$j # set parameter noapt to that string... and so for others.
echo "Parameter $j is set:(${!j}) "
fi
done
if [ "$1" == "-y" -o "$2" == "-y" -o "$3" == "-y" ] ; then
unattended="unattended"
echo "Unattended Enabled... "
fi
################################################################################################
# Function Definitions #
################################################################################################
# Stub function for apt-get
function check_internet () {
host google.com 2>&1 > /dev/null
if [ $? -ne 0 ] ; then
echo "You seem to have no internet connection. Are you sure you want to try to continue? (y/n)"
read c
if [ "$c" == "n" ] ; then
exit
fi
fi
}
function installaptget () {
echo "now let's try to install apt-get on your system."
echo "Not yet implemented"
}
function check_programs(){
for i in *.php
do
php -l $i > /dev/null
if [ $? -ne 0 ] ; then
echo "programda hata var: $i"
exit
fi
done
}
# Stub function fot yum
function installyum () {
echo "now let's try to install yum on your system."
echo "Not yet implemented"
}
# Initial Welcome Screen
function ehcpHeader() {
echo
echo
echo "STAGE 1"
echo "====================================================================="
echo
echo "--------------------EHCP PRE-INSTALLER $ehcpversion -------------------------"
echo "-----Easy Hosting Control Panel for Ubuntu, Debian and alikes--------"
echo "-------------------------www.ehcp.net--------------------------------"
echo "---------------------------------------------------------------------"
echo
echo
echo "Now, ehcp pre-installer begins, a series of operations will be performed and main installer will be invoked. "
echo "If any problem occurs, refer to www.ehcp.net forum section, or contact me, mail/msn: [email protected]"
echo
echo "For automated installs, use $0 unattended (passwords are default in this case)"
echo "Please be patient, press enter to continue"
echo
if [ "$unattended" == "" ] ; then
read
fi
echo
echo "Note that ehcp can only be installed automatically on Debian based Linux OS'es or Linux'es with apt-get enabled..(Ubuntu, Kubuntu, debian and so on) Do not try to install ehcp with this installer on redhat, centos and non-debian Linux's... To use ehcp on no-debian systems, you need to manually install.. "
echo "This installer is for installing onto a clean, newly installed Ubuntu/Debian. If you install it on existing system, some existing packages will be removed after prompting, if they conflict with packages that are used in ehcp, so, be careful to answer yes/no when using in non-new system"
echo "Note that, this is just a utility.. use at your own risk."
echo "Ehcp also sends some usage data to developer for statistical/improvement purposes"
echo
echo "Outline of install process:"
echo "1- Update apt-get repo info (apt-get update)"
echo "2- Install Php (That will run Main installer)"
echo "3- Run Main installer (Run install_1.php and install_2.php to install other server related software, such as mysql/mariadb, apache, nginx, etc.)"
echo
echo "Press enter to continue"
echo
if [ "$unattended" == "" ] ; then
read
fi
}
# Check for yum
function checkyum () {
which yum > /dev/null 2>&1
if [ "$?" == "0" ]; then
echo "yum is available"
return 0
else
# This should never happen
echo "Please install yum"
installyum
fi
}
# Check for apt-get
function checkAptget(){
sayi=`which apt-get | wc -w`
if [ $sayi -eq 0 ] ; then
echo "apt-get is not found. This is a serious problem. Note that ehcp can only be installed on Debian & Ubuntu & other debian/ubuntu based systems. We strongly suggest Ubuntu."
installaptget
fi
echo "apt-get seems to be installed on your system."
aptIsInstalled=1
sayi=`grep -v "#" /etc/apt/sources.list | wc -l`
if [ $sayi -lt 10 ] ; then
echo
echo "WARNING ! Your /etc/apt/sources.list file contains very few sources, This may cause problems installing some packages.. see http://www.ehcp.net/?q=node/389 for an example file"
echo "This may be normal for some versions of debian"
echo "press enter to continue or Ctrl-C to cancel and fix that file"
if [ "$unattended" == "" ] ; then
read
fi
fi
}
# Retrieve statistics
# Marcel: This freezed the installer on one of my Centos Servers (needs more investigating)
# developer:answer: this infomail may be disabled, only for statistical purposes... may hang if for 10 second if user is not connected to internet, or something is wrong with wget or dns resolution...
# no hanging longer than 10 sec should occur... i think.. btw, your code is perfect, Marcel
function infoMail(){
if $emailenable ; then
ip=`ifconfig | grep "inet addr" | grep -v "127.0.0.1" | awk '{print $2}' 2>/dev/null `
wget -q -O /dev/null --timeout=10 http://www.ehcp.net/diger/msg.php?msg=$1.$ip > /dev/null 2>&1 &
fi
}
# Function to be called when installing packages, by Marcel <[email protected]>
function installPack(){
if [ -n "$noapt" ] ; then # skip install
echo "skipping apt-get install for:$1"
return
fi
if [ $distro == "ubuntu" ] || [ $distro == "debian" ];then
# first, try to install without any prompt, then if anything goes wrong, normal install..
apt-get -y -qq --no-remove --allow-unauthenticated install $1
echo "apt-get -y -qq --no-remove --allow-unauthenticated install $1" >> ehcp-apt-get-install.log
if [ $? -ne 0 ]; then
apt-get --allow-unauthenticated install $1
fi
else
# Yum is nice, you don't get prompted :) ; Yum is not fully supported yet in ehcp. only apt fully supported.
yum -y -t install $1
fi
}
function logToFile(){
logfile="ehcp-apt-get-install.log"
echo "$1" >> $logfile
}
function aptget_Update(){
if [ -n "$noapt" ] ; then # skip install
echo "skipping apt-get update"
return
fi
apt-get update
}
function aptgetInstall(){
if [ -n "$noapt" ] ; then # skip install
echo "skipping apt-get install for:$1"
return
fi
killall update-manager > /dev/null 2>&1
killall update-notifier > /dev/null 2>&1 # these cause other apt-get commands fail because of dpkg lock
# first, try to install without any prompt, then if anything goes wrong, normal install..
cmd="apt-get -y -qq --no-remove --allow-unauthenticated install $1"
echo "Running: $cmd"
logToFile "$cmd"
$cmd
if [ $? -ne 0 ]; then
cmd="apt-get --allow-unauthenticated install $1"
logToFile "$cmd"
$cmd
fi
}
function aptgetRemove(){
if [ -n "$noapt" ] ; then # skip uninstall
echo "skipping apt-get remove for:$1"
return
fi
# first, try to uninstall without any prompt, then if anything goes wrong, normal uninstall..
cmd="apt-get -y -qq remove $1"
logToFile "$cmd"
$cmd
if [ $? -ne 0 ]; then
cmd="apt-get remove $1"
logToFile "$cmd"
$cmd
fi
}
# Get distro name , by Marcel <[email protected]>, thanks to marcel for fixing whole code syntax
# No longer works in Ubuntu 13.04
# Fixed by Eric Martin <[email protected]>
function checkDistro() {
# Below code doesn't work
#cat /etc/*release | grep -i ubuntu &> /dev/null && distro="ubuntu"
#cat /etc/*release | grep -i red &> /dev/null && distro="redhat" # not yet supported
#cat /etc/*release | grep -i centos && distro="centos"
#cat /etc/*release | grep -i debian &> /dev/null && distro="debian"
# Get distro properly
if [ -e /etc/issue ]; then
distro=$( cat /etc/issue | awk '{ print $1 }' )
fi
if [ -z "$distro" ]; then
if [ -e /etc/os-release ]; then
distro=$( cat os-release | grep -o "^NAME=.*" | grep -o "[^NAME=\"].*[^\"]" )
fi
fi
# Assume Ubuntu
if [ -z "$distro" ]; then
distro="ubuntu"
else
# Convert it to lowercase
distro=$( echo $distro | awk '{print tolower($0)}' )
fi
# Get actual release version information
version=$( cat /etc/issue | awk '{ print $2 }' )
if [ -z "$version" ]; then
version=$( lsb_release -r | awk '{ print $2 }' )
fi
# Separate year and version
if [[ "$version" == *.* ]]; then
yrelease=$( echo "$version" | cut -d. -f1 )
mrelease=$( echo "$version" | cut -d. -f2 )
fi
# Get 64-bit OS or 32-bit OS [used in vsftpd fix]
if [ $( uname -m ) == 'x86_64' ]; then
OSBits=64
else
OSBits=32
fi
# Another way to get the version number
# version=$(lsb_release -r | awk '{ print $2 }')
echo "Your distro is $distro runnning version $version"
}
# Check if the running user is root, if not restart with sudo
function checkUser() {
if [ `whoami` != "root" ];then
echo "you are $who, you have to be root to use ehcp installation program. switching to root mode, please enter password or re-run install.sh as root"
sudo $0 $@ # restart this with superuser-root privileges
exit
fi
}
# Function to kill any running ehcp / php daemons
function killallEhcp() {
for i in `ps aux | grep ehcpdaemon.sh | grep -v grep | awk -F " " '{ print $2 }'`;do
kill -9 $i
done
for i in `ps aux | grep 'php index.php' | grep -v grep | awk -F " " '{ print $2 }'`;do
kill -9 $i
done
}
function checkPhp(){
which php
if [ $? -eq 0 ] ; then
echo "php seems installed. This is good.."
else
echo "PHP IS STILL NOT INSTALLED. THIS IS A SERIOUS PROBLEM. MOST PROBABLY, YOU WILL NOT BE ABLE TO CONTINUE. TRY TO INSTLL PHP yourself."
echo "if rest of install is successfull, then, this is a false alarm, just ignore"
fi
}
function launchPanel(){
firefox=`which firefox`
if [ -n "$firefox" ] ; then
echo "now, you should be able to navigate to your panel"
echo "panel admin username: admin "
echo "now will try to launch your control panel, if it is on local computer.. "
echo -e "\nwill use firefox as browser...\n\n"
$firefox "http://localhost" &
fi
}
# Thanks a lot to [email protected] for fail2ban integration & vsftpd fixes.
function slaveDNSApparmorFix(){ # by [email protected]
if [ -e /etc/apparmor.d/usr.sbin.named ]; then
echo -e "\nChanging bind apparmor rule to allow master DNS synchronization for slave setups.\n"
sed -i 's#/etc/bind/\*\* r,#/etc/bind/\*\* rw,#g' /etc/apparmor.d/usr.sbin.named
fi
}
function libldapFix(){ # by [email protected]
# install libldap, for vsftpd fix, without prompts
#Remove originally installed libpam-ldap if it exists
origDir=$(pwd)
aptgetRemove libpam-ldap
DEBIAN_FRONTEND=noninteractive apt-get -y -qq install libpam-ldap
cd $patchDir
mkdir lib32gccfix
cd lib32gccfix
# wget -O "ldap_conf.tar.gz" http://dinofly.com/files/linux/ldap_conf_64bit_vsftpd.tar.gz
# tar -zxvf ldap_conf.tar.gz
# cp ldap.conf /etc/
cd $origDir
cp etc/ldap.conf ./
cp etc/ldap.conf /etc/
}
function fixVSFTPConfig(){ # by [email protected]
sed -i 's/chroot_local_user=NO/chroot_local_user=YES/g' /etc/vsftpd.conf
allowWriteValue=$( cat /etc/vsftpd.conf | grep -o "allow_writeable_chroot=.*" | grep -o "=.*$" | grep -o "[^=].*" )
if [ -z "$allowWriteValue" ]; then
sh -c "echo 'allow_writeable_chroot=YES' >> /etc/vsftpd.conf"
else
sed -i 's/allow_writeable_chroot=NO/allow_writeable_chroot=YES/g' /etc/vsftpd.conf
fi
if [ $OSBits -eq "64" ]; then
#aptgetInstall libpam-ldap # this is required in buggy vsftpd installs.. ubuntu 12.04,12.10, 13.04, now...
libldapFix
aptgetInstall libgcc1
# 64-bit 500 OOPS: priv_sock_get_cmd Fix
# seccomp_sandbox=NO
allowSandBox=$( cat /etc/vsftpd.conf | grep -o "seccomp_sandbox=.*" | grep -o "=.*$" | grep -o "[^=].*" )
if [ -z "$allowSandBox" ]; then
if [ "$yrelease" -ge "13" ] ; then
sh -c "echo 'seccomp_sandbox=NO' >> /etc/vsftpd.conf"
fi
else
sed -i 's/seccomp_sandbox=YES/seccomp_sandbox=NO/g' /etc/vsftpd.conf
fi
fi
service vsftpd restart
}
function remove_vsftpd(){
#Remove originally installed vsftpd
aptgetRemove vsftpd
# Just incase it's been installed already or another version has been installed using dpgk, let's remove it
dpkg --remove vsftpd
}
function fixApacheDefault(){ # by [email protected]
ApacheFile="/etc/apache2/apache2.conf"
confStr="IncludeOptional sites-enabled/\*.conf"
correctConfStr="IncludeOptional sites-enabled/\*"
if [ -e "$ApacheFile" ]; then
ConfCheck=$( cat "$ApacheFile" | grep -o "$confStr" )
if [ ! -z "$ConfCheck" ]; then
sed -i "s#$confStr#$correctConfStr#g" "$ApacheFile"
service apache2 restart
fi
fi
}
function removeNameVirtualHost(){ # by [email protected]
ApacheFile="/etc/apache2/ports.conf"
confStr="NameVirtualHost \*"
if [ -e "$ApacheFile" ]; then
ConfCheck=$( cat "$ApacheFile" | grep -o "$confStr" )
if [ ! -z "$ConfCheck" ]; then
sed -i "s#$confStr##g" "$ApacheFile"
service apache2 restart
fi
fi
}
function genUbuntuFixes(){ # by [email protected]
# Ubuntu packages keep coming with new features that mess things up
# Thanks Ubuntu for the unneccessary headaches!
if [ ! -z "$yrelease" ]; then
if [ "$distro" == "ubuntu" ]; then
if [[ "$yrelease" == "13" && "$mrelease" == "10" ]] || [ "$yrelease" -ge "14" ]; then
fixApacheDefault
removeNameVirtualHost
addConfDFolder
fi
fi
fi
}
function addConfDFolder(){
if [ -e "/etc/apache2/apache2.conf" ]; then
APACHECONFCONTENTS=$(cat "/etc/apache2/apache2.conf" | grep "IncludeOptional conf.d")
if [ -z "$APACHECONFCONTENTS" ]; then
echo "IncludeOptional conf.d/*" >> "/etc/apache2/apache2.conf"
fi
fi
}
function ubuntuVSFTPDFix(){ # by [email protected]
# Get currently working directory
origDir=$( pwd )
patchDir="/root/Downloads"
if [ ! -e $patchDir ]; then
mkdir $patchDir
fi
# Ubuntu VSFTPD Fixes
if [ ! -z "$yrelease" ]; then
if [ "$distro" == "ubuntu" ]; then
if [ "$yrelease" == "12" ] ; then
if [ "$mrelease" == "04" ]; then
# Run 12.04 Fix
remove_vsftpd
echo -e "\nRunning VSFTPD fix for Ubuntu 12.04\n"
add-apt-repository -y ppa:thefrontiergroup/vsftpd
aptget_Update
aptgetInstall vsftpd
fixVSFTPConfig
elif [ "$mrelease" == "10" ]; then
# Run 12.10 Fix
remove_vsftpd
echo -e "\nRunning VSFTPD fix for Ubuntu 12.10\n"
#get the code
cd $patchDir
if [ ! -e vsftpd_2.3.5-3ubuntu1.deb ]; then
if [ $OSBits -eq "32" ]; then
wget -O "vsftpd_2.3.5-3ubuntu1.deb" http://dinofly.com/files/linux/vsftpd_2.3.5-3ubuntu1_i386.deb
else
wget -O "vsftpd_2.3.5-3ubuntu1.deb" http://dinofly.com/files/linux/vsftpd_2.3.5-3.jme_amd64.deb
fi
fi
#install
rm -f /etc/systemd/system/vsftpd.service
dpkg -i --force-confdef vsftpd_2.3.5-3ubuntu1.deb
cd $origDir
fixVSFTPConfig
fi
elif [ "$yrelease" == "13" ]; then
# Ubuntu 13.04
if [ "$mrelease" == "04" ]; then
remove_vsftpd
echo -e "\nRunning VSFTPD fix for Ubuntu 13.04\n"
cd $patchDir
if [ ! -e vsftpd_3.0.2-patched_ubuntu.deb ]; then
if [ $OSBits -eq "32" ]; then
wget -N -O "vsftpd_3.0.2-patched_ubuntu.deb" http://dinofly.com/files/linux/vsftpd_3.0.2-patched_ubuntu_13.04_x86.deb
else
wget -N -O "vsftpd_3.0.2-patched_ubuntu.deb" http://dinofly.com/files/linux/vsftpd_3.0.2-1ubuntu1_amd64_patched.deb
fi
fi
rm -f /etc/systemd/system/vsftpd.service
dpkg -i --force-confdef vsftpd_3.0.2-patched_ubuntu.deb
cd $origDir
fixVSFTPConfig
fi
# Ubuntu 13.10
if [ "$mrelease" == "10" ]; then
echo -e "\nRunning VSFTPD fix for Ubuntu 13.10\n"
fixVSFTPConfig
fi
elif [ "$yrelease" -ge "14" ]; then
echo -e "\nRunning VSFTPD fix for Ubuntu"
if [ $OSBits -eq "64" ]; then
remove_vsftpd
# file now within ehcp files. We should check&update this when needed..
# I will test normal vsftpd with U14.04, or seek another ftp solution which supports mysql auth.
# wget -N -O "vsftpd_3.0.2-1ubuntu2.deb" http://dinofly.com/files/linux/vsftpd_3.0.2-1ubuntu2_amd64.deb
# if [ $? -ne 0 ] ; then # just retry
# wget -N -O "vsftpd_3.0.2-1ubuntu2.deb" http://dinofly.com/files/linux/vsftpd_3.0.2-1ubuntu2_amd64.deb
# fi
rm -f /etc/systemd/system/vsftpd.service
dpkg -i --force-confdef vsftpd_3.0.2-1ubuntu2.deb
fi
fixVSFTPConfig
fi
fi
fi
}
function logDirFix(){ # by [email protected]
chmod 755 log
chmod 744 log/ehcp_failed_authentication.log
chown www-data:www-data log/ehcp_failed_authentication.log
}
function fixBINDPerms(){ # by [email protected]
chmod -R 774 /etc/bind
}
function fix_permissions1(){
# sometime, permissions are lost because of cile copying etc.
chmod a+rx install*
chmod a+rx *.sh
chmod a+rx ehcp
find ./ -type d -exec chmod a+rx {} \; # fix directory perms
}
function fixEHCPPerms(){ # by [email protected]
chmod a+rx /var/www/new/ehcp/
chmod -R a+r /var/www/new/ehcp/
find ./ -type d -exec chmod a+rx {} \;
chown -R www-data:www-data /var/www/new/ehcp/webmail
chmod 755 -R /var/www/new/ehcp/webmail
chmod 755 /var/www/new/index.html
}
function fixPHPConfig(){ # by [email protected]
PHPConfFile="/etc/php5/cli/php.ini"
if [ -e $PHPConfFile ]; then
PHPConfCheck=$( cat $PHPConfFile | grep -o ";extension=mysql.so" )
if [ -z "$PHPConfCheck" ]; then
sed -i "s/extension=mysql.so/;extension=mysql.so/g" $PHPConfFile
service apache2 restart
fi
fi
}
function fixPHPPerms(){ # by [email protected]
# PHP Runs Under www-data so www-data must own the vhosts directory
# Set correct permissions on vhosts folder
vhostsDir="/var/www/vhosts"
# this is not a good idea, giving all files www-data permission would cause all files webserver writable, which is a high security issue.
#if [ -e $vhostsDir ]; then
# chown -R www-data:www-data $vhostsDir
# chmod g+s -R $vhostsDir
# chmod 774 -R $vhostsDir
#fi
# Add vsftpd user as a member of the www-data group so that it may create/delete files
sudo usermod -a -G www-data vsftpd # this is good, because otherwise, vsftpd cannot delete webserver written files.
}
function updateBeforeInstall(){ # by [email protected]
# Update packages before installing to avoid errors
# return # cancelled now, user should do this his/herself. a few reason: may be dangerous, user may choose to do it later, slowing down installation... etc..
# without this function, apt-get installations cannot be done in a new server..
if [ -n "$noapt" ] ; then # skip install
echo "skipping apt-get update"
return
fi
if [ "$aptIsInstalled" -eq "1" ] ; then
echo "Updating package information and downloading package updates before installation."
apt-key update
apt-get update -y
# apt-get upgrade -y --allow-unauthenticated
else
echo "apt-get seems not installed, so, cannot update apt repository.. press Enter to continue"
read a
fi
}
function check_mysql(){
# mysql hangs somehow on some systems. this checks if mysql working, and tries to start it if not.
say=`php test_mysql.php | grep "t connect to local MySQL server through socket" | wc -l `
if [ $say -gt 0 ] ; then
echo "Mysql düzgün calısmıyor galiba.. yeniden deniyor."
killall mysqld
killall mysqld
killall mysqld
service mysql start
fi
say=`php test_mysql.php | grep "t connect to local MySQL server through socket" | wc -l `
if [ $say -gt 0 ] ; then
echo "Mysql düzgün calısmıyor galiba.. yeniden deniyor."
killall mysqld
killall mysqld
killall mysqld
service mysql start
fi
say=`php test_mysql.php | grep "t connect to local MySQL server through socket" | wc -l `
if [ $say -gt 0 ] ; then
echo "mysql hala çalışmıyor.. "
ps aux | grep mysq[l] | grep -v grep | awk '{print $2}' | xargs kill -9
ps aux | grep mysq[l] | grep -v grep | awk '{print $2}' | xargs kill -9
service mysql start
fi
say=`php test_mysql.php | grep "t connect to local MySQL server through socket" | wc -l `
if [ $say -gt 0 ] ; then
echo "I am sory that, mysql seems still not working. We/You should fix this... This may be serious. Your panel may not work without mysql."
fi
}
#############################################################
# End Functions & Start Install #
#############################################################
check_internet
checkUser $@
ehcpHeader
fix_permissions1
dpkg --configure -a # complete any pending operations, to avoid "dpkg interrupted" errors.
installdir=$(pwd)
if [ ! -f $installdir/install.sh ] ; then
echo "install.sh is not in install dir. Run install.sh from within ehcp installation dir."
exit 1
fi
#echo "`date`: initializing.b" # i added these echo's because on some system, some stages are very slow. i need to investigate that.
#infoMail "ehcp_1_installstarted_ver_$ehcpversion"
#/etc/init.d/apparmor stop & > /dev/null # apparmor causes many problems..
/etc/init.d/apparmor teardown & > /dev/null # apparmor causes many problems..if anybody knows a better solution, let us know.
checkDistro
killallEhcp
if [ -z "$distro" ] ; then
echo "Your system type could not be detected or detected to be ($distro), You may not install ehcp automatically on this system, anyway, to continue press enter"
read
fi
checkAptget
#Update the system before installation
#If your package information is out of date, MySQL and others may fail to install
updateBeforeInstall
#----------------------start some install --------------------------------------
#echo "`date`: initializing.g"
mkdir /etc/ehcp
#aptget_Update
aptgetInstall python-software-properties # for add-apt-repository
# apt-get upgrade # may be cancelled later... this may be dangerous... server owner should do it manually...
# alias ins='apt-get -y -qq install $1'
# sftp://[email protected]
aptgetInstall php5
aptgetInstall php5-mysqlnd # why here: If I install php5-mysql after install_1.php started, mysqli_connect functions does not work.
aptgetInstall php5-cli
# in case previuos ones fail..
aptgetInstall php
aptgetInstall php-mysqlnd # why here: If I install php5-mysql after install_1.php started, mysqli_connect functions does not work.
aptgetInstall php-cli
aptgetInstall sudo
aptgetInstall wget
aptgetInstall aptitude
aptgetInstall apache2-utils # for password protected directories
check_programs
# This is needed to provide a default answer for configuring certain packages such as mysql and phpmyadmin
if [ ! -z "$unattended" ]; then
aptgetInstall debconf-utils
fi
#outside_ip=`echo "" > ip ; wget -q -O ip http://ehcp.net/diger/myip.php ; echo ip`
#rm -f ip
echo
echo
checkPhp
echo
echo
echo
echo "STAGE 2"
echo "====================================================================="
echo "now running install_1.php "
#infoMail ehcp_2_install-starting-install_1.php
php install_1.php $version $distro $noapt $unattended $light
if [ $? -gt 0 ] ; then
echo "install_1.php returned error, check this.. "
exit 1
else
echo "php ended normally"
fi
echo
echo
echo "STAGE 3"
echo "====================================================================="
echo "now running install_2.php "
#infoMail ehcp_2_2_install-starting-install_2.php
#Send version to avoid installing nginx on Ubuntu 12.10 --- there is a bug and it's not supported
#php install_2.php $noapt || php /etc/ehcp/install_2.php $noapt # start install_2.php if first install is successfull at php level. to prevent many errors.
php install_2.php $version $distro $noapt $unattended $light
if [ $? -gt 0 ] ; then
echo "install_2.php returned error, check this.. "
exit 1
else
echo "php ended normally"
fi
########### Append ehcp restart to crontab, because, ehcp daemon dies sometime..
line="1 */6 * * * /etc/init.d/ehcp restart &"
say=`crontab -l | grep "ehcp restart" | wc -l`
if [ $say -eq 0 ] ; then
(crontab -u root -l; echo "$line" ) | crontab -u root -
fi
# Post Install Functions by Eric Arnol-Martin
mv /var/www/new/ehcp/install_?.php /etc/ehcp/ # move it, to prevent later unauthorized access of installer from web
cd "/var/www/new/ehcp"
# Run VSFTPD Fix depending on version
# ubuntuVSFTPDFix ; switching to another ftp server..
# Run SlaveDNS Fix So that DNS Zones can be transfered
slaveDNSApparmorFix
# Run log chmod fix
logDirFix
# Configure Fail2Ban for EHCP if Fail2Ban is present and configured
# fail2banCheck # done in install*php files.
# Fix EHCP Permissions
fixEHCPPerms
# Fix extra mysql module getting loaded in the PHP config printing warning messages
fixPHPConfig
# Fix /etc/bind directory permissions required for slave dns
fixBINDPerms
# Fix Perms for PHP CHMOD Fix
fixPHPPerms
# Fix generic problems in Ubuntu
genUbuntuFixes
check_mysql
echo "$PATH" > path # fill this file, so that ehcp can run correctly in crontab or similar
infoMail "ehcp_8_install-finished-install.sh_ver_$ehcpversion.$outside_ip"
echo "now running ehcp daemon.."
cd /var/log
/etc/init.d/ehcp restart
echo "ehcp run/restart complete.."
sleep 5 # to let ehcp log fill a little
# you may disable following lines, these are for debug/check purposes.
ps aux > debug.txt
echo "============================================" >> debug.txt
tail -100 /var/log/syslog >> debug.txt
tail -100 /var/log/ehcp.log >> debug.txt
if $emailenable ; then
cat debug.txt | sendmail -s "ehcp installation debug info" [email protected] > /dev/null 2>&1
fi
echo "
A reseller account is setupd inside your ehcp, to support ehcp development, we will use it when we need some hosting, you may delete it if you want.
thank you for trying/using ehcp
if your server is behind a router/modem in your network, you need to Open/redirect necessary ports on your modem/router:
these ports need to be opened/redirected :
20,21,22,25,53,80,110,143 (tcp+udp)
ehcp install finished up to now. we are continuing on simplifying the install process.
sory for any inconvenience. you can contact email/msn: [email protected]
you may join us in developing this control panel.
You may visit http://www.ehcp.net
You may support by donating cash, buying a pro license, doing php coding, html design, graphic design...
You may support by donating free dedicated or virtual servers for this project...
CURRENTLY WE NEED A DEDICATED SERVER WITH 8 CORE, 8GRAM, 500G hdd at least (or, you may consider to buy a pro license or donate..)
ehcp : Finished all operations.. go to your panel at http://yourip/ now..."