Skip to content

Instantly share code, notes, and snippets.

@cesc1989
Last active January 29, 2016 19:32
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 cesc1989/fe643a812a52cbc07e53 to your computer and use it in GitHub Desktop.
Save cesc1989/fe643a812a52cbc07e53 to your computer and use it in GitHub Desktop.
Provisioning Dev Stack. Provision a normal Linux machine or a Vagrant Ubuntu-based box.
#!/bin/bash
# Provisions a machine (not a vagrant box) for a Ruby on Rails development environment
# Change [USERNAME] for your username
set -e
if [ ! -f /home/[USERNAME]/.provisioning-progress ]; then
su [USERNAME] -c "touch /home/[USERNAME]/.provisioning-progress"
echo "--> Progress file created in /home/[USERNAME]/.provision-progress"
apt-get update
else
echo "--> Progress file exists in /home/[USERNAME]/.provisioning-progress"
fi
#Install Git, Build-essential, curl, vim, htop
if grep -q +core-libs .provisioning-progress; then
echo "--> Core libs (git, curl, etc) already installed, moving on."
else
echo "--> Installing core libs (git, curl, etc)..."
apt-get update
apt-get -y install build-essential curl git-core python-software-properties htop vim
apt-get -y install zlib1g-dev libssl-dev libreadline6-dev libyaml-dev libncurses5-dev libxml2-dev
apt-get -y install libsqlite3-dev sqlite3 libcurl4-openssl-dev libffi-dev libxslt-de libgmp-dev
su [USERNAME] -c "echo +core-libs >> /home/[USERNAME]/.provisioning-progress"
echo "--> Core libs (git, curl, etc) are now installed."
fi
# Install nodejs
if grep -q +nodejs .provisioning-progress; then
echo "--> NodeJS already installed, moving on."
else
echo "--> Installing nodeJS"
apt-add-repository ppa:chris-lea/node.js
apt-get update
apt-get -y install nodejs # needed by Rails to have a Javascript runtime
su [USERNAME] -c "echo +nodejs >> /home/[USERNAME]/.provisioning-progress"
echo "--> nodeJS is now installed"
fi
# Install ruby
if grep -q +ruby/2.1.5 .provisioning-progress; then
echo "--> ruby-2.1.5 is installed, moving on."
else
echo "--> Installing ruby-2.1.5 ..."
su [USERNAME] -c "mkdir -p /home/[USERNAME]/downloads; cd /home/[USERNAME]/downloads; \
wget --no-check-certificate https://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz; \
tar -xvf ruby-2.1.5.tar.gz; cd ruby-2.1.5; \
mkdir -p /home/[USERNAME]/ruby; \
./configure --prefix=/home/[USERNAME]/ruby --disable-install-doc; \
make; make install;"
sudo -u [USERNAME] printf 'export PATH=/home/[USERNAME]/ruby/bin:$PATH\n' >> /home/[USERNAME]/.profile
su [USERNAME] -c "echo +ruby/2.1.5 >> /home/[USERNAME]/.provisioning-progress"
echo "--> ruby-2.1.5 is now installed."
fi
# Install bundler
if grep -q +bundler .provisioning-progress; then
echo "--> bundler already installed, moving on."
else
echo "--> Installing bundler..."
su [USERNAME] -c "/home/[USERNAME]/ruby/bin/gem install bundler --no-ri --no-rdoc"
su [USERNAME] -c "echo +bundler >> /home/[USERNAME]/.provisioning-progress"
echo "--> +bundler is now installed."
fi
# Install postgresql
if grep -q +postgresql .provisioning-progress; then
echo "--> postgresql already installed, moving on."
else
echo "--> Installing postgresql..."
apt-get update
apt-get -y install postgresql
apt-get -y install libpq-dev
su [USERNAME] -c "echo +postgresql >> /home/[USERNAME]/.provisioning-progress"
echo "--> +postgresql is now installed."
fi
#Install image magick
if grep -q +imagemagick .provisioning-progress; then
echo "--> Image magick already installed, moving on."
else
echo "--> Installing Image magick on machine..."
apt-get update
apt-get -y install libpng12-dev libglib2.0-dev zlib1g-dev libbz2-dev libtiff4-dev libjpeg8-dev
mkdir -p /home/vagrant/im
cd /home/vagrant/im
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar -xzf ImageMagick.tar.gz
cd ImageMagick-*
echo "Proceding to compile ImageMagick"
sudo ./configure
sudo make
sudo make install
sudo ldconfig /usr/local/lib
su vagrant -c "echo +imagemagick >>/home/vagrant/.provisioning-progress"
echo "Image magick installation is now completed... Hopefully"
fi
echo "All done"
#!/bin/bash
# Provisions a Vagrant box with dependencies for a Ruby on Rails development environment
set -e
if [ ! -f /home/vagrant/.provisioning-progress ]; then
su vagrant -c "touch /home/vagrant/.provisioning-progress"
echo "--> Progress file created in /home/vagrant/.provision-progress"
apt-get update
else
echo "--> Progress file exists in /home/vagrant/.provisioning-progress"
fi
#Install Git, Build-essential, curl, vim, htop
if grep -q +core-libs .provisioning-progress; then
echo "--> Core libs (git, curl, etc) already installed, moving on."
else
echo "--> Installing core libs (git, curl, etc)..."
apt-get update
apt-get -y install build-essential curl git-core python-software-properties htop vim
apt-get -y install zlib1g-dev libssl-dev libreadline6-dev libyaml-dev libncurses5-dev libxml2-dev
apt-get -y install libsqlite3-dev sqlite3 libcurl4-openssl-dev libffi-dev libxslt-de libgmp-dev
su vagrant -c "echo +core-libs >> /home/vagrant/.provisioning-progress"
echo "--> Core libs (git, curl, etc) are now installed."
fi
# Install nodejs
if grep -q +nodejs .provisioning-progress; then
echo "--> NodeJS already installed, moving on."
else
echo "--> Installing nodeJS"
apt-add-repository ppa:chris-lea/node.js
apt-get update
apt-get -y install nodejs # needed by Rails to have a Javascript runtime
su vagrant -c "echo +nodejs >> /home/vagrant/.provisioning-progress"
echo "--> nodeJS is now installed"
fi
# Default folder to /vagrant
if grep -q +default/vagrant .provisioning-progress; then
echo "--> default/vagrant already configured"
else
echo "--> configuring default /vagrant"
sudo -u vagrant printf 'cd /vagrant\n' >> /home/vagrant/.profile
su vagrant -c "echo +default/vagrant >> /home/vagrant/.provisioning-progress"
echo "--> default/vagrant is now configured."
fi
# Install ruby
if grep -q +ruby/2.1.5 .provisioning-progress; then
echo "--> ruby-2.1.5 is installed, moving on."
else
echo "--> Installing ruby-2.1.5 ..."
su vagrant -c "mkdir -p /home/vagrant/downloads; cd /home/vagrant/downloads; \
wget --no-check-certificate https://ftp.ruby-lang.org/pub/ruby/2.1/ruby-2.1.5.tar.gz; \
tar -xvf ruby-2.1.5.tar.gz; cd ruby-2.1.5; \
mkdir -p /home/vagrant/ruby; \
./configure --prefix=/home/vagrant/ruby --disable-install-doc; \
make; make install;"
sudo -u vagrant printf 'export PATH=/home/vagrant/ruby/bin:$PATH\n' >> /home/vagrant/.profile
su vagrant -c "echo +ruby/2.1.5 >> /home/vagrant/.provisioning-progress"
echo "--> ruby-2.1.5 is now installed."
fi
# Install bundler
if grep -q +bundler .provisioning-progress; then
echo "--> bundler already installed, moving on."
else
echo "--> Installing bundler..."
su vagrant -c "/home/vagrant/ruby/bin/gem install bundler --no-ri --no-rdoc"
su vagrant -c "echo +bundler >> /home/vagrant/.provisioning-progress"
echo "--> +bundler is now installed."
fi
# Install postgresql
if grep -q +postgresql .provisioning-progress; then
echo "--> postgresql already installed, moving on."
else
echo "--> Installing postgresql..."
apt-get update
apt-get -y install postgresql
apt-get -y install libpq-dev
su vagrant -c "echo +postgresql >> /home/vagrant/.provisioning-progress"
echo "--> +postgresql is now installed."
fi
#Install mysql
if grep -q +mysql .provisioning-progress; then
echo "--> mysql already installed, moving on."
else
echo "--> Installing mysql..."
apt-get update
apt-get -y install libmysqlclient-dev
apt-get -y install mysql-server-5.5
apt-get -f install mysql-server
su vagrant -c "echo +mysql >> /home/vagrant/.provisioning-progress"
echo "--> +mysql is now installed."
fi
# Install redis
if grep -q +redis .provisioning-progress; then
echo "--> redis already installed, moving on."
else
echo "--> Installing redis..."
apt-get update
apt-get -y install tcl8.5
curl -sSL http://download.redis.io/releases/redis-stable.tar.gz -o /tmp/redis.tar.gz
mkdir -p /tmp/redis
tar -xzf /tmp/redis.tar.gz -C /tmp/redis --strip-components=1
make -C /tmp/redis
make -C /tmp/redis install
echo -n | /tmp/redis/utils/install_server.sh
rm -rf /tmp/redis*
sysctl vm.overcommit_memory=1
sed -ie 's/# bind 127.0.0.1/bind 127.0.0.1/g' /etc/redis/6379.conf
service redis_6379 restart
su vagrant -c "echo +redis >> /home/vagrant/.provisioning-progress"
echo "--> +redis is now installed."
fi
#Set the system locale
if grep -q +locale .provisioning-progress; then
echo "--> Locale already set, moving on."
else
echo "--> Setting the system locale..."
echo "LC_ALL=\"en_US.UTF-8\"" >> /etc/default/locale
locale-gen en_US.UTF-8
update-locale LANG=en_US.UTF-8
su vagrant -c "echo +locale >> /home/vagrant/.provisioning-progress"
echo "--> Locale is now set."
fi
#Install image magick
if grep -q +imagemagick .provisioning-progress; then
echo "--> Image magick already installed, moving on."
else
echo "--> Installing Image magick on machine..."
apt-get update
apt-get -y install libpng12-dev libglib2.0-dev zlib1g-dev libbz2-dev libtiff4-dev libjpeg8-dev
mkdir -p /home/vagrant/im
cd /home/vagrant/im
wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar -xzf ImageMagick.tar.gz
cd ImageMagick-*
echo "Proceding to compile ImageMagick"
sudo ./configure
sudo make
sudo make install
sudo ldconfig /usr/local/lib
su vagrant -c "echo +imagemagick >>/home/vagrant/.provisioning-progress"
echo "Image magick installation is now completed... Hopefully"
fi
echo "All done"
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty32"
config.vm.network 'forwarded_port', guest: 3000, host: 3000
config.vm.provision 'shell', path: 'install_software.sh'
# if placed in project folder, guest folder /vagrant will be sync with project folder
config.vm.provider "virtualbox" do |v|
v.memory = 2024
end
end
@cesc1989
Copy link
Author

Para instalar una versión de ruby diferente a la 2.1.5, ver las versiones disponibles en: https://ftp.ruby-lang.org/pub/ruby/2.2

@cesc1989
Copy link
Author

cesc1989 commented Jan 5, 2016

Desinstalar ImageMagick:

sudo apt-get remove imagemagick

Fuente

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