Skip to content

Instantly share code, notes, and snippets.

@kenshin17
Forked from gnutix/README.md
Created March 11, 2020 17:32
Show Gist options
  • Save kenshin17/90bfe9771a29336d63aeee2db182deef to your computer and use it in GitHub Desktop.
Save kenshin17/90bfe9771a29336d63aeee2db182deef to your computer and use it in GitHub Desktop.
Install a Raspberry Pi as a torrent download station (09.2019)

Install a Raspberry Pi as a torrent download station (09.2019)

Install Raspbian Lite

  1. Download as zip https://www.raspberrypi.org/downloads/raspbian/ and extract it

  2. Download and install Etcher https://www.balena.io/etcher/

  3. Plug the SD card in the computer, run Etcher and flash the .img on the SD card, remove the SD card, plug it into the RPi, boot

  4. Default login is pi / raspberry. Beware that the default locale is en_UK, which means if you have an (QWERT)Z keyboard layout, you'll need to type "raspberrz" as the password for it to work

  5. Change the keyboard settings : sudo nano /etc/default/keyboard (/ is the found on the - key on QWERTZ) and set (something along the lines of) the following (which is my personal setup), then reboot.

    XKBMODEL="pc105"
    XKBLAYOUT="ch"
    XKBVARIANT="fr"
    XKBOPTIONS="ctrl:nocaps,shift:both_capslock"
    
  6. Enable SSH access : sudo raspi-config, "5 Interfacing Options > P2 SSH".

  7. Set a static IP : run ip -4 addr show | grep global to get the "network space" (the number after the / at the end of the IP address). Then sudo nano /etc/dhcpcd.conf and add your static IP address with the correct "network space" (in my case 17. Most often it's 24). Finally, reboot.

    interface eth0
    static ip_address=192.168.0.48/17
    static routers=192.168.0.1
    static domain_name_servers=192.168.0.1 
    
  8. Add an SSH alias to your config : sudo nano ~/.ssh/config

    Host *
        PreferredAuthentications publickey,password
        
    Host raspbian
        Hostname 192.168.0.48
        User pi
    
  9. Add your public SSH key to the RPi : cat ~/.ssh/id_rsa.pub | ssh raspbian-wired 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys'. Connect using ssh raspbian without password.

  10. Update packages (might take a while - apparently it includes kernel stuff. Grab some snacks) :

    sudo apt-get update
    sudo apt-get upgrade
    
  11. Install speedtest (optional) :

    wget -O speedtest-cli https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py
    chmod +x speedtest-cli
    

Done !

Install fan (optional)

You can buy this awesome product and follow this installation guide.

Install softwares

  1. Mount the Synology's drive.

    Start by following this guide : https://www.junipermonkeys.com/2019/03/making-a-raspberry-pi-downloader-box-work-with-a-synology-when-youre-dumb-and-impatient/ , which basically says how to configure the NFS permissions on the Shared Folders :

    • Host/IP : 192.168.0.0/255.255.255.0
    • Privilege : Read/write
    • Squash : Map all users to admin (SUPER IMPORTANT !! Otherwise transmission's user can't write in the Downloads folder)

    And enable NFS in "Settings > File Services". Then on the RPi :

    sudo apt-get install ntfs-3g
    sudo mkdir -p /media/synology/{Downloads,Movies,TVShows}
    

    Add an SSH alias for the Synology : sudo nano ~/.ssh/config

    Host *
        ForwardAgent yes
        ServerAliveInterval 300
        ServerAliveCountMax 10
        StrictHostKeyChecking no
        PreferredAuthentications publickey,password
    
    Host synology
        Hostname 192.168.0.42
        User root
        Port 99
    

    Add an entry in the hosts file :

    echo '192.168.0.42 synology' | sudo tee -a /etc/hosts
    

    Edit sudo nano /etc/fstab with the following :

    synology:/volume1/Downloads /media/synology/Downloads nfs defaults,noatime,x-systemd.automount,nolock 0 0
    synology:/volume1/Movies /media/synology/Movies nfs defaults,noatime,x-systemd.automount,nolock 0 0
    synology:/volume1/TVShows /media/synology/TVShows nfs defaults,noatime,x-systemd.automount,nolock 0 0
    

    Then, sudo mount -av. If it doesn't work, it's probably one of the fstab mounting options... good luck! Finally, run sudo chmod -R 0777 /media/synology/* to ensure we avoid permissions issues.

  2. Install Mono for Sonarr/Radarr install

    sudo apt install apt-transport-https dirmngr gnupg ca-certificates
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
    echo "deb https://download.mono-project.com/repo/debian stable-raspbianbuster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
    sudo apt update
    sudo apt-get libmono-cil-dev
    

RPi-Monitor (optional)

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2C0D3C0F
echo 'deb http://giteduberger.fr rpimonitor/' | sudo tee /etc/apt/sources.list.d/rpimonitor.list
sudo apt-get update
sudo apt-get install rpimonitor
sudo /etc/init.d/rpimonitor update
sudo /etc/init.d/rpimonitor install_auto_package_status_update

Edit sudo nano /etc/rpimonitor/template/network.conf to uncomment every lines except the following lines that should be commented out :

#web.status.1.content.8.line.1="To activate network monitoring, edit and customize <font color='#AA0000'><b>network.conf</b></font>"
#web.status.1.content.8.line.2="Help is available in man pages:"
#web.status.1.content.8.line.3="<font color='#AA0000'><b>man rpimonitord</b></font> or <font color='#AA0000'><b>man rpimonitord.conf</b></font>"

Restart the service sudo service rpimonitor restart. Access it via http://192.168.0.48:8888/ .

RasPi Check Android app (optional)

You can download RasPi Check's Android app if you want nice dashboards to monitor your PI from your smartphone.

Transmission

sudo apt-get install transmission-daemon
# you need to stop the daemon to be able to edit the config file, otherwise it gets overridden immediately
sudo service transmission-daemon stop
sudo mkdir -p /media/synology/Downloads/transmission/{incomplete,completed}

Then edit the settings : sudo nano /etc/transmission-daemon/settings.json

    "download-dir": "/media/synology/Downloads/transmission/completed",
    "incomplete-dir": "/media/synology/Downloads/transmission/incomplete",
    "incomplete-dir-enabled": true,
    "rpc-whitelist-enabled": false,

And run the service again : sudo service transmission-daemon start.

Access http://192.168.0.48:9091/transmission/web and login with transmission / transmission. Try to upload a torrent and make sure it gets downloaded into synology's Downloads/incomplete folder.

Jackett

sudo apt-get install jq
jackettassets=$(curl --silent "https://api.github.com/repos/Jackett/Jackett/releases/latest" | grep -Po '"assets_url": "\K.*?(?=")')
jacketturl=$(curl --silent $jackettassets | jq -r '.[] | select(.name == "Jackett.Binaries.LinuxARM32.tar.gz") .browser_download_url')
wget ${jacketturl} -P /tmp/
sudo tar -xf /tmp/Jackett* -C /opt/
sudo chown -R pi:pi /opt/Jackett
sudo chmod +x /opt/Jackett/jackett
sudo /opt/Jackett/install_service_systemd.sh

Finally access the service using http://192.168.0.48:9117/.

Sonarr

sudo apt-get install libmediainfo-dev
wget "http://update.sonarr.tv/v2/master/mono/NzbDrone.master.tar.gz" -P /tmp/
sudo tar -xf /tmp/NzbDrone* -C /opt/
sudo mv /opt/NzbDrone /opt/Sonarr
sudo chown -R pi:pi /opt/Sonarr

Then add this into this file : sudo nano /etc/systemd/system/sonarr.service

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

[Service]
User=pi
Group=pi
Type=simple
ExecStart=/usr/bin/mono --debug /opt/Sonarr/NzbDrone.exe -nobrowser
TimeoutStopSec=20
KillMode=process
Restart=on-failure
StandardOutput=null

[Install]
WantedBy=multi-user.target

Then :

sudo systemctl enable sonarr
sudo service sonarr start

Finally, access http://192.168.0.48:8989/.

Radarr

radarrurl=$(curl -s https://api.github.com/repos/Radarr/Radarr/releases | grep linux.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4)
wget ${radarrurl} -P /tmp/
sudo tar -xvzf /tmp/Radarr.develop.*.linux.tar.gz -C /opt/
sudo chown -R pi:pi /opt/Radarr

Then add this into this file : sudo nano /etc/systemd/system/radarr.service

[Unit]
Description=Radarr Daemon
After=network.target

[Service]
User=pi
Group=pi
Type=simple
ExecStart=/usr/bin/mono --debug /opt/Radarr/Radarr.exe -nobrowser
TimeoutStopSec=20
KillMode=process
Restart=on-failure
StandardOutput=null

[Install]
WantedBy=multi-user.target

Then :

sudo systemctl enable radarr
sudo service radarr start

Finally access http://192.168.0.48:7878/.

FileBot

sudo apt-get install openjdk-8-jdk
wget https://get.filebot.net/filebot/FileBot_4.8.5/FileBot_4.8.5-portable.tar.xz -P /tmp/
sudo mkdir /opt/FileBot
sudo tar xf /tmp/FileBot* -C /opt/FileBot
sudo chown -R pi:pi /opt/FileBot
sudo chmod +x /opt/FileBot/filebot.sh
sudo ln -s /opt/FileBot/filebot.sh /usr/bin/filebot

Then run filebot -version to make sure it works.

Configuration

This part is up to you. It's too specific for me to document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment