Skip to content

Instantly share code, notes, and snippets.

@croaky
Last active June 14, 2016 21:04
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 croaky/51e896eb837fbdc6d1786893d215e120 to your computer and use it in GitHub Desktop.
Save croaky/51e896eb837fbdc6d1786893d215e120 to your computer and use it in GitHub Desktop.
Ubuntu setup for a Rails app

Read the script, then run:

https://gist.githubusercontent.com/croaky/51e896eb837fbdc6d1786893d215e120/raw/87beeec2e9de349d6d6af93fd9c1cd253cecfc2e/ubuntu
#!/bin/sh
# A combination of the best of
# https://gorails.com/setup/ubuntu/14.10 and
# https://github.com/thoughtbot/laptop
fancy_echo() {
printf "\n%b\n" "$1"
}
if command -v aptitude >/dev/null; then
fancy_echo "Using aptitude ..."
else
fancy_echo "Installing aptitude for package management, better error messages than apt-get, is a super-set of apt-get ..."
sudo apt-get install -y aptitude
fi
sudo aptitude update
fancy_echo "Installing Git, for source control management ..."
sudo aptitude install -y git
fancy_echo "Installing system libraries for common dependencies ..."
sudo aptitude install -y libssl-dev \
libxslt1-dev \
libyaml-dev \
libxml2-dev \
curl \
libcurl4-openssl-dev \
libksba8 \
libksba-dev \
libqtwebkit-dev \
libreadline-dev \
zlib1g-dev \
build-essential \
libffi-dev
# Need-to-have - Ruby
if ! [ -d ~/.rbenv ]; then
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
exec $SHELL
fi
sudo chown -R `whoami` ~/.rbenv
if ! [ -d ~/.rbenv/plugins/ruby-build ]; then
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
exec $SHELL
fi
find_latest_ruby() {
rbenv install -l | grep -v - | tail -1 | sed -e 's/^ *//'
}
ruby_version="$(find_latest_ruby)"
rbenv install "$ruby_version"
rbenv global "$ruby_version"
rbenv shell "$ruby_version"
gem_install_or_update() {
if gem list "$1" --installed > /dev/null; then
gem update "$@"
else
gem install "$@" --no-document
rbenv rehash
fi
}
gem update --system
gem_install_or_update 'bundler'
number_of_cores=$(nproc)
bundle config --global jobs $((number_of_cores - 1))
fancy_echo "Installing Postgres, a good open source relational database ..."
sudo aptitude install -y postgresql postgresql-server-dev-all
sudo -u postgres createuser `whoami` -s
fancy_echo "Installing Node, to render the rails asset pipeline ..."
sudo aptitude install -y nodejs
fancy_echo "Installing Heroku Toolbelt, for interacting with Heroku ..."
wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
fancy_echo "Installing ImageMagick, to crop and resize images ..."
sudo aptitude install -y imagemagick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment