Created
June 17, 2013 23:43
-
-
Save ErikEvenson/5801503 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
echo "Provisioning VM" | |
PROJECT_NAME=VBEZ | |
# Update the local package index | |
echo "#######################" | |
echo "## Updating base box ##" | |
echo "#######################" | |
apt-get update -y | |
# # Actually upgrade all packages that can be upgraded | |
# apt-get dist-upgrade -y | |
# Install git and mercurial | |
echo "######################" | |
echo "## Installing DVCSs ##" | |
echo "######################" | |
apt-get install -y git | |
apt-get install -y mercurial | |
# Install python dev packages | |
echo "############################################" | |
echo "## Installing python development packages ##" | |
echo "############################################" | |
apt-get install -y build-essential python python-dev python-setuptools python-pip | |
# Install PostgreSQL 9.2.4 | |
if ! command -v psql; then | |
echo "###########################" | |
echo "## Installing PostgreSQL ##" | |
echo "###########################" | |
apt-get install -y bison flex libreadline-gplv2-dev | |
wget -q http://ftp.postgresql.org/pub/source/v9.2.4/postgresql-9.2.4.tar.bz2 | |
tar jxf postgresql-9.2.4.tar.bz2 | |
cd postgresql-9.2.4 | |
./configure --prefix=/usr | |
make | |
make install | |
cd .. | |
rm -rf postgresql-9.2.4* | |
# Initialize postgres DB | |
useradd -p postgres postgres | |
mkdir -p /var/pgsql/data | |
chown postgres /var/pgsql/data | |
su -c "/usr/bin/initdb -D /var/pgsql/data --locale=en_US.UTF-8 --encoding=UNICODE" postgres | |
mkdir /var/pgsql/data/log | |
chown postgres /var/pgsql/data/log | |
# Start postgres | |
su -c '/usr/bin/pg_ctl start -l /var/pgsql/data/log/logfile -D /var/pgsql/data' postgres | |
# Start postgres at boot | |
sed -i -e 's/exit 0//g' /etc/rc.local | |
echo "su -c '/usr/bin/pg_ctl start -l /var/pgsql/data/log/logfile -D /var/pgsql/data' postgres" >> /etc/rc.local | |
fi | |
# Install memcached | |
echo "#########################" | |
echo "## Installing memcache ##" | |
echo "#########################" | |
apt-get install -y memcached libmemcached-dev | |
# Install redis | |
echo "######################" | |
echo "## Installing redis ##" | |
echo "######################" | |
apt-get install -y redis-server | |
# Install heroku toolbelt | |
if ! command -v heroku; then | |
echo "################################" | |
echo "## Installing heroku toolbelt ##" | |
echo "################################" | |
wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh | |
fi | |
if [[ ! -f /usr/local/bin/virtualenv ]]; then | |
echo "###########################" | |
echo "## Installing virtualenv ##" | |
echo "###########################" | |
pip install virtualenv virtualenvwrapper | |
echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~vagrant/.bashrc | |
echo "##########################################" | |
echo "## Creating a virualenv for the project ##" | |
echo "##########################################" | |
source /usr/local/bin/virtualenvwrapper.sh | |
WORKON_HOME=~vagrant/.virtualenvs | |
mkvirtualenv -a /vagrant -r /vagrant/requirements.txt $PROJECT_NAME | |
chown -R vagrant:vagrant ~vagrant/.virtualenvs | |
echo "source /vagrant/config/env" >> ~vagrant/.virtualenvs/$PROJECT_NAME/bin/postactivate | |
echo "workon $PROJECT_NAME" >> ~vagrant/.bashrc | |
fi | |
# Remove any packages that are no longer needed | |
echo "#################################################" | |
echo "## Removing packages that are no longer needed ##" | |
echo "#################################################" | |
apt-get autoremove -y | |
# Report | |
echo -e "\nInstalled versions:" | |
( | |
git --version | |
psql --version | |
python --version | |
ruby --version | |
) | sed -u "s/^/ /" | |
echo -e "\nSuccess!" | |
exit 0 |
This file contains hidden or 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
Vagrant.configure("2") do |config| | |
# Use Ubuntu 12.04 64-bit for now. | |
config.vm.box = "precise-server-cloudimg-amd64-vagrant-disk1" | |
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/precise/current/precise-server-cloudimg-amd64-vagrant-disk1.box" | |
# Provision the VM | |
config.vm.provision :shell, :path => "vagrant_data/install.sh" | |
# Configure network | |
config.vm.network :private_network, ip: "192.168.50.4" | |
# Set up VM | |
config.vm.provider "virtualbox" do |v| | |
# Set memory to 512MB to match Heroku limits. | |
v.customize [ | |
"modifyvm", :id, | |
"--memory", "512", | |
"--cpus", "2" | |
] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment