Select Page

Raspberry Pi – Install Sonarr

Overview

  • Install Sonarr.
  • Automatically manage your media.
  • Find missing episodes.

Sonarr automates the finding, downloading, naming and organisation of TV shows. It is designed to work in conjunction with a torrent client and media server. E.g. qBittorrent to download files and Plex Media Server to distribute them to clients.

If you haven’t already, check out the guide to setup a secure torrent client before continuing with the install of Sonarr.

I do not in any way, shape or form condone or support the downloading of illegal or copyrighted material.

Technical Jargon

SSH

SSH stands for secure shell. SSH is an encrypted connection established between two computer programs. On the server side (the computer being connected to) a service is running that listens for another computer trying to contact it via SSH.

Click here for a full detailed description of SSH.

Assumptions

This guide assumes you have a fresh install of Raspbian on a headless server.

This guide assumes you either have a folder on the Raspberry Pi for your TV shows, or have setup a connection to your network share that contains your TV media.

If it is legal to download TV box sets where you are and you wish to use Sonarr’s ability to tap into torrent RSS feeds, it’s assumed you have setup a secure torrent client.

Install Sonarr

Before we start we’re going to ensure the Raspberry Pi is up to date. Run the following commands to grab and install the latest packages:

sudo apt-get update

sudo apt-get upgrade -y

As Sonarr isn’t in the default Raspbian repository we’ll want to add Sonarr’s. To do this let’s install the directory manager to allow us to modify our repositories:

sudo apt-get install dirmngr

Now we can add new repositories let’s make sure we can use secure connections:

sudo apt-get install apt-transport-https -y –force-yes

With all that sorted we can add Sonarr’s repository:

sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys 0xA236C58F409091A18ACA53CBEBFF6B99D9B78493
echo “deb http://apt.sonarr.tv/ master main” | sudo tee /etc/apt/sources.list.d/sonarr.list

With the repository available we’ll now be able to install Sonarr, but before we do we need to  update our sources so the Pi knows where to look:

sudo apt update
sudo apt install nzbdrone -y

Create a Service

It is recommended to run Sonarr as its own user for security purposes. We’re going to use qbtuser to own the Sonarr install and run the service. This is to tie in with the user setup in the secure torrent client guide. Feel free to use any user you like. E.g. pi:

sudo chown -R qbtuser:qbtuser /opt/NzbDrone

We’re going to create a file under /etc/systemd/system that will tell the Raspberry Pi how to handle Sonarr and ensure it runs as a service:

sudo nano /lib/systemd/system/sonarr.service

Now that we’ve created the file, paste the following into it:

[Unit]
Description=Sonarr Daemon
After=syslog.target network.target

[Service]
User=qbtuser
Group=qbtuser

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

[Install]
WantedBy=multi-user.target

Press Ctrl+x to exit and you’ll be prompted to Save modified. Type Y and then return to save the file.

Start the Sonarr Service

If everything has gone to plan we can start the service.

Start the service for the first time with:

sudo systemctl start sonarr

Check it all Works

Now we’ve finished installing Sonarr and the service is running, lets check it all works by going to http://*Rasbperry Pi Ip Address*:8989 and we should see the default page.

Auto Start Sonarr – No Torrenting

If Sonarr is used to check the status of your collections we want to start Sonarr with the Raspberry Pi:

sudo systemctl enable sonarr

Now ensure everything works, reboot your Raspberry Pi:

sudo reboot

If you intend to use Sonarr to find torrents enable it by following the below section. Note I do not condone this.

Auto Start Sonarr – Linked to Torrent Client

If Sonarr is used to find torrents, we only want the Sonarr service to be active when there is a VPN connection available.

To do this we’re going to update some files in the OpenVPN directory so cd into /etc/openvpn:

cd /etc/openvpn

To auto start Sonarr when the VPN connection is established we need to edit route-up.sh.

sudo nano route-up.sh

And paste the following at the bottom of the file:

systemctl start sonarr

The file should look like:

#!/bin/sh
iptables -t nat -I POSTROUTING -o tun0 -j MASQUERADE
systemctl start qbittorrent

systemctl start sonarr

 Press Ctrl+x to exit and you’ll be prompted to Save modified. Type Y and then return to save the file.

Auto Stop Sonarr – Linked to Torrent Client

To make sure no peer 2 peer traffic is sent over your clear internet connection we’re going to ensure the Sonarr service is stopped before we lose our VPN connection.

To do this we’re going to add a line to down.sh:

sudo nano down.sh

Paste the following line above “iptables -t nat -D POSTROUTING -o tun0 -j MASQUERADE”:

systemctl stop sonarr

The file should look like:

#!/bin/sh
systemctl stop qbittorrent

systemctl stop sonarr
iptables -t nat -D POSTROUTING -o tun0 -j MASQUERADE

Press Ctrl+x to exit and you’ll be prompted to Save modified. Type Y and then return to save the file.

Reboot your Raspberry Pi to ensure all our changes are applied:

sudo reboot

Check Everything is Working

After the reboot lets check everything is working as we expect.

In your web browser navigate to the Sonarr Web UI as you did earlier and make sure it loads.

Add A TV Show

Now that everything is working let’s add a TV show. Click Add Series and search for the series you want to monitor. I’ve searched for one of my favourite shows Black Books.

Point the path to the parent folder containing your TV Shows and click the green plus button to add it to your list.

You can either add a single series that you don’t currently have by searching for it and clicking add, or you can import your entire folder by clicking “Import Existing Series On Disk” and selecting the parent folder of your TV shows. This will bulk import everything you have already.

Finished

The installation of Sonarr is complete and it’s up to you to play around with the settings to get everything sorted. Jump in and have a go.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *