forked from cloudfoundry-attic/vcap
/
install
executable file
·129 lines (103 loc) · 3.9 KB
/
install
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
#!/bin/bash
# Allow VCAP_REPO to be overriden for testing
VCAP_REPO=${VCAP_REPO:-https://github.com/cloudfoundry/vcap.git}
export rvm_trust_rvmrcs_flag=1 # Trust all rmvrcs we find
OS=`uname -s`
if [[ $OS == 'Linux' ]]; then
PLATFORM='Linux'
elif [[ $OS == 'Darwin' ]]; then
PLATFORM='MacOSX'
else
echo "Unknown System, cancelling setup"
exit 1
fi
echo ""
echo '-----------------------------------------------------------'
echo "($PLATFORM) One Click Installer for VMware's Cloud Application Platform!"
echo '-----------------------------------------------------------'
echo ""
echo "Hopefully this will be the last time you type your password"
sudo ls > /dev/null
read -p "Enter the password you want to use for root mysql user: " MYSQL_PASS
read -p "Enter the password you want to use for root postgresql user: " POSTGRESQL_PASS
echo "Installing dependencies"
if [[ $PLATFORM == 'Linux' ]]; then
sudo apt-get update
sudo apt-get -qqy install coreutils autoconf libtool curl git-core ruby bison build-essential zlib1g-dev libssl-dev libreadline5-dev
else
echo "Sorry, we can't install dependencies for your system yet."
fi
# Overide user-supplied mysql & postgresql passwords with random ones
# if we know how to do it on this platform
if [[ $PLATFORM == 'Linux' ]]; then
MYSQL_PASS="$(cat /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c10)"
POSTGRESQL_PASS="$(cat /dev/urandom | tr -dc _A-Z-a-z-0-9 | head -c10)"
elif [[ $PLATFORM == 'MacOSX' ]]; then
MYSQL_PASS="$(md5 -qs "$(date)")"
sleep 1
POSTGRESQL_PASS="$(md5 -qs "$(date)")"
fi
echo "Patch around .bash_profile issue with RMV"
if [ -f ~/.bashrc ]; then
if [ ! -f ~/.bash_profile ]; then
# rvm install is going to write into .bash_profile in this
# case and short circuit loading of .bashrc so we need to
# create a proper .bash_profile if its missing
echo "# This file is sourced by bash for login shells. The following line" >> ~/.bash_profile
echo "# runs your .bashrc and is recommended by the bash info pages." >> ~/.bash_profile
echo "[[ -f ~/.bashrc ]] && . ~/.bashrc" >> ~/.bash_profile
fi
fi
echo "Installing rvm"
curl -s -k -B https://rvm.beginrescueend.com/install/rvm > /tmp/install_rvm
bash /tmp/install_rvm
rm /tmp/install_rvm
echo "Activate rvm"
if [ "$(id -u)" != "0" ]; then
rvm_path="$HOME/.rvm"
else
rvm_path="/usr/local/rvm"
fi
[[ -s "$rvm_path/scripts/rvm" ]] && source "$rvm_path/scripts/rvm"
type rvm | head -1
# remove rake from default and global gems and instead install manually
rm $rvm_path/gemsets/default.gems
rm $rvm_path/gemsets/global.gems
echo "Installing various rubies"
rvm install 1.9.2-p180
rvm --default 1.9.2-p180
rvm install 1.8.7-p352
# install only rake 0.8.7
rvm use 1.8.7-p352
gem install rake --version '0.8.7' --no-rdoc --no-ri
rvm use 1.9.2-p180
gem install rake --version '0.8.7' --no-rdoc --no-ri
echo "Getting vcap"
[ -d ~/cloudfoundry ] || mkdir ~/cloudfoundry
cd ~/cloudfoundry
[ -d vcap ] || git clone $VCAP_REPO
cd vcap
git submodule update --init
gem install vmc --no-rdoc --no-ri
echo "Setting up vcap."
cd ~/cloudfoundry/vcap
sudo setup/vcap_setup -a -s -p "$MYSQL_PASS" -q "$POSTGRESQL_PASS"
cd ~/cloudfoundry/vcap/services/mysql/config
sed -i.bkup -e "s/pass: root/pass: $MYSQL_PASS/" mysql_node.yml
if [ -d ~/cloudfoundry/vcap/services/postgresql ]; then
cd ~/cloudfoundry/vcap/services/postgresql/config
sed -i.bkup -e "s/9.0/8.4/g" postgresql_gateway.yml
sed -i.bkup -e "s/user: vcap/user: postgres/" -e "s/pass: vcap/pass: $POSTGRESQL_PASS/" postgresql_node.yml
fi
echo "Restarting nginx"
cd ~/cloudfoundry/vcap
sudo cp setup/simple.nginx.conf /etc/nginx/nginx.conf
sudo /etc/init.d/nginx restart
echo "Installing bundler"
cd ~/cloudfoundry/vcap
gem install bundler --no-rdoc --no-ri
rake bundler:install
# don't start up vcap in this shell
# its best to exit the shell and then
# come back in so that the .rvmrc in cloudfoundry/vcap activates correctly
echo 'Success!'