Ruby Install

by ratnikov
10 deployments · 1 still active · last rev. 5 years ago

Compatible with: No distros currently supported
						#!/bin/bash

# <udf name="ruby_version" label="Choose Ruby Version" default="ruby-1.9.2-p0" oneOf="ruby-1.9.2-p0,ruby-1.9.1-p376" example="These are downloaded from ftp://ftp.ruby-lang.org" />
# <udf name="bundler_version" label="Choose Bundler version" oneOf="0.9.24,NONE" />

if [ ! -n "$TMPDIR" ]; then
  TMPDIR=/var/tmp
fi

WORKING_DIR="$TMPDIR/ruby"
RUBY_FILENAME="$RUBY_VERSION.tar.gz"

mkdir -p "$WORKING_DIR"

apt-get update

apt-get install -y build-essential zlib1g-dev libssl-dev libreadline5-dev

echo "Installing ruby $RUBY_VERSION..."

cd $WORKING_DIR

wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/$RUBY_VERSION.tar.gz -O "$RUBY_FILENAME"

tar xzf "$RUBY_FILENAME"
cd "$RUBY_VERSION"

./configure --enable-shared --enable-pthread
make
make install

echo "Updating rubygems..."

./ruby bin/gem update --system

echo "Done installing ruby!"

echo "Installing rvm..."
./ruby bin/gem install rvm
echo "RVM installed!"

if [ "$BUNDLER_VERSION" == "NONE" ]; then
  echo "Skipping bundler installation"
else
  echo "Installing bundler $BUNDLER_VERSION..."
  if [ ! -n $BUNDLER_VERSION]; then
    ./ruby bin/gem install bundler --version $BUNDLER_VERSION
  else
    ./ruby bin/gem install bundler
  fi

  echo "Bundler $BUNDLER_VERSION installed."
fi