-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup.sh
executable file
·1326 lines (1192 loc) · 56.4 KB
/
setup.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
# -*- coding: utf-8 -*-
# (c) 2013, Steve Morin <[email protected]>
#
# This file is part of the DemandCube, (the "Project")
#
# This Project is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This Project 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this Project. If not, see <http://www.gnu.org/licenses/agpl-3.0.html>.
# Test if easy_install exists
# If it doesn't install it
# curl -O http://python-distribute.org/distribute_setup.py
# sudo python distribute_setup.py
# sudo rm distribute_setup.py
# TEST if not existent command
# command -v foo >/dev/null 2>&1
# INSTALLED=$?
# echo $INSTALLED # -> 1
#
# TEST for command that exists
# command -v java >/dev/null 2>&1
# INSTALLED=$?
# echo $INSTALLED # -> 0
echo " ";
echo ",--. |,---. | ";
echo "| |,---.,-.-.,---.,---.,---|| . .|---.,---.";
echo "| ||---'| | |,---|| || || | || ||---'";
echo "\`--' \`---'\` ' '\`---^\` '\`---'\`---'\`---'\`---'\`---'";
echo " ";
echo " ";
echo ",--. | ,---. | ";
echo "| |,---.. ,,---.| ,---.,---.,---.,---. \`---.,---.|--- . .,---.";
echo "| ||---' \ / |---'| | || ||---'| ||---'| | || |";
echo "\`--' \`---' \`' \`---'\`---'\`---'|---'\`---'\` \`---'\`---'\`---'\`---'|---'";
echo " | | ";
# present working directory
BASE_DIR=$(cd $(dirname $0); pwd -P)
# including os_meta_info.sh file which provides following meta information
#### OS_NAME
#### OS_DISTRO
#### OS_DISTRO_BASED_ON
#### OS_PSUEDO_NAME
#### OS_REVISION
#### OS_KERNEL_VER
#### OS_ARCH
# sudo ln -sf bash /bin/sh should be done for Ubuntu in case if source command doesn't work
#source $BASE_DIR/bootstrap/os_meta_info.sh
. ./bootstrap/os_meta_info.sh
# installing developement tools withch are required to build and run softwares in linux
echo ""
echo "[INFO]: Installing common developement tools************************************"
echo ""
if [ $OS_DISTRO == "CentOS" ] ; then
#dkms for dynamic kernal module support;kernel-devel for kernel soruce
# and some of other below components are required by virtualbox
sudo yum install binutils qt gcc make patch libgomp glibc-headers glibc-devel \
kernel-headers kernel-devel dkms alsa-lib cairo cdparanoia-libs fontconfig freetype \
gstreamer gstreamer-plugins-base gstreamer-tools iso-codes lcms-libs libXft libXi \
libXrandr libXv libgudev1 libjpeg-turbo libmng libogg liboil libthai libtheora libtiff \
libvisual libvorbis mesa-libGLU pango phonon-backend-gstreamer pixman qt-sqlite \
qt-x11 libudev libXmu SDL-static
#######################...........OR..........############################################
# sudo yum install gcc-c++ make libcap-devel libcurl-devel libIDL-devel libstdc++-static \
# libxslt-devel libXmu-devel openssl-devel pam-devel pulseaudio-libs-devel \
# python-devel qt-devel SDL_ttf-devel SDL-static texlive-latex wine-core \
# device-mapper-devel wget subversion subversion-gnome kernel-devel \
# glibc-static zlib-static glibc-devel.i686 libstdc++.i686 libpng-devel
######################....if above first set of commands are insufficient...###############
elif [ $OS_DISTRO == "Ubuntu" ] ; then
# dkms for dynamic kernal module support;kernel-devel for kernel soruce
# and some of other below components are required by virtualbox
sudo apt-get install gcc make linux-headers-$(uname -r) dkms build-essential fontconfig fontconfig-config libasound2 libasyncns0 libaudio2 libavahi-client3 libavahi-common-data libavahi-common3 libcaca0 \
libcups2 libflac8 libfontconfig1 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libice6 libjpeg-turbo8 libjpeg8 libjson0 liblcms1 \
libllvm3.0 libmng1 libmysqlclient18 libogg0 libpulse0 libpython2.7 libqt4-dbus libqt4-declarative libqt4-network libqt4-opengl \
libqt4-script libqt4-sql libqt4-sql-mysql libqt4-xml libqt4-xmlpatterns libqtcore4 libqtgui4 libsdl1.2debian libsm6 libsndfile1 \
libtiff4 libvorbis0a libvorbisenc2 libvpx1 libx11-xcb1 libxcb-glx0 libxcursor1 libxdamage1 libxfixes3 libxi6 libxinerama1 libxmu6 \
libxrender1 libxt6 libxxf86vm1 mysql-common qdbus ttf-dejavu-core x11-common
fi
#######################################
#######################################
###
### Installation of python,easy_install
### pip,and ansible with little change
### is same for Ubuntu,Mac,and CentOS
#######################################
#######################################
########################################
########################################
####
#### INSTALL PYTHON
####
########################################
########################################
# Test if python is installed
command -v python >/dev/null 2>&1
INSTALLED=$?
if [ ! $INSTALLED == 0 ] ; then
echo "Install python it's missing"
exit 1
fi
# Test if python version is 2.6 or above
# python 2.7.5
python -c 'import sys; version=sys.version_info[0]*10; version=version+sys.version_info[1];sys.exit(1)if(version<26) else sys.exit(0)'
INSTALLED=$?
echo ""
if [ ! $INSTALLED == 0 ] ; then
echo "Install python greater than 2.6"
exit 1
else
echo "INSTALLED: [ python ]"
printf "\t"
python -V 2>&1 | awk '{ print $2 }'
fi
########################################
########################################
####
#### INSTALL CURL
####
########################################
########################################
# Test if easy_install if not install manually
command -v curl >/dev/null 2>&1
INSTALLED=$?
echo ""
if [ ! $INSTALLED == 0 ] ; then
echo "[INFO] $OS_NAME is current OS"
# determining os distribution in case of linux and taking action accordingly
case $OS_DISTRO in
"CentOS" ) sudo yum install curl-devel break;;
"Ubuntu" ) sudo apt-get install curl break;;
* ) #Cases for other Distros such as Debian,SuSe,Solaris etc
echo "Install curl"
break;;
esac
else
echo "INSTALLED: [ curl ]"
fi
########################################
########################################
####
#### INSTALL EASY_INSTALL
####
########################################
########################################
# Test if easy_install if not install manually
command -v easy_install >/dev/null 2>&1
INSTALLED=$?
echo ""
if [ ! $INSTALLED == 0 ] ; then
echo "Installing easy_install it was missing"
curl http://python-distribute.org/distribute_setup.py -o distribute_setup.py
sudo python distribute_setup.py
sudo rm distribute_setup.py
else
echo "INSTALLED: [ easy_install ]"
fi
########################################
########################################
####
#### INSTALL PIP
####
########################################
########################################
# Test and install pip if not installed
# pip >= 1.5.4
PIP_VERSION=1.5.4
command -v pip >/dev/null 2>&1
INSTALLED=$?
echo ""
if [ ! $INSTALLED == 0 ] ; then
echo "INSTALLING: [ pip ]"
printf "\t"
sudo easy_install pip
else
echo "INSTALLED: [ pip ]"
printf "\t"
$BASE_DIR/bootstrap/version_compare.py `$BASE_DIR/bootstrap/pip_version.py` $PIP_VERSION
CMP_RESULT=$?
if [ $CMP_RESULT -lt 2 ] ; then
# Upgrade pip
$BASE_DIR/bootstrap/pip_version.py
echo "Upgrading pip to $PIP_VERSION"
# http://www.pip-installer.org/en/latest/installing.html#install-or-upgrade-pip
sudo pip install --upgrade setuptools
SETUPTOOLS_RESULT=$?
if [ $SETUPTOOLS_RESULT -ne 0 ] ; then
echo "upgrading setuptools failed try manually"
exit 1
fi
curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py -O
CURL_RESULT=$?
if [ $CURL_RESULT -ne 0 ] ; then
echo "downloading new pip failed try manually"
exit 1
fi
sudo python get-pip.py
PIP_RESULT=$?
echo "PIP_RESULT:$PIP_RESULT"
if [ $PIP_RESULT -ne 0 ] ; then
echo "upgrading pip failed try manually"
exit 1
fi
rm get-pip.py
echo "New Pip Version"
$BASE_DIR/bootstrap/pip_version.py
# https://pypi.python.org/pypi/setuptools#installation-instructions
# Instructions to Install setuptools
#
# curl https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O
# sudo python ez_setup.py
# rm ez_setup.py
elif [ $CMP_RESULT -eq 0 ] ; then
echo "There was an error comparing the pip version, please check manually"
exit 1
else
$BASE_DIR/bootstrap/pip_version.py
fi
# pip -V # pip verions only works on 1.4
fi
########################################
########################################
####
#### INSTALL ANSIBLE
####
########################################
########################################
# installed ansible paramiko jinja2 PyYAML httplib2 pycrypto ecdsa markupsafe
# install libselinux-python on remote nodes using selinux
# Test and install ansible if not installed
# ansible 1.4.3
# paramiko-1.12.0
# Jinja2-2.7.1
# PyYAML-3.10
# httplib2-0.8
# pycrypto-2.6.1
# ecdsa-0.10
# MarkupSafe-0.18
# Test if ansible is already installed
command -v ansible >/dev/null 2>&1
INSTALLED=$?
echo ""
# Todo test for version and upgrade
# Version 1.4.4
if [ ! $INSTALLED == 0 ] ; then
echo "INSTALLING: [ ansible ]"
# determining OS and taking action accordingly
case $OS_NAME in
"Linux" )
echo "[INFO] $OS_NAME is current OS"
# determining os distribution in case of linux and taking action accordingly
case $OS_DISTRO in
"CentOS" )
echo "[INFO] $OS_DISTRO-$OS_NAME Proceeding"
#sudo yum groupinstall "Development Tools"
sudo yum install python-devel
sudo pip install paramiko PyYAML jinja2 httplib2
sudo pip install ansible
break;;
"Ubuntu" )
echo "[INFO] $OS_DISTRO-$OS_NAME Proceeding"
#sudo apt-get install "build-essential"
sudo apt-get install -y python-dev
sudo pip install paramiko PyYAML jinja2 httplib2
sudo pip install ansible
break;;
* )
#Cases for other Distros such as Debian,Ubuntu,SuSe,Solaris etc may come here
echo "Script for $OS_NAME "-" $OS_DISTRO has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
break;;
"Darwin" )
# script may be needed here to install python-devel
sudo pip install paramiko PyYAML jinja2 httplib2
sudo pip install ansible
break;;
* )
#Cases for other OS such as Windows may come here
echo "Script for $OS_NAME has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
else
echo "INSTALLED: [ ansible ]"
printf "\t"
ansible --version | awk '{ print $2 }'
fi
########################################
########################################
####
#### INSTALL NOSE
####
########################################
########################################
# variable declarations
REQUIRED_NOSE_VERSION=1.3.0
VERSION_NOSE=''
NOSE_DOWNLOAD_URL='https://pypi.python.org/packages/source/n/nose/nose-1.3.0.tar.gz'
NOSE_INSTALL_CMD='sudo pip install -I'
NOSE_UNISTALL_CMD='sudo pip uninstall -y nose'
INSTALL_NOSE=''
# Test if nose already installed
command -v nosetests >/dev/null 2>&1
INSTALLED=$?
echo ""
if [ $INSTALLED == 0 ] ; then
# Already installed
# test existing version and required version
# first command outputs full version(eg. nosetests version 1.3.0) and
# second command extracts version part
VERSION_NOSE=`nosetests --version | cut -f3 -d" "`
echo "INSTALLED: [ nose ]"
printf "\t"
echo $VERSION_NOSE
echo
# Compare the required and found version
$BASE_DIR/bootstrap/version_compare.py $VERSION_NOSE $REQUIRED_NOSE_VERSION
CMP_RESULT=$?
# Test if installed version is lower then required version
if [ ! $CMP_RESULT -eq 2 ] ; then
# Remove Nose if not verion: $REQUIRED_NOSE_VERSION
echo "[INFO] Current Nose Version: $VERSION_NOSE"
echo "[INFO] Required Nose Version: $REQUIRED_NOSE_VERSION"
echo ""
echo "Install Correct Nose (Delete and Install)?"
while true; do
read -p "Is this ok [y/N]:" yn
case $yn in
[Yy]* )
echo "[INFO] Removing nose***********"
$NOSE_UNISTALL_CMD
INSTALL_NOSE=1
break;;
[Nn]* )
echo "No"; break;;
* )
echo "Please answer yes or no.";;
esac
done
fi
else
echo "[INFO] Nose not installed"
INSTALL_NOSE=1
fi
# test if nose needs to be installed
if [[ -n "$INSTALL_NOSE" ]]; then
echo "[INFO] Installing nose it was missing"
echo "INSTALLING: [ nose ]"
printf "\t"
$NOSE_INSTALL_CMD $NOSE_DOWNLOAD_URL
echo "[INFO] nose-$REQUIRED_NOSE_VERSION installed successfully"
fi
########################################
########################################
####
#### INSTALL VIRTUALBOX
####
########################################
########################################
# variable declarations
INSTALL_VIRTUALBOX=''
REQUIRED_VIRTUALBOX_VERSION=4.3.10
VERSION_VIRTUALBOX=''
VIRTUALBOX_DOWNLOAD_URL=''
VIRTUALBOX_INSTALL_CMD=''
VIRTUALBOX_FILE=''
#Determining OS and taking action accordingly
case $OS_NAME in
"Linux" )
echo "[INFO]: $OS_NAME is current OS. "
# Test if VirtualBox is already installed
command -v virtualbox >/dev/null 2>&1
INSTALLED=$?
if [ $INSTALLED == 0 ] ; then
echo "[INFO]: VirtualBox is already installed."
echo ""
# first command outputs full version(eg. 4.2.6r02546) and second command removes release part of version(eg. r025)
VERSION_VIRTUALBOX=`VBoxManage -v | cut -f1 -d"r"`
#VERSION_VIRTUALBOX=${VERSION_VIRTUALBOX:0:6}
echo "INSTALLED: [Virtualbox]"
printf "\t"
echo $VERSION_VIRTUALBOX
echo ""
# Compare the required and found versions
$BASE_DIR/bootstrap/version_compare.py $VERSION_VIRTUALBOX $REQUIRED_VIRTUALBOX_VERSION
CMP_RESULT=$?
# Test if installed version is lower then required version
if [ ! $CMP_RESULT -eq 2 ] ; then
# Remove VIRTUALBOX if not verion: $REQUIRED_VIRTUALBOX_VERSION
echo "Current VirtualBox Version: $VERSION_VIRTUALBOX"
echo "Required VirtualBox Version: $REQUIRED_VIRTUALBOX_VERSION"
echo ""
echo "Install Correct VirtualBox (Delete and Install)?"
while true; do
read -p "Is this ok [y/N]:" yn
case $yn in
[Yy]* )
echo "Removing VirtualBox";
INSTALL_VIRTUALBOX=1
#Determining OS Distribution and taking remove action accordingly
case $OS_DISTRO in
"CentOS" )
echo "$OS_DISTRO - $OS_NAME Proceeding."
VM="`rpm -qa | grep VirtualBox`"
echo "Removing package-$VM"
sudo rpm -e "$VM"
break;;
"Ubuntu" )
echo "$OS_DISTRO - $OS_NAME Proceeding."
sudo apt-get purge virtualbox*
break;;
* )
#Cases for other Distros such as Debian,Ubuntu,SuSe,Solaris etc may come here
echo "Script for $OS_NAME "-" $OS_DISTRO has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
break;;
[Nn]* )
echo "No"; break;;
* )
echo "Please answer yes or no.";;
esac
done
fi
else
INSTALL_VIRTUALBOX=1
echo "VirtualBox is Not Installed"
fi
# Test whether to install Virtualbox or not
if [ -n "$INSTALL_VIRTUALBOX" ] ; then
echo "Install VirtualBox"
#Determining OS Distribution and taking install action accordingly
case $OS_DISTRO in
"CentOS" )
echo "$OS_DISTRO - $OS_NAME Proceeding."
VIRTUALBOX_FILE="$HOME/Downloads/VirtualBox-$REQUIRED_VIRTUALBOX_VERSION.rpm"
VIRTUALBOX_DOWNLOAD_URL="http://download.virtualbox.org/virtualbox/4.3.10/VirtualBox-4.3-4.3.10_93012_el6-1.x86_64.rpm"
VIRTUALBOX_INSTALL_CMD="sudo rpm -ivh"
break;;
"Ubuntu" )
echo "$OS_DISTRO-$OS_ARCH-$OS_REVISION - $OS_NAME Proceeding."
# Determining OS architecture 32-bit or 64-bit
case $OS_ARCH in
# 32-bit OS
"i686" )
# Determine OS version
case $OS_REVISION in
"12.04" )
VIRTUALBOX_FILE="$HOME/Downloads/VirtualBox-$REQUIRED_VIRTUALBOX_VERSION.deb"
VIRTUALBOX_DOWNLOAD_URL="http://download.virtualbox.org/virtualbox/4.3.10/virtualbox-4.3_4.3.10-93012~Ubuntu~precise_i386.deb"
VIRTUALBOX_INSTALL_CMD="sudo dpkg -i"
break;;
"12.10" )
VIRTUALBOX_FILE="$HOME/Downloads/VirtualBox-$REQUIRED_VIRTUALBOX_VERSION.deb"
VIRTUALBOX_DOWNLOAD_URL="http://download.virtualbox.org/virtualbox/4.3.10/virtualbox-4.3_4.3.10-93012~Ubuntu~raring_i386.deb"
VIRTUALBOX_INSTALL_CMD="sudo dpkg -i"
break;;
"13.04" )
VIRTUALBOX_FILE="$HOME/Downloads/VirtualBox-$REQUIRED_VIRTUALBOX_VERSION.deb"
VIRTUALBOX_DOWNLOAD_URL="http://download.virtualbox.org/virtualbox/4.3.10/virtualbox-4.3_4.3.10-93012~Ubuntu~quantal_i386.deb"
VIRTUALBOX_INSTALL_CMD="sudo dpkg -i"
break;;
* )
echo "[INFO] Current Version of Script doesn't support this architecture of $OS_NAME"
break;;
esac
break;;
# 64-bit OS
"x86_64")
# Determine OS version
case $OS_REVISION in
"12.04" )
VIRTUALBOX_FILE="$HOME/Downloads/VirtualBox-$REQUIRED_VIRTUALBOX_VERSION.deb"
VIRTUALBOX_DOWNLOAD_URL="http://download.virtualbox.org/virtualbox/4.3.10/virtualbox-4.3_4.3.10-93012~Ubuntu~precise_amd64.deb"
VIRTUALBOX_INSTALL_CMD="sudo dpkg -i"
break;;
"12.10" )
VIRTUALBOX_FILE="$HOME/Downloads/VirtualBox-$REQUIRED_VIRTUALBOX_VERSION.deb"
VIRTUALBOX_DOWNLOAD_URL="http://download.virtualbox.org/virtualbox/4.3.10/virtualbox-4.3_4.3.10-93012~Ubuntu~quantal_amd64.deb"
VIRTUALBOX_INSTALL_CMD="sudo dpkg -i"
break;;
"13.04" )
VIRTUALBOX_FILE="$HOME/Downloads/VirtualBox-$REQUIRED_VIRTUALBOX_VERSION.deb"
VIRTUALBOX_DOWNLOAD_URL="http://download.virtualbox.org/virtualbox/4.3.10/virtualbox-4.3_4.3.10-93012~Ubuntu~raring_amd64.deb"
VIRTUALBOX_INSTALL_CMD="sudo dpkg -i"
break;;
* )
echo "[INFO] Current Version of Script doesn't support this architecture of $OS_NAME"
break;;
esac
break;;
# other than 32-bit and 64-bit
* )
echo "[INFO] Current Version of Script doesn't support this architecture of $OS_NAME"
break;;
esac
break;;
*)
#Cases for other Distros such as Debian,Ubuntu,SuSe,Solaris etc may come here
echo "Script for $OS_NAME "-" $OS_DISTRO has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
# Test if Virtualbox needs to be downloaded
if [ ! -d "$VIRTUALBOX_FILE" ] ; then
# Find version here
# http://download.virtualbox.org/virtualbox/
# check if Downloads directory exists, other create it
if [ ! -d "$HOME/Downloads" ]; then
mkdir "$HOME/Downloads"
fi
curl -Lk $VIRTUALBOX_DOWNLOAD_URL -o $VIRTUALBOX_FILE
echo "[INFO::] Downloaded"
fi
# Installing downloaded file
$VIRTUALBOX_INSTALL_CMD $VIRTUALBOX_FILE
sudo service vboxdrv setup
# Removing downloaded file
rm $VIRTUALBOX_FILE
fi
break;;
"Darwin")
echo "Mac OS X - Proceeding"
# $BASE_DIR/bootstrap/mac_app_installed.sh
# $BASE_DIR/bootstrap/mac_app_version.sh
# org.virtualbox.app.VirtualBox
$BASE_DIR/bootstrap/mac_app_installed.sh org.virtualbox.app.VirtualBox
INSTALLED=$?
echo ""
REQUIRED_VIRTUALBOX_VERSION=4.3.10
REQUIRED_VIRTUALBOX_URL=http://download.virtualbox.org/virtualbox/4.3.10/VirtualBox-4.3.10-93012-OSX.dmg
# https://github.com/noitcudni/vagrant-ae
if [ $INSTALLED == 1 ] ; then
# VirtualBox is installed
VERSION_VIRTUALBOX=`$BASE_DIR/bootstrap/mac_app_version.sh org.virtualbox.app.VirtualBox`
echo "INSTALLED: [ VirtualBox ]"
printf "\t"
echo "$VERSION_VIRTUALBOX"
# Test virtualbox in system
$BASE_DIR/bootstrap/version_compare.py $VERSION_VIRTUALBOX $REQUIRED_VIRTUALBOX_VERSION
CMP_RESULT=$?
if [ ! $CMP_RESULT -eq 2 ] ; then
# Remove VIRTUALBOX if not verion: $REQUIRED_VIRTUALBOX_VERSION
# http://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell-script
echo "Current VirtualBox Version: $VERSION_VIRTUALBOX"
echo "Required VirtualBox Version: $REQUIRED_VIRTUALBOX_VERSION"
echo ""
echo "Install Correct VirtualBox (Delete and Install)?"
while true; do
read -p "Is this ok [y/N]:" yn
case $yn in
[Yy]* )
echo "Removing VirtualBox";
PATH_VIRTUALBOX=`$BASE_DIR/bootstrap/mac_app_path.sh org.virtualbox.app.VirtualBox`
if [ ! $? -eq 0 ] ; then
echo "Determining Path to VirtualBox returned and error."
echo "Please manually remove VirtualBox"
exit 1;
fi
echo "Remove Path ($PATH_VIRTUALBOX):?"
while true; do
read -p "Is this ok [y/N]:" yn
case $yn in
[Yy]* )
echo "Removing VirtualBox";
INSTALL_VIRTUALBOX=1
# Test if there are any running VM's and shut them down
# VBoxManage controlvm `VBoxManage list runningvms | awk '{ print $1 }' | tr -d '"' | head -n 1` poweroff
VM_COUNT=`VBoxManage list runningvms | wc -l | awk '{ print $1 }'`
while [ $VM_COUNT -gt 0 ]
do
VBoxManage controlvm `VBoxManage list runningvms | awk '{ print $1 }' | tr -d '"' | head -n 1` poweroff
VM_COUNT=`VBoxManage list runningvms | wc -l | awk '{ print $1 }'`
done
if [ -n "$PATH_VIRTUALBOX" -a -d "$PATH_VIRTUALBOX" ] ; then
sudo rm -rf $PATH_VIRTUALBOX
fi
break;;
[Nn]* ) echo "Skipping Removing"; break;;
* ) echo "Please answer yes or no.";;
esac
done
break;;
[Nn]* ) echo "No"; break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
else
# VirtualBox is not installed
INSTALL_VIRTUALBOX=1
echo "Not Installed"
fi
# Install VirtualBox
if [ -n "$INSTALL_VIRTUALBOX" ] ; then
echo "Install VirtualBox"
VIRTUALBOX_FILE="$HOME/Downloads/VirtualBox-$REQUIRED_VIRTUALBOX_VERSION.dmg"
if [ ! -d "$VIRTUALBOX_FILE" ] ; then
# Find version here
# http://download.virtualbox.org/virtualbox/
# check if Downloads directory exists, other create it
if [ ! -d "$HOME/Downloads" ]; then
mkdir "$HOME/Downloads"
fi
curl -Lk ${REQUIRED_VIRTUALBOX_URL} -o $VIRTUALBOX_FILE
fi
hdiutil attach $VIRTUALBOX_FILE
sudo installer -package /Volumes/VirtualBox/VirtualBox.pkg -target '/Volumes/Macintosh HD'
hdiutil detach /Volumes/VirtualBox/
rm $VIRTUALBOX_FILE
fi
break;;
* )
#Cases for other OS such as Windows may come here
echo "Script for $OS_NAME has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
########################################
########################################
####
#### INSTALL VAGRANT
####
########################################
########################################
# variable declarations
INSTALL_VAGRANT=''
REQUIRED_VAGRANT_VERSION=1.5.2
VERSION_VAGRANT=''
VAGRANT_DOWNLOAD_URL=''
VAGRANT_INSTALL_CMD=''
VAGRANT_FILE=''
# Test if Vagrant is installed
command -v vagrant >/dev/null 2>&1
INSTALLED=$?
# Test if already installed
if [ $INSTALLED == 0 ] ; then
#echo "Vagrant is already installed."
echo ""
VERSION_VAGRANT=`vagrant -v | awk '{ print $2 }'`
echo "INSTALLED: [ Vagrant ]"
printf "\t"
echo "$VERSION_VAGRANT"
# Comparing installed and required versions
$BASE_DIR/bootstrap/version_compare.py $VERSION_VAGRANT $REQUIRED_VAGRANT_VERSION
CMP_RESULT=$?
# Test if installed version is lower then required version
if [ ! $CMP_RESULT -eq 2 ] ; then
# Remove Vagrant if not verion: $REQUIRED_VAGRANT_VERSION
echo "Current Vagrant Version: $VERSION_VAGRANT"
echo "Required Vagrant Version: $REQUIRED_VAGRANT_VERSION"
echo ""
echo "Install Correct Vagrant (Delete and Install)?"
while true; do
read -p "Is this ok [y/N]:" yn
case $yn in
[Yy]* )
echo -e "\n Removing Vagrant \n";
INSTALL_VAGRANT=1
#Determining OS and taking action accordingly
case $OS_NAME in
"Linux" )
echo "$OS_NAME is current OS. "
echo ""
#Determining OS Distribution and taking remove action accordingly
case $OS_DISTRO in
"CentOS" )
echo -e "$OS_DISTRO - $OS_NAME Proceeding.\n"
sudo rm -rf /opt/vagrant
sudo rm /usr/bin/vagrant
break;;
"Ubuntu" )
echo -e "$OS_DISTRO - $OS_NAME Proceeding.\n"
sudo rm -rf /opt/vagrant
sudo rm /usr/bin/vagrant
break;;
*)
#Cases for other Distros such as Debian,Ubuntu,SuSe,Solaris etc may come here
echo "Script for $OS_NAME "-" $OS_DISTRO has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
break;;
"Darwin" )
echo -e "Mac OS X Proceeding"
break;;
* )
#Cases for other Distros such as Windows etc may come here
echo "Script for $OS_NAME "-" $OS_DISTRO has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
break;;
[Nn]* )
echo "No"; break;;
* )
echo "Please answer yes or no.";;
esac
done
fi
else
INSTALL_VAGRANT=1
echo "Vagrant is Not Installed"
fi
# Test whether Vagrant needs to be installed or not
if [ -n "$INSTALL_VAGRANT" ] ; then
echo "Install Vagrant"
# Determining OS and talking actiion accordingly
case $OS_NAME in
"Linux" )
echo "$OS_NAME is current OS"
echo ""
# Determining OS Distribution and taking install action accordingly
case $OS_DISTRO in
"CentOS" )
echo "$OS_DISTRO - $OS_NAME Proceeding."
VAGRANT_FILE="$HOME/Downloads/Vagrant-$REQUIRED_VAGRANT_VERSION.rpm"
VAGRANT_DOWNLOAD_URL="https://dl.bintray.com/mitchellh/vagrant/vagrant_1.5.2_x86_64.rpm"
VAGRANT_INSTALL_CMD='sudo rpm -ivh'
break;;
"Ubuntu" )
echo "$OS_DISTRO-$OS_ARCH - $OS_NAME Proceeding."
# Determining OS Architecture
case $OS_ARCH in
# 32-bit os
"i686" )
echo "$OS_DISTRO - $OS_NAME Proceeding."
VAGRANT_FILE="$HOME/Downloads/Vagrant-$REQUIRED_VAGRANT_VERSION.deb"
VAGRANT_DOWNLOAD_URL="https://dl.bintray.com/mitchellh/vagrant/vagrant_1.5.2_i686.deb"
VAGRANT_INSTALL_CMD="sudo dpkg -i"
break;;
# 64-bit os
"x86_64" )
VAGRANT_FILE="$HOME/Downloads/Vagrant-$REQUIRED_VAGRANT_VERSION.deb"
VAGRANT_DOWNLOAD_URL="https://dl.bintray.com/mitchellh/vagrant/vagrant_1.5.2_x86_64.deb"
VAGRANT_INSTALL_CMD="sudo dpkg -i"
break;;
# other
* )
#Cases for other Distros such as Debian,Ubuntu,SuSe,Solaris etc may come here
echo "Script for $OS_NAME "-" $OS_DISTRO has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
break;;
* )
#Cases for other Distros such as Debian,Ubuntu,SuSe,Solaris etc may come here
echo "Script for $OS_NAME "-" $OS_DISTRO has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
break;;
"Darwin" )
echo "Mac OS X Proceeding"
echo ""
VAGRANT_FILE="$HOME/Downloads/Vagrant-$REQUIRED_VAGRANT_VERSION.dmg"
VAGRANT_DOWNLOAD_URL="https://dl.bintray.com/mitchellh/vagrant/vagrant_1.5.2.dmg"
VAGRANT_INSTALL_CMD="hdiutil attach $VAGRANT_FILE && sudo installer -package /Volumes/Vagrant/Vagrant.pkg -target '/Volumes/Macintosh HD' && hdiutil detach /Volumes/Vagrant/"
break;;
* )
#Cases for other OS such as Windows etc may come here
echo "Script for $OS_NAME has not been tested yet."
echo "Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
# Test if Vagrant needs to be downloaded
if [ ! -d "$VAGRANT_FILE" ] ; then
# Find version here
# http://download.virtualbox.org/virtualbox/
# check if Downloads directory exists, other create it
if [ ! -d "$HOME/Downloads" ]; then
mkdir "$HOME/Downloads"
fi
curl -Lk $VAGRANT_DOWNLOAD_URL -o $VAGRANT_FILE
fi
# Installing downloaded file
case $OS_NAME in
"Linux" )
$VAGRANT_INSTALL_CMD $VAGRANT_FILE
break;;
"Darwin" )
eval $VAGRANT_INSTALL_CMD
break;;
esac
# Removing downloaded file
rm $VAGRANT_FILE
fi
########################################
########################################
####
#### INSTALL JAVA
####
########################################
########################################
# Variable declarations
INSTALL_JAVA=''
VERSION_JAVA=''
REQUIRED_JAVA_VERSION=1.7
JAVA_DOWNLOAD_URL=''
JAVA_FILE=''
JAVA_INSTALL_CMD=''
# Testing java installation
command -v java -version >/dev/null 2>&1
INSTALLED=$?
echo ""
# Checking java if installed
if [ $INSTALLED == 0 ] ; then
# Java is installed
# java version "1.7.0_17"
# Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
# Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
# 1) send to standard out
# 2) pull third column "version"
# 3) only get first line
# 4) remove quotes
VERSION_JAVA=`java -version 2>&1 | awk '{ print $3 }' | head -n 1 | tr -d '"'`
# 1) Remove everything after the "_" underscore
VERSION_JAVA=${VERSION_JAVA%%_*}
echo "INSTALLED: [ Java ]"
printf "\t"
echo "$VERSION_JAVA"
$BASE_DIR/bootstrap/version_compare.py $VERSION_JAVA $REQUIRED_JAVA_VERSION
CMP_RESULT=$?
# Test if installed version is less than required version
if [ $CMP_RESULT -lt 2 ] ; then
# Remove JAVA if not verion: $REQUIRED_JAVA_VERSION
# http://stackoverflow.com/questions/226703/how-do-i-prompt-for-input-in-a-linux-shell-script
echo "Current Java Version: $VERSION_JAVA"
echo "Required Java Version: $REQUIRED_JAVA_VERSION"
echo ""
echo "Install Correct Java (Delete and Install)?"
echo ""
while true; do
read -p "Is this ok [y/N]:" yn
case $yn in
[Yy]* )
echo "[INFO] Removing Java";
#http://www.java.com/en/download/help/linux_uninstall.xml
######################RPM uninstall####################################
# Note: If you have RPM on your Linux box, you should first find out if Java is already installed using RPM. If Java is not installed using RPM, you should skip reading.
# Open Terminal Window
# Login as the super user
# Try to find jre package by typing: rpm -qa
# If RPM reports a package similar to jre-<version>-fcs, then Java is installed with RPM.
# Note: Normally, you do not need to uninstall Java with RPM, because RPM is able to uninstall the old version of Java when installing a new version! You may skip reading, unless you want to remove Java permanently.
# To uninstall Java, type: rpm -e jre-<version>-fcs
#######################Self-extracting file uninstall##################
# Find out if Java is installed in some folder. Common locations are /usr/java/jre_<version> or /opt/jre_nb/jre_<version>/bin/java/
# When you have located the folder, you may delete folder.
# Warning: You should be certain that Java is not already installed using RPM before removing the folder.
# Type: rm -r jre<version>
# For example: rm -r jre1.6.0
# For Mac OS X
#Navigate to /Library/Java/JavaVirtualMachines and remove the directory whose name matches the following format:*
# /Library/Java/JavaVirtualMachines/jdk<major>.<minor>.<macro[_update]>.jdk
#For example, to uninstall 7u6:
# % rm -rf jdk1.7.0_06.jdk
# For Linux
# sudo rm -rf /opt/vagrant
# sudo rm /usr/bin/vagrant
# User Dir
# ~/.vagrant.d
INSTALL_JAVA=1
#Determining OS and taking remove action accordingly
case $OS_NAME in
"Linux" )
echo "[INFO] $OS_NAME is current OS. "
#Determining OS Distribution and taking remove action accordingly
case $OS_DISTRO in
"CentOS" )
echo -e "[INFO] $OS_DISTRO - $OS_NAME Proceeding.\n"
break;;
"Ubuntu" )
echo -e "[INFO::] $OS_DISTRO - $OS_NAME Proceeding.\n"
break;;
*)
#Cases for other Distros such as Debian,Ubuntu,SuSe,Solaris etc may come here
echo "[INFO] Script for $OS_NAME "-" $OS_DISTRO has not been tested yet."
echo "[INFO] Submit Patch to https://github.com/DemandCube/developer-setup."
break;;
esac
break;;
"Darwin" )