Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Provision a vagrant box with ruby stable (using rvm), postgres, redis and node (using nvm)
#!/usr/bin/env bash
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8
sudo apt-get update
sudo apt-get install -y build-essential git curl libxslt1-dev libxml2-dev libssl-dev
# postgres
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main " | sudo tee -a /etc/apt/sources.list.d/pgdg.list
sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y postgresql-9.3 libpq-dev
echo '# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 0.0.0.0/0 trust
# IPv6 local connections:
host all all ::/0 trust' | sudo tee /etc/postgresql/9.3/main/pg_hba.conf
sudo sed -i "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /etc/postgresql/9.3/main/postgresql.conf
sudo /etc/init.d/postgresql restart
sudo su - postgres -c 'createuser -s vagrant'
# redis
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:rwky/redis
sudo apt-get update
sudo apt-get install -y redis-server
# rvm and ruby
su - vagrant -c 'curl -sSL https://get.rvm.io | bash -s stable --ruby'
su - vagrant -c 'rvm rvmrc warning ignore allGemfiles'
# node
su - vagrant -c 'curl https://raw.githubusercontent.com/creationix/nvm/v0.14.0/install.sh | sh'
su - vagrant -c 'nvm install 0.10'
su - vagrant -c 'nvm alias default 0.10'
echo "All done installing!
Next steps: type 'vagrant ssh' to log into the machine."
@lfv89

This comment has been minimized.

Copy link

@lfv89 lfv89 commented Jan 22, 2015

Hey, thanks for this, very helpful.
Would you mind to explain me why RVM and NODE are being installed with "su - vagrant -c" ?

@pietromenna

This comment has been minimized.

Copy link

@pietromenna pietromenna commented May 12, 2015

@vasconcelloslf I think because that command can safely be run as "vagrant" user. The -c is simple to run a command as the user indicated in the su.
@johanneswuerbach, thanks a lot for sharing this snippet!

@mr64bit

This comment has been minimized.

Copy link

@mr64bit mr64bit commented Oct 20, 2015

Almost exactly what I needed, thanks!

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