Skip to content

Instantly share code, notes, and snippets.

@BillyNate
Last active September 20, 2020 09:26
Show Gist options
  • Save BillyNate/60c030a3ca6892361afe0941e201bfc2 to your computer and use it in GitHub Desktop.
Save BillyNate/60c030a3ca6892361afe0941e201bfc2 to your computer and use it in GitHub Desktop.
Pi running Sonarr, Radarr & Lidarr in RAM (on piCore)

Pi running Sonarr, Radarr & Lidarr in RAM (on piCore)

These are the steps taken to have Sonarr, Radarr & Lidarr on piCore 9.0.3 running Mono 4.4.2
Newer version might work as well (or maybe even better), but have not been tested.

Set up piCore

  1. Download the piCore image

  2. Unpack the .zip file and write the .img file to the SD-Card (using USB Image Tool for example)

  3. Move the SD-Card to the Pi, plug the Pi into the network and plug in the power source

  4. SSH into the Pi (using Putty for example)
    Login using tc / piCore

  5. Execute filetool.sh -b shell command after the first boot to save generated unique SSH keys which will be used during next boots.

  6. Expand the partition:

    1. Start the partition tool: sudo fdisk -u /dev/mmcblk0
    2. List partitions with p command and write down the StartLBA and EndLBA of the second partition
    3. Delete second partition with d than recreate it with n command
      Select p for Primary Partition and 2 for Partition Number
      Use the same starting sector as deleted had and use the default value for Last Cylinder
      Exit fdisk with w command
    4. Reboot the Pi: sudo reboot
    5. After reboot expand the partition: sudo resize2fs /dev/mmcblk0p2 (may take a while)
  7. Optionally install the nano text editor (or keep using vi): tce-load -wi nano

  8. Install Curl, Mono and SQLite: tce-load -wi curl mono sqlite3

Install Sonarr

  1. Download Sonarr: wget http://update.sonarr.tv/v2/master/mono/NzbDrone.master.tar.gz
  2. Create a temporary directory: mkdir -p /tmp/SonarrExt/usr/local/bin
  3. Unpack the tarball: tar -xvzf NzbDrone.master.tar.gz -C /tmp/SonarrExt/usr/local/bin
  4. Create extension: mksquashfs /tmp/SonarrExt /mnt/mmcblk0p2/tce/optional/sonarr.tcz
  5. Add sonarr.tcz to /mnt/mmcblk0p2/tce/onboot.lst
  6. Have Sonarr auto start on boot: sudo nano /opt/bootlocal.sh, add mono /usr/local/bin/NzbDrone/NzbDrone.exe /data=/home/tc/.config/NzbDrone & to the end
  7. Save the changes: filetool.sh -b
  8. Reboot: sudo reboot

Note: Don't forget to do filetool.sh -b after making a change to the configuration of Sonarr

Install Radarr

  1. Download a linux tarball from https://github.com/Radarr/Radarr/releases
  2. Create a temporary directory: mkdir -p /tmp/RadarrExt/usr/local/bin
  3. Unpack the tarball: tar -xvzf Radarr.develop.*.linux.tar.gz -C /tmp/RadarrExt/usr/local/bin
  4. Create extension: mksquashfs /tmp/RadarrExt /mnt/mmcblk0p2/tce/optional/radarr.tcz
  5. Add radarr.tcz to /mnt/mmcblk0p2/tce/onboot.lst
  6. Have Radarr auto start on boot: sudo nano /opt/bootlocal.sh, add mono /usr/local/bin/Radarr/Radarr.exe /data=/home/tc/.config/Radarr & to the end
  7. Save the changes: filetool.sh -b
  8. Reboot: sudo reboot

Optionally: Make Radarr actually work

Radarr won't load any movie data because Radarr gets its information from TMDB, but TMDB is on a newer SSL key than mono 4.x can handle.

  1. Check the version Mono is on: mono -V, if this is <5, proceed
  2. Install Apache (will be used as a proxy): tce-load -wi apache2.4
  3. Create SSL certificate files in ~/certs: sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/tc/certs/themoviedb-selfsigned.key -out /home/tc/certs/themoviedb-selfsigned.crt.
    Some questions will be asked, they can mostle be skipped through, only Common Name need to be api.themoviedb.org
  4. Copy over the configuration file: cp /usr/local/httpd/httpd.conf /home/tc/.config/httpd.conf
  5. Edit the copied httpd.conf:
    1. Add Listen 443 below Listen 80
    2. Enable (by removing #) modules mod_ssl.so, mod_proxy.so & mod_proxy_http.so
    3. Below <Directory "/usr/local/apach2/htdocs"></Directory> add:
    <VirtualHost *:443>
        ServerName api.themoviedb.org
    
        SSLEngine On
        SSLCertificateFile "/home/tc/certs/themoviedb-selfsigned.crt"
        SSLCertificateKeyFile "/home/tc/certs/themoviedb-selfsigned.key"
    
        SSLProxyEngine on
    
        ProxyPreserveHost On
        ProxyPass / https://x.x.x.x/
        ProxyPassReverse / https://x.x.x.x/
    
        # Whenever Radarr still doesn't work, one can enable the logging:
        #LogLevel debug
        #ErrorLog "/home/tc/apache.log"
    </VirtualHost>
    
  6. Get the IP of api.themoviedb.org (for example by issueing a ping) and edit the ProxyPass & ProxyPassReverse to reflect the IP
  7. Edit /opt/bootlocal.sh to make Apache auto start on boot, and also relay TMDB API traffic through Apache:
    httpd -f /home/tc/.config/httpd.conf
    echo "127.0.0.1 api.themoviedb.org" | tee -a /etc/hosts
  8. Save the changes: filetool.sh -b
  9. Reboot: sudo reboot

Install Lidarr

  1. Download a linux tarball from https://github.com/lidarr/Lidarr/releases
  2. Create a temporary directory: mkdir -p /tmp/LidarrExt/usr/local/bin
  3. Unpack the tarball: tar -xvzf Lidarr.develop.*.linux.tar.gz -C /tmp/LidarrExt/usr/local/bin
  4. Create extension: mksquashfs /tmp/LidarrExt /mnt/mmcblk0p2/tce/optional/lidarr.tcz
  5. Add lidarr.tcz to /mnt/mmcblk0p2/tce/onboot.lst
  6. Have Lidarr auto start on boot: sudo nano /opt/bootlocal.sh, add mono /usr/local/bin/Lidarr/Lidarr.exe /data=/home/tc/.config/Lidarr & to the end
  7. Save the changes: filetool.sh -b
  8. Reboot: sudo reboot

Install libmediainfo

  1. Install compiler: tce-load -wi compiletc
  2. Go to the MediaInfo download page and download (wget) the SO.gz file
  3. Unpack the tarball: tar zxvf MediaInfo_DLL_??.??_GNU_FromSource.tar.gz and change directory: cd MediaInfo_DLL_GNU_FromSource
  4. Run SO_Compile.sh (might take a while)
  5. Change directory into MediaInfoLib/Project/GNU/Library and perform a make install
  6. Add the following lines to /opt/.filetool.lst:
    libmediainfo.la
    libmediainfo.so
    libmediainfo.so.0
    libmediainfo.so.0.0.0
  7. Add ldconfig to /opt/bootlocal.sh (otherwise the lib won't be found)
  8. Remove files from user directory: rm -rf ~/MediaInfo*
  9. Save changes: filetool.sh -b

Install Bazarr

  1. Install Python 2.7: tce-load -wi python python-dev
  2. Install necessary dependencies: tce-load -wi libxslt-dev libxml2-dev
  3. Download get-pip.py: wget https://bootstrap.pypa.io/get-pip.py and make executable: chmod +x get-pip.py
  4. Install pip: sudo ./get-pip.py
  5. Add pip to the back-up list: sudo nano /opt/.filetool.lst, add usr/local/bin/pip, usr/local/bin/pip2 & usr/local/bin/pip2.7 to the end
  6. Download a linux tarball from https://github.com/morpheus65535/bazarr/releases, for example: wget https://github.com/morpheus65535/bazarr/archive/v0.7.5.tar.gz -O Bazarr.develop.0.7.5.linux.tar.gz
  7. Create a temporary directory: mkdir -p /tmp/BazarrExt/usr/local/bin
  8. Unpack the tarball: sudo tar -xvzf Bazarr.develop.*.linux.tar.gz -C /tmp/BazarrExt/usr/local/bin
  9. Rename the Bazarr directory: sudo mv /tmp/BazarrExt/usr/local/bin/bazarr* /tmp/BazarrExt/usr/local/bin/bazarr
  10. Create extension: mksquashfs /tmp/BazarrExt /mnt/mmcblk0p2/tce/optional/bazarr.tcz
  11. Add bazarr.tcz to /mnt/mmcblk0p2/tce/onboot.lst
  12. Manually install all dependencies mentioned in the requirements.txt (sudo pip install gevent lxml)
  13. Turn python site-packages into an extension:
    1. Create a temporary directory: mkdir -p /tmp/sitepackagesExt/usr/local/lib/python2.7/site-packages
    2. Copy over the files: cp -r /usr/local/lib/python2.7/site-packages/* /tmp/sitepackagesExt/usr/local/lib/python2.7/site-packages/
    3. Create extension: mksquashfs /tmp/sitepackagesExt /mnt/mmcblk0p2/tce/optional/sitepackages.tcz
    4. Add sitepackages.tcz to /mnt/mmcblk0p2/tce/onboot.lst
  14. Add UTF-8 support:
    1. Install getlocale: tce-load -wi getlocale
    2. Install en_US.UTF-8: sudo getlocale.sh (use spacebar to enable/disable a locale)
    3. Follow steps below to not only set the timezone, but also the locale
  15. Set the timezone:
    1. Mount the /dev/mmcblk0p1 partition: mount /dev/mmcblk0p1
    2. Figure out what file to edit: cat /mnt/mmcblk0p1/config.txt | more
    3. Edit the file (according to previous command): sudo nano /mnt/mmcblk0p1/cmdline.txt
    4. Add TZ=America/Chicago (obviously change to your timezone)
    5. Add LANG=en_US.UTF8
  16. Have Bazarr auto start on boot: sudo nano /opt/bootlocal.sh, add python /usr/local/bin/bazarr/bazarr.py -c /home/tc/.config/Bazarr & to the end
  17. Save the changes: filetool.sh -b

Accessing NAS share

  1. Install cifs: tce-load -wi cifs-utils samba4 filesystems-KERNEL

  2. Create a file containing the login credentials of the share /home/tc/.smb:

    user=username
    password=xxxxxx
    
  3. Add a line to /etc/fstab: //192.168.x.xxx/sharedfolder /mnt/shared cifs credentials=/home/tc/.smb,_netdev 0 0

  4. Make fstab saved by adding /etc/fstab to /opt/.filetool.lst

  5. Create a script for mounting /opt/mount.sh:

    #!/bin/sh
    mkdir /mnt/shared
    until cat /etc/fstab | grep shared
    do
      sleep 1
    done
    sleep 5
    mount /mnt/shared
    
  6. Add the script to /opt/bootlocal.sh: /opt/mount.sh &

  7. Save the changes: filetool.sh -b

  8. Reboot: sudo reboot

Link Sonarr, Radarr & Lidarr db to remote share

  1. Kill Sonarr/Radarr/Lidarr
  2. Remove (or even better; back-up) the /home/tc/.config/*/*.db file
  3. Create symlinks:
  • Sonarr: ln -s /mnt/share/.sonarr/nzbdrone.db /home/tc/.config/NzbDrone/nzbdrone.db
  • Radarr: ln -s /mnt/share/.radarr/radarr.db /home/tc/.config/Radarr/radarr.db
  • Lidarr: ln -s /mnt/share/.lidarr/lidarr.db /home/tc/.config/Lidarr/lidarr.db
  • Bazarr: ln -s /mnt/share/.bazarr/config /home/tc/.config/bazarr/config
    ln -s /mnt/share/.bazarr/db /home/tc/.config/bazarr/db
  1. Save the changes: filetool.sh -b

Optionally: Fix Telegram notifications

If you use Telegram to get notifications from Sonarr & Radarr you might notice these don't work. This is thanks to the same issue as the TMDB connection from Radarr and can be fixed by also adding a certificate for Telegram to Apache:

  1. Create SSL certificate files in ~/certs: sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/tc/certs/telegram-selfsigned.key -out /home/tc/certs/telegram-selfsigned.crt.
    Some questions will be asked, they can mostle be skipped through, only Common Name need to be api.telegram.org
  2. Edit /home/tc/.config/httpd.conf:
    1. Below <VirtualHost *:443></VirtualHost> of api.themoviedb.org add:
    <VirtualHost *:443>
        ServerName api.telegram.org
    
        SSLEngine On
        SSLCertificateFile "/home/tc/certs/telegram-selfsigned.crt"
        SSLCertificateKeyFile "/home/tc/certs/telegram-selfsigned.key"
    
        SSLProxyEngine on
    
        ProxyPreserveHost On
        ProxyPass / https://x.x.x.x/
        ProxyPassReverse / https://x.x.x.x/
    
        # Whenever Telegram still doesn't work, one can enable the logging:
        #LogLevel debug
        #ErrorLog "/home/tc/apache.log"
    </VirtualHost>
    
  3. Get the IP of api.telegram.org (for example by issueing a ping) and edit the ProxyPass & ProxyPassReverse to reflect the IP
  4. Edit /opt/bootlocal.sh to also relay Telegram API traffic through Apache:
    echo "127.0.0.1 api.telegram.org" | tee -a /etc/hosts
  5. Save the changes: filetool.sh -b
  6. Reboot: sudo reboot

Exclude files from filetool back-up

  1. Create a file /opt/.xfiletool.lst and add:
    home/tc/.config/*/log*
    home/tc/.config/*/nzbdrone.pid
    home/tc/.config/*/MediaCover
    home/tc/.config/*/Backups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment