Skip to content

Instantly share code, notes, and snippets.

@wnoguchi
Created October 22, 2013 11:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wnoguchi/7099085 to your computer and use it in GitHub Desktop.
Save wnoguchi/7099085 to your computer and use it in GitHub Desktop.
rbenv and rails environement one shot install script.
#!/bin/bash
#=====================================
# Settings Here
#=====================================
# Platform
PLATFORM=Ubuntu
#PLATFORM="CentOS"
# Rails Application Name
RAILS_APP_NAME=example
# Ruby Version
#RUBY_VERSION=2.0.0-p247
RUBY_VERSION=1.9.3-p392
# Rails Version
#RAILS_VERSION=4.0.0
RAILS_VERSION=3.2.14
# Git User Configuration
GIT_USER_NAME="Wataru Noguchi"
EMAIL="user@example.com"
GIT_OPTIONS=--global
#=====================================
if [ "$PLATFORM" = "Ubuntu" ]; then
sudo apt-get -y install libssl-dev zlib1g-dev libreadline-dev libmysqlclient-dev sqlite3 libsqlite3-dev g++ git curl
else
yum -y groupinstall "Development Tools"
yum -y install openssl-devel zlib-devel readline-devel mysql-devel sqlite-devel git
fi
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
source ~/.bash_profile
git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
cd ~/.rbenv/plugins/ruby-build/
sudo ./install.sh
rbenv install $RUBY_VERSION
rbenv global $RUBY_VERSION
rbenv rehash
rbenv exec gem install bundler --no-ri --no-rdoc
rbenv rehash
cd ~
mkdir rails_projects
cd rails_projects/
cat << EOS > Gemfile
source "https://rubygems.org"
gem "rails", "$RAILS_VERSION"
EOS
bundle install --path vendor/bundle
bundle exec rails new $RAILS_APP_NAME --skip-bundle
cd $RAILS_APP_NAME
cat <<EOF >> Gemfile
gem 'execjs'
gem 'therubyracer'
EOF
bundle install --path vendor/bundle
echo '/vendor/bundle' >> .gitignore
git init
git add .
git config $GIT_OPTIONS user.name $USERNAME
git config $GIT_OPTIONS user.email $EMAIL
git commit -m "Initial commit."
echo "finished!"
@kendofriendo
Copy link

これを六年前作りましたからもしかして忘れましたが、たまたま見つけまして感謝するしなきゃいけませんでした。ありがとうございます!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment