#!/bin/bash

sudo service rtorrent stop

# Build libtorrent
cd /tmp
if [ -d libtorrent ]; then
  sudo rm -r libtorrent
fi
sudo git clone https://github.com/rakshasa/libtorrent.git
cd libtorrent
sudo git checkout 0.13.6
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install

# Build rtorrent
cd /tmp
if [ -d rtorrent ]; then
  sudo rm -r rtorrent
fi
sudo git clone https://github.com/rakshasa/rtorrent.git
cd rtorrent
sudo git checkout 0.9.6
sudo ./autogen.sh
sudo ./configure --with-xmlrpc-c
sudo make
sudo make install

sudo ldconfig

# Update ruTorrent
cd /var/www/rutorrent
sudo git pull
sudo chown -R www-data:www-data /var/www/rutorrent

sudo service rtorrent start
