Skip to content

Instantly share code, notes, and snippets.

@foscomputerservices
Last active September 5, 2017 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foscomputerservices/c9b3cc6530d0b8a6e30078e3b9f74358 to your computer and use it in GitHub Desktop.
Save foscomputerservices/c9b3cc6530d0b8a6e30078e3b9f74358 to your computer and use it in GitHub Desktop.
#
# Usage: install-amazon-linux-rbenv.sh
#
# This script is meant to work in conjunction with:
# https://gist.github.com/foscomputerservices/e97aeccbc820c42ff125
#
# If the EBS mount-point /mnt/bamboo-ebs/.rbenv exists, that will be used as the .rbenv directory,
# otherwise a full install of ruby/rails will be performed.
#
# For install to succeed, the following packages must already be installed:
# * yum install -y openssl-devel readline-devel zlib-devel mysql-devel mysql-libs
# * yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
set -x
RUBY_VER="2.4.1"
INSTALL=""
if [ -e /mnt/bamboo-ebs/.rbenv ] ; then
INSTALL=""
else
INSTALL="-install"
fi
if [ "$INSTALL" = "-install" ]; then
echo "Installing RBENV..."
# Manually configure RBENV
git clone git://github.com/sstephenson/rbenv.git $HOME/.rbenv
git clone git://github.com/sstephenson/ruby-build.git $HOME/.rbenv/plugins/ruby-build
else
# Copy pre-configured Ruby on Rails configuration from EBS
cp -R /mnt/bamboo-ebs/.rbenv $HOME
fi
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> $HOME/.bashrc
eval "$(rbenv init -)"
echo 'eval "$(rbenv init -)"' >> $HOME/.bashrc
# Manually install Ruby (takes about 12 minutes)
if [ "$INSTALL" = "-install" ] ; then
echo "Installing Ruby version $RUBY_VER..."
rbenv install $RUBY_VER
fi
rbenv global $RUBY_VER
if [ "$INSTALL" = "-install" ] ; then
echo 'gem: --no-document' > $HOME/.gemrc
gem install bundler
# gem install aws-sdk # Amazon Web Service support
# gem install rails -v $RAILS_VER
rbenv rehash
fi
if [ "$INSTALL" = "-install" ] ; then
# Source: https://github.com/teampoltergeist/poltergeist
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar xvjf phantomjs-2.1.1-linux-x86_64.tar.bz2
mkdir $HOME/bin
cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs $HOME/bin
fi
echo "**************************************************"
echo "*** Amazon Linux Ruby Installation Complete!!! ***"
echo "**************************************************"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment