Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: e6378a1d79
Fetching contributors…

Cannot retrieve contributors at this time

executable file 567 lines (479 sloc) 16.563 kB
#!/bin/bash
# Copyright (c) 2009-2011 VMware, Inc.
# Try to detect platform. VCAP installs well on Ubuntu and MacOS X Systems.
usage() {
cat <<EOF
usage: $0 options
OPTIONS:
-h Show this message
-a Answer yes to all questions
-s Install all optional services
-p PASSWORD Preseed the MySQL password
-q PASSWORD Preseed the PostgreSQL password
EOF
}
while getopts "hasp:q:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
a)
ALL=true
;;
s)
ALL_SERVICES=true
;;
p)
MYSQL_PASS="$OPTARG"
;;
q)
POSTGRESQL_PASS="$OPTARG"
;;
esac
done
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) Setup for VMware's Cloud Application Platform!"
echo '-----------------------------------------------------------'
echo ""
if [[ $ALL != true ]]; then
echo "Just hit <enter> to skip any item"
echo ""
fi
if [ "$(id -u)" != "0" ]; then
echo '** Setup must be run as root **'
exit 1
fi
if [[ $ALL != true ]]; then
read -p "Setup all components? default: individual components? [y/N]"
if [[ $REPLY =~ ^[yY]$ ]]; then
ALL=true
fi
fi
# Defaults, done for everyone
echo "Installing default packages"
if [[ $PLATFORM == 'Linux' ]]; then
apt-get install -qqy wget curl libcurl3 libcurl3-dev bison build-essential zlib1g-dev libssl-dev libreadline5-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev git-core sqlite3 libsqlite3-ruby libsqlite3-dev unzip zip libcurl4-openssl-dev
fi
if [[ $PLATFORM == 'Linux' ]]; then
# Probably should make this something different instead of apt_get
echo "Installing Ruby"
apt-get install -qqy ruby-full rake
fi
# This is site/setup specific, can be commented out if not needed.
# export http_proxy='http://192.168.208.20:3128'
RUBYGEMS_VERSION=1.6.2
echo "Checking rubygems version"
if [ "$(gem -v)" != $RUBYGEMS_VERSION ]; then
echo "Installing rubygems $RUBYGEMS_VERSION"
pushd .
cd /tmp
wget http://production.cf.rubygems.org/rubygems/rubygems-$RUBYGEMS_VERSION.tgz
tar -zxf rubygems-$RUBYGEMS_VERSION.tgz
cd rubygems-$RUBYGEMS_VERSION
ruby setup.rb
if [ -f /usr/local/bin/gem ]; then
rm /usr/local/bin/gem
fi
cd ..
rm rubygems-$RUBYGEMS_VERSION.tgz
rm -fr rubygems-$RUBYGEMS_VERSION
popd
fi
ln -sf /usr/bin/gem1.8 /usr/bin/gem
echo "Creating default directories at /var/vcap"
if [ ! -d '/var/vcap' ]; then
mkdir /var/vcap
mkdir /var/vcap/sys
mkdir /var/vcap/sys/log
mkdir /var/vcap/shared
mkdir /var/vcap/services
chmod -R 777 /var/vcap
fi
if [[ ! "$(bundle -v)" =~ "1.0.10" ]]; then
echo "Installing bundler 1.0.10"
gem install bundler -v 1.0.10 --no-rdoc --no-ri
fi
#######################################################################
# Router
if [[ $ALL != true ]]; then
echo ""
read -p "Should I do a Router setup? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
ROUTER=true
fi
fi
if [[ $ROUTER == true || $ALL == true ]]; then
echo "Installing Nginx."
if [[ $PLATFORM == 'Linux' ]]; then
apt-get install -qqy nginx
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Implement for MacOSX \033[0m"
fi
echo ""
fi
# CloudController
if [[ $ALL != true ]]; then
read -p "Should I do a CloudController setup? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
CC=true
fi
fi
if [[ $CC == true || $ALL == true ]]; then
if [[ $PLATFORM == 'Linux' ]]; then
if [[ $ALL != true ]]; then
read -p "Should I do a production setup as well (Postgres/MySQL)? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
RELATIONAL_DBS=true
fi
fi
if [[ $RELATIONAL_DBS == true || $ALL == true ]]; then
echo "Installing PostgreSQL server and support"
apt-get install -qqy postgresql libpq-dev
if [[ -n "$POSTGRESQL_PASS" ]]; then
su - postgres -c "/usr/bin/psql -c \"alter role postgres password '$POSTGRESQL_PASS'\""
fi
echo "Installing pg gems"
gem install pg --no-rdoc --no-ri
echo ""
echo "Installing MySQL server and support"
if [[ -n "$MYSQL_PASS" ]]; then
echo mysql-server-5.1 mysql-server/root_password select $MYSQL_PASS | debconf-set-selections
echo mysql-server-5.1 mysql-server/root_password_again select $MYSQL_PASS | debconf-set-selections
fi
apt-get install -qqy mysql-server ruby-dev libmysql-ruby libmysqlclient-dev
echo "Installing mysql gems"
gem install mysql --no-rdoc --no-ri
echo ""
fi
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Implement for MacOSX \033[0m"
fi
# note: vcap start runs db:migrate on each cloud boot
# no need to run anything during setup
fi
# DEA
if [[ $ALL != true ]]; then
read -p "Should I do a DEA setup (Java, Ruby, Node, etc)? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
DEA=true
fi
fi
if [[ $DEA == true || $ALL == true ]]; then
echo "Setting up for support for DEA"
# lsof support for secure dea monitoring, psmisc is for JeOS, which has killall5, not killall
if [[ $PLATFORM == 'Linux' ]]; then
apt-get install -qqy lsof psmisc
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Implement for MacOSX \033[0m"
fi
# For Ruby
if [[ $PLATFORM == 'Linux' ]]; then
apt-get install -qqy librmagick-ruby
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Implement for MacOSX \033[0m"
fi
# Java
if [[ $PLATFORM == 'Linux' ]]; then
JAVA=`dpkg --get-selections | grep sun-java6`
echo $JAVA
elif [[ $PLATFORM == 'MacOSX' ]]; then
JAVA=`java -version | grep 'build 1.6.0_22'`
fi
if [[ $JAVA == '' ]]; then
echo "Installing Sun Java 1.6"
if [[ $PLATFORM == 'Linux' ]]; then
apt-get install -qqy python-software-properties
add-apt-repository "deb http://archive.canonical.com/ lucid partner"
apt-get -qqy update
echo sun-java6-jdk shared/accepted-sun-dlj-v1-1 boolean true | debconf-set-selections
echo sun-java6-jre shared/accepted-sun-dlj-v1-1 boolean true | debconf-set-selections
apt-get install -qqy curl sun-java6-bin sun-java6-jre sun-java6-jdk
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Implement for MacOSX \033[0m"
fi
fi
# Python support
if [[ $PLATFORM == 'Linux' ]]; then
apt-get install -qqy python-setuptools python-dev
fi
easy_install pip
# Node framework
pushd .
cd /tmp
NODE_VERSION=0.4.12
if [[ ! `node -v` == 'v'$NODE_VERSION ]]; then
wget http://nodejs.org/dist/node-v$NODE_VERSION.tar.gz
tar -zxf node-v$NODE_VERSION.tar.gz
cd node-v$NODE_VERSION
./configure
make
make install
cd ..
rm node-v$NODE_VERSION.tar.gz
rm -fr node-v$NODE_VERSION
fi
# For PHP
if [[ $PLATFORM == 'Linux' ]]; then
apt-get install -qqy libpcre3 libpcre3-dev apache2 php5 php5-mysql php5-dev php-pear php5-gd libapr1 libaprutil1 php5-common php5-curl php5-mcrypt php5-imagick php5-xmlrpc zend-framework php5-imap
/etc/init.d/apache2 stop
update-rc.d -f apache2 remove
pear channel-discover pear.phpunit.de
pear channel-discover pear.symfony-project.com
pear channel-discover components.ez.no
pear install phpunit/PHPUnit
yes | pecl install apc
yes | pecl install memcache
yes | pecl install mongo
git clone git://github.com/owlient/phpredis.git
cd phpredis
phpize
./configure
make && make install
cd ..
rm -rf phpredis
echo "extension=apc.so" > /etc/php5/apache2/conf.d/cf.ini
echo "extension=memcache.so" >> /etc/php5/apache2/conf.d/cf.ini
echo "extension=mongo.so" >> /etc/php5/apache2/conf.d/cf.ini
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Implement for MacOSX \033[0m"
fi
# Erlang framework
ERLANG_VERSION=R14B02
if [ ! -d "/var/vcap/runtimes/erlang-$ERLANG_VERSION" ]; then
if [[ $PLATFORM == 'Linux' ]]; then
apt-get -qqy install build-essential libncurses5-dev openssl libssl-dev
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Install MacOSX dependencies \033[0m"
fi
wget http://erlang.org/download/otp_src_$ERLANG_VERSION.tar.gz
tar zxvf otp_src_$ERLANG_VERSION.tar.gz
cd otp_src_$ERLANG_VERSION
if [[ $PLATFORM == 'Linux' ]]; then
apt-get -qqy install build-essential libncurses5-dev openssl libssl-dev
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Install MacOSX dependencies \033[0m"
fi
./configure --prefix /var/vcap/runtimes/erlang-$ERLANG_VERSION
make
make install
fi
popd
echo "App Platform Support"
echo "===================="
echo -e "\nRuby should now be installed -->"
ruby -v
echo -e "\nJava should now be installed -->"
java -version
echo -e "\nNode should now be installed -->"
node -v
echo ""
echo -e "\nPHP should now be installed -->"
php -v
echo ""
echo -e "\nPython should now be installed -->"
python -V
echo ""
echo -e "\nErlang should now be installed -->"
erl -version
echo ""
echo "Setting up Ruby System Gems and Support"
if [[ $PLATFORM == 'Linux' ]]; then
apt-get install -qqy ruby-dev libmysql-ruby libmysqlclient-dev libpq-dev postgresql-client
elif [[ $PLATFORM == 'MacOSX' ]]; then
echo -e "\033[31mFIXME: Implement for MacOSX \033[0m"
fi
echo "Installing some default system gems"
echo "gem: --no-rdoc --no-ri" > ~/.gemrc
# original code did this in one shot, BUT with the rake issues with 0.9.0 and rails 3
# we hard version the rake gem to 0.8.7 since that is the only one that really works
gem install rack
gem install rake --version '0.8.7'
gem install thin sinatra eventmachine
if [ ! -d '/var/vcap.local' ]; then
echo "Creating directory /var/vcap.local"
mkdir "/var/vcap.local"
chmod 777 "/var/vcap.local"
fi
fi
if [[ $ALL != true ]]; then
read -p "Should I do a production setup and secure this system? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
PROD_SETUP=true
# Setup var directory
echo "Securing directories and permissions"
chmod 755 "/var"
chmod -R 700 "/var/vcap/sys"
chmod -R 700 "/var/vcap/shared"
chmod -R 700 "/var/vcap.local"
chmod -R 711 "/var/vcap.local"
chmod -R 711 "/var/vcap.local/apps"
chmod -R 700 "/tmp"
chmod -R 700 "/var/tmp"
fi
fi
###################
echo ""
echo "Additional Optional Services"
# if you answered no to the production setup
# question than you should answer yes here for sure
X=`which mysqld`
if [ $? != 0 ]; then
if [[ $ALL_SERVICES != true ]]; then
read -p "Should I add MySQL Server? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
MYSQL=true
fi
fi
if [[ $MYSQL == true || $ALL_SERVICES == true ]]; then
echo "Installing MySQL server and support"
if [[ -n "$MYSQL_PASS" && $PLATFORM == "Linux" ]]; then
echo mysql-server-5.1 mysql-server/root_password select $MYSQL_PASS | debconf-set-selections
echo mysql-server-5.1 mysql-server/root_password_again select $MYSQL_PASS | debconf-set-selections
fi
apt-get install -qqy mysql-server ruby-dev libmysql-ruby libmysqlclient-dev
echo "Installing mysql gems"
gem install mysql --no-rdoc --no-ri
echo ""
fi
fi
X=`which psql`
if [ $? != 0 ]; then
if [[ $ALL_SERVICES != true ]]; then
read -p "Should I add PostgreSQL Server? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
POSTGRESQL=true
fi
fi
if [[ $POSTGRESQL == true || $ALL_SERVICES == true ]]; then
echo "Installing PostgreSQL server and support"
apt-get install -qqy postgresql libpq-dev
if [[ -n "$POSTGRESQL_PASS" ]]; then
su - postgres -c "/usr/bin/psql -c \"alter role postgres password '$POSTGRESQL_PASS'\""
fi
echo "Installing pg gems"
gem install pg --no-rdoc --no-ri
echo ""
fi
fi
REDIS_VERSION=2.2.4
redis_current=`redis-server -v | grep $REDIS_VERSION`
if [[ -z "$redis_current" ]]; then
if [[ $ALL_SERVICES != true ]]; then
read -p "Should I add Redis Server? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
REDIS=true
fi
fi
fi
if [[ $REDIS == true || $ALL_SERVICES == true ]]; then
echo "Installing Redis (version $REDIS_VERSION)"
pushd .
cd /tmp
wget --no-check-certificate -O redis_master.tgz http://redis.googlecode.com/files/redis-$REDIS_VERSION.tar.gz
tar -zxf redis_master.tgz
cd redis-$REDIS_VERSION/src
make
cp redis-server /usr/bin
cp redis-cli /usr/bin
cd ../..
rm redis_master.tgz
rm -fr redis-$REDIS_VERSION
popd
else
echo "Redis Server (version $REDIS_VERSION) is current"
fi
RABBITMQ_VERSION=2.4.0
RABBITMQ_VERSION_FULL=2.4.0-1_all
if [[ $ALL_SERVICES != true ]]; then
read -p "Should I add RabbitMQ Server? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
RABBITMQ=true
fi
fi
if [[ $RABBITMQ == true || $ALL_SERVICES == true ]]; then
echo "Installing RabbitMQ Server (version $RABBITMQ_VERSION)"
apt-get install -qqy erlang-nox
pushd .
cd /tmp
wget http://www.rabbitmq.com/releases/rabbitmq-server/v$RABBITMQ_VERSION/rabbitmq-server_$RABBITMQ_VERSION_FULL.deb
dpkg -i rabbitmq-server_$RABBITMQ_VERSION_FULL.deb
rm rabbitmq-server_$RABBITMQ_VERSION_FULL.deb
popd
fi
MONGODB_VERSION=1.8.1
mongodb_current=`mongod --version | grep $MONGODB_VERSION`
if [[ -z "$mongodb_current" ]]; then
if [[ $ALL_SERVICES != true ]]; then
read -p "Should I add the MongoDB Server? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
MONGODB=true
fi
fi
if [[ $MONGODB == true || $ALL_SERVICES == true ]]; then
echo "Installing MongoDB Server (version $MONGODB_VERSION)"
if [[ `uname -a` =~ "x86_64" ]] ; then
mongodb="mongodb-linux-x86_64-$MONGODB_VERSION"
echo "Installing 64-bit version"
else
mongodb="mongodb-linux-i686-$MONGODB_VERSION"
echo "Installing 32-bit version"
fi
pushd .
cd /tmp
wget http://fastdl.mongodb.org/linux/$mongodb.tgz
tar -zxvf $mongodb.tgz
cp $mongodb/bin/* /usr/bin
rm $mongodb.tgz
rm -fr $mongodb
popd
fi
else
echo "MongoDB Server (version $MONGODB_VERSION) is current"
fi
if [[ $ALL_SERVICES != true ]]; then
read -p "Should I add Neo4j Server? [y/N] "
if [[ $REPLY =~ ^[yY]$ ]]; then
NEO4J=true
fi
fi
NEO4J_VERSION=community-1.4.1
NEO4J_DIST_FILE=neo4j-community-1.4.1-unix.tar.gz
NEO4J_SERVICE_DIR=/var/vcap/services/neo4j
NEO4J_HOSTING_EXTENSION=authentication-extension-1.4.jar
if [[ -f "$NEO4J_SERVICE_DIR/$NEO4J_DIST_FILE" ]]; then
echo "Neo4j ($NEO4J_VERSION) is current"
else
if [[ $NEO4J == true || $ALL_SERVICES == true ]]; then
echo "Installing Neo4j Server (version $NEO4J_VERSION)"
pushd .
mkdir -p $NEO4J_SERVICE_DIR/instances
chmod -R 777 $NEO4J_SERVICE_DIR
cd $NEO4J_SERVICE_DIR
curl -O http://dist.neo4j.org/$NEO4J_DIST_FILE
rm neo4j-server.tgz
ln -s $NEO4J_DIST_FILE neo4j-server.tgz
curl -O http://dist.neo4j.org/$NEO4J_HOSTING_EXTENSION
rm neo4j-hosting-extension.jar
ln -s $NEO4J_HOSTING_EXTENSION neo4j-hosting-extension.jar
popd
fi
fi
echo -e "\n\nYou should be good to go!!\n\n"
ruby -v
echo -n "Gem version: "
gem -v
echo -e "\nGem List"
gem list --local
echo -e "\n\nBYE!\n\n"
Jump to Line
Something went wrong with that request. Please try again.