-
Notifications
You must be signed in to change notification settings - Fork 10
/
aegir.sh
executable file
·1458 lines (1260 loc) · 57.6 KB
/
aegir.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/sh
# Written by Brian Gilbert @BrianGilbert_ https://github.com/BrianGilbert
# of Realityloop @Realityloop http://realitylop.com/
# I'm by no means a bash scripter, please submit pull requests/issues for improvements. :)
{
# set volume so say text can be heard
osascript -e "set Volume 5"
curl --silent --head https://www.github.com/ | grep "20[0-9] Found|30[0-9] Found" > /dev/null
if [[ $? -eq 1 ]] ; then
printf "########\n# Online, continuing $(date +"%Y-%m-%d %H:%M:%S")\n"
else
printf "########\n# This script needs Internet access and you are offline, exiting\n########\n"
say " you need to be online to run this script, exiting"
exit
fi
# Set some variables for username, installing aegir, backups dir, and the OS X version
USERNAME=${USER-$LOGNAME} #`ps -o user= $(ps -o ppid= $PPID)`
DRUSH='drush --php=/usr/local/bin/php'
BACKUPS_DIR=~/Desktop/aegir-install-backup-$(date +"%Y-%m-%d.%H.%M.%S")
OSX=`sw_vers -productVersion | cut -c 1-5`
# Make sure that the script wasn't run as root.
if [ ${USERNAME} = "root" ] ; then
printf "########\n# This script should not be run as sudo or root. exiting.\n########\n"
say "This script should not be run as sudo or root. exiting."
exit
else
#fresh installations of mac osx does not have /usr/local, so we need to create it first in case it's not there.
printf "########\n# Checking /usr/local exists..\n"
if [ ! -d '/usr/local' ] ; then
printf "# It doesn't so I'm creating it..\n"
say "you may need to enter your password"
sudo mkdir -p /usr/local
fi
ls -l /usr/local| awk '{print $3}'|grep root > /dev/null
if [[ $? -eq 0 ]] ; then
printf "# Setting it's permissions correctly..\n########\n"
sudo chown -R ${USERNAME}:admin /usr/local
chmod 775 /usr/local
fi
fi
printf "########
# This script is designed to be run by the primary account
# it has not been tested on a multi user setup.
########
# You will need the following information during this script:
# -a gmail account that is configured to allow remote smtp access
# -the password for the gmail account address
# -an email address to receive notifications from aegir
# -attention to what is being requested via the script
########
# You cannot use this script if you have macports installed
# so we will uninstall it automatically
########
# OS X's inbuilt apache uses port 80 if it's running we'll disable
# it for you during install so that nginx can run on port 80.
########
# Logging install process to file on desktop in case anything
# goes wrong during install, No passwords are logged..
########\n"
if type "port" > /dev/null 2>&1; then
printf "########\n# Attempting to uninstall macports..\n"
say "you may need to enter your password"
sudo port -fp uninstall installed > /dev/null 2&>1
sudo rm -rf \
/opt/local \
/Applications/DarwinPorts \
/Applications/MacPorts \
/Library/LaunchDaemons/org.macports.* \
/Library/Receipts/DarwinPorts*.pkg \
/Library/Receipts/MacPorts*.pkg \
/Library/StartupItems/DarwinPortsStartup \
/Library/Tcl/darwinports1.0 \
/Library/Tcl/macports1.0 \
~/.macports > /dev/null 2&>1
else
printf "########\n# macports isn't installed continuing..\n"
fi
if type "drush" > /dev/null 2>&1; then
printf "########\n# Remove your existing version of drush first..\n########"
exit
else
printf "########\n# Great, Drush isn't already installed continuing..\n"
fi
ps aux|grep "httpd"|grep -v grep > /dev/null
if [[ $? -eq 1 ]] ; then
printf "########\n# Apache isn't active, continuing..\n########\n"
else
printf "########\n# Disabling apache now..\n########\n"
say "you may need to enter your password"
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
fi
printf "\n########\n# Checking OS version..\n########\n"
if [[ ${OSX} = 10.11 || ${OSX} = 10.10 || ${OSX} = 10.9. ]] ; then
printf "# You're using $OSX, so let's go!\n########\n"
else
printf "# ${OSX} isn't a supported version for this script\n# Update to 10.9+ and rerun the script, exiting.\n########\n"
exit
fi
# Check Aegir isn't already installed.
if [ -e "/var/aegir/.osxaegir" ] ; then
printf "# You already have aegir installed..\n########\n"
say "You already have a gir installed.."
#exit # Remove this line when uninstall block below is fixed.
# Possibly I'll allow reinstallations in the future..
#
printf "# Should I backup some important bits then remove it? \n# The option to re-install will be given after this, if you say no I'll prompt you to update the homebrew components. [Y/n]\n########\n"
say "input required"
read -n1 CLEAN
if [[ ${CLEAN} =~ ^(y|Y)$ ]]; then
printf "# You entered Y\n########\n"
printf "# There is no turning back..\n# This will uninstall aegir and all related homebrew components, are you sure? [Y/n]\n########\n"
say "There is no turning back.. This will uninstall a gir and all related homebrew components including any existing databases, are you sure?"
read -n1 FORSURE
if [[ ${FORSURE} =~ ^(y|Y)$ ]]; then
printf "\n########\n# You entered Y\n"
printf "\n########\n# Don't say I didn't warn you, cleaning everything..\n########\n"
say "Don't say I didn't warn you, removing components.."
mkdir -p $BACKUPS_DIR
printf "# Stopping and deleting any services that are already installed..\n########\n"
if [ -e "/Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist" ] ; then
sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo rm /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
fi
if [ -e "/Library/LaunchDaemons/homebrew.mxcl.nginx.plist" ] ; then
sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
sudo rm /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
fi
if [ -e "/Library/LaunchDaemons/homebrew.mxcl.nginx-full.plist" ] ; then
sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.nginx-full.plist
sudo rm /Library/LaunchDaemons/homebrew.mxcl.nginx-full.plist
fi
if [ -e "~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist" ] ; then
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
kill $(ps aux | grep 'mysqld' | awk '{print $2}')
fi
if [ -e "~/Library/LaunchAgents/homebrew.mxcl.php53.plist" ] ; then
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php53.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.php53.plist
fi
if [ -e "~/Library/LaunchAgents/homebrew.mxcl.php54.plist" ] ; then
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php54.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.php54.plist
fi
if [ -e "~/Library/LaunchAgents/homebrew.mxcl.php55.plist" ] ; then
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
fi
if [ -e "~/Library/LaunchAgents/homebrew.mxcl.php56.plist" ] ; then
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
fi
if [ -e "~/Library/LaunchAgents/org.aegir.hosting.queued.plist" ] ; then
launchctl unload -w ~/Library/LaunchAgents/org.aegir.hosting.queued.plist
rm ~/Library/LaunchAgents/org.aegir.hosting.queued.plist
fi
printf "########\n# Uninstalling related brews..\n########\n"
brew uninstall php53-geoip
brew uninstall php53-imagick
brew uninstall php53-mcrypt
brew uninstall php53-uploadprogress
brew uninstall php53-xdebug
brew uninstall php53-xhprof
brew uninstall php53
sudo rm /var/log/nginx/php53-fpm.log
sudo rm /var/log/aegir/php53-fpm.log
rm /usr/local/bin/go53
brew uninstall php54-geoip
brew uninstall php54-imagick
brew uninstall php54-mcrypt
brew uninstall php54-uploadprogress
brew uninstall php54-xdebug
brew uninstall php54-xhprof
brew uninstall php54
sudo rm /var/log/nginx/php54-fpm.log
sudo rm /var/log/aegir/php54-fpm.log
rm /usr/local/bin/go54
brew uninstall php55-geoip
brew uninstall php55-imagick
brew uninstall php55-mcrypt
brew uninstall php55-uploadprogress
brew uninstall php55-xdebug
brew uninstall php55-xhprof
brew uninstall php55
sudo rm /var/log/nginx/php55-fpm.log
sudo rm /var/log/aegir/php55-fpm.log
rm /usr/local/bin/go55
brew uninstall php56-geoip
brew uninstall php56-imagick
brew uninstall php56-mcrypt
brew uninstall php56-uploadprogress
brew uninstall php56-xdebug
brew uninstall php56-xhprof
brew uninstall php56
sudo rm /var/log/nginx/php56-fpm.log
sudo rm /var/log/aegir/php56-fpm.log
rm /usr/local/bin/go56
rm -rf /usr/local/etc/php
brew uninstall php-code-sniffer
brew uninstall drupal-code-sniffer
brew uninstall phpunit
brew untap josegonzalez/php
brew uninstall re2c
brew uninstall flex
brew uninstall bison27
brew uninstall libevent
brew uninstall openssl
brew uninstall solr
sudo mv /var/log/nginx/access.log $BACKUPS_DIR/brew.nginx.access.log
sudo mv /var/log/nginx/error.log $BACKUPS_DIR/brew.nginx.error.log
sudo mv /var/log/aegir/access.log $BACKUPS_DIR/brew.nginx.access.log
sudo mv /var/log/aegir/error.log $BACKUPS_DIR/brew.nginx.error.log
rm -rf /usr/local/etc/nginx
rm -rf /usr/local/var/run/nginx
sudo rm /var/log/nginx/error.log
sudo rm /var/log/aegir/error.log
brew uninstall nginx
brew uninstall nginx-full
brew uninstall pcre geoip
rm -rf /usr/local/share/GeoIP
brew uninstall dnsmasq
sudo networksetup -setdnsservers AirPort empty
sudo networksetup -setdnsservers Ethernet empty
sudo networksetup -setdnsservers 'Thunderbolt Ethernet' empty
sudo networksetup -setdnsservers Wi-Fi empty
sudo mv /etc/resolv.dnsmasq.conf $BACKUPS_DIR
sudo mv /usr/local/etc/dnsmasq.conf $BACKUPS_DIR
sudo mv /etc/resolver/default $BACKUPS_DIR/resolver.default
sudo mv /etc/resolver/ld $BACKUPS_DIR/resolver.ld
sudo mv /usr/local/etc/dnsmasq.hosts $BACKUPS_DIR
sudo networksetup -setdnsservers AirPort empty
sudo networksetup -setdnsservers Ethernet empty
sudo networksetup -setdnsservers 'Thunderbolt Ethernet' empty
sudo networksetup -setdnsservers Wi-Fi empty
printf "# Removing previous drush installation, this may error..\n########\n"
brew uninstall composer
brew uninstall drush
brew uninstall gzip
brew uninstall wget
printf "# Removing related configurations..\n########\n"
sudo launchctl unload /System/Library/LaunchDaemons/org.postfix.master.plist
sudo mv /etc/postfix/sasl_passwd $BACKUPS_DIR/postfix.sasl_passwd
sudo mv /etc/postfix/main.cf $BACKUPS_DIR/postfix.main.cf
sudo cp /etc/postfix/main.cf.orig /etc/postfix/main.cf
rm ~/.forward
say "Do you want to create backups of your databases?"
printf "# Do you want to backup all existing databases?\n# If you say no here make sure you have backups from your databases.\n# Answer [Y/n]\n########\n"
read -n1 DBBACKUP
if [[ $DBBACKUP =~ ^(y|Y)$ ]]; then
mkdir -p $BACKUPS_DIR/databases
printf "\n# What is your current MariaDB root password? \n########\n"
read DBPASS passw
DBLIST="$(mysql -uroot -h localhost -p$DBPASS -Bse 'show databases')"
if [ ${#DBLIST} -gt 0 ]; then
printf "\n# Backing up databases..\n########\n"
for DBITEM in $DBLIST
do
if [ "$DBITEM" != "performance_schema" ]; then
printf "\n# Database: $DBITEM"
FILE=$BACKUPS_DIR/databases/$DBITEM.$NOW-$(date +"%Y-%m-%d.%H.%M.%S").sql
mysqldump --events --single-transaction -u root -h localhost -p$DBPASS $DBITEM > $FILE
tar czfP $FILE.tar.gz $FILE
rm $FILE
fi
done
fi
fi
printf "\n########\n# Now removing mariadb and all databases..\n########\n"
rm ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
brew uninstall mariadb
mv /usr/local/etc/my-drupal.cnf $BACKUPS_DIR
mv /usr/local/etc/my.cnf $BACKUPS_DIR/local.etc.my.cnf
mv /usr/local/etc/my.cnf.d $BACKUPS_DIR
sudo mv /etc/my.cnf $BACKUPS_DIR/etc.my.cnf
rm -rf /usr/local/var/mysql
sudo killall mysqld
brew uninstall autoconf
brew uninstall cmake
brew uninstall curl
brew uninstall freetype
brew uninstall gettext
brew uninstall gmp
brew uninstall gzip
brew uninstall imagemagick
brew uninstall imap-uw
brew uninstall jpeg
brew uninstall libpng
brew uninstall libtool
brew uninstall mcrypt
brew uninstall pkg-config
brew uninstall unixodbc
brew uninstall zlib
brew uninstall apple-gcc42
sudo killall php-fpm
mv ~/Desktop/YourAegirSetup.txt $BACKUPS_DIR/YourAegirSetup.txt-.pre-uninstall-$(date +"%Y-%m-%d.%H.%M.%S")
printf "# Renaming your Aegir folder to /var/aegir.pre-uninstall-TI-ME-ST-AM-P....\n########\n"
sudo mv /var/aegir $BACKUPS_DIR/aegir-config-pre-uninstall-$(date +"%Y-%m-%d.%H.%M.%S")
mv ~/.drush/provision $BACKUPS_DIR/aegir-config-pre-uninstall-$(date +"%Y-%m-%d.%H.%M.%S")
say "input required"
printf "# would you now like to re-install Aegir? [Y/n]\n########\n"
read -n1 REINSTALL
if [[ ${REINSTALL} =~ ^(y|Y)$ ]]; then
printf "\n########\n# You entered Y\n########\n"
else
printf "\n########\n# You entered N\n########\n"
exit
fi
else
printf "# Exiting..\n########\n"
exit
fi
else
printf "# Should I attempt an upgrade of the homebrew components? [Y/n]\n########\n"
say "Should try an of homebrews bits?"
read UPGRADE
if [[ $UPGRADE =~ ^(y|Y)$ ]]; then
# printf "# Should I install the dev version of Aegir? [Y/n]\n########\n"
# read DEV
# if [[ $DEV =~ ^(y|Y)$ ]]; then
# INSTALL = '7.x-3.x';
# else
# INSTALL = '6.x-2.1';
# fi
# if [ -d "/var/aegir/hostmaster-6.x-2.x" ]; then
# # Control will enter here if 6.x-2.0 directory exists.
# CURRENTINSTALL = '/var/aegir/hostmaster-6.x-2.x';
# fi
# if [ -d "/var/aegir/hostmaster-6.x-2.0" ]; then
# # Control will enter here if 6.x-2.0 directory exists.
# CURRENTINSTALL = '/var/aegir/hostmaster-6.x-2.0';
# fi
# if [ -d "/var/aegir/hostmaster-6.x-2.1" ]; then
# # Control will enter here if 6.x-2.0 directory exists.
# CURRENTINSTALL = '/var/aegir/hostmaster-6.x-2.1';
# fi
# if [ -d "/var/aegir/hostmaster-7.x-3.x" ]; then
# # Control will enter here if 7.x-3.x directory exists.
# CURRENTINSTALL = '/var/aegir/hostmaster-7.x-3.x';
# fi
printf "# Upgrading homebrew components...\n########\n"
brew update
brew upgrade apple-gcc42
brew upgrade wget
brew upgrade curl --with-homebrew-openssl
brew upgrade gzip
brew upgrade libpng
brew upgrade dnsmasq
brew upgrade pcre geoip
brew upgrade nginx-full --with-debug --with-flv --with-geoip --with-gzip-static --with-webdav --with-mp4 --with-spdy --with-ssl --with-status --with-upload-progress-module
if [ -e "/Library/LaunchDaemons/homebrew.mxcl.nginx.plist" ] ; then
sudo rm /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
sudo cp $(brew --prefix nginx-full)/homebrew.mxcl.nginx-full.plist /Library/LaunchDaemons/
fi
echo "update path to nginx logfiles, you'll need to enter password here."
sudo mkdir -p /var/log/aegir
sudo chown -R ${USERNAME}:admin /var/log/aegir
sudo rm /var/log/nginx/error.log
sudo rm /var/log/aegir/nginx-error.log
brew upgrade cmake
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
brew upgrade mariadb
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
PHPAVAIL=`ls -d /usr/local/Cellar/php5* | grep 'php5[0-9]$' | cut -c 22-24`
PHPLIVE=`php --version |grep 5|cut -c 5-7`
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php53.plist > /dev/null 2>&1
rm ~/Library/LaunchAgents/homebrew.mxcl.php53.plist
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php54.plist > /dev/null 2>&1
rm ~/Library/LaunchAgents/homebrew.mxcl.php54.plist
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist > /dev/null 2>&1
rm ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist > /dev/null 2>&1
rm ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
if [[ ${PHPAVAIL} == *"56"* ]] ; then
sudo rm -rf $(brew --prefix homebrew/php/php56)/var
brew unlink php53 > /dev/null 2>&1
brew unlink php54 > /dev/null 2>&1
brew unlink php55 > /dev/null 2>&1
brew link php56
brew upgrade php56 --without-snmp --with-fpm --with-gmp --with-imap --with-mysql --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-curl --with-homebrew-openssl
brew upgrade php56-geoip
brew upgrade php56-imagick
brew upgrade php56-mcrypt
brew upgrade php56-uploadprogress
brew upgrade php56-xdebug
brew upgrade php56-xhprof
sudo rm /var/log/nginx/php56-fpm.log
sudo rm /var/log/aegir/php56-fpm.log
cp $(brew --prefix homebrew/php/php56)/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
brew unlink php56
fi
if [[ ${PHPAVAIL} == *"55"* ]] ; then
sudo rm -rf $(brew --prefix homebrew/php/php55)/var
brew unlink php53 > /dev/null 2>&1
brew unlink php54 > /dev/null 2>&1
brew unlink php56 > /dev/null 2>&1
brew link php55
brew upgrade php55 --without-snmp --with-fpm --with-gmp --with-imap --with-mysql --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-curl --with-homebrew-openssl
brew upgrade php55-geoip
brew upgrade php55-imagick
brew upgrade php55-mcrypt
brew upgrade php55-uploadprogress
brew upgrade php55-xdebug
brew upgrade php55-xhprof
sudo rm /var/log/nginx/php55-fpm.log
sudo rm /var/log/aegir/php55-fpm.log
cp $(brew --prefix homebrew/php/php55)/homebrew.mxcl.php55.plist ~/Library/LaunchAgents/
brew unlink php55
fi
if [[ ${PHPAVAIL} == *"54"* ]] ; then
sudo rm -rf $(brew --prefix homebrew/php/php54)/var
brew unlink php53 > /dev/null 2>&1
brew unlink php55 > /dev/null 2>&1
brew unlink php56 > /dev/null 2>&1
brew link php54
brew upgrade php54 --without-snmp --with-fpm --with-gmp --with-imap --with-mysql --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-curl --with-homebrew-openssl
brew upgrade php54-geoip
brew upgrade php54-imagick
brew upgrade php54-mcrypt
brew upgrade php54-uploadprogress
brew upgrade php54-xdebug
brew upgrade php54-xhprof
sudo rm /var/log/nginx/php54-fpm.log
sudo rm /var/log/aegir/php54-fpm.log
cp $(brew --prefix homebrew/php/php54)/homebrew.mxcl.php54.plist ~/Library/LaunchAgents/
brew unlink php54
fi
if [[ ${PHPAVAIL} == *"53"* ]] ; then
sudo rm -rf $(brew --prefix homebrew/php/php53)/var
brew unlink php54 > /dev/null 2>&1
brew unlink php55 > /dev/null 2>&1
brew unlink php56 > /dev/null 2>&1
brew link php53
brew upgrade re2c
brew upgrade flex
brew upgrade bison27
brew upgrade libevent
brew upgrade php53 --without-snmp --with-fpm --with-gmp --with-imap --with-mysql --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-curl --with-homebrew-openssl
brew upgrade php53-geoip
brew upgrade php53-imagick
brew upgrade php53-mcrypt
brew upgrade php53-uploadprogress
brew upgrade php53-xdebug
brew upgrade php53-xhprof
sudo rm /var/log/nginx/php53-fpm.log
sudo rm /var/log/aegir/php53-fpm.log
cp $(brew --prefix homebrew/php/php53)/homebrew.mxcl.php53.plist ~/Library/LaunchAgents/
brew unlink php53
fi
if [[ ${PHPAVAIL} == *"53"* ]] ; then
brew link php53
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php53.plist
fi
if [[ ${PHPAVAIL} == *"54"* ]] ; then
brew link php54
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php54.plist
fi
if [[ ${PHPAVAIL} == *"55"* ]] ; then
brew link php55
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
fi
if [[ ${PHPAVAIL} == *"56"* ]] ; then
brew link php56
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
fi
mkdir -p /usr/local/share/GeoIP
curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz > /usr/local/share/GeoIP/GeoIP.dat.gz
gunzip -f GeoIP.dat.gz &> /dev/null
brew upgrade php-code-sniffer
brew upgrade drupal-code-sniffer
brew upgrade phpunit
brew upgrade homebrew/php/composer
composer global require drush/drush:dev-master
HAVESOLR=`ls -d /usr/local/Cellar/solr`
if [[ ${HAVESOLR} == *"solr"* ]] ; then
brew upgrade solr
fi
brew cleanup
# # Aegir upgrade
# say "Input will be required."
# $DRUSH dl --destination=/Users/admin/.drush provision-{$INSTALL};
# $DRUSH cache-clear drush
# OLD_AEGIR_DIR={$CURRENTINSTALL};
# AEGIR_VERSION={$INSTALL};
# AEGIR_DOMAIN=aegir.ld;
# cd $OLD_AEGIR_DIR;
# drush hostmaster-migrate $AEGIR_DOMAIN /var/aegir/hostmaster-$AEGIR_VERSION --debug
exit
else
printf "# Exiting..\n########\n"
say "Exiting."
exit
fi
fi
fi
# printf "\n########\n# If xcode is installed check it's license has been agreed to..\n########\n"
# xcode-select -p > /dev/null 2&>1
# if [[ $? -eq 127 ]] ; then
# printf "########\n# xcode isn't installed continuing..\n"
# else
# printf "########\n# ensuring xcode license has been agreed to..\nn"
# xcodebuild -license
# fi
printf "\n########\n# Checking if Homebrew is installed..\n########\n"
if type "brew" > /dev/null 2>&1; then
printf "\n########\n# Affirmative! Let's make sure everything is up to date..\n# Just so you know, this may throw a few warnings..\n########\n"
say "Making sure homebrew is up to date, you may see some errors in the output, that's ok."
export PATH=/usr/local/bin:/usr/local/sbin:${HOME}/.composer/vendor/bin:${PATH}
brew prune
brew update
brew doctor
if [[ $? -eq 0 ]] ; then
printf "########\n# Homebrew in order, continuing\n########"
else
printf "########\n# Homebrew needs some work, exiting\n########"
exit
fi
else
printf "# Nope! Installing Homebrew now..\n########\n"
say "Installing homebrew now, you'll need to hit return when prompted"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "export PATH=/usr/local/bin:/usr/local/sbin:${HOME}/.composer/vendor/bin:${PATH}" >> ~/.bash_profile
echo "export PATH=/usr/local/bin:/usr/local/sbin:${HOME}/.composer/vendor/bin:${PATH}" >> ~/.zshrc
source ~/.bash_profile
fi
printf "\n########\n# Doing some setup ready for Aegir install..\n########\n"
sudo mkdir -p /var/aegir
sudo chown ${USERNAME} /var/aegir
sudo chgrp staff /var/aegir
echo "$(date +"%Y-%m-%d %H:%M:%S")" > /var/aegir/.osxaegir
sudo dscl . append /Groups/_www GroupMembership ${USERNAME}
echo "
# Your hostname will be set to aegir.ld
########
# Install the developmental version of Aegir (7.x-3.x)? [Y/n]:
########"
say "input required"
read -n1 AEGIR7X
if [[ ${AEGIR7X} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
echo "
########
# I can install multiple versions of PHP; 5.3, 5.4 5.5 and/or 5.6.
# Let me know which versions you'd like installed.
# Set up PHP 5.3 [Y/n]:
########"
say "input required"
read -n1 PHP53
if [[ ${PHP53} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
if [[ ${PHP53} =~ ^(y|Y)$ ]]; then
echo "
########
# Make PHP 5.3 the default [Y/n]:
########"
say "input required"
read -n1 PHP53DEF
if [[ ${PHP53DEF} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
fi
echo "
########
# Set up PHP 5.4 [Y/n]:
########"
say "input required"
read -n1 PHP54
if [[ ${PHP54} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
if [[ ! ${PHP53DEF} =~ ^(y|Y)$ ]]; then
if [[ ${PHP54} =~ ^(y|Y)$ ]]; then
echo "
########
# Make PHP 5.4 the default [Y/n]:
########"
say "input required"
read -n1 PHP54DEF
if [[ ${PHP54DEF} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
fi
fi
echo "
########
# Set up PHP 5.5 [Y/n]:
########"
say "input required"
read -n1 PHP55
if [[ ${PHP55} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
if [[ ${PHP53DEF} =~ ^(y|Y)$ || ${PHP54DEF} =~ ^(y|Y)$ ]]; then
echo ""
else
echo "
########
# Make PHP 5.5 the default [Y/n]:
########"
say "input required"
read -n1 PHP55DEF
if [[ ${PHP55DEF} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
fi
echo "
########
# Set up PHP 5.6 [Y/n]:
########"
say "input required"
read -n1 PHP56
if [[ ${PHP56} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
if [[ ${PHP53DEF} =~ ^(y|Y)$ || ${PHP54DEF} =~ ^(y|Y)$ || ${PHP55DEF} =~ ^(y|Y)$ ]]; then
echo ""
else
echo "
########
# Make PHP 5.6 the default [Y/n]:
########"
say "input required"
read -n1 PHP56DEF
if [[ ${PHP56DEF} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
else
printf "\n# You entered N\n########\n"
fi
fi
if [[ ! ${PHP53} =~ ^(y|Y)$ && ! ${PHP54} =~ ^(y|Y)$ && ! ${PHP55} =~ ^(y|Y)$ ]]; then
echo "
########
# You didn't select any version of PHP?!? So I'm installing PHP5.6
########"
PHP56="Y"
PHP56DEF="Y"
fi
echo "
########
# I can also setup ApacheSolr which is best used in conjunction with:
# https://drupal.org/project/search_api_solr
# Set up solr [Y/n]:
########"
say "input required"
read -n1 SOLR
if [[ ${SOLR} =~ ^(y|Y)$ ]]; then
printf "\n# You entered Y\n########\n"
fi
# Tap required kegs
printf "\n########\n# Now we'll tap some extra kegs we need..\n########\n"
brew tap homebrew/versions
brew tap homebrew/dupes
brew tap homebrew/homebrew-php
brew tap homebrew/nginx
brew update
brew doctor
# Install required formula's
printf "# Installing required brew formulae..\n########\n"
printf "# Installing cask..\n########\n"
brew install caskroom/cask/brew-cask
printf "# Installing gcc..\n########\n"
brew install apple-gcc42
printf "\n########\n# Installing java8..\n########\n"
say "You may need to enter your password now"
brew cask install java
printf "\n########\n# Installing wget..\n########\n"
brew install wget
printf "\n########\n# Installing curl..\n########\n"
brew install --with-openssl curl
printf "\n########\n# Installing gzip..\n########\n"
brew install gzip
printf "\n########\n# Installing libpng..\n########\n"
brew install libpng
printf "\n########\n# Installing dnsmasq..\n########\n"
brew install dnsmasq
printf "\n########\n# Configuring dnsmasq..\n########\n"
mkdir -p /usr/local/etc
# Configure dnsmasq
printf "########\n# Setting up wildcard DNS so that domains ending in dot ld will resolve to your local machine\n"
if [ -e "/usr/local/etc/dnsmasq.conf" ] ; then
printf "########\n# You already have a dnsmasq.conf file..\n# So this all works proerly I'm going to backup and recreate it..\n########\n"
mv /usr/local/etc/dnsmasq.conf $BACKUPS_DIR
fi
printf "# Setting dnsmasq config..\n########\n"
cp $(brew --prefix dnsmasq)/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
echo '# Edited by OSX Aegir install script' | cat - /usr/local/etc/dnsmasq.conf > temp && mv temp /usr/local/etc/dnsmasq.conf
echo "\nresolv-file=/etc/resolv.dnsmasq.conf" >> /usr/local/etc/dnsmasq.conf
echo "address=/.ld/127.0.0.1" >> /usr/local/etc/dnsmasq.conf
echo "listen-address=127.0.0.1" >> /usr/local/etc/dnsmasq.conf
echo "addn-hosts=/usr/local/etc/dnsmasq.hosts" >> /usr/local/etc/dnsmasq.conf
touch /usr/local/etc/dnsmasq.hosts
if [ -e "/etc/resolv.dnsmasq.conf" ] ; then
printf "# You already have a resolv.conf set..\n# So this all works properly I'm going to backup and recreate it..\n########\n"
say "You may be prompted for your password"
sudo mv /etc/resolv.dnsmasq.conf $BACKUPS_DIR
fi
printf "# Setting OpenDNS and Google DNS servers as fallbacks..\n########\n"
say "You may need to enter your password now"
sudo sh -c 'echo "# OpenDNS IPv6:
nameserver 2620:0:ccd::2
nameserver 2620:0:ccc::2
# Google IPv6:
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
# OpenDNS:
nameserver 208.67.222.222
nameserver 208.67.220.220
# Google:
nameserver 8.8.8.8
nameserver 8.8.4.4" >> /etc/resolv.dnsmasq.conf'
if [ -e "/etc/resolver/ld" ] ; then
printf "# You already have a resolver set for when you are offline..\n# So this all works properly I'm going to backup and recreate it..\n########\n"
say "You may be prompted for your password"
sudo mv /etc/resolver/ $BACKUPS_DIR
fi
printf "########\n# Making local domains resolve when your disconnected from net..\n########\n"
sudo mkdir -p /etc/resolver
sudo sh -c 'echo "nameserver 127.0.0.1" >> /etc/resolver/ld'
printf "# Setting hostname to aegir.ld\n########\n"
sudo scutil --set HostName aegir.ld
# Start dnsmasq
printf "# Copying dnsmasq launch daemon into place..\n########\n"
sudo cp $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
printf "# Starting dnsmasq..\n########\n"
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
printf "\n########\n# Installing nginx..\n########\n"
brew install pcre geoip
brew install nginx-full --with-debug --with-flv --with-geoip --with-gzip-static --with-webdav --with-mp4 --with-spdy --with-ssl --with-status --with-upload-progress-module
printf "\n########\n# Configuring nginx..\n########\n"
if [ -e "/usr/local/etc/nginx/nginx.conf" ] ; then
mv /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/nginx.conf.bak
fi
curl https://gist.githubusercontent.com/BrianGilbert/5908352/raw/097a8128efd6815dbbacd18339b60c0ad780f65f/nginx.conf > /usr/local/etc/nginx/nginx.conf
sed -i '' 's/\[username\]/'${USERNAME}'/' /usr/local/etc/nginx/nginx.conf
mkdir -p /usr/local/etc/nginx/conf.d
say "You may be prompted for your password"
sudo mkdir -p /var/log/aegir
sudo chown -R ${USERNAME}:admin /var/log/aegir
sudo mkdir -p /var/lib/nginx
mkdir -p /usr/local/var/run/nginx/proxy_temp
mkdir -p /usr/local/share/GeoIP
curl http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz > /usr/local/share/GeoIP/GeoIP.dat.gz
gunzip -f GeoIP.dat.gz &> /dev/null
printf "\n########\n# Installing mariadb..\n########\n"
brew install cmake
brew install mariadb
unset TMPDIR
printf "\n########\n# Configuring mariadb..\n########\n"
mkdir -p /usr/local/etc/my.cnf.d
mysql_install_db --user=${USERNAME} --basedir="$(brew --prefix mariadb)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
curl https://gist.githubusercontent.com/BrianGilbert/6207328/raw/10e298624ede46e361359b78a1020c82ddb8b943/my-drupal.cnf > /usr/local/etc/my.cnf.d/my-drupal.cnf
say "You may be prompted for your password"
if [[ ${PHP56} =~ ^(y|Y)$ ]]; then
printf "\n########\n# Installing php56..\n########\n"
brew install php56 --without-snmp --with-fpm --with-gmp --with-imap --with-mysql --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-openssl
brew install php56-geoip
brew install php56-imagick
brew install php56-mcrypt
brew install php56-uploadprogress
brew install php56-xdebug
brew install php56-xhprof
# Make sure LaunchAgents directory exists
mkdir -p ~/Library/LaunchAgents
printf "\n########\n# Configuring php56..\n########\n"
sed -i '' '/timezone =/ a\
date.timezone = Australia/Melbourne\
' /usr/local/etc/php/5.6/php.ini
sed -i '' 's/post_max_size = .*/post_max_size = '50M'/' /usr/local/etc/php/5.6/php.ini
sed -i '' 's/upload_max_filesize = .*/upload_max_filesize = '10M'/' /usr/local/etc/php/5.6/php.ini
sed -i '' 's/max_execution_time = .*/max_execution_time = '90'/' /usr/local/etc/php/5.6/php.ini
sed -i '' 's/memory_limit = .*/memory_limit = '512M'/' /usr/local/etc/php/5.6/php.ini
sed -i '' 's/pdo_mysql.default_socket=.*/pdo_mysql.default_socket= \/tmp\/mysql.sock/' /usr/local/etc/php/5.6/php.ini
sed -i '' '/pid = run/ a\
pid = /usr/local/var/run/php-fpm.pid\
' /usr/local/etc/php/5.6/php-fpm.conf
# Additions for xdebug to work with PHPStorm
echo "xdebug.max_nesting_level = 200
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = xdebug-profile-cachegrind.out-%H-%R
xdebug.profiler_output_dir = /tmp/xdebug/
xdebug.remote_autostart = 0
xdebug.remote_enable=1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001
xdebug.remote_host = localhost
xdebug.var_display_max_children = 128
xdebug.var_display_max_data = 2048
xdebug.var_display_max_depth = 32" >> /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini
say "You may be prompted for your password"
sudo ln -s $(brew --prefix homebrew/php/php56)/var/log/php-fpm.log /var/log/aegir/php56-fpm.log
cp $(brew --prefix homebrew/php/php56)/homebrew.mxcl.php56.plist ~/Library/LaunchAgents/
echo "#!/bin/sh
# Written by Brian Gilbert @BrianGilbert_ https://github.com/BrianGilbert
# of Realityloop @Realityloop http://realitylop.com/
# Remove old symlink for xhprof and create correct one for this version of php
rm /usr/local/opt/xhprof > /dev/null 2>&1
ln -s $(brew --prefix php56-xhprof) /usr/local/opt/xhprof
# Stop php-fpm and start correct version
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php53.plist > /dev/null 2>&1
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php54.plist > /dev/null 2>&1
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist > /dev/null 2>&1
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist > /dev/null 2>&1
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
# Brew link correct php version
brew unlink php53 > /dev/null 2>&1
brew unlink php54 > /dev/null 2>&1
brew unlink php55 > /dev/null 2>&1
brew link php56
# Restart nginx
sudo /usr/local/bin/nginx -s reload" >> /usr/local/bin/go56
chmod 755 /usr/local/bin/go56
brew unlink php56
fi
if [[ ${PHP55} =~ ^(y|Y)$ ]]; then
printf "\n########\n# Installing php55..\n########\n"
brew install php55 --without-snmp --with-fpm --with-gmp --with-imap --with-mysql --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-openssl
brew install php55-geoip
brew install php55-imagick
brew install php55-mcrypt
brew install php55-uploadprogress
brew install php55-xdebug
brew install php55-xhprof
# Make sure LaunchAgents directory exists
mkdir -p ~/Library/LaunchAgents
printf "\n########\n# Configuring php55..\n########\n"
sed -i '' '/timezone =/ a\
date.timezone = Australia/Melbourne\
' /usr/local/etc/php/5.5/php.ini
sed -i '' 's/post_max_size = .*/post_max_size = '50M'/' /usr/local/etc/php/5.5/php.ini
sed -i '' 's/upload_max_filesize = .*/upload_max_filesize = '10M'/' /usr/local/etc/php/5.5/php.ini
sed -i '' 's/max_execution_time = .*/max_execution_time = '90'/' /usr/local/etc/php/5.5/php.ini
sed -i '' 's/memory_limit = .*/memory_limit = '512M'/' /usr/local/etc/php/5.5/php.ini
sed -i '' 's/pdo_mysql.default_socket=.*/pdo_mysql.default_socket= \/tmp\/mysql.sock/' /usr/local/etc/php/5.5/php.ini
sed -i '' '/pid = run/ a\
pid = /usr/local/var/run/php-fpm.pid\
' /usr/local/etc/php/5.5/php-fpm.conf
# Additions for xdebug to work with PHPStorm
echo "xdebug.max_nesting_level = 200
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_name = xdebug-profile-cachegrind.out-%H-%R
xdebug.profiler_output_dir = /tmp/xdebug/
xdebug.remote_autostart = 0
xdebug.remote_enable=1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001
xdebug.remote_host = localhost
xdebug.var_display_max_children = 128
xdebug.var_display_max_data = 2048
xdebug.var_display_max_depth = 32" >> /usr/local/etc/php/5.5/conf.d/ext-xdebug.ini
say "You may be prompted for your password"
sudo ln -s $(brew --prefix homebrew/php/php55)/var/log/php-fpm.log /var/log/aegir/php55-fpm.log
cp $(brew --prefix homebrew/php/php55)/homebrew.mxcl.php55.plist ~/Library/LaunchAgents/
echo "#!/bin/sh
# Written by Brian Gilbert @BrianGilbert_ https://github.com/BrianGilbert
# of Realityloop @Realityloop http://realitylop.com/
# Remove old symlink for xhprof and create correct one for this version of php
rm /usr/local/opt/xhprof > /dev/null 2>&1
ln -s $(brew --prefix php55-xhprof) /usr/local/opt/xhprof
# Stop php-fpm and start correct version
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php53.plist > /dev/null 2>&1
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php54.plist > /dev/null 2>&1
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist > /dev/null 2>&1
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php56.plist > /dev/null 2>&1
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php55.plist