Ruby 1.9.3,Mysql,Nginx,Unicorn - CTS-V1.4

by ctsimpson
40 deployments · 5 still active · last rev. 6 years ago

Ruby 1.9.3, Nginx, mysql, essentials and deploy user with bundler,rails,and unicorn gems

Compatible with: No distros currently supported

source <ssinclude StackScriptID="1">

# <UDF name="db_password" Label="MySQL root Password" />
# <UDF name="db_name" Label="Create Database" default="" example="Optionally create this database" />
# <UDF name="db_user" Label="Create MySQL User" default="" example="Optionally create this user" />
# <UDF name="db_user_password" Label="MySQL User's Password" default="" example="User's password" />

# <udf name="rails_version" label="Rails Version" oneOf="3.2.8" example="These versions have been tested" />

# <udf name="ruby_version" label="Choose Ruby Version" oneOf="ruby-1.9.3-p194" example="These are downloaded from" />
# <udf name="gems_to_install1" label="Gems to install" manyOf="mysql,unicorn,bundler,sqlite3-ruby,rspec,rcov,capistrano" default="mysql,unicorn,bundler" example="Each selected gem will be installed." />
# <udf name="gems_to_install2" label="More gems to install" default="" example="Comma separated inputs to gem install. Example: rails,nifty-generators,formtastic,... Add the -v if you need a specific version." />

# This script is generated and run after gem is installed to
# install the list of gems given by the stack script."

export logfile
export gems_to_install1="$GEMS_TO_INSTALL1"
export gems_to_install2="$GEMS_TO_INSTALL2"
# exported to be available in ruby_script_to_run.rb

echo "System Updated" >> $logfile
echo "postfix_install_loopback_only" >> $logfile
mysql_install "$DB_PASSWORD" && mysql_tune 40
echo "Mysql installed" >> $logfile
mysql_create_database "$DB_PASSWORD" "$DB_NAME"
mysql_create_user "$DB_PASSWORD" "$DB_USER" "$DB_USER_PASSWORD"
mysql_grant_user "$DB_PASSWORD" "$DB_USER" "$DB_NAME"

if [[ $PHP_INSTALL == yes ]]
  php_install_with_apache && php_tune
  echo "Php installed" >> $logfile

#installing nginx
echo -ne '\n' | apt-add-repository ppa:nginx/stable
apt-get -y update
apt-get -y install nginx
echo "Nginx installed" >> $logfile

#install nodejs
echo -ne '\n' | apt-add-repository ppa:chris-lea/node.js
apt-get -y update
apt-get -y install nodejs

#install imagemagick
apt-get -y install imagemagick

#installing ruby
apt-get -y install curl build-essential openssl ruby-dev libmysqlclient-dev libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison python-software-properties
echo "libs for ruby installed" >> $logfile
echo "$RUBY_VERSION.tar.gz" >> $logfile
echo "$RUBY_VERSION" >> $logfile

echo "" >> $logfile
if [[ $RUBY_VERSION == ruby\-1\.9* ]]
	echo "Downloading: (from calling wget$RUBY_VERSION.tar.gz)" >> $logfile
echo "" >> $logfile
	wget$RUBY_VERSION.tar.gz  >> $logfile
	echo "Downloadin: (from calling wget$RUBY_VERSION.tar.gz)" >> $logfile
echo "" >> $logfile
	wget$RUBY_VERSION.tar.gz  >> $logfile

echo ""
echo "tar output:"
tar xzf $RUBY_VERSION.tar.gz >> $logfile
rm $RUBY_VERSION.tar.gz

echo ""
echo "current directory:"
pwd >> $logfile

echo "" >> $logfile
echo "Ruby Configuration output: (from calling ./configure --disable-ucontext --enable-pthread)" >> $logfile
echo "" >> $logfile
./configure >> $logfile

echo "" >> $logfile
echo "Ruby make output: (from calling make)" >> $logfile
echo "" >> $logfile
make >> $logfile

echo "" >> $logfile
echo "Ruby make install output: (from calling make install)" >> $logfile
echo "" >> $logfile
make install >> $logfile
cd /

echo "" >> $logfile
echo "Downloading Ruby Gems with wget" >> $logfile
echo "" >> $logfile
wget >> $logfile

echo ""
echo "tar output:"
tar xzvf rubygems-1.8.24.tgz  >> $logfile
rm rubygems-1.8.24.tgz

echo ""
echo "rubygems setup:"
cd rubygems-1.8.24
ruby setup.rb >> $logfile
cd /
rm -rf rubygems-1.8.24

#install rails
gem install rails -v $RAILS_VERSION --no-ri --no-rdoc >> $logfile

echo ""
echo "gem update --system:"
gem update --system >> $logfile

# echo the ruby code to a file to be run
echo "
    ##### Ruby Code Starts Here #####

    gems_to_install1 = ENV['gems_to_install1']
    gems_to_install2 = ENV['gems_to_install2']
    puts gems_to_install1
    puts gems_to_install2
    gems_to_install1.split(',').each do |gem_name|
      \`gem install #{gem_name} --no-ri --no-rdoc >> $logfile\`
    gems_to_install2.split(',').each do |gem_name|
      \`gem install #{gem_name} --no-ri --no-rdoc >> $logfile\`

    ##### Ruby Code Ends Here #####" >> $rubyscript

ruby $rubyscript >> $logfile

echo "StackScript Finished!" >> $logfile