Last active
September 29, 2024 21:04
-
-
Save johanneswuerbach/10785de9cc856009f6ea to your computer and use it in GitHub Desktop.
Provision a vagrant box with ruby stable (using rvm), postgres, redis and node (using nvm)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." | |
@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!
Almost exactly what I needed, thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, thanks for this, very helpful.
Would you mind to explain me why RVM and NODE are being installed with "su - vagrant -c" ?