Skip to content

Instantly share code, notes, and snippets.

@gnutix
Last active April 17, 2024 18:36
Show Gist options
  • Save gnutix/f32f057f40f4a28ad397e36c840fdcb8 to your computer and use it in GitHub Desktop.
Save gnutix/f32f057f40f4a28ad397e36c840fdcb8 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 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). Add IPQoS cs0 cs0 on its own line at the very end of /etc/ssh/sshd_config to prevent potential SSH freezes. 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 /volume1/{Downloads,Movies,TVShows} on the Synology NAS to ensure we avoid permissions issues.

  2. Install .NET Core 3.1 for Jackett/Radarr install

    wget https://download.visualstudio.microsoft.com/download/pr/349f13f0-400e-476c-ba10-fe284b35b932/44a5863469051c5cf103129f1423ddb8/dotnet-sdk-3.1.102-linux-arm.tar.gz -P /tmp
    wget https://download.visualstudio.microsoft.com/download/pr/8ccacf09-e5eb-481b-a407-2398b08ac6ac/1cef921566cb9d1ca8c742c9c26a521c/aspnetcore-runtime-3.1.2-linux-arm.tar.gz -P /tmp
    sudo mkdir /opt/dotnet-arm32
    sudo tar -xf /tmp/dotnet-sdk-*-linux-arm.tar.gz -C /opt/dotnet-arm32
    sudo tar -xf /tmp/aspnetcore-runtime-*-linux-arm.tar.gz -C /opt/dotnet-arm32
    sudo chown -R pi:pi /opt/dotnet-arm32
    sudo chmod +x /opt/dotnet-arm32/dotnet
    

    Then edit the ~/.profile file to add at the end of it :

    export DOTNET_ROOT=/opt/dotnet-arm32
    export PATH=$PATH:/opt/dotnet-arm32
    

    Finally run source ~/.profile and dotnet --info (from another folder than /opt/dotnet-arm32) to make sure it works.

  3. Install Mono for Sonarr install (only if using v3)

    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/ . If it does not start automatically after ar reboot, add $network at the end of these lines in /etc/init.d/rpimonitor :

- # Required-Start:    $remote_fs $syslog	# Required-Start:    $remote_fs $syslog
+ # Required-Start:    $remote_fs $syslog	# Required-Start:    $remote_fs $syslog $network
- # Required-Stop:     $remote_fs $syslog	# Required-Stop:     $remote_fs $syslog
+ # Required-Stop:     $remote_fs $syslog	# Required-Stop:     $remote_fs $syslog $network

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,

Then add the following line in the [Unit] section of : sudo nano /lib/systemd/system/transmission-daemon.service

RequiresMountsFor=/media/scratology/Downloads

And run the service again : sudo service transmission-daemon start. To make sure it will start at boot automatically, run : sudo systemctl enable transmission-daemon.service.

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

wget "https://services.sonarr.tv/v1/download/main/latest?version=4&os=linux&arch=arm" -O /tmp/sonarr_v4.tar.gz
sudo tar -xvzf /tmp/sonarr_v4.tar.gz -C /opt/
sudo chown -R pi:pi /opt/Sonarr
sudo mkdir /var/lib/sonarr
sudo chown -R pi:pi /var/lib/sonarr

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

[Unit]
Description=Sonarr Daemon
After=network.target
RequiresMountsFor=/media/scratology/TVShows

[Service]
User=pi
Group=pi
Type=simple
ExecStart=/opt/Sonarr/Sonarr -nobrowser -data=/var/lib/sonarr
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-core-arm.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4)
wget ${radarrurl} -P /tmp/
sudo tar -xvzf /tmp/Radarr.master.*.linux-core-arm.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
RequiresMountsFor=/media/scratology/Movies

[Service]
User=pi
Group=pi
Type=simple
ExecStart=/opt/Radarr/Radarr -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