forked from omega8cc/boa
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBARRACUDA.sh.txt
1132 lines (1019 loc) · 39.1 KB
/
BARRACUDA.sh.txt
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
###----------------------------------------###
###
### Barracuda Aegir Installer
### Copyright 2010 Omega8.cc
### [email protected] www.omega8.cc
###
### This script is free software licensed
### under the GNU GPLv3. No warranty is
### provided and the authors claims no
### responsibility for any disasters caused
### during the execution of this script.
###
### Code: http://github.com/omega8cc
###
###----------------------------------------###
###----------------------------------------###
### HOW-TO: run it with bash, not with sh ###
###----------------------------------------###
###
### $ bash BARRACUDA.sh.txt
###
###----------------------------------------###
### EDITME ###
###----------------------------------------###
###
### Enter your valid e-mail address below.
###
_MY_EMAIL="[email protected]"
###----------------------------------------###
### AEGIR VERSION ###
###----------------------------------------###
###
### By default the latest release will be
### installed, but if you are brave and want
### to test current HEAD, you can change it
### below to:
###
### _AEGIR_VERSION="HEAD"
### _AEGIR_VERSION="0.4-alpha12"
###
_AEGIR_VERSION="0.4-alpha12"
###----------------------------------------###
### DNS MANUAL CONFIG - AVOID USING IT ###
###----------------------------------------###
###
### Starting with release 0.4-alpha9 Aegir
### requires proper DNS configuration
### of your server. Your hostname has to be
### FQDN and has to match your server IP.
###
### This script is trying to discover your
### DNS details and allow or deny the install,
### if something doesn't look correct.
###
### This script will also use your FQDN
### hostname as a web address of your Aegir
### frontend (control panel).
###
### You can try to change the automatic
### defaults by setting up your IP address,
### your FQDN hostname and your Aegir frontend
### web address below.
###
### It can be useful when you are using local
### environment with custom settings in your
### /etc/hosts, when you have more than one
### public IPs on eth0 and you wish to use
### non-default (first) IP address, or when
### you want to use non-hostname (sub)domain
### to access your Aegir frontend.
###
### Please change all 3 values if you wish
### to customize this automatic setup.
###
### Example:
###
### _MY_OWNIP="192.168.0.108"
### _MY_HOSTN="server.mydomain.com"
### _MY_FRONT="aegir.mydomain.com"
###
### NOTE:
###
### If you will use your custom DNS settings,
### they will be still validated, therefore
### make sure your _MY_HOSTN and _MY_FRONT
### both matches your _MY_OWNIP or the script
### will fail to install Aegir.
###
### You can't use "localhost" as your
### _MY_HOSTN and/or _MY_FRONT, because
### there is already default Nginx host
### with this name in every vanilla install
### and we don't want to override it.
###
_MY_OWNIP=""
_MY_HOSTN=""
_MY_FRONT=""
###----------------------------------------###
### DON'T EDIT ANYTHING BELOW THIS LINE ###
###----------------------------------------###
_INSTALLER_VERSION=A12.A
_NGINX_VERSION=0.8.49
_PHP_VERSION=5.2.14
_DRUSH_VERSION=6.x-3.3
###---### Avoid too many questions
#
export DEBIAN_FRONTEND=noninteractive
#
###---### Functions
#
# Noticeable messages
msg () {
echo "==> $*"
}
# Simple prompt
prompt_yes_no () {
while true ; do
printf "$* [Y/n] "
read answer
if [ -z "$answer" ] ; then
return 0
fi
case $answer in
[Yy]|[Yy][Ee][Ss])
return 0
;;
[Nn]|[Nn][Oo])
return 1
;;
*)
echo "Please answer yes or no"
;;
esac
done
}
#
# Stop on error
# set -e ### disable this for debugging
#
# Success msg
success () {
msg "$1 Succeeded."
}
#
# Error msg
fatal () {
echo
msg "Fatal Error Occurred: $1"
msg "Cannot continue installation."
exit 1
}
#
# Not supported OS
not_supported_os () {
msg "EXIT: Invalid install script or OS used."
msg "EXIT: It is not any supported Ubuntu or Debian version. Sorry."
msg "EXIT: You need Debian (Lenny) or Ubuntu (Lucid or Karmic or Jaunty)."
msg "Ciao... :)"
exit 1
}
#
# Perform an action, log it, and run the spinner throughout
runner () {
CMD="$1"
touch busy
bash $SRCDIR/spinner busy &
if $CMD >> $LOG; then
rm busy
sleep 1
success "$CMD:"
return 0
else
rm busy
sleep 1
echo "$CMD failed. Error (if any): $?"
echo
echo "Displaying the last 15 lines of $LOG to help troubleshoot this problem:"
tail -15 $LOG
return 1
fi
}
#
# Small spinner
mrun () {
CMD="$1"
touch busy
bash $SRCDIR/spinner busy &
if $CMD >> $LOG; then
rm busy
sleep 1
return 0
fi
}
#
# Silent runner
st_runner () {
CMD="$1"
touch busy
bash $SRCDIR/spinner busy &
if $CMD >> $LOG; then
rm busy
sleep 1
success "$CMD:"
return 0
else
rm busy
sleep 1
echo "$CMD failed. Error (if any): $?"
echo
echo "Displaying the last 15 lines of $LOG to help troubleshoot this problem:"
tail -15 $LOG
return 1
fi
}
###--------------------###
msg "`date` INFO: Install or upgrade checking, please wait..."
sleep 8
if [ -f "/var/aegir/config/includes/nginx_advanced_include.conf" ] ; then
_STATUS=UPGRADE
msg "`date` INFO: UPGRADE..."
else
_STATUS=INIT
msg "`date` INFO: INIT..."
fi
INITINS="/usr/bin/apt-get -y --force-yes install"
INSTALL="/usr/bin/apt-get --config-file /var/tmp/apt.conf.noninteractive -y --force-yes install"
SRCDIR=/var/tmp/files
rm -f -r /var/tmp/*
mkdir -p $SRCDIR
chmod -R 777 /var/tmp
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "`date` INFO: We need to install wget & git first, please wait..."
sleep 8
apt-get update &> /dev/null
apt-get clean &> /dev/null
$INITINS wget git-core &> /dev/null
fi
###--------------------###
msg "`date` INFO: Downloading little helpers, please wait..."
sleep 8
#
# Git clone all
cd /var/tmp
rm -f -r /var/tmp/nginx-for-drupal
git clone git://github.com/omega8cc/nginx-for-drupal.git &> /dev/null
#
# Get apt helper
rm -f apt.conf.noninteractive*
cp -af /var/tmp/nginx-for-drupal/aegir/helpers/apt.conf.noninteractive ./
#
# Create tmp stuff
LOG=/var/tmp/aegir-install.log
SILENT=/var/tmp/silent.log
cd $SRCDIR
#
# Get spinner
rm -f spinner*
cp -af /var/tmp/nginx-for-drupal/aegir/helpers/spinner ./
chmod +x spinner
#
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "`date` INFO: Installing lsb-release / dnsutils now, please wait..."
mrun "sleep 8"
if ! runner "$INSTALL lsb-release dnsutils"; then
fatal "Installation failed: $?"
fi
fi
###--------------------###
msg "STATUS: Checking your Debian or Ubuntu version..."
mrun "sleep 8"
_THIS_OS=`lsb_release -si`
_THIS_RV=`lsb_release -sc`
if [ $_THIS_OS = "Ubuntu" ] ; then
if [ $_THIS_RV = "lucid" ] ; then
_REL_VERSION="lucid"
elif [ $_THIS_RV = "karmic" ] ; then
_REL_VERSION="karmic"
elif [ $_THIS_RV = "jaunty" ] ; then
_REL_VERSION="jaunty"
elif [ $_THIS_RV = "hardy" ] ; then
_REL_VERSION="hardy"
else
not_supported_os
fi
elif [ $_THIS_OS = "Debian" ] ; then
if [ $_THIS_RV = "lenny" ] ; then
_REL_VERSION="lenny"
else
not_supported_os
fi
else
not_supported_os
fi
echo " "
msg "Aegir v.$_AEGIR_VERSION with Nginx on $_THIS_OS/$_REL_VERSION - highly automated install script."
echo " "
mrun "sleep 8"
if [ `whoami` = "root" ] ; then
msg "STATUS: This script is ran as a root user."
else
msg "ERROR: This script should be ran as a root user, please su - root first."
exit 1
fi
###--------------------###
if [ $_STATUS = "INIT" ] ; then
if [ -e "/proc/bean_counters" ] ; then
_VMFAMILY="VZ"
_IFCONFIG="venet0:0"
else
_VMFAMILY="XEN"
_IFCONFIG="eth0"
fi
if [ ! -z "$_MY_OWNIP" ] ; then
_THISHTIP="$_MY_OWNIP"
_THISHOST="$_MY_HOSTN"
_THISRDIP=`host $_THISHOST | cut -d: -f2 | awk '{ print $4}'`
if [ "$_THISRDIP" = "$_THISHTIP" ] ; then
_FQDNTEST="TRUE"
_THEFRDIP=`host $_MY_FRONT | cut -d: -f2 | awk '{ print $4}'`
if [ "$_THEFRDIP" = "$_THISHTIP" ] ; then
_TESTHOST=`hostname -f`
_TESTRDIP=`host $_TESTHOST | cut -d: -f2 | awk '{ print $4}'`
if [ "$_TESTRDIP" = "$_THISHTIP" ] ; then
_FQDNTEST="TRUE"
hostname -v $_TESTHOST
else
_FQDNTEST="FALSE"
fi
else
_FQDNTEST="FALSE"
fi
else
_FQDNTEST="FALSE"
fi
else
_THISHTIP=`ifconfig $_IFCONFIG | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`
_FQDNPROB=`hostname -f 2> /dev/null`
_FQDNTEST="FALSE"
_THISHOST=`uname -n`
if [ ! -z "$_FQDNPROB" ] ; then
_THISHOST=`hostname -f`
_THISRDIP=`host $_THISHOST | cut -d: -f2 | awk '{ print $4}'`
if [ "$_THISRDIP" = "$_THISHTIP" ] ; then
_FQDNTEST="TRUE"
hostname -v $_THISHOST
else
_FQDNTEST="FALSE"
_REVHOSTN=`host $_THISHTIP | cut -d: -f2 | awk '{ print $5}'`
_REVHOSTN=`echo -n $_REVHOSTN |sed 's/\(.*\)./\1/'`
_REVHSTIP=`host $_REVHOSTN | cut -d: -f2 | awk '{ print $4}'`
if [ "$_REVHSTIP" = "$_THISHTIP" ] ; then
hostname -v $_REVHOSTN
_THISHOST="$_REVHOSTN"
_FQDNTEST="TRUE"
else
_FQDNTEST="FALSE"
fi
fi
else
_REVHOSTN=`host $_THISHTIP | cut -d: -f2 | awk '{ print $5}'`
_REVHOSTN=`echo -n $_REVHOSTN |sed 's/\(.*\)./\1/'`
_REVHSTIP=`host $_REVHOSTN | cut -d: -f2 | awk '{ print $4}'`
if [ "$_REVHSTIP" = "$_THISHTIP" ] ; then
hostname -v $_REVHOSTN
_THISHOST="$_REVHOSTN"
_FQDNTEST="TRUE"
else
_FQDNTEST="FALSE"
fi
fi
fi
if [ ! -z "$_MY_FRONT" ] ; then
_THIS_FRONT="$_MY_FRONT"
else
_THIS_FRONT="$_THISHOST"
fi
if [ "$_FQDNTEST" = "FALSE" ] ; then
echo " "
msg "EXIT on error due to invalid DNS setup."
if [ ! -z "$_MY_OWNIP" ] ; then
cat <<EOF
* Your custom _MY_OWNIP is set to "$_MY_OWNIP"
* Your custom _MY_HOSTN is set to "$_MY_HOSTN"
* Your custom _MY_FRONT is set to "$_MY_FRONT"
* Your _MY_HOSTN and/or _MY_FRONT doesn't match your _MY_OWNIP,
or your hostname is not set properly yet.
* Please add/check correct line in your /etc/hosts file on the server:
$ echo "$_MY_OWNIP $_MY_HOSTN $_MY_FRONT" >> /etc/hosts
* Please make sure that below command returns your FQDN hostname "$_MY_HOSTN":
$ hostname -f
EOF
fi
cat <<EOF
* Your server has to have already working FQDN hostname matching your IP address.
This means you _have to_ configure the dns for your server IP/hostname _before_
trying to use this install script. Reverse dns is _not_ required.
* Your hostname appears to be $_THISHOST - are you sure it's a valid FQDN hostname?
* Are you sure your FQDN hostname matches your IP address: $_THISHTIP?
EOF
msg "EXIT on error due to invalid DNS setup."
echo " "
exit 1
else
echo "$_THISHOST" > /etc/hostname
hostname -v $_THISHOST
msg "DNS test OK - your FQDN hostname is $_THISHOST and it matches your IP $_THISHTIP"
msg "Please double check whether this is a valid result of my test."
fi
mrun "sleep 8"
echo " "
msg "INSTALL START -> checkpoint: "
cat <<EOF
* Your e-mail address appears to be $_MY_EMAIL - is that correct?
* Your hostname appears to be $_THISHOST - are you sure it's a valid FQDN hostname?
* Your Aegir control panel will be available at http://$_THIS_FRONT.
* Your Chive database manager will be available at http://db.$_THIS_FRONT.
* Your IP address appears to be $_THISHTIP - are you sure it's a valid IP?
* If your outgoing SMTP requires using relayhost, uncomment two lines in section:
'SMTP check' before running this script.
EOF
echo " "
if prompt_yes_no "Do you want to proceed with the install?" ; then
true
else
echo "Installation aborted by you."
exit 1
fi
else ### if [ $_STATUS = "UPGRADE" ] ; then
_THISHOST=`cat /etc/hostname`
_THISHOST=`echo -n $_THISHOST | tr -d "\n"`
_THIS_FRONT=`cat /var/aegir/.drush/hostmaster.alias.drushrc.php | grep 'uri' | cut -d: -f2 | awk '{ print $3}'`
_THIS_FRONT=`echo $_THIS_FRONT | sed "s/[\,']//g"`
mrun "sleep 8"
echo " "
msg "UPGRADE START -> checkpoint: "
cat <<EOF
* Your e-mail address appears to be $_MY_EMAIL - is that correct?
* Your server hostname is $_THISHOST.
* Your Aegir control panel is/will be available at http://$_THIS_FRONT.
EOF
echo " "
if prompt_yes_no "Do you want to proceed with the upgrade?" ; then
true
else
echo "Upgrade aborted by you."
exit 1
fi
fi
###--------------------###
msg "`date` INFO: Clean up temp files in /var/opt/"
mrun "sleep 8"
rm -f -r /var/opt/*
mkdir -p /var/log/php
chmod 777 /var/log/php*
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "`date` INFO: Update apt sources"
mrun "sleep 8"
if [ "$_THIS_OS" = "Ubuntu" ] ; then
echo "## MAIN REPOSITORIES" > /etc/apt/sources.list
echo "deb http://us.archive.ubuntu.com/ubuntu/ $_REL_VERSION main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://us.archive.ubuntu.com/ubuntu/ $_REL_VERSION main restricted universe multiverse" >> /etc/apt/sources.list
echo "" >> /etc/apt/sources.list
echo "## MAJOR BUG FIX UPDATES produced after the final release" >> /etc/apt/sources.list
echo "deb http://us.archive.ubuntu.com/ubuntu/ $_REL_VERSION-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://us.archive.ubuntu.com/ubuntu/ $_REL_VERSION-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "" >> /etc/apt/sources.list
echo "## UBUNTU SECURITY UPDATES" >> /etc/apt/sources.list
echo "deb http://security.ubuntu.com/ubuntu $_REL_VERSION-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://security.ubuntu.com/ubuntu $_REL_VERSION-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "" >> /etc/apt/sources.list
echo "## BACKPORTS REPOSITORY" >> /etc/apt/sources.list
echo "deb http://us.archive.ubuntu.com/ubuntu/ $_REL_VERSION-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://us.archive.ubuntu.com/ubuntu/ $_REL_VERSION-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "" >> /etc/apt/sources.list
echo "## PROPOSED REPOSITORY" >> /etc/apt/sources.list
echo "deb http://archive.ubuntu.com/ubuntu $_REL_VERSION-proposed main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://archive.ubuntu.com/ubuntu $_REL_VERSION-proposed main restricted universe multiverse" >> /etc/apt/sources.list
elif [ "$_THIS_OS" = "Debian" ] ; then
echo "deb http://ftp.us.debian.org/debian/ $_REL_VERSION main contrib non-free" > /etc/apt/sources.list
echo "deb-src http://ftp.us.debian.org/debian/ $_REL_VERSION main contrib non-free" >> /etc/apt/sources.list
echo "deb http://security.debian.org/ $_REL_VERSION/updates main contrib non-free" >> /etc/apt/sources.list
echo "deb-src http://security.debian.org/ $_REL_VERSION/updates main contrib non-free" >> /etc/apt/sources.list
echo "deb http://ftp.us.debian.org/debian experimental main" >> /etc/apt/sources.list
echo "deb-src http://ftp.us.debian.org/debian/ experimental main" >> /etc/apt/sources.list
fi
fi
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "`date` INFO: Add apt sources for MariaDB"
mrun "sleep 8"
cd /var/opt
wget http://ourdelta.org/deb/ourdelta.gpg &> /dev/null
apt-key add ourdelta.gpg 2> /dev/null
wget http://ourdelta.org/deb/sources/$_REL_VERSION-mariadb-ourdelta.list &> /dev/null
cp $_REL_VERSION-mariadb-ourdelta.list /etc/apt/sources.list.d/ourdelta.list &> /dev/null
fi
###--------------------###
msg "`date` INFO: Run apt update, please wait..."
runner "aptitude update"
runner "aptitude clean"
if [ "$_THIS_OS" = "Ubuntu" ] ; then
runner "apt-get upgrade -y"
runner "apt-get dist-upgrade"
runner "apt-get autoclean"
elif [ "$_THIS_OS" = "Debian" ] ; then
runner "aptitude full-upgrade -y"
fi
###--------------------###
msg "`date` INFO: Run apt update again, please wait..."
runner "aptitude update"
runner "aptitude clean"
if [ "$_THIS_OS" = "Ubuntu" ] ; then
runner "apt-get upgrade -y"
runner "apt-get dist-upgrade"
runner "apt-get autoclean"
elif [ "$_THIS_OS" = "Debian" ] ; then
runner "aptitude full-upgrade -y"
fi
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "`date` INFO: Install and set locales"
runner "aptitude -y install locales"
runner "locale-gen en_US en_US.UTF-8"
fi
###--------------------###
msg "`date` INFO: Install/upgrade required libraries and tools"
msg "`date` NOTE: This step can take a few minutes (depending on your server speed), please wait..."
if [ "$_THIS_OS" = "Debian" ] ; then
DEBDEPS="apticron aptitude autoconf2.13 automake automake1.4 autotools-dev bc bison build-essential cron curl cvs defoma devscripts dnsutils dstat flex fontconfig-config ghostscript gnupg imagemagick htop ifstat iptables lemon libapr1 libaprutil1 libc-client-dev libc-client2007b libc-client2007b-dev libcurl4-gnutls-dev libdbd-mysql-perl libdbi-perl libfilesys-diskspace-perl libfontconfig1 libfreetype6 libfreetype6-dev libfribidi0 libgd2-xpm libhtml-template-perl libjpeg-dev libjpeg62 libltdl7 libltdl7-dev libmariadbclient-dev libmariadbclient16 libmariadbd-dev libmcrypt-dev libmemcache-dev libnet-daemon-perl libpcre3 libpcre3-dev libplrpc-perl libpng12-dev libpng12-0 libpq5 libsasl2-modules libssl-dev libt1-5 libt1-dev libtool libwww-perl libxml2-dev libxpm4 libxslt-dev libxslt1-dbg libxslt1-dev libxslt1.1 lftp m4 makepasswd mariadb-client-5.1 mariadb-common mariadb-server-5.1 mc mcrypt nano netcat nginx ncurses-dev openjdk-6-jdk postfix postfix-pcre pwgen python-dev python-mysqldb re2c redis-server rsync shtool ssh ssl-cert subversion sudo sysstat sysvconfig t1lib-bin telnet time ttf-dejavu ttf-dejavu-core ttf-dejavu-extra vim whois xml-core xml2 zlib1g-dev zlibc unzip zip"
elif [ "$_REL_VERSION" = "lucid" ] ; then
DEBDEPS="apticron aptitude autoconf2.13 automake automake1.4 autotools-dev bc bison build-essential cron curl cvs defoma devscripts dnsutils dstat flex fontconfig-config ghostscript gnupg imagemagick htop ifstat iptables libapr1 lemon libaprutil1 libc-client-dev libc-client2007e libc-client2007e-dev libcurl4-gnutls-dev libdbd-mysql-perl libdbi-perl libfilesys-diskspace-perl libfontconfig1 libfreetype6 libfreetype6-dev libfribidi0 libgd2-xpm libhtml-template-perl libjpeg-dev libjpeg62 libmariadbclient-dev libmariadbclient16 libmariadbd-dev libmcrypt-dev libmemcache-dev libnet-daemon-perl libpcre3 libpcre3-dev libplrpc-perl libpng12-0 libpng12-dev libpq5 libsasl2-modules libssl-dev libt1-5 libt1-dev libtool libwww-perl libxml2-dev libxpm4 libxslt-dev libxslt1-dbg libxslt1-dev libxslt1.1 lftp m4 makepasswd mariadb-client-5.1 mariadb-common mariadb-server-5.1 mc mcrypt nano netcat ncurses-dev nginx openjdk-6-jdk postfix postfix-pcre pwgen python-dev python-mysqldb re2c redis-server rsync shtool ssh ssl-cert subversion sudo sysstat sysvinit-utils t1lib-bin telnet time ttf-dejavu ttf-dejavu-core ttf-dejavu-extra unzip vim whois xml-core xml2 zip zlib1g-dev zlibc"
else
DEBDEPS="apticron aptitude autoconf2.13 automake automake1.4 autotools-dev bc bison build-essential cron curl cvs defoma devscripts dnsutils dstat flex fontconfig-config ghostscript gnupg imagemagick htop ifstat iptables lemon libapr1 libaprutil1 libc-client-dev libc-client2007b libc-client2007b-dev libcurl4-gnutls-dev libdbd-mysql-perl libdbi-perl libfilesys-diskspace-perl libfontconfig1 libfreetype6 libfreetype6-dev libfribidi0 libgd2-xpm libhtml-template-perl libjpeg-dev libjpeg62 libltdl7 libltdl7-dev libmariadbclient-dev libmariadbclient16 libmariadbd-dev libmcrypt-dev libmemcache-dev libnet-daemon-perl libpcre3 libpcre3-dev libplrpc-perl libpng12-dev libpng12-0 libpq5 libsasl2-modules libssl-dev libt1-5 libt1-dev libtool libwww-perl libxml2-dev libxpm4 libxslt-dev libxslt1-dbg libxslt1-dev libxslt1.1 lftp m4 makepasswd mariadb-client-5.1 mariadb-common mariadb-server-5.1 mc mcrypt nano netcat nginx ncurses-dev openjdk-6-jdk postfix postfix-pcre pwgen python-dev python-mysqldb re2c redis-server rsync shtool ssh ssl-cert subversion sudo sysstat sysvinit-utils t1lib-bin telnet time ttf-dejavu ttf-dejavu-core ttf-dejavu-extra vim whois xml-core xml2 zlib1g-dev zlibc unzip zip"
fi
install_with_apt () {
if ! runner "$INSTALL $DEBDEPS"; then
fatal "Installation failed: $?"
fi
return 0
}
install_with_apt
###--------------------###
msg "`date` INFO: SMTP check"
mrun "sleep 8"
if ! netcat -w 8 -z smtp.host8.biz 25 ; then
WE_NEED_RELAY="YES"
cat <<EOF
Your outgoing SMTP port 25 doesn't work
as expected, so your server can't send out
any e-mails directly.
It appears you need a SMTP relayhost added
in your Postfix /etc/postfix/main.cf config.
Uncomment 2 lines in the 'SMTP check' section
and enter there your SMTP relayhost name.
Then run this script again.
EOF
exit 1
else
true
fi
###
### required if you have closed outgoing smtp port and you have to use smtp relay
### in this example it is for Voxel servers
###
# perl -p -i -e "s/(smtp.cust.voxel.net)//g" /etc/postfix/main.cf
# perl -p -i -e "s/(relayhost =)/relayhost = smtp.cust.voxel.net/g" /etc/postfix/main.cf
postfix reload
###
###
###--------------------###
msg "`date` INFO: Install/upgrade a few more tools, please wait..."
mrun "sleep 8"
cd /var
if [ -d "/var/xdrago" ] ; then
cp -af /opt/etc/init.d /var/xdrago/log/init.d-pre-$_INSTALLER_VERSION
cp -af /var/spool/cron/crontabs/root /var/xdrago/log/cron-root-pre-$_INSTALLER_VERSION
touch /var/xdrago/log/cron-root-pre-$_INSTALLER_VERSION
cp -af /var/xdrago /var/xdrago-pre-$_INSTALLER_VERSION
fi
if [ $_STATUS = "INIT" ] ; then
mkdir -p ./xdrago
cp -af /var/tmp/nginx-for-drupal/aegir/tools/auto-healing-monitoring/* ./xdrago/
cp -af /var/xdrago/etc /opt/
cp -af /opt/etc/init.d/* /etc/init.d/
cp -af /var/xdrago/cron/crontabs/root /var/spool/cron/crontabs/
perl -p -i -e "s/(>127.0.0.1<)/\>127.0.0.1,$_THISHTIP\</g" /opt/etc/php-fpm.conf
perl -p -i -e "s/(max_children\">1)/max_children\"\>4/g" /opt/etc/php-fpm.conf
fi
if [ $_STATUS = "INIT" ] ; then
echo $_MY_EMAIL > /tmp/.email.txt
perl -p -i -e "s/(\@)/\\\@/g" /tmp/.email.txt
APTEMAILA=`cat /tmp/.email.txt`
APTEMAIL=`echo -n $APTEMAILA | tr -d "\n"`
perl -p -i -e "s/(root)/$APTEMAIL/g" /etc/apticron/apticron.conf
rm -f /tmp/.email.txt
runner "sh /usr/sbin/apticron"
fi
if [ -d "/var/xdrago-pre-$_INSTALLER_VERSION" ] ; then
cp -af /var/xdrago-pre-$_INSTALLER_VERSION/run* /var/xdrago/
fi
###--------------------###
msg "`date` INFO: PHP installed version auto-discovering now, please wait..."
mrun "sleep 8"
_PHP_INSTALLED=`php -v | grep 'PHP 5' | cut -d: -f1 | awk '{ print $2}'`
if [ "$_PHP_INSTALLED" = "$_PHP_VERSION" ] ; then
_PHP_INSTALL_REQUIRED=NO
else
_PHP_INSTALL_REQUIRED=YES
fi
if [ -f "/usr/local/bin/php" ] ; then
msg "`date` INFO: Installed PHP version $_PHP_INSTALLED"
mrun "sleep 8"
fi
###
if [ $_PHP_INSTALL_REQUIRED = "YES" ] ; then
###
###--------------------###
msg "`date` INFO: Installing libevent, please wait..."
rm -f -r /var/opt/libevent*
cd /var/opt
wget -U iCab http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz &> /dev/null
tar -xzf libevent-1.4.14b-stable.tar.gz
cd /var/opt/libevent-1.4.14b-stable
st_runner "sh ./configure --prefix=/usr" 2> /dev/null
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
rm -f -r /var/opt/libevent*
cd /var/opt
wget -U iCab http://www.monkey.org/~provos/libevent-1.4.14b-stable.tar.gz &> /dev/null
tar -xzf libevent-1.4.14b-stable.tar.gz
cd /var/opt/libevent-1.4.14b-stable
st_runner "sh ./configure" 2> /dev/null
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
st_runner "ldconfig" 2> /dev/null
###--------------------###
msg "`date` INFO: Installing PHP-FPM"
msg "`date` NOTE: This step can take longer than 8 minutes (depending on your server speed), please wait..."
mrun "sleep 8"
cd /var/opt
rm -f -r /var/opt/php*
mv /etc/init.d/php-fpm /etc/init.d/php-fpm-5-13
wget -U iCab http://www.php.net/distributions/php-5.2.14.tar.gz &> /dev/null
wget -U iCab http://download.suhosin.org/suhosin-patch-5.2.14-0.9.7.patch.gz &> /dev/null
wget -U iCab http://php-fpm.org/downloads/php-5.2.14-fpm-0.5.14.diff.gz &> /dev/null
tar -xzf php-5.2.14.tar.gz
gunzip php-5.2.14-fpm-0.5.14.diff.gz
gunzip suhosin-patch-5.2.14-0.9.7.patch.gz
cat php-5.2.14-fpm-0.5.14.diff | patch -d php-5.2.14 -p1 &> /dev/null
cat suhosin-patch-5.2.14-0.9.7.patch | patch -d php-5.2.14 -p1 &> /dev/null
msg "`date` INFO: Installing PHP-FPM part 1/3"
mrun "sleep 8"
cd /var/opt/php-5.2.14
st_runner "sh ./buildconf --force" 2> /dev/null
msg "`date` INFO: Installing PHP-FPM part 2/3"
mrun "sleep 8"
st_runner "sh ./configure --quiet --enable-fpm --enable-fastcgi --with-mysql --with-mysqli --enable-force-cgi-redirect --enable-discard-path --with-zlib --with-curl --with-curlwrappers --with-gd --enable-gd-native-ttf --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr --with-t1lib=/usr --with-pear --with-imap --with-imap-ssl --with-openssl --with-pdo-mysql --enable-exif --enable-soap --enable-ftp --enable-mbstring --enable-pcntl --enable-bcmath --with-kerberos --with-xsl --with-mcrypt" 2> /dev/null
msg "`date` INFO: Installing PHP-FPM part 3/3"
mrun "sleep 8"
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
ln -s /usr/local/sbin/php-fpm /etc/init.d/php-fpm
perl -p -i -e "s/(php_fpm_CONF\")/php_fpm_CONF -c \/opt\/etc\/php.ini\"/g" /usr/local/sbin/php-fpm
perl -p -i -e "s/(\/usr\/local\/etc\/php-fpm.conf)/\/opt\/etc\/php-fpm.conf/g" /usr/local/sbin/php-fpm
perl -p -i -e "s/(\/usr\/local\/logs\/php-fpm.pid)/\/var\/run\/php-fpm.pid/g" /usr/local/sbin/php-fpm
###--------------------###
msg "`date` INFO: Installing memcache for php, please wait..."
mrun "sleep 8"
cd /var/opt
wget -U iCab http://pecl.php.net/get/memcache-3.0.3.tgz &> /dev/null
tar -xzf memcache-3.0.3.tgz
cd /var/opt/memcache-3.0.3
st_runner "/usr/local/bin/phpize" 2> /dev/null
st_runner "sh ./configure --with-php-config=/usr/local/bin/php-config" 2> /dev/null
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
###--------------------###
msg "`date` INFO: Installing suhosin for php, please wait..."
mrun "sleep 8"
cd /var/opt
wget -U iCab http://download.suhosin.org/suhosin-0.9.31.tgz &> /dev/null
tar -xzf suhosin-0.9.31.tgz
cd /var/opt/suhosin-0.9.31
st_runner "/usr/local/bin/phpize" 2> /dev/null
st_runner "sh ./configure --with-php-config=/usr/local/bin/php-config" 2> /dev/null
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
###--------------------###
msg "`date` INFO: Installing uploadprogress for php, please wait..."
mrun "sleep 8"
cd /var/opt
wget -U iCab http://pecl.php.net/get/uploadprogress-1.0.1.tgz &> /dev/null
tar -xzf uploadprogress-1.0.1.tgz
cd /var/opt/uploadprogress-1.0.1
st_runner "/usr/local/bin/phpize" 2> /dev/null
st_runner "sh ./configure --with-php-config=/usr/local/bin/php-config" 2> /dev/null
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
###--------------------###
msg "`date` INFO: Installing apc for php, please wait..."
mrun "sleep 8"
cd /var/opt
wget -U iCab http://pecl.php.net/get/APC-3.1.3p1.tgz &> /dev/null
tar -xzf APC-3.1.3p1.tgz
cd /var/opt/APC-3.1.3p1
st_runner "/usr/local/bin/phpize" 2> /dev/null
st_runner "sh ./configure --with-php-config=/usr/local/bin/php-config" 2> /dev/null
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
###--------------------###
mkdir -p /usr/local/ioncube
_X86_64_TEST=`uname -m`
if [ "$_X86_64_TEST" = "x86_64" ] ; then
SYSTEMARCH="x86_64"
msg "`date` INFO: Installing ioncube $SYSTEMARCH version for php, please wait..."
mrun "sleep 8"
cd /var/opt
wget -U iCab http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz &> /dev/null
tar -xzf ioncube_loaders_lin_x86-64.tar.gz
else
SYSTEMARCH="x86"
msg "`date` INFO: Installing ioncube $SYSTEMARCH version for php, please wait..."
mrun "sleep 8"
cd /var/opt
wget -U iCab http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz &> /dev/null
tar -xzf ioncube_loaders_lin_x86.tar.gz
fi
cp -af /var/opt/ioncube/* /usr/local/ioncube/
###
fi ### end if [ $_PHP_INSTALL_REQUIRED = "YES" ] ; then
###
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "`date` INFO: Installing bzr, please wait..."
mrun "sleep 8"
cd /var/opt
wget -U iCab http://launchpad.net/bzr/2.2/2.2b4/+download/bzr-2.2b4.tar.gz &> /dev/null
tar -xzf bzr-2.2b4.tar.gz
cd /var/opt/bzr-2.2b4
st_runner "python setup.py --quiet install build_ext --allow-python-fallback" 2> /dev/null
fi
###--------------------###
msg "`date` INFO: Nginx version test, please wait..."
mrun "sleep 8"
if [ $_STATUS = "INIT" ] ; then
_NGINX_INSTALL_REQUIRED=YES
else
_NGINX_F_INSTALLED=`/usr/sbin/nginx -v 2>&1`
_NGINX_F_VERSION="nginx version: nginx/$_NGINX_VERSION"
if [ "$_NGINX_F_INSTALLED" = "$_NGINX_F_VERSION" ] ; then
_NGINX_INSTALL_REQUIRED=NO
else
_NGINX_INSTALL_REQUIRED=YES
fi
fi
if [ -f "/usr/sbin/nginx" ] ; then
msg "`date` INFO: Installed $_NGINX_F_INSTALLED"
mrun "sleep 8"
fi
###--------------------###
if [ $_NGINX_INSTALL_REQUIRED = "YES" ] ; then
msg "`date` INFO: Install/upgrade Nginx, please wait..."
mrun "sleep 8"
cd /var/opt; rm -f -r nginx*
git clone git://github.com/masterzen/nginx-upload-progress-module.git &> /dev/null
cd /var/opt
wget -U iCab http://sysoev.ru/nginx/nginx-$_NGINX_VERSION.tar.gz &> /dev/null
tar -xzf nginx-$_NGINX_VERSION.tar.gz
cd /var/opt/nginx-$_NGINX_VERSION
st_runner "sh ./configure --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --user=www-data --group=www-data --with-http_realip_module --with-rtsig_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --add-module=/var/opt/nginx-upload-progress-module/" 2> /dev/null
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
fi
if [ ! -L "/usr/bin/nginx" ] ; then
ln -s /usr/sbin/nginx /usr/bin/nginx
fi
###--------------------###
if [ ! -f "/usr/local/bin/memcached" ] ; then
msg "`date` INFO: Installing Memcached, please wait..."
mrun "sleep 8"
cd /var/opt
rm -f /opt/bin/memcached
rm -f /usr/bin/memcached
rm -f /usr/local/bin/memcached
wget -U iCab wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz &> /dev/null
tar -xzf memcached-1.4.5.tar.gz
cd /var/opt/memcached-1.4.5
st_runner "sh ./configure" 2> /dev/null
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
ln -s /usr/local/bin/memcached /usr/bin/memcached
fi
###--------------------###
if [ ! -d "/opt/solr" ] ; then
msg "`date` INFO: Installing Apache Solr Tomcat, please wait..."
mrun "sleep 8"
cd /var/opt
rm -f -r apachesolr*
rm -f -r /opt/solr
rm -f -r /opt/tomcat6
wget http://omega8.cc/dev/apachesolr.tar.gz &> /dev/null
tar -xzf apachesolr.tar.gz
cd apachesolr
mv tomcat /etc/init.d/
mv solr /opt/
mv tomcat6 /opt/
echo "ENABLED=1" > /etc/default/tomcat
perl -p -i -e "s/(\/usr\/lib\/jvm\/java-6-sun\/jre)/\/usr\/lib\/jvm\/java-6-openjdk\/jre/g" /etc/init.d/tomcat
runner "update-rc.d tomcat defaults" &> /dev/null
runner "invoke-rc.d tomcat start" 2> /dev/null
fi
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "`date` INFO: Update rc.d"
mrun "sleep 8"
chown root:crontab /var/spool/cron/crontabs/root
chmod 600 /var/spool/cron/crontabs/root
echo "UseDNS no" >> /etc/ssh/sshd_config
#cp -a /opt/etc/php.ini /usr/local/lib/
rm -f /usr/local/lib/php.ini
killall nginx php-cgi php-fpm &> /dev/null
runner "invoke-rc.d ssh restart" &> /dev/null
runner "update-rc.d cron defaults" &> /dev/null
runner "update-rc.d php-fpm defaults" &> /dev/null
runner "update-rc.d nginx defaults" &> /dev/null
runner "invoke-rc.d php-fpm start" 2> /dev/null
runner "invoke-rc.d nginx start" 2> /dev/null
cd /etc/mysql
mv -f my.cnf my.cnf.bak.copy
cp -af /var/tmp/nginx-for-drupal/aegir/conf/my.cnf.txt ./
mv my.cnf.txt my.cnf
runner "invoke-rc.d mysql restart" 2> /dev/null
else
msg "`date` INFO: Restarting php-fpm and Nginx"
mrun "sleep 8"
killall nginx php-cgi php-fpm &> /dev/null
runner "invoke-rc.d php-fpm start" 2> /dev/null
runner "invoke-rc.d nginx start" 2> /dev/null
fi
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "`date` INFO: Generate random password for MariaDB"
mrun "sleep 8"
touch /root/.my.pass.txt
chmod 0600 /root/.my.pass.txt
pwgen -c -v -s > /root/.my.pass.txt
fi
PXSWD=`cat /root/.my.pass.txt`
PASWD=`echo -n $PXSWD | tr -d "\n"`
for Files in `find /var/xdrago -type f`
do
perl -p -i -e "s/(NdKBu34erty325r6mUHxWy)/$PASWD/g" $Files
perl -p -i -e "s/(php-fpm nginx php)/php-fpm php-cgi nginx php/g" $Files
done
msg "`date` INFO: OS and services installation/upgrade completed"
mrun "sleep 8"
###
if [ $_STATUS = "INIT" ] ; then
###
###--------------------###
msg "`date` INFO: Installing Aegir, please wait..."
mrun "sleep 8"
runner "adduser --system --group --home /var/aegir aegir"
runner "adduser aegir www-data"
echo "aegir ALL=NOPASSWD: /etc/init.d/nginx" >> /etc/sudoers
ln -s /var/aegir/config/nginx.conf /etc/nginx/conf.d/aegir.conf
cd /var/aegir
if [ "$_AEGIR_VERSION" = "HEAD" ] ; then
_AEGIR_SCRIPT="aegir-head-install"
elif [ "$_AEGIR_VERSION" = "TEST" ] ; then
_AEGIR_SCRIPT="aegir-test-install"
else
_AEGIR_SCRIPT="aegir-alpha-install"
fi
cp -af /var/tmp/nginx-for-drupal/aegir/scripts/$_AEGIR_SCRIPT.sh.txt ./
msg "`date` INFO: Now running Aegir installer for backend and frontend"
mrun "sleep 8"
su -s /bin/bash aegir -c "bash $_AEGIR_SCRIPT.sh.txt $_THIS_FRONT --http_service_type='nginx' --db_service_type='mysql' --db_port='3306' --client_email='$_MY_EMAIL' >/var/aegir/install.log 2>&1"
mrun "sleep 8"
###--------------------###
msg "`date` INFO: Simple check if Aegir install is successful"
mrun "sleep 8"
if [ -f "/var/aegir/config/includes/nginx_advanced_include.conf" ] ; then
msg "`date` INFO: Aegir installation almost completed"
else
msg "`date` FATAL ERROR: Something is wrong, Aegir not installed - exit now"
exit 1
fi
###--------------------###
msg "`date` INFO: Fix for access to global.inc for www-data user issue"
mrun "sleep 8"
chmod 755 /var/aegir/config/includes
chmod 755 /var/aegir/config
runner "invoke-rc.d cron restart" &> /dev/null
mrun "sleep 8"