-
Notifications
You must be signed in to change notification settings - Fork 75
/
OCTOPUS.sh.txt
executable file
·2168 lines (2076 loc) · 74 KB
/
OCTOPUS.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
###----------------------------------------###
###
### Octopus Aegir Installer
###
### Copyright (C) 2010-2014 Omega8.cc
### noc@omega8.cc www.omega8.cc
###
### This program is free software. You can
### redistribute it and/or modify it under
### the terms of the GNU GPL as published by
### the Free Software Foundation, version 2
### or later.
###
### This program is distributed in the hope
### that it will be useful, but WITHOUT ANY
### WARRANTY; without even the implied
### warranty of MERCHANTABILITY or FITNESS
### FOR A PARTICULAR PURPOSE. See the GNU GPL
### for more details.
###
### You should have received a copy of the
### GNU GPL along with this program.
### If not, see http://www.gnu.org/licenses/
###
### Code: https://code.aegir.cc/aegir
###
###----------------------------------------###
###----------------------------------------###
### HOW-TO: run it with bash, not with sh ###
###----------------------------------------###
###
### $ bash OCTOPUS.sh.txt
###
###----------------------------------------###
### EDITME ###
###----------------------------------------###
###
### Enter below your valid e-mail address and
### the (sub)domain for this Aegir Satellite
### Instance, already pointing to your server.
### Define also your *new* Aegir user for this
### instance or existing if this is an upgrade
###
### NOTE: if this is an upgrade, it's enough
### to define the _USER value only, since
### _DOMAIN etc. will be auto-discovered
### and you can't override it here nor even
### in the /root/.${_USER}.octopus.cnf file.
###
_USER=o1
_DOMAIN=$_USER.`uname -n`
_MY_EMAIL="noc@omega8.cc"
_CLIENT_EMAIL="notify@omega8.cc"
_CLIENT_OPTION=SSD
_CLIENT_SUBSCR=Y
_CLIENT_CORES=8
###----------------------------------------###
### EASY LOCALHOST MODE ###
###----------------------------------------###
###
### This option is available and enabled
### automatically only when Barracuda has been
### installed with option _EASY_LOCALHOST=YES
###
### It will automate/force only some of other
### Octopus configuration options, as listed
### below:
###
### _PHP_FPM_VERSION=5.3
### _PHP_CLI_VERSION=5.3
### _DEBUG_MODE=NO
### _AEGIR_VERSION=BOA-2.2.9
### _DNS_SETUP_TEST=NO
### _THIS_DB_HOST=localhost
### _LOCAL_NETWORK_IP="127.0.1.1"
### _DOMAIN=$_USER.sub.aegir.local
###
### Thanks to local DNS wildcard, you will be
### able to use many levels of subdomains for
### created sites, for example:
### site.aegir.local, abc.xyz.site.aegir.local
### This wildcard will rely only on the local,
### basic DNS system, without any need to use
### external DNS.
###
###----------------------------------------###
### PHP-FPM VERSION ###
###----------------------------------------###
###
### You can choose PHP-FPM version per Aegir
### Satellite Instance - both on install and
### upgrade.
###
### Available options (if installed):
###
### _PHP_FPM_VERSION=5.5
### _PHP_FPM_VERSION=5.4
### _PHP_FPM_VERSION=5.3
### _PHP_FPM_VERSION=5.2
###
### Note that 5.3 will be set automatically
### if you specify any other, not installed
### version.
###
_PHP_FPM_VERSION=5.3
###----------------------------------------###
### PHP-CLI VERSION ###
###----------------------------------------###
###
### You can choose PHP-CLI version per Aegir
### Satellite Instance - both on install and
### upgrade.
###
### Available options (if installed):
###
### _PHP_CLI_VERSION=5.5
### _PHP_CLI_VERSION=5.4
### _PHP_CLI_VERSION=5.3
### _PHP_CLI_VERSION=5.2
###
### Note that 5.3 will be set automatically
### if you specify any other, not installed
### version.
###
_PHP_CLI_VERSION=5.3
###----------------------------------------###
### PLATFORMS INSTALL MODE ###
###----------------------------------------###
###
### You can use wildcard "ALL" to install all
### available platforms or configure the list
### of platforms to be installed as explained
### below.
###
### Note: the "ALL" wildcard is not default!
###
### When combined with _AUTOPILOT=YES option
### you can speed up the process and still
### control which platforms will be installed,
### using the symbols listed below.
###
### D8D ----------- Drupal 8 dev-tested (off)
### D8E ----------- Drupal 8 dev-edge (off)
### D7P D7S D7D --- Drupal 7 prod/stage/dev
### D6P D6S D6D --- Pressflow 6 p/s/d
### AGV ----------- aGov
### AQ6 ----------- Acquia D6 (off)
### CM6 ----------- CiviCRM 4.1.6 D6 (off)
### CM7 ----------- CiviCRM 4.3.7 D7 (off)
### CME ----------- Commerce v.2
### COD ----------- Conference (off)
### CS7 ----------- Commons 7
### DCE ----------- Commerce v.1
### DCS ----------- Commons 6
### ERP ----------- ERPAL
### FSR ----------- Feature Server
### GDR ----------- Guardr
### MNS ----------- Managing News
### OA7 ----------- Open Atrium D7
### OAM ----------- Open Atrium D6
### OAY ----------- Open Academy
### OBG ----------- OpenBlog
### OCH ----------- OpenChurch
### ODS ----------- Open Deals
### OOH ----------- Open Outreach
### OPC ----------- OpenPublic
### OPH ----------- OpenPublish (off)
### OSR ----------- OpenScholar
### PPT ----------- ProsePoint (off)
### PPY ----------- Panopoly
### RER ----------- Recruiter
### RST ----------- Restaurant
### SRK ----------- Spark
### TTM ----------- Totem
### UC7 ----------- Ubercart D7
### UCT ----------- Ubercart D6
###
### Examples:
###
### _PLATFORMS_LIST=ALL
### _PLATFORMS_LIST="D7P D6P PPY RST OOH"
###
_PLATFORMS_LIST="D7P D7S D7D D6P D6S D6D"
###----------------------------------------###
### UNSUPPORTED (off) DISTROS INSTALL ###
###----------------------------------------###
###
### If you wish to install also distros listed
### above as (off), change the option below
### to: _ALLOW_UNSUPPORTED=YES
###
### Note that this option works only with BOA
### HEAD and not stable version.
###
_ALLOW_UNSUPPORTED=NO
###----------------------------------------###
### AUTOPILOT MODE ###
###----------------------------------------###
###
### To disable all Yes/no prompts and just run
### everything as-is, change this to YES.
###
### _AUTOPILOT=YES
###
_AUTOPILOT=NO
###----------------------------------------###
### UPGRADE MODE ###
###----------------------------------------###
###
### To upgrade Hostmaster without installing
### new platforms, change this to YES.
###
### Don't use this option for initial install.
###
### _HM_ONLY=YES
###
_HM_ONLY=NO
###----------------------------------------###
### O_CONTRIB UPGRADE ###
###----------------------------------------###
###
### To upgrade o_contrib modules in the latest
### and one previous platforms series 00x
### change this to YES.
###
### This option is available only on Aegir
### Satellite Instance upgrade.
###
### _O_CONTRIB_UP=YES
###
_O_CONTRIB_UP=NO
###----------------------------------------###
### DRUSH DEBUG MODE ###
###----------------------------------------###
###
### When set to YES it will run this Satellite
### Instance install/upgrade with -d option,
### displaying complete Drush backend report.
###
### _DEBUG_MODE=YES
###
_DEBUG_MODE=NO
###----------------------------------------###
### FORCED IP MODE ###
###----------------------------------------###
###
### To install or upgrade Aegir Satellite
### Instance on any non-default IP address
### available on your server/machine, please
### define it below. For default, main IP
### based install, leave this empty.
###
### _MY_OWNIP=123.45.67.89
###
_MY_OWNIP=""
###----------------------------------------###
### AEGIR BARRACUDA VERSION ###
###----------------------------------------###
###
### By default latest release version will
### be installed. Please never use HEAD (dev)
### version on any production server.
### The HEAD can be occasionally broken
### and should be used **only** for testing!
###
### _AEGIR_VERSION=HEAD
### _AEGIR_VERSION=BOA-2.2.9
###
_AEGIR_VERSION=BOA-2.2.9
###----------------------------------------###
### FORCE PREFERRED GIT REPOSITORY ###
###----------------------------------------###
###
### Use this when you are experiencing issues
### trying to connect to the default github
### repository. Valid options:
###
### _FORCE_GIT_MIRROR=github
### _FORCE_GIT_MIRROR=gitorious
###
### Note: with forced mirror the script will
### not try to connect and then switch to
### alternate mirror. It will simply fail
### if the forced mirror doesn't respond.
###
### We recommend github - it is much faster.
###
_FORCE_GIT_MIRROR=""
###----------------------------------------###
### 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
###----------------------------------------###
### DATABASE CUSTOM HOST ###
###----------------------------------------###
###
### If you prefer, you can set the database
### to be connected via FQDN pointing to your
### public IP instead of default "localhost".
###
### Note: the "FQDN" is a keyword.
### Don't replace it with a real hostname.
###
### For local or Amazon based installs with
### local/dynamic IP address it is recommended
### to use default "localhost" option.
###
### Available options:
###
### _THIS_DB_HOST=localhost
### _THIS_DB_HOST=FQDN
###
_THIS_DB_HOST=localhost
###----------------------------------------###
### DISTRO INITIAL VERSION NR ###
###----------------------------------------###
###
### By default every new Aegir Satellite
### Instance will use shared code for its
### platforms, created during previous Aegir
### Satellite Instance install or upgrade,
### resulting with new 00x number in the
### /data/all directory.
###
### It is not always good, since you want
### to keep the code shared between instances,
### but you also don't want to create a new
### instance with outdated code if your last
### install/upgrade was performed a few months
### ago.
###
### If you don't want to build a new Aegir
### Satellite Instance with latest code, then
### leave it at default value. Otherwise
### change it to:
###
### _HOT_SAUCE=YES
###
_HOT_SAUCE=NO
###----------------------------------------###
### DISTRO USING EXISTING VERSION NR ###
###----------------------------------------###
###
### We changed the default to YES to avoid
### creating many duplicated platforms on
### every Aegir Satellite Instance upgrade,
### when there is no new core, thus no reason
### to create newer platforms for the same
### distributions versions.
###
### It will also allow you to add some newer
### platforms to the existing shared code,
### which helps to keep your opcache memory
### as low as possible without fragmentation.
###
### When set to _USE_CURRENT=NO it will force
### creating new set (with increased serial
### number) of *all* platforms on upgrade,
### so it is useful *only* when there is
### a newer Drupal core version released, or
### when newer Pressflow head includes some
### important fixes.
###
### Note: it will not work at all if you are
### using _HOT_SAUCE=YES above, because
### _HOT_SAUCE=YES forces new serial number
### both on install and upgrade.
###
_USE_CURRENT=YES
###----------------------------------------###
### DELETE OLD EMPTY PLATFORMS ###
###----------------------------------------###
###
### Change to any integer greater than "0" to
### automatically delete empty platforms with
### no sites hosted, during daily cleanup,
### if verified more than X days ago, where X
### is a number of days defined below.
### If "0" then this option is disabled.
###
_DEL_OLD_EMPTY_PLATFORMS="0"
###----------------------------------------###
### DELETE OLD BACKUPS ###
###----------------------------------------###
###
### Change to any integer greater than "0" to
### automatically delete backups stored in the
### /data/disk/U/backups/ directory and in all
### hosted sites backup_migrate directories,
### during daily cleanup, if created more
### than X days ago, where X is a number
### of days defined below. If "0" then
### this option is disabled.
###
_DEL_OLD_BACKUPS="0"
###----------------------------------------###
### DELETE OLD TMP FILES ###
###----------------------------------------###
###
### Change to any integer greater than "0" to
### automatically delete temporary files
### in all hosted sites files/tmp/ and also
### private/temp/ directories, during daily
### cleanup, if created more than X days ago,
### where X is a number of days defined below.
### If "0" then this option is disabled.
###
_DEL_OLD_TMP="0"
###----------------------------------------###
### LOCALHOST ON LOCAL NETWORK ###
###----------------------------------------###
###
### When enabled, it will force your Nginx web
### server to listen only on local IP:
###
### _LOCAL_NETWORK_IP=10.10.80.80
###
### 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 on upgrade.
###
### You should use this option only when you
### already used it with initial Barracuda
### install. It will override any defined
### above _MY_OWNIP value and disable DNS test
### automatically.
###
_LOCAL_NETWORK_IP=""
###----------------------------------------###
### STOCK AEGIR TESTING ###
###----------------------------------------###
###
### Change to YES to try Stock Aegir 2.x with
### Drush 5.x - without any BOA specific
### modifications or improvements. This option
### is enabled on command line when you type
### "stock" instead of "mini", "max" or "ask".
###
_USE_STOCK=NO
###----------------------------------------###
### STRONG PASSWORDS ###
###----------------------------------------###
###
### Use YES only if both "randpass 32 esc"
### and "randpass 32 alnum" commands produce
### well looking, strong passwords and not
### some binary garbage, which is typically
### a sign of unreliable /dev/urandom.
### See: https://drupal.org/node/1952042
###
### By default new passwords are generated
### with "pwgen -v -s -1" command.
###
_STRONG_PASSWORDS=NO
###----------------------------------------###
### DB ENGINE AUTO-CONVERSION ###
###----------------------------------------###
###
### Automatic, running daily DB conversion to
### InnoDB or MyISAM for all sites hosted on
### the instance via the 'sqlmagic' tool.
###
### If _SQL_CONVERT=NO is set, the conversion
### mode can be individually enabled and more
### precisely configured with variable:
###
### sql_conversion_mode
###
### if set in the site and/or platform level,
### active INI files:
###
### boa_platform_control.ini
### boa_site_control.ini
###
### More info: https://omega8.cc/node/293
###
### Please note that if you will change it
### to _SQL_CONVERT=YES, the system will
### ignore sql_conversion_mode variables set
### in the active INI files, and instead will
### force conversion to InnoDB format in all
### sites hosted on this instance.
###
### Note that it will run daily on all sites
### even if all tables have been already
### converted to the desired format/engine.
###
### This behaviour has two purposes. It will
### effectively run OPTIMIZE foo; on all,
### even already converted tables via the
### ALTER TABLE foo ENGINE=bar; command.
### It will also make sure that any newly
### created table will receive expected
### format/engine, despite system or Drupal
### core defaults.
###
### Accepted values:
###
### innodb (forced globally)
### myisam (forced globally)
### YES (same as innodb, forced globally)
### NO (nothing forced globally)
###
_SQL_CONVERT=NO
###----------------------------------------###
### ADVANCED CONFIGURATION OPTIONS ###
###----------------------------------------###
###
### AUTO will default to value calculated
### on the fly and based on available RAM.
### You can force workers number for PHP-FPM.
###
_PHP_FPM_WORKERS=AUTO
###
### AUTO will not modify default TTL (180).
### You can lower it to any number < 180.
###
_PHP_FPM_TIMEOUT=AUTO
###
### You can define custom list of functions
### to disable besides those already denied
### in the system level 'disable_functions'.
###
### Note: If this option is left empty, BOA
### will deny access also to function:
###
### passthru
###
### If _PHP_FPM_DENY is *not* empty, its value
### will *replace* 'passthru', so any denied
### function must be listed explicitly.
###
### Note that while it will improve security
### it will also break modules which rely
### on any of disabled functions.
###
### This option affects only this Satellite
### Instance. It is not affected by the same
### option set in the Barracuda Master.
###
### Example:
###
### _PHP_FPM_DENY="system,exec,shell_exec"
###
_PHP_FPM_DENY=""
###
### Define the amount of RAM you want to keep
### reserved for other services installed which
### are not controlled by BOA, so it will
### assume that available RAM is the value of
### $_RAM - $_RESERVED_RAM (in MB).
###
### Example for 256MB: _RESERVED_RAM=256
###
_RESERVED_RAM=0
###----------------------------------------###
### DON'T EDIT ANYTHING BELOW THIS LINE ###
###----------------------------------------###
_INSTALLER_VERSION=BOA-2.2.9
###
### Variables
###
_DRUSH_VERSION=mini-4-14-03-2014
_NOW=`date +%y%m%d-%H%M`
_PLATFORMS_ONLY=NO
_PURGE_FOR_SEVEN=YES
_REDIS_M_VERSION=mod-21-07-2014
_SMALLCORE6=6.33.1
_SMALLCORE7=7.31.1
_SMALLCORE8=8.0-alpha4
_SPINNER=YES
_T_BUILD=HEAD
_TODAY=`date +%y%m%d`
_USRG=users
_WEBG=www-data
PATH=/usr/local/bin:/usr/local/sbin:/opt/local/bin:/usr/bin:/usr/sbin:/bin:/sbin
SHELL=/bin/bash
if [ -n "${STY+x}" ]; then
_SPINNER=NO
fi
if [ "$_USE_STOCK" = "YES" ] ; then
_DRUSH_VERSION=mini-6-14-08-2014
fi
###
### Distributions
###
_AGOV=7.x-1.2
_CIVICRM_M6=4.1.6
_CIVICRM_M7=4.3.7
_CIVICRM_PN=boa-2.2.9-dev
_COD=7.x-1.0-alpha5
_COMMERCE1=7.x-1.29
_COMMERCE2=7.x-2.17
_COMMONS2=6.x-2.20
_COMMONS3=7.x-3.17
_DRUPAL_EDGE_8="8.0-dev-$_TODAY-edge"
_DRUPAL7="drupal-$_SMALLCORE7"
_DRUPAL8="8.0-dev-120915"
_ERPAL=7.x-2.0-beta5
_GUARDR=7.x-1.11
_MANAGINGNEWS=1.2.4
_OPEN_DEALS=1.33
_OPENACADEMY=7.x-1.0
_OPENATRIUM6=6.x-1.7
_OPENATRIUM7=7.x-2.21
_OPENBLOG=7.x-1.0-alpha3
_OPENCHURCH=7.x-1.12
_OPENDEALS=7.x-1.33
_OPENOUTREACH=7.x-1.10
_OPENPUBLIC=7.x-1.0-rc4
_OPENPUBLISH=7.x-1.0-beta7
_OPENSCHOLAR=7.x-3.12.1
_PANOPOLY=7.x-1.11
_PROSEPOINT=0.46
_RECRUITER=7.x-1.2
_RESTAURANT=7.x-1.0-beta2
_SPARK=7.x-1.0-beta1
_TOTEM=7.x-1.1
_UBERCART6=2.13
_UBERCART7=3.6
###---### Functions
#
# Noticeable messages.
msg () {
echo "Octopus [`date`] ==> $*"
}
# Simple prompt.
prompt_yes_no () {
if [ "$_AUTOPILOT" = "YES" ] ; then
return 0
else
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
fi
}
#
# Small spinner.
mrun () {
CMD="$1"
touch busy
if [ "$_SPINNER" = "YES" ] ; then
bash $_SRCDIR/spinner busy &
fi
if $CMD >> $_LOG; then
rm busy
sleep 1
return 0
fi
}
#
# Tune FPM workers.
tune_fpm_workers () {
_ETH_TEST=`ifconfig 2>&1`
_VM_TEST=`uname -a 2>&1`
if [[ "$_ETH_TEST" =~ "venet0" ]] ; then
_VMFAMILY="VZ"
elif [ -e "/proc/bean_counters" ] ; then
_VMFAMILY="VZ"
elif [[ "$_THISHOST" =~ ".host8." ]] && [ -e "/boot/grub/menu.lst" ] ; then
_VMFAMILY="TG"
elif [[ "$_THISHOST" =~ ".host8." ]] && [ -e "/boot/grub/grub.cfg" ] ; then
_VMFAMILY="TG"
else
_VMFAMILY="XEN"
fi
if [[ "$_VM_TEST" =~ beng ]] ; then
_VMFAMILY="VS"
fi
if [[ "$_AWS_TEST_A" =~ "cloudimg" ]] || [[ "$_AWS_TEST_B" =~ "cloudconfig" ]] ; then
_VMFAMILY="AWS"
fi
_RAM=`free -mto | grep Mem: | awk '{ print $2 }'`
if [ "$_RESERVED_RAM" -gt "0" ] ; then
let "_RAM = (($_RAM - $_RESERVED_RAM))"
fi
let "_USE = (($_RAM / 4))"
if [ "$_USE" -ge "512" ] && [ "$_USE" -lt "1024" ] ; then
if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then
_L_PHP_FPM_WORKERS=12
else
_L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS
fi
elif [ "$_USE" -ge "1024" ] ; then
if [ "$_VMFAMILY" = "XEN" ] || [ "$_VMFAMILY" = "AWS" ] ; then
if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then
_L_PHP_FPM_WORKERS=24
else
_L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS
fi
elif [ "$_VMFAMILY" = "VS" ] || [ "$_VMFAMILY" = "TG" ] ; then
if [ -e "/boot/grub/grub.cfg" ] || [ -e "/boot/grub/menu.lst" ] || [ -e "/root/.tg.cnf" ] ; then
if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then
_L_PHP_FPM_WORKERS=24
else
_L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS
fi
else
if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then
_L_PHP_FPM_WORKERS=6
else
_L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS
fi
fi
else
if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then
_L_PHP_FPM_WORKERS=12
else
_L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS
fi
fi
else
if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then
_L_PHP_FPM_WORKERS=6
else
_L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS
fi
fi
}
#
# Tune FPM configuration.
tune_fpm_config () {
tune_fpm_workers
_LIM_FPM="$_L_PHP_FPM_WORKERS"
if [ "$_LIM_FPM" -lt "24" ] ; then
if [[ "$_THISHOST" =~ ".host8." ]] || [ "$_VMFAMILY" = "VS" ] ; then
_LIM_FPM=24
fi
fi
if [ "$_CLIENT_OPTION" = "MICRO" ] ; then
_LIM_FPM=2
_PHP_FPM_WORKERS=4
fi
let "_CHILD_MAX_FPM = (($_LIM_FPM * 2))"
if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then
_DO_NOTHING=YES
else
_PHP_FPM_WORKERS=${_PHP_FPM_WORKERS//[^0-9]/}
if [ ! -z "$_PHP_FPM_WORKERS" ] && [ "$_PHP_FPM_WORKERS" -gt "0" ] ; then
_CHILD_MAX_FPM="$_PHP_FPM_WORKERS"
fi
fi
_PHP_SV=${_PHP_FPM_VERSION//[^0-9]/}
if [ -z "$_PHP_SV" ] ; then
_PHP_SV=53
fi
if [ -e "/opt/php55/etc/pool.d/${_USER}.conf" ] ; then
_PHP_OLD_SV=55
elif [ -e "/opt/php54/etc/pool.d/${_USER}.conf" ] ; then
_PHP_OLD_SV=54
elif [ -e "/opt/php53/etc/pool.d/${_USER}.conf" ] ; then
_PHP_OLD_SV=53
else
_PHP_OLD_SV=""
fi
if [ "$_PHP_FPM_TIMEOUT" = "AUTO" ] || [ -z "$_PHP_FPM_TIMEOUT" ] ; then
_PHP_FPM_TIMEOUT=180
fi
_PHP_FPM_TIMEOUT=${_PHP_FPM_TIMEOUT//[^0-9]/}
if [ "$_PHP_FPM_TIMEOUT" -lt "60" ] ; then
_PHP_FPM_TIMEOUT=60
fi
if [ ! -e "/var/xdrago/conf/fpm-pool-foo.conf" ] ; then
mkdir -p /var/xdrago/conf
fi
cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/fpm-pool-foo.conf /var/xdrago/conf/fpm-pool-foo.conf
if [ ! -z "$_PHP_FPM_TIMEOUT" ] && [ ! -z "$_PHP_SV" ] ; then
if [ -e "/var/xdrago/conf/fpm-pool-foo.conf" ] ; then
rm -f /opt/php*/etc/pool.d/${_USER}.conf
cp -af /var/xdrago/conf/fpm-pool-foo.conf /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf
fi
if [ -e "/opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf" ] ; then
sed -i "s/foo/$_USER/g" /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf &> /dev/null
if [ ! -z "$_PHP_FPM_DENY" ] ; then
sed -i "s/passthru,/$_PHP_FPM_DENY,/g" /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf &> /dev/null
fi
fi
_PHP_TO="${_PHP_FPM_TIMEOUT}s"
sed -i "s/180s/$_PHP_TO/g" /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf &> /dev/null
if [ ! -z "$_CHILD_MAX_FPM" ] ; then
sed -i "s/pm.max_children =.*/pm.max_children = $_CHILD_MAX_FPM/g" /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf &> /dev/null
fi
if [ ! -d "/data/disk/$_USER/tmp" ] ; then
rm -f -r /data/disk/$_USER/tmp
mkdir -p /data/disk/$_USER/tmp
chown $_USER:www-data /data/disk/$_USER/tmp &> /dev/null
fi
if [ ! -z "$_PHP_OLD_SV" ] && [ -e "/etc/init.d/php${_PHP_OLD_SV}-fpm" ] ; then
mrun "service php${_PHP_OLD_SV}-fpm reload" &> /dev/null
fi
if [ -e "/etc/init.d/php${_PHP_SV}-fpm" ] ; then
mrun "service php${_PHP_SV}-fpm reload" &> /dev/null
fi
fi
}
#
# Make sure that username is unique and not restricted.
check_id () {
_ID_EXISTS=$(getent passwd $_USER 2>&1)
if [ -z "$_ID_EXISTS" ] ; then
_DO_NOTHING=YES
elif [[ "$_ID_EXISTS" =~ "$_USER" ]] ; then
msg "ERROR: $_USER username is already taken"
msg "Please choose different _USER"
exit 1
else
msg "ERROR: $_USER username check failed"
msg "Please try different _USER"
exit 1
fi
if [ "$_USER" = "admin" ] || [ "$_USER" = "hostmaster" ] || [ "$_USER" = "barracuda" ] || [ "$_USER" = "octopus" ] || [ "$_USER" = "boa" ] ; then
msg "ERROR: $_USER is a restricted username, please choose different _USER"
exit 1
elif [[ "$_USER" =~ "drupal" ]] || [[ "$_USER" =~ "drush" ]] || [[ "$_USER" =~ "sites" ]] || [[ "$_USER" =~ "default" ]] ; then
msg "ERROR: $_USER includes restricted keyword, please choose different _USER"
exit 1
fi
_REGEX="^[[:digit:]]"
if [[ "$_USER" =~ "$_REGEX" ]] ; then
msg "ERROR: $_USER is a wrong username, it should start with a letter, not digit"
exit 1
fi
}
#
# Find correct IP.
find_correct_ip () {
_LOC_IP=`echo $(getent ahostsv4 $_LOC_DOM) | cut -d: -f2 | awk '{ print $1}'`
}
#
# Check repo status.
check_git_repos_status () {
_GITHUB_WORKS=NO
_GITORIOUS_WORKS=NO
if [ "$_FORCE_GIT_MIRROR" = "drupal" ] ; then
_FORCE_GIT_MIRROR=github
fi
if [ "$_FORCE_GIT_MIRROR" = "github" ] ; then
msg "INFO: We will use forced GitHub repository without testing connection"
_GITHUB_WORKS=YES
_GITORIOUS_WORKS=NO
sleep 1
elif [ "$_FORCE_GIT_MIRROR" = "gitorious" ] ; then
msg "INFO: We will use forced Gitorious mirror without testing connection"
_GITHUB_WORKS=NO
_GITORIOUS_WORKS=YES
sleep 1
else
msg "INFO: Testing repository mirror servers availability..."
sleep 1
_GITHUB_WORKS=YES
_GITORIOUS_WORKS=YES
if ! netcat -w 8 -z github.com 9418 ; then
_GITHUB_WORKS=NO
msg "WARN: The GitHub master repository server doesn't respond..."
elif ! netcat -w 8 -z code.aegir.cc 9418 ; then
_GITORIOUS_WORKS=NO
msg "WARN: The Gitorious mirror repository server doesn't respond..."
fi
fi
if [ "$_GITHUB_WORKS" = "YES" ] ; then
_BOA_REPO_NAME="boa"
_BOA_REPO_GIT_URL="git://github.com/omega8cc"
msg "INFO: GitHub master repository will be used"
elif [ "$_GITORIOUS_WORKS" = "YES" ] ; then
_BOA_REPO_NAME="barracuda-octopus"
_BOA_REPO_GIT_URL="git://code.aegir.cc/aegir"
msg "INFO: Gitorious mirror repository will be used"
else
cat <<EOF
None of repository servers responded in 8 seconds,
so we can't continue this installation.
Please try again later or check if your firewall has port 9418 open.
Bye.
EOF
exit 1
fi
_BOA_REPO_GIT_URLX=${_BOA_REPO_GIT_URL//\//\\\/}
}
#
# Read or create Octopus cnf file.
octopus_cnf () {
if [ ! -e "/root/.${_USER}.octopus.cnf" ] ; then
if [[ "$_MY_EMAIL" =~ "omega8.cc" ]] || [[ "$_CLIENT_EMAIL" =~ "omega8.cc" ]] ; then
_CHECK_HOST=`uname -n`
if [ -e "/root/.host8.cnf" ] || [[ "$_CHECK_HOST" =~ ".host8." ]] || [ "$_VMFAMILY" = "VS" ] ; then
_DO_NOTHING=YES
else
msg "EXIT: You must enter **your** valid e-mail address"
msg "EXIT: in the _MY_EMAIL **and** _CLIENT_EMAIL variables"
exit 1