Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Developing on a Mac
# Setting up a simple Debian system.
hostname=$1
echo
echo "Bootstrapping ${hostname}"
echo
# Update the system.
apt-get update
apt-get upgrade -y
# Install a few additional tools.
apt-get install vim less nmap git mercurial screen strace net-tools -y
# Install Nginx.
cat <<EOM >/etc/apt/sources.list.d/nginx.list
deb http://nginx.org/packages/mainline/debian/ wheezy nginx
deb-src http://nginx.org/packages/mainline/debian/ wheezy nginx
EOM
wget --quiet -O - http://nginx.org/keys/nginx_signing.key | apt-key add -
apt-get update
apt-get install nginx -y
# Install Redis (6379).
cat <<EOM > /etc/apt/sources.list.d/dotdeb.list
deb http://packages.dotdeb.org wheezy all
deb-src http://packages.dotdeb.org wheezy all
EOM
wget --quiet -O - http://www.dotdeb.org/dotdeb.gpg | apt-key add -
apt-get update
apt-get install redis-server -y
sed -i -r 's/(bind)/#bind/' /etc/redis/redis.conf
service redis-server restart
# Install Postgresql (5432).
cat <<EOM >/etc/apt/sources.list.d/pgdg.list
deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main 9.4
EOM
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
apt-get update
apt-get install postgresql-9.4 postgresql-contrib-9.4 postgresql-server-dev-9.4 -y
TS=`date +%Y-%m%d-%H%M%S` && mv /etc/postgresql/9.4/main/pg_hba.conf /etc/postgresql/9.4/main/pg_hba.conf.$TS
cat <<EOM >/etc/postgresql/9.4/main/pg_hba.conf
host all all 0.0.0.0/0 trust
EOM
cat <<EOM >>/etc/postgresql/9.4/main/postgresql.conf
listen_addresses = '*'
EOM
service postgresql start
# Install Mongo (27017).
cat <<EOM >/etc/apt/sources.list.d/mongodb.list
deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen
EOM
apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
apt-get update
apt-get install -y mongodb-org
sed -i -r 's/(bind_ip.*)/# \1/' /etc/mongod.conf
service mongod restart
# Install Beanstalk queue (11300).
apt-get install beanstalkd -y
sed -i -r 's/(#START)/START/' /etc/default/beanstalkd
sed -i -r 's/(\$BEANSTALKD_LISTEN_PORT\")/$BEANSTALKD_LISTEN_PORT -b \/var\/lib\/beanstalkd\"/' /etc/default/beanstalkd
service beanstalkd restart
# Install Go.
rm -rf /usr/local/go
wget https://storage.googleapis.com/golang/go1.3.3.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.3.3.linux-amd64.tar.gz
rm -f go1.3.3.linux-amd64.tar.gz
mkdir -p /usr/local/gocode
echo "export GOROOT=/usr/local/go" >> /root/.bashrc
echo "export GOROOT=/usr/local/go" >> /home/vagrant/.bashrc
echo "export GOPATH=/usr/local/gocode" >> /root/.bashrc
echo "export GOPATH=/usr/local/gocode" >> /home/vagrant/.bashrc
echo "export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin" >> /root/.bashrc
echo "export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin" >> /home/vagrant/.bashrc
# -*- mode: ruby -*-
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "debian7" # Download one from here if needed: https://github.com/ffuenf/vagrant-boxes
config.vm.network "private_network", ip: "192.168.56.91"
config.vm.hostname = "unrolled.vm"
config.vm.network "forwarded_port", guest: 80, host: 8080 # Nginx http
config.vm.network "forwarded_port", guest: 443, host: 8443 # Nginx https
config.vm.network "forwarded_port", guest: 6379, host: 6379 # Redis
config.vm.network "forwarded_port", guest: 5432, host: 5432 # Postgres
config.vm.network "forwarded_port", guest: 27017, host: 27017 # Mongo
config.vm.network "forwarded_port", guest: 11300, host: 11300 # Beanstalk
config.vm.provider "virtualbox" do |v|
v.gui = false
v.memory = 1024
v.cpus = 1
v.name = config.vm.hostname
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
end
config.vm.synced_folder ".", "/vagrant/", type: "nfs", create: "true"
config.vm.provision "shell" do |s|
s.path = "bootstrap.sh"
s.args = config.vm.hostname
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment