forked from omega8cc/boa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBARRACUDA.sh.txt
2271 lines (2059 loc) · 79.4 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://gitorious.org/aegir
###
###----------------------------------------###
###----------------------------------------###
### 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]"
###----------------------------------------###
### LOCAL DEBIAN OR UBUNTU MIRROR ###
###----------------------------------------###
###
### Use this when you prefer to use the mirror
### you know is the best / the fastest for you
### and skip searching around the globe.
###
### _LOCAL_DEBIAN_MIRROR=ftp.au.debian.org
### _LOCAL_UBUNTU_MIRROR=au.archive.ubuntu.com
###
_LOCAL_DEBIAN_MIRROR=""
_LOCAL_UBUNTU_MIRROR=""
###----------------------------------------###
### DEBUG MODE SWITCH (available) ###
###----------------------------------------###
###
### Use this when you experience silent hangs
### or other hard to debug problems to display
### some errors on screen.
###
### _DEBUG_MODE=YES
###
_DEBUG_MODE=NO
###----------------------------------------###
### AEGIR VERSION ###
###----------------------------------------###
###
### By default the current HEAD version will
### be installed, but if you prefer, you can
### change it below to:
###
### _AEGIR_VERSION=0.4-beta1
###
_AEGIR_VERSION=HEAD
###----------------------------------------###
### DNS MANUAL CONFIG ###
###----------------------------------------###
###
### 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.
###
### It is also useful when you plan to use
### available in Barracuda optional installs
### of Chive, SQL Buddy and Collectd, since
### all of them will use subdomains in the
### server hostname and it will not work
### when your hostname domain DNS is not
### under your control (like many default
### hostnames and reverse DNS provided by
### VPS hosting companies).
###
### 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 (unless you
### will disable the DNS test completely
### below in _DNS_SETUP_TEST).
###
_MY_OWNIP=""
_MY_HOSTN=""
_MY_FRONT=""
###----------------------------------------###
### DATABASE CUSTOM HOST ###
###----------------------------------------###
###
### If you prefer, you can set the database
### to be connected locally via "localhost"
### instead of FQDN pointing to your public IP
### address.
###
### This feature allows you to "revert" to the
### old Aegir behaviuor, when it was using by
### default localhost for database connection.
###
### You could also use this feature to connect
### to the remote database server by default,
### since it allows to "override" the new
### behaviuor, designed for Aegir multiserver
### compatibility.
###
### If not sure, please don't change the
### default, which is here still FQDN setup.
###
### Possible usage:
###
### _THIS_DB_HOST=localhost
### _THIS_DB_HOST=some.remote.host.name
###
_THIS_DB_HOST=FQDN
###----------------------------------------###
### DNS SETUP TEST ###
###----------------------------------------###
###
### If you don't want to test your DNS
### because of some custom local setup
### you know is correct (like DynDNS)
### but the script can't validate it with its
### standard ifconfig tests, set this to:
###
### _DNS_SETUP_TEST=NO
###
### There is no guarantee it will work.
###
_DNS_SETUP_TEST=YES
###----------------------------------------###
### SMTP CONNECTION TEST ###
###----------------------------------------###
###
### If you don't want to test outgoing SMTP
### connections, change _SMTP_RELAY_TEST
### value to "NO".
###
_SMTP_RELAY_TEST=YES
###----------------------------------------###
### SMTP RELAY HOST - ONLY WHEN REQUIRED ###
###----------------------------------------###
###
### _SMTP_RELAY_HOST="smtp.cust.voxel.net"
###
_SMTP_RELAY_HOST=""
###----------------------------------------###
### LOCALHOST ON LOCAL NETWORK ###
###----------------------------------------###
###
### When enabled, it will force your Nginx web
### server to listen only on local IP with
### local hostname:
###
### _LOCAL_NETWORK_IP=10.10.80.80
### _LOCAL_NETWORK_HN=aegir.local
###
### In this example 10.10.80.80 is your local
### server IP address, where public traffic
### is NAT'd from another, public IP address.
###
### In this case "aegir.local" will be used
### as your hostname and all connections and
### grants will use "aegir.local" instead of
### FQDN. Also your core Hostmaster will be
### available at http://aegir.local
###
### This option is useful when your server is
### available only in your local network
### without any public IP address assigned/
### available on any eth interface. This also
### means it should work as a handy local
### setup on your wirelessly connected laptop
### or netbook, with improved DNS cache
### support - pdnsd will save results in file.
###
### In this case you could use 127.0.1.1 as
### _LOCAL_NETWORK_IP to avoid issues with
### DHCP changing your assigned IP on the fly
### and to avoid conflicts with some other
### services listening on 127.0.0.1
###
### This option works only with initial
### install and is disabled for upgrades.
### When used, it will override all defined
### above _MY_OWNIP, _MY_HOSTN and _MY_FRONT.
### It will also disable all DNS and SMTP
### relay tests automatically. It will also
### enable debug mode by default.
###
### In general: DON'T TRY THIS OPTION, unless
### you know, what are you doing. It is only
### to make local install easier and helps
### with using Aegir on servers without direct
### connection to the Internet, but again, you
### must understand how it works.
###
_LOCAL_NETWORK_IP=""
_LOCAL_NETWORK_HN=""
###----------------------------------------###
### DON'T EDIT ANYTHING BELOW THIS LINE ###
###----------------------------------------###
_INSTALLER_VERSION=B1.E.dev2
_NGINX_VERSION=0.9.3
_PHP_VERSION=5.2.16
_LSHELL_VERSION=0.9.14
_DRUSH_VERSION=6.x-4.0-rc3
_NOW=`date +%y%m%d-%H%M`
###---### Avoid too many questions
#
export DEBIAN_FRONTEND=noninteractive
#
###---### Functions
#
# Noticeable messages
msg () {
echo "Barracuda [`date`] ==> $*"
}
# 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
}
#
# Prompt to confirm choice
prompt_confirm_choice () {
read -p "$1 [$2]:" _CONFIRMED_ANSWER
if [ -z "$_CONFIRMED_ANSWER" ] ; then
_CONFIRMED_ANSWER=$2
fi
}
#
# 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 "== FATAL ERROR =="
msg "Invalid install script or OS used."
msg "It is not any supported Ubuntu or Debian version. Sorry."
msg "You need Debian (Lenny) or Ubuntu (Lucid or Karmic or Jaunty),"
msg "or Jolicloud (Robby)."
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."
echo "If you see any error with advice to run 'dpkg --configure -a', run this"
echo "command first and choose default answer, then run this installer again."
echo " "
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
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."
echo "If you see any error with advice to run 'dpkg --configure -a', run this"
echo "command first and choose default answer, then run this installer again."
echo " "
tail -15 $_LOG
return 1
fi
}
#
# Install Redis from sources
install_redis_src () {
msg "INFO: Installing Redis for $_THIS_OS/$_THIS_RV, please wait..."
mrun "sleep 3"
st_runner "adduser --system --group redis"
cd /var/opt
rm -f -r /var/opt/redis*
wget -q -U iCab http://redis.googlecode.com/files/redis-2.0.1.tar.gz
tar -xzf redis-2.0.1.tar.gz
cd redis-2.0.1
st_runner "make --quiet" 2> /dev/null
st_runner "make --quiet install" 2> /dev/null
cd /usr/local/bin
cp -p redis-server /usr/bin/
cp -p redis-benchmark /usr/bin/
cp -p redis-cli /usr/bin/
cp -p redis-check-dump /usr/bin/
cp -p redis-check-aof /usr/bin/
cd /etc/init.d
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/redis-server ./
chmod 755 redis-server &> /dev/null
st_runner "update-rc.d redis-server defaults" &> /dev/null
mkdir /etc/redis
cd /etc/redis
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/redis.conf ./
mkdir -p /var/log/redis
chown redis:redis /var/log/redis
mkdir -p /var/lib/redis
chown redis:redis /var/lib/redis
st_runner "invoke-rc.d redis-server start" &> /dev/null
}
#
# Fix this on upgrade
fix_on_upgrade () {
perl -p -i -e "s/apc.include_once_override = 1/apc.include_once_override = 0/g" /opt/etc/php.ini
mkdir -p /var/backups/dragon/t
cp -af /opt/etc/php.ini /var/backups/dragon/t/opt-etc-php.ini-pre-$_INSTALLER_VERSION-$_NOW
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/php.ini /opt/etc/php.ini
cp -af /usr/local/lib/php.ini /var/backups/dragon/t/usr-local-lib-php.ini-pre-$_INSTALLER_VERSION-$_NOW
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/php-cli.ini /usr/local/lib/php.ini
if [ ! -e "/var/log/check_for_crashed_tables_disabled" ] ; then
perl -p -i -e "s/check_for_crashed_tables/\#check_for_crashed_tables/g" /etc/mysql/debian-start
touch /var/log/check_for_crashed_tables_disabled
fi
}
#
# Force advanced Nginx configuration
force_advanced_nginx_config () {
cd /var/aegir/config/includes
rm -f nginx_compact_include.conf
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/nginx_compact_include.conf ./
mv -f nginx_simple_include.conf nginx_simple_include.conf-$_NOW &> /dev/null
mv -f nginx_advanced_include.conf nginx_advanced_include.conf-$_NOW &> /dev/null
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/nginx_advanced_include.conf ./
cp -af nginx_advanced_include.conf nginx_simple_include.conf
chown aegir:aegir *
cd /var/aegir/.drush/provision/http/nginx
rm -f nginx_simple_include.conf
rm -f nginx_advanced_include.conf
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/nginx_advanced_include.conf ./
cp -af nginx_advanced_include.conf nginx_simple_include.conf
chown aegir:aegir *
}
###--------------------###
if [ `whoami` = "root" ] ; then
msg "STATUS: This script is ran as a root user."
#msg "STATUS: Stop cron and wait 3 sec."
rm -f -r /opt/tmp/*
#invoke-rc.d cron stop &> /dev/null
touch /var/run/octopus_barracuda.pid
sleep 3
else
msg "ERROR: This script should be ran as a root user, please `su - root` or `sudo -i` first."
exit 1
fi
###--------------------###
msg "INFO: Install or upgrade checking, please wait..."
sleep 3
if [ -d "/var/aegir" ] ; then
_STATUS=UPGRADE
msg "INFO: UPGRADE..."
else
_STATUS=INIT
msg "INFO: INIT..."
fi
_INITINS="/usr/bin/apt-get -y --force-yes install"
_INSTALL="/usr/bin/apt-fast -y --force-yes --config-file /opt/tmp/apt.conf.noninteractive install"
_SRCDIR=/opt/tmp/files
rm -f -r /var/opt/*
mkdir -p $_SRCDIR
chmod -R 777 /opt/tmp &> /dev/null
rm -f /var/run/aegir_upgrade.pid
###--------------------###
if [ $_STATUS = "UPGRADE" ] ; then
if [ ! -e "/root/.my.cnf" ] ; then
msg "EXIT on error due to not found file with your MySQL/MariaDB root password."
cat <<EOF
It appears you don't have required file with your root sql password.
Create this file first and run this script again:
echo "[client]" > /root/.my.cnf
echo "user=root" >> /root/.my.cnf
echo "password=your_SQL_ROOT_password" >> /root/.my.cnf
chmod 0600 /root/.my.cnf
EOF
msg "EXIT on error due to not found file with your MySQL/MariaDB root password."
echo " "
exit 1
fi
fi
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "INFO: We need to install wget, axel, netcat & git first, please wait..."
sleep 3
apt-get update &> /dev/null
$_INITINS locales &> /dev/null
sleep 5
_LOC_TEST=`locale 2>&1`
if [[ $_LOC_TEST =~ Cannot ]] ; then
_LOCALE_TEST=BROKEN
msg "WARNING!"
cat <<EOF
Locales on this system are broken or not installed
and/or not configured correctly yet. This is "default"
issue at RackSpaceCloud (and maybe others).
We will fix this problem for you now, so you shouldn't
use any tricks to change system/ssh settings before
running this Barracuda installer.
You can experience problems if your SSH client
forces locales other than en_US.UTF-8 we are using by default.
You should log out when Barracuda will finish all its tasks
and display last line with "BYE!" and then log in again
to see the result (and possibly run Octopus installer).
We will continue in 30 seconds...
EOF
sleep 30
locale-gen en_US en_US.UTF-8 &> /dev/null
update-locale &> /dev/null
localedef -v -c -i en_US -f UTF-8 en_US.UTF-8 &> /dev/null
echo "LANG=en_US.UTF-8" > /etc/default/locale
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
echo "export LANG=en_US.UTF-8" >> /root/.bashrc
echo "export LC_ALL=en_US.UTF-8" >> /root/.bashrc
echo "export LANGUAGE=en_US.UTF-8" >> /root/.bashrc
else
_LOCALE_TEST=OK
locale-gen en_US en_US.UTF-8 &> /dev/null
fi
$_INITINS wget git-core axel netcat &> /dev/null
fi
###--------------------###
msg "INFO: Testing Gitorious and GitHub servers availability, please wait..."
sleep 3
_GITORIOUS_WORKS=YES
_GITHUB_WORKS=YES
if ! netcat -w 8 -z gitorious.org 9418 ; then
_GITORIOUS_WORKS="NO"
cat <<EOF
The Gitorious master repository server doesn't respond now,
let's try GitHub mirror...
EOF
elif ! netcat -w 8 -z github.com 9418 ; then
_GITHUB_WORKS="NO"
cat <<EOF
The GitHub mirror repository server doesn't respond now,
so we can't continue this installation.
Please try again later.
Bye.
EOF
exit 1
else
true
fi
if [ $_GITORIOUS_WORKS = "YES" ] ; then
_BOA_REPO_NAME="barracuda-octopus"
_BOA_REPO_GIT_URL="git://gitorious.org/aegir"
msg "INFO: Gitorious master repository will be used for this install"
elif [ $_GITHUB_WORKS = "YES" ] ; then
_BOA_REPO_NAME="nginx-for-drupal"
_BOA_REPO_GIT_URL="git://github.com/omega8cc"
msg "INFO: GitHub mirror repository will be used for this install"
fi
###--------------------###
if [ -d "/usr/share/git-core" ] ; then
msg "INFO: Fix for possibly broken git-core after upgrade to version: 1:1.5.6.5-3+lenny3.1"
sleep 3
chmod 644 /usr/share/git-core/templates/description &> /dev/null
chmod 644 /usr/share/git-core/templates/hooks/* &> /dev/null
chmod 644 /usr/share/git-core/templates/info/* &> /dev/null
fi
###--------------------###
msg "INFO: Downloading little helpers, please wait..."
sleep 3
#
# Git clone all
cd /opt/tmp
rm -f -r /opt/tmp/$_BOA_REPO_NAME
git clone $_BOA_REPO_GIT_URL/$_BOA_REPO_NAME.git &> /dev/null
#
# Get apt helper
rm -f apt.conf.noninteractive*
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/helpers/apt.conf.noninteractive ./
#
# Create tmp stuff
_LOG=/opt/tmp/aegir-install.log
_SILENT=/opt/tmp/silent.log
cd $_SRCDIR
#
# Get spinner
rm -f spinner*
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/helpers/spinner ./
chmod +x spinner &> /dev/null
#
# Get axelerator
if [ ! -e "/usr/bin/apt-fast" ] ; then
cd /usr/bin
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/helpers/apt-fast.sh.txt ./
mv -f apt-fast.sh.txt apt-fast &> /dev/null
chmod +x apt-fast &> /dev/null
cd /opt/tmp
fi
###--------------------###
if [ $_STATUS = "INIT" ] ; then
msg "INFO: Installing lsb-release and dnsutils now, please wait..."
mrun "sleep 3"
if ! st_runner "$_INSTALL lsb-release dnsutils"; then
fatal "Installation failed: $?"
fi
fi
###--------------------###
msg "STATUS: Checking your Debian or Ubuntu version..."
mrun "sleep 3"
_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
elif [ $_THIS_OS = "Jolicloud" ] ; then
if [ $_THIS_RV = "robby" ] ; then
_THIS_OS=Ubuntu
_REL_VERSION=jaunty
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 3"
###--------------------###
if [ $_STATUS = "INIT" ] ; then
if [ ! -z "$_LOCAL_NETWORK_IP" ] ; then
if [ -z "$_LOCAL_NETWORK_HN" ] ; then
msg "FATAL ERROR: you must specify also _LOCAL_NETWORK_HN"
exit 1
else
_DNS_SETUP_TEST=NO
_SMTP_RELAY_TEST=NO
_DEBUG_MODE=YES
_MY_OWNIP="$_LOCAL_NETWORK_IP"
_MY_HOSTN="$_LOCAL_NETWORK_HN"
_MY_FRONT="$_LOCAL_NETWORK_HN"
fi
fi
fi
###--------------------###
if [ $_STATUS = "INIT" ] ; then
_ETH_TEST=`ifconfig 2>&1`
if [[ $_ETH_TEST =~ venet0 ]] ; then
_VMFAMILY="VZ"
_IFCONFIG="venet0:0"
elif [ -e "/proc/bean_counters" ] ; then
_VMFAMILY="VZ"
_IFCONFIG="venet0:0"
else
_VMFAMILY="XEN"
_IFCONFIG="eth0"
fi
if [ ! -z "$_MY_OWNIP" ] ; then
if [ ! -z "$_MY_HOSTN" ] ; then
_S_N=$_MY_HOSTN
_S_T=${_S_N#*.*}
_S_Q=${_S_N%%${_S_T}}
_S_E=${_S_Q%*.*}
if [ ! -z "$_LOCAL_NETWORK_HN" ] ; then
echo "$_MY_OWNIP .$_MY_HOSTN $_S_E" >> /etc/hosts
else
_TURNED=OFF
#echo "$_MY_OWNIP .$_MY_HOSTN $_S_E" >> /etc/hosts
fi
hostname -v $_MY_HOSTN ### force our custom FQDN/local hostname
echo "$_MY_HOSTN" > /etc/hostname
echo "$_MY_HOSTN" > /etc/mailname
fi
_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=`uname -n`
_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=`uname -n 2> /dev/null`
_FQDNTEST="FALSE"
_THISHOST=`uname -n`
if [ ! -z "$_FQDNPROB" ] ; then
_THISHOST=`uname -n`
_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 [ "$_DNS_SETUP_TEST" = "NO" ] ; then
_FQDNTEST=TRUE
fi
if [ $_THISHOST = "localhost" ] ; then
msg "FATAL ERROR: you can't use localhost as your FQDN hostname"
msg "Please try something like: aegir.local"
exit 1
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":
$ uname -n
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
echo "$_THISHOST" > /etc/mailname
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 3"
echo " "
msg "INSTALL START -> checkpoint: "
cat <<EOF
* Your e-mail address appears to be $_MY_EMAIL - is that correct?
* Your IP address appears to be $_THISHTIP - are you sure it's a valid IP?
* Your hostname appears to be $_THISHOST - are you sure it's a valid FQDN hostname?
NOTE: If your outgoing SMTP requires using relayhost, define _SMTP_RELAY_HOST first.
* Your core Aegir instance control panel will be available at https://$_THIS_FRONT.
* Your (optional) fast DNS cache server (pdnsd) will listen on 127.0.0.1:53.
* Your (optional) Bind9 DNS Server will listen on $_THISHTIP:53.
* Your (optional) MultiCore Apache Solr Tomcat will listen on 127.0.0.1:8080.
* Your (optional) Chive MariaDB Manager will be available at https://chive.$_THIS_FRONT.
* Your (optional) SQL Buddy MariaDB Manager will be available at https://sqlbuddy.$_THIS_FRONT.
* Your (optional) Collectd Graph Panel will be available at https://cgp.$_THIS_FRONT.
* Your (optional) Webmin Control Panel will be available at https://$_THISHOST:10000.
NOTE: Chive, SQL Buddy and Collectd will work only if chive. sqlbuddy. and cgp.
subdomains point to your IP (we recommend using wildcard DNS to simplify it).
But don't worry, you can add proper DNS entries for those subdomains later,
if you didn't enable wildcard DNS yet. Barracuda can install it all now, anyway.
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"`
if [ -e "/var/aegir/.drush/hostmaster.alias.drushrc.php" ] ; then
_THIS_FRONT=`cat /var/aegir/.drush/hostmaster.alias.drushrc.php | grep "uri'" | cut -d: -f2 | awk '{ print $3}' | sed "s/[\,']//g"`
elif [ ! -z "$_MY_FRONT" ] ; then
_THIS_FRONT="$_MY_FRONT"
else
msg "EXIT on error due to not found or not specified Aegir domain."
msg "Please specify your previously working Aegir domain as a value of _MY_FRONT."
echo " "
exit 1
fi
mrun "sleep 3"
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
###--------------------###
if [ $_THIS_DB_HOST = "FQDN" ] ; then
_THIS_DB_HOST="$_THISHOST"
fi
###--------------------###
msg "INFO: Clean up temp files in /var/opt/"
mrun "sleep 3"
rm -f -r /var/opt/*
mkdir -p /var/log/php
chmod 777 /var/log/php* &> /dev/null
###--------------------###
_INSTALL_PDNSD=NO
_HOSTN_TEST=`hostname -f 2>&1`
if [[ $_HOSTN_TEST =~ "Name or service not known" ]] ; then
_INSTALL_PDNSD=YES
fi
if [ ! -z "$_LOCAL_NETWORK_HN" ] ; then
_INSTALL_PDNSD=YES
fi
if [ $_INSTALL_PDNSD = "YES" ] ; then
if [ ! -e "/usr/sbin/pdnsd" ] ; then
msg "INFO: Installing DNS cache pdnsd, please wait..."
mrun "sleep 3"
cp -a /etc/resolv.conf /var/backups/resolv.conf.bak
st_runner "$_INSTALL pdnsd resolvconf";
perl -p -i -e "s/START_DAEMON=no/START_DAEMON=yes/g" /etc/default/pdnsd
cat /opt/tmp/$_BOA_REPO_NAME/aegir/conf/pdnsd.conf > /etc/pdnsd.conf
st_runner "invoke-rc.d pdnsd stop" &> /dev/null
rm -f /var/cache/pdnsd/pdnsd.cache
st_runner "invoke-rc.d pdnsd start" &> /dev/null
mrun "sleep 3"
st_runner "invoke-rc.d pdnsd stop" &> /dev/null
mrun "sleep 3"
rm -f /var/cache/pdnsd/pdnsd.cache
st_runner "invoke-rc.d pdnsd start" &> /dev/null
fi
fi
###--------------------###
#if [ $_STATUS = "INIT" ] ; then
if [ ! -e "/var/log/apt-fast-install-log.txt" ] ; then
msg "INFO: Update apt sources"
mrun "sleep 3"
mv -f /etc/apt/sources.list /var/backups/sources.list-pre-$_INSTALLER_VERSION-$_NOW &> /dev/null
if [ "$_THIS_OS" = "Ubuntu" ] ; then
if [ -z "$_LOCAL_UBUNTU_MIRROR" ] ; then
msg "INFO: Now looking for the best/fastest $_THIS_OS mirror, it can take a while, please wait..."
mrun "sleep 3"
cd /opt/tmp/$_BOA_REPO_NAME/aegir/helpers
_MIRROR=`bash ffmirror.sh.txt < apt-list-ubuntu.txt`
_MIRROR=`bash ffmirror.sh.txt < apt-list-ubuntu.txt`
echo " "
prompt_confirm_choice "Enter your own mirror to use or press enter to use the fastest found mirror" $_MIRROR
echo " "
_MIRROR=$_CONFIRMED_ANSWER
else
_MIRROR=$_LOCAL_UBUNTU_MIRROR
fi
if ! netcat -w 5 -z $_MIRROR 80 ; then
msg "INFO: The mirror $_MIRROR doesn't respond now, let's try default"
_MIRROR=archive.ubuntu.com
fi
msg "INFO: We will use $_THIS_OS mirror $_MIRROR"
cd /var/opt