Clone the Onionoo server repository
-----------------------------------

Create working directory /srv/onionoo/, make it writable for the metrics
user, and clone the Onionoo server repository into it.  Commands prefixed
with # are meant to be run by root, commands with $ by user metrics:

# mkdir /srv/onionoo
# chown metrics:metrics /srv/onionoo
$ git clone https://git.torproject.org/onionoo.git /srv/onionoo/
$ cd /srv/onionoo


Install Java 1.7 or higher and ant 1.8 or higher
------------------------------------------------

$ javac -version
javac 1.7.0_65

$ ant -version
Apache Ant version 1.8.0 compiled on March 11 2010


Provide required .jar files
---------------------------

Download .jar files listed in the build.xml classpath.  Onionoo usually
uses Debian stable provided libraries; see vagrant/bootstrap.sh for Debian
package names.  If you download .jar files elsewhere, please edit the
corresponding paths in build.xml.

DescripTor is provided by The Tor Project and can be found here:
    https://dist.torproject.org/descriptor/
Download the tar.gz file with the version number listed in build.xml.
The README inside the tar.gz file has all the information about DescripTor
and explains how to verify the downloaded files.

Attempt to compile the Java sources to make sure that everything works
correctly:

$ ant compile


Download GeoIP and ASN database files
-------------------------------------

Onionoo uses an IP-to-city database and an IP-to-ASN database to provide
additional information about a relay's location.

First, create the geoip/ directory and change to it:

$ mkdir -p geoip
$ cd geoip/

Download the most recent MaxMind GeoLite2 City database and unzip it in
the current directory, junking paths:

$ wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-City-CSV.zip
$ unzip -j GeoLite2-City-CSV.zip

Download the most recent MaxMind GeoLite ASN database file and unzip it in
the current directory:

$ wget https://www.maxmind.com/download/geoip/database/asnum/GeoIPASNum2.zip
$ unzip GeoIPASNum2.zip

Change back to the root working directory:

$ cd ../


Test the hourly data processing process
---------------------------------------

Run the data processing process that will afterwards be run once per hour.

Create a .jar file:

$ ant jar

The initial run may take a while:

$ java -DLOGBASE=/path/to/logfiles -Xmx4g -jar dist/onionoo-<version>.jar


Set up an hourly cronjob
------------------------

Add a crontab line similar to the command above:

15 * * * * cd /srv/onionoo/ && java -DLOGBASE=/path/to/logfiles \
                                    -Xmx4g -jar dist/onionoo-<version>.jar


Run the web server
------------------

Create a .war file:

$ ant war

Start the Onionoo server

$ java -DLOGBASE=/path/to/logfiles -Xmx4g -jar dist/onionoo-<version>.war

The Onionoo server should now be available at
http://localhost:8080/.


Configure Embedded Jetty
------------------------

Settings for the embedded jetty can be found in etc/jetty.xml
If you change anything, run

$ ant clean war

again.


Configure logging
-----------------

Logging can be configured inside etc/logback.xml
If you change anything, run

$ ant clean war jar

again.

The command line option LOGBASE is the path for the log files.
In case you forget to set it, you'll find the logs in the current
path in the folder LOGBASE_IS_UNDEFINED/

