[tor-commits] [onionoo/master] Add Vagrantfile and provisioning shell script.

karsten at torproject.org karsten at torproject.org
Tue Aug 19 18:20:37 UTC 2014


commit 20623020e4bf25f97a0277d8aeed3347c9c3dd34
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Aug 19 20:18:57 2014 +0200

    Add Vagrantfile and provisioning shell script.
---
 HOWTO-VAGRANT.md     |   42 ++++++++++++++++++++++++++++++++++++++++++
 Vagrantfile          |   19 +++++++++++++++++++
 vagrant/bootstrap.sh |   30 ++++++++++++++++++++++++++++++
 3 files changed, 91 insertions(+)

diff --git a/HOWTO-VAGRANT.md b/HOWTO-VAGRANT.md
new file mode 100644
index 0000000..ae8783e
--- /dev/null
+++ b/HOWTO-VAGRANT.md
@@ -0,0 +1,42 @@
+How to use Vagrant to build and test Onionoo
+============================================
+
+Before using Vagrant, make sure that Onionoo builds correctly on the host system.  This may require running `git submodule init && git submodule update`, as well as providing all required libraries.
+
+Create a Debian Wheezy 64 bit instance:
+
+```
+vagrant up
+```
+
+This command downloads the virtual machine imagine, unless it has been downloaded before, creates a new virtual machine, and runs the bootstrap script in `vagrant/bootstrap.sh`.  This may take a few minutes.
+
+Once this is all done, log into the virtual machine and change to the Onionoo working directory:
+
+```
+vagrant ssh
+cd /srv/onionoo.torproject.org/onionoo/
+```
+
+Important: better avoid runninng Ant in the `/vagrant/` directory (which is shared with the host), or the guest system will write directly to the host system, which performs not really well.
+
+Compile Onionoo, run the unit tests and then the cron part of it:
+
+```
+ant compile
+ant test
+ant run
+```
+
+This step may take an hour or more.  Onionoo downloads the last three days of Tor descriptors, which is about 2 GiB, and processes them.
+
+Once these steps are done, deploy the servlet to the local Tomcat server:
+
+```
+ant war
+```
+
+Test the Onionoo service using a browser on the host (port 8080 on the guest is forwarded to the host).  Sample URL:
+
+http://localhost:8080/onionoo/summary?limit=2
+
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644
index 0000000..c30e452
--- /dev/null
+++ b/Vagrantfile
@@ -0,0 +1,19 @@
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+
+  config.vm.box = "wheezy64"
+  config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-puppet.box"
+
+  config.vm.boot_timeout = 60
+
+  config.vm.network "forwarded_port", guest: 8080, host: 8080
+
+  config.vm.provider "virtualbox" do |vb|
+    vb.memory = 4096
+  end
+
+  config.vm.provision :shell, :path => "vagrant/bootstrap.sh"
+
+end
+
diff --git a/vagrant/bootstrap.sh b/vagrant/bootstrap.sh
new file mode 100644
index 0000000..78e48f3
--- /dev/null
+++ b/vagrant/bootstrap.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+echo "Starting provisioning."
+
+echo "Updating package list and upgrading existing packages."
+apt-get update
+apt-get -y upgrade
+
+echo "Installing required packages."
+apt-get install -y libcommons-codec-java libcommons-compress-java \
+libcommons-lang-java libgoogle-gson-java junit4 libservlet3.0-java \
+openjdk-6-jdk ant liblog4j1.2-java tomcat6
+
+echo "Setting up paths and creating symbolic links."
+mkdir -p /srv/onionoo.torproject.org/onionoo/
+cd /srv/onionoo.torproject.org/onionoo/
+ln -s /vagrant/bin
+ln -s /vagrant/build.xml
+ln -s /vagrant/deps
+ln -s /vagrant/etc
+ln -s /vagrant/geoip
+ln -s /vagrant/src
+ln -s /vagrant/web
+ln -s /srv/o
+ln -s /srv/onionoo.torproject.org/onionoo/onionoo.war \
+/var/lib/tomcat6/webapps/onionoo.war
+chown -R vagrant:vagrant /srv/onionoo.torproject.org/
+
+echo "Done provisioning."
+



More information about the tor-commits mailing list