Skip to content

Instantly share code, notes, and snippets.

@VanTanev
Forked from TylerRick/bootstrap-rvm-erb.sh
Last active December 17, 2015 18:49
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 VanTanev/5656085 to your computer and use it in GitHub Desktop.
Save VanTanev/5656085 to your computer and use it in GitHub Desktop.
Opinionated version of the bootstrap file
# Based on: https://gist.github.com/TylerRick/1961638
#
# vim: set ft=sh
#
# This script automatically bootstraps the system with everything it needs to run chef-solo.
# Note: This should only do the absolute minimum necessary to get chef-solo (and your recipes)
# working. All else should be done via chef recipes.
#===================================================================================================
# Config
ruby_version="ruby-2.0.0"
#===================================================================================================
# Initialization
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
OS=$DISTRIB_ID
elif [ -f /etc/redhat-release ]; then
OS="Red Hat"
else
echo "This distro isn't supported yet. Please submit a patch."
ls /etc/*release
cat /etc/issue
exit 1
fi
function fail {
echo "Error: $1"
exit 1
}
#===================================================================================================
echo
echo "Installing prerequisite packages..."
if [[ "$OS" == "Ubuntu" ]]; then
sudo apt-get update
# This list is from running 'rvm requirements'
sudo apt-get install -y build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion
elif [[ "$OS" == "Red Hat" ]]; then
# based on build-essential cookbook: https://github.com/opscode-cookbooks/build-essential/blob/master/recipes/rhel.rb
sudo yum install -y git autoconf bison flex gcc gcc-c++ kernel-devel make m4
# Another option for installing git would be:
# sudo bash < <( curl -s https://rvm.io/install/git )
fi
#===================================================================================================
# In case rvm is already installed, this is needed in order to find the rvm command.
source /etc/profile
if { rvm -v; }; then
echo "rvm already installed"
else
echo "Installing rvm..."
sudo curl -L https://get.rvm.io | bash -s stable
source /etc/profile
fi
#===================================================================================================
echo
# if user is not root
if [[ $EUID -ne 0 ]]; then
echo "Adding $(whoami) to rvm group..."
#sudo adduser $(whoami) rvm
sudo usermod -a -G rvm $(whoami)
id --groups --name | grep rvm || fail "$(whoami) still not in rvm group; you may have to run this again for the new group to take effect"
fi
echo
echo "Installing ruby..."
rvm install $ruby_version || fail "rvm install $ruby_version failed"
rvm --default $ruby_version
#===================================================================================================
echo
echo "Installing default gems..."
rvm use default@global &&
rvm default@global do gem install bundler --no-rdoc --no-ri || fail "could not install bundler"
echo "Creating chef gemset"
rvm use --create default@chef &&
gem install chef --no-rdoc --no-ri || fail "could not install chef"
echo "Creating chef-berkshelf gemset"
rvm use --create default@chef-berkshelf &&
gem install chef --no-rdoc --no-ri || fail "could not install chef"
rvm use --create default@chef-berkshelf &&
gem install berkshelf --no-rdoc --no-ri || fail "could not install berkshelf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment