not logged in | [Login]

Torrent Box with Ubuntu, VPN, Deluge, Couch Potato, Jackett, Sonarr.tv, PlexPy

These notes cover setting up an Ubuntu box running in Virtual Box with a VPN.

Setup Virtual Box and Ubuntu

Download Virtual Box from https://www.virtualbox.org/wiki/Downloads. Make sure to install the VBox guest additions.

Then download and install Ubuntu inside the Virtual Box.

Once you get Ubuntu up, install the following

# The basics
sudo apt install openssh-server
sudo apt install  libcurl4-openssl-dev
sudo apt install bzip2

# User experience
sudo apt install mate
sudo apt install tmux
sudo apt install vim
sudo apt install git git-core

# Optional clients
sudo apt install rtorrent
sudo apt install qbittorrent

Setup VPN

Next we will setup OpenVPN and make it start when you boot up

sudo apt install openvpn bridge-utils
sudo apt install network-manager-openvpn network-manager-openvpn-gnome network-manager-pptp network-manager-vpnc
# Configure you OpenVPN however you like
# Move your .ovpn config file to /etc/openvpn/<whatever>.conf  # It must end with .conf
sudo vim /etc/default/openvpn  # uncomment AUTOSTART="all"
systemctl daemon-reload
sudo systemctl start openvpn
sudo systemctl status openvpn

Install Deluge.

Deluge will be the main client. It has a cli, web UI, and native GUI.

Let's first setup the Deluge daemon.

sudo touch /var/log/deluged.log
sudo touch /var/log/deluge-web.log
sudo chown r:r /var/log/deluge*

sudo apt install deluged
sudo apt install deluge-webui
sudo apt install deluge-console

Now make a service out of it so it'll startup when Ubuntu boots

cat > deluged.service << EOF
[Unit]
Description=Deluge Bittorrent Client Daemon
After=network-online.target

[Service]
Type=simple
User=r
Group=r
UMask=000

ExecStart=/usr/bin/deluged -d

Restart=on-failure

# Configures the time to wait before service is stopped forcefully.
TimeoutStopSec=300

[Install]
WantedBy=multi-user.target
EOF

Now enable and start it.

sudo mv deluged.service /lib/systemd/system/deluged.service
sudo systemctl enable deluged
sudo systemctl start deluged
sudo systemctl status deluged

Now lets setup the Deluge web UI

cat > deluged-web.service << EOF
[Unit]
Description=Deluge Bittorrent Client Web Interface
After=network-online.target

[Service]
Type=simple

User=r
Group=r
UMask=027

ExecStart=/usr/bin/deluge-web

Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

Enable and start it

sudo mv deluged-web.service /lib/systemd/system/deluged-web.service
sudo systemctl enable deluged-web
sudo systemctl start deluged-web
sudo systemctl status deluged-web

# open http://localhost:8112

Install sonarr.tv

Now install Sonarr.tv - https://github.com/Sonarr/Sonarr

# https://github.com/Sonarr/Sonarr/wiki/Installation
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FDA5DFFC
echo "deb http://apt.sonarr.tv/ master main" | sudo tee /etc/apt/sources.list.d/sonarr.list
sudo apt-get update
sudo apt-get install nzbdrone

# Test that you can start Sonar manually: mono --debug /opt/NzbDrone/NzbDrone.exe

Now, lets make it start automatically

# https://github.com/Sonarr/Sonarr/wiki/Autostart-on-Linux
cat > sonarr.service << EOF
[Unit]
Description=Sonarr Daemon
After=syslog.target network.target

[Service]
User=r
Group=r

Type=simple
ExecStart=/usr/bin/mono /opt/NzbDrone/NzbDrone.exe -nobrowser
TimeoutStopSec=20
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

Enable and start it

sudo mv sonarr.service /lib/systemd/system/sonarr.service
systemctl enable sonarr.service
systemctl start sonarr.service
systemctl status sonarr.service

# open http://localhost:8989

Install Couch Potato

Install Couch Potato https://couchpota.to

# https://couchpota.to/#linux
cd ~
git clone https://github.com/CouchPotato/CouchPotatoServer.git

Make a service out of it

cat > couchpotato.service << EOF
[Unit]
Description=Job that runs Couchpotato
After=network.target

[Service]
User=r
Group=r
ExecStart=/usr/bin/python /home/r/CouchPotatoServer/CouchPotato.py
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

Enable and start it

sudo mv couchpotato.service /lib/systemd/system/couchpotato.service
sudo systemctl enable couchpotato
sudo systemctl start couchpotato
sudo systemctl status couchpotato

# open http://localhost:5050

Install PlexPy

Install PlexPy https://github.com/drzoidberg33/plexpy

# https://github.com/drzoidberg33/plexpy/wiki/Installation
git clone https://github.com/drzoidberg33/plexpy.git

Make a service out of it

cat > plexpy.service << EOF
[Unit]
Description=PlexPy - Stats for Plex Media Server usage

[Service]
ExecStart=/home/r/plexpy/PlexPy.py --quiet --daemon --nolaunch --config /home/r/plexpy/config.ini --datadir /home/r/plexpy
GuessMainPID=no
Type=forking
User=r
Group=nogroup

[Install]
WantedBy=multi-user.target
EOF

Enable and start it

sudo mv plexpy.service /lib/systemd/system/plexpy.service
sudo systemctl enable plexpy
sudo systemctl start plexpy
sudo systemctl status plexpy

# open http://localhost:8181

Install Jackett

This version of Jackett only supports private trackers. We'll install a second copy of Jackett that supports public trackers next.

jackettver=$(wget -q https://github.com/Jackett/Jackett/releases/latest -O - | grep -E \/tag\/ | awk -F "[><]" '{print $3}')
wget -q https://github.com/Jackett/Jackett/releases/download/$jackettver/Jackett.Binaries.Mono.tar.gz
tar zxvf Jackett.Binaries.Mono.tar.gz

Now make a service out of it

cat > jackett.service << EOF
[Unit]
Description=Jackett Daemon
After=network.target

[Service]
User=r
Restart=always
RestartSec=5
Type=simple
ExecStart=/usr/bin/mono --debug /home/r/Jackett/JackettConsole.exe
TimeoutStopSec=20

[Install]
WantedBy=multi-user.target
EOF

Enable and start it

sudo mv jackett.service /lib/systemd/system/jackett.service
sudo systemctl enable jackett
sudo systemctl start jackett
sudo systemctl status jackett

# open http://localhost:9117

Install Jackett Public

Install Jackett Public https://github.com/dreamcat4/Jackett-public

cd ~
jackettver=$(wget -q https://github.com/dreamcat4/Jackett-public/releases/latest -O - | grep -E \/tag\/ | awk -F "[><]" '{print $3}')
wget -q https://github.com/dreamcat4/Jackett-public/releases/download/$jackettver/Jackett-public.Binaries.Mono.tar.gz
tar zxvf Jackett-public.Binaries.Mono.tar.gz

cp -r ~/.config/Jackett ~/.config/Jackett-public
rm -rf ~/.config/Jackett-public/Indexers/

# Change the port from 9117 to 9118
sed -i -e 's/9117/9118/g' ~/.config/Jackett-public/ServerConfig.json

Now make a service out of it

cat > jackett-public.service << EOF
[Unit]
Description=Jackett Public Daemon
After=network.target

[Service]
User=r
Restart=always
RestartSec=5
Type=simple
ExecStart=/usr/bin/mono --debug /home/r/Jackett-public/JackettConsole.exe
TimeoutStopSec=20

[Install]
WantedBy=multi-user.target
EOF

Enable and start it

sudo mv jackett-public.service /lib/systemd/system/jackett-public.service
sudo systemctl enable jackett-public
sudo systemctl start jackett-public
sudo systemctl status jackett-public

# open http://localhost:9118/

Install Headphones

Install headphones https://github.com/rembo10/headphones

cd ~
git clone https://github.com/rembo10/headphones.git

Create a configuration file

cat > ~/.headphones << EOF
[General]
http_port = 8888

# 0.0.0.0 allows outside connections. Use 'localhost' to restrict
http_host = 0.0.0.0
EOF

Now make a service out of it

cat > headphones.service << EOF
[Unit]
Description=Headphones Daemon
After=network.target

[Service]
User=r
Restart=always
RestartSec=5
Type=simple
ExecStart=/usr/bin/python /home/r/headphones/Headphones.py --config /home/r/.headphones
TimeoutStopSec=20

[Install]
WantedBy=multi-user.target
EOF

Enable and start it

sudo mv headphones.service /lib/systemd/system/headphones.service
sudo systemctl enable headphones
sudo systemctl start headphones
sudo systemctl status headphones

# open http://localhost:8888/

Install youtube-dl

Source: https://github.com/rg3/youtube-dl

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

# To update: sudo youtube-dl -U

Enable remote access

See my reverse SSH tunnel howto wiki for creating a reverse SSH tunnel to access your home Ubuntu box remotely.