User Tools

Site Tools


esxi:media_server

Media Server

Uses Swizzin to setup a media server with Plex and various downloaders

Setup

First, install a minimal installation of Debian 10 with the following changes:

  • VM Name: Swizzin Media Server
  • Hostname: Optiplex-Media-Swizzin
  • CPU: 3
  • Memory: 3 GB
  • Hard Disk: 100 GB
  • Enable autostart with a priority near the end
  • Doesn't matter what username is used for the non root user

Install Debian 10

  • Download the 64-bit PC netinst iso file from debian.org
  • In ESXi:
    • Upload the iso to the iso folder in the datastore
    • Create/Register VM:
      • Create a new virtual machine
      • Name the VM, and choose Linux and Debian GNU/Linux 10 (64-bit)
      • Specify the desired Target Datastore
      • Customise:
        • CPU:
          • Use the full amount of cores per socket to end up with one socket
          • Enable Expose hardware assisted virtualization to the guest OS
        • If using NVMe storage for the datastore:
          • Add other device > NVMe controller
          • Hard Disk 1 > Controller location > NVMe controller 0
          • Remove SCSI controller 0
        • Select other appropriate VM settings depending on desired applications
      • Confirm settings and Finish
    • If autostart is desired for this machine go to Host > Manage > System > Autostart:
      • Click on the current VM
      • Enable
      • Use Start earlier and Start later to set the desired order
    • Go to Virtual Machines on the sidebar and click on the current VM
      • Power on the VM
      • Go through the Debian setup process
        • In software selection, selecting only the SSH server and Standard system utilities
    • Give the VM a static IP address from your router using the generated MAC address (found under Hardware Configuration > Network adapter 1) and desired hostname
    • Reboot the VM
    • Using an SSH client, connect to the hostname set above, then run:
# Login with root details that were set earlier
# Update packages:
apt update
apt upgrade
# Install VMWare tools
apt install open-vm-tools
 
# Change the SSH port to 50001:
sed -i "s/#Port 22/Port 50001/" /etc/ssh/sshd_config
exit
  • Shutdown the VM
  • Edit VM note to be the following:
Minimal server installation of Debian 10

Ports:
50001/tcp SSH
  • Save a snapshot called Base Install
2020/12/22 08:35 · derek

Install Swizzin

  • Power on the VM
  • Login as root using an SSH client
  • Delete the non root user with userdel -r <username>
  • Start the Swizzin installation with bash <(wget -qO - git.io/swizzin) && . ~/.bashrc
  • Follow the setup, selecting the following services, and saving the Deluge ports in the VM note:
    • NGINX
    • Panel
    • Plex
    • Deluge
    • Jackett
    • Lidarr
    • Radarr
    • Sonarr
    • FIXME: Make sure the list is correct, and possibly add more
  • Check that they can be accessed at https://Optiplex-Media-Swizzin
  • Shutdown the server with shutdown 0
  • Create a snapshot called Swizzin installed

Setup Base Things

  • In Caddy, add a reverse proxy entry from media.domain.com to https://Optiplex-Media-Swizzin
  • In Synology:
    • Create a folder called deluge in the root of the Downloads share
    • Create a user called Media and using a randomly generated password
    • For each of the following shares: Downloads, Music, and Video
      • Create a snapshot
      • Give read/write permission to the Media user
  • Open an SSH session to optiples-media-swizzin:50001 using the admin account created with Swizzin and run the following:
sudo apt install cifs-utils
 
# Setup mount points
mkdir /mnt/Music /mnt/Video
chmod 777 /mnt/Music /mnt/Video
rm -r /home/derek/torrents/deluge # Check using ls -a for hidden files first
 
# Using this command, add the following lines to fstab:
sudo nano /etc/fstab
# Lines to add (replace the password):
//FileServer/Downloads /home/derek/torrents cifs user=Media,password=<password>,x-systemd.automount,rw,dir_mode=0777,file_mode=0777,uid=1000,gid=1000  0  0
//FileServer/Music     /mnt/Music           cifs user=Media,password=<password>,x-systemd.automount,rw,dir_mode=0777,file_mode=0777,uid=1000,gid=1000  0  0
//FileServer/Video     /mnt/Video           cifs user=Media,password=<password>,x-systemd.automount,rw,dir_mode=0777,file_mode=0777,uid=1000,gid=1000  0  0
 
# Allow CIFS mounts to show in the panel admin page
# Using this command, change the ''get_mounts()'' function to match the function below
sudo -u swizzin nano /opt/swizzin/core/util.py
 
# Restart
sudo shutdown 0

The resulting get_mounts() function (added the two lines between the octothorpes):

def get_mounts():
    mounts = []
    with open("/proc/mounts") as mount:
        for line in mount:
            fields = line.strip().split()
            if fields[0].startswith("/dev"):
                if ("boot" in fields[1]) or ("fuse" in fields) or ("/snap/" in fields[1]) or ("/loop" in fields[0]):
                    continue
                else:
                    mounts.append(fields[1])
            ###
            elif fields[0].startswith("//"):
                mounts.append(fields[1])
            ###
    with open("/etc/fstab") as fstab:
        for line in fstab:
            fields = line.strip().split()
            if "bind" in str(fields):
                try:
                    mounts.remove(fields[1])
                except:
                    pass
    return mounts

Configure Services

  • Create a snapshot called Mounts configured, before Plex transfer
  • Go to https://media.domain.com
  • Go to Plex in the sidebar:
  • Go to Deluge from the sidebar:
  • Go to Jackett from the sidebar:
    • Sign in with the password used to set up Swizzin
    • Add desired indexers
    • Keep the page open to add the feeds into Sonarr and Radarr
  • Go to Sonarr from the sidebar:
    • Settings:
      • Enable Show Advanced
      • Media Management:
        • Enable Rename Episodes
        • Add brackets around each of the quality tags in the formats
        • Season Folder Format: Season {season:00}
        • Specials Folder Format: Season 00
        • Multi-Episode Style: Range
        • Disable Use Hardlinks Instead of Copy
        • Enable Import Extra Files, keeping just srt enabled
        • FIXME: Set Root Folders —————————————————————-
        • Save Changes
      • FIXME: Profiles and Quality (HEVC/1Mbps and things)
      • Indexers:
        • Add the indexers from Jackett using their instructions, except to replace the start of each of the URLs with http://localhost:9117
      • Download Clients:
        • Add new client:
          • Name: Deluge
          • Host: localhost
          • Port: The Deluge Web Port saved from earlier
          • Password: Your Swizzin password
      • Connect:
        • FIXME: maybe setup notifications?
      • UI:
        • First Day of Week: Monday
        • Week Column Header: Tue 25/03
        • Short Date Format: 25/03/2014
        • Long Date Format: Tuesday, 25 March, 2014
        • Time Format: 17:00/17:30
        • Save Changes
  • Go to Radarr in the sidebar:
    • Settings:
      • Enable Show Advanced
      • Media Management:
        • Enable Rename Movies
        • Add brackets around the quality tag in the Standard Movie Format
        • Disable Use Hardlinks Instead of Copy
        • Enable Import Extra Files, keeping just srt enabled
        • Enable Unmonitor Deleted Movies
        • FIXME: Set Root Folders —————————————————————-
        • Save Changes
      • Custom Formats > Add new custom format > Import > Paste the custom format import string from below
      • Profiles:
        • Edit the Any profile:
          • Set the HEVC custom format score to 50
      • FIXME: Profiles and Quality (HEVC/1Mbps and things)
      • Indexers:
        • Add the indexers from Jackett using the Jackett preset of Torznab, changing the name, replacing YOURINDEXER with the name used in Jackett, the API Key from Jackett, and setting appropriate categories
        • Availability Delay: 3 Days
        • Add a Restriction with a Must Not Contain of 3d
      • Download Clients:
        • Add new client:
          • Name: Deluge
          • Host: localhost
          • Port: The Deluge Web Port saved from earlier
          • Password: Your Swizzin password
      • Connect:
        • FIXME: maybe setup notifications?
      • UI:
        • First Day of Week: Monday
        • Week Column Header: Tue 25/03
        • Short Date Format: 25/03/2014
        • Long Date Format: Tuesday, 25 March, 2014
        • Time Format: 17:00/17:30
        • Save Changes
  • Go to Lidarr in the sidebar:
    • Settings:
      • Enable Show Advanced
      • Media Management:
        • Enable Rename Tracks
        • Potentially use the following formats that match iTunes:
          • Standard Track Format: {track:00} {Track Title}
          • Multi Disc Track Format: {medium:0}-{track:00} {Track Title}
          • Album Folder Format: {Album Title}
        • Disable Use Hardlinks Instead of Copy
        • FIXME: Set Root Folders —————————————————————-
        • Save Changes
      • FIXME: Profiles and Quality
      • Indexers:
        • Add the indexers from Jackett using their instructions, except to replace the start of each of the URLs with http://localhost:9117
      • Download Clients:
        • Add new client:
          • Name: Deluge
          • Host: localhost
          • Port: The Deluge Web Port saved from earlier
          • Password: Your Swizzin password
      • Connect:
        • FIXME: maybe setup notifications?
      • UI:
        • First Day of Week: Monday
        • Week Column Header: Tue 25/03
        • Short Date Format: 25/03/2014
        • Long Date Format: Tuesday, 25 March, 2014
        • Time Format: 17:00/17:30
        • Save Changes
  • Shutdown the VM and create a snapshot called Configured

FIXME: Figure out Lidarr process

Deluge Chrome Integration

Set up Remote Torrent Adder (Github) for Chrome:

  • Add the extension to Chrome Remote Torrent Adder
  • Open the extension options through Chrome’s wrench menu and set your server’s info:
    • Add Server:
      • Name: Deluge
      • Server type: Deluge WebUI
    • Fill in details:
      • Host: <media.domain.com>
      • Port: 443
      • Enable SSL
      • Username: Your Swizzin username
      • Password: Your Swizzin password
      • Relative Path: /deluge

Update

FIXME: Write update process and add to update page using {{page>esxi:media_server#Update}}

  • If desired, Log in to ESXi, navigate to the docker VM and create new snapshot
  • Using an SSH client, connect to <hostname>:50001 then run:
# Run the following with sudo if not logged in as root
apt update
apt upgrade
reboot  # If desired/needed
2020/12/22 08:35 · derek

Sources

Notes

Folder format:

~
  torrents          (mapped to //fileserver/Downloads)
    deluge          (Deluge target)
    Music           (symlink on smb server)
      Add to Music
        Lidarr      (Lidarr target)
    Videos          (symlink on smb server)
      Movies        (Radarr target)
      TV Shows      (Sonarr target)
/mnt
  Music             (//fileserver/Music)
    iTunes
      iTunes Media  
        Music       (Plex Library)
  Video             (//fileserver/Video)
    Movies          (Plex Library)
    TV Shows        (Plex Library)

Alternatives:

  • Pro version of QuickBox is a similar solution
  • OpenFLIXR version 3 when it comes out, is a fully configured option

TODO

esxi/media_server.txt · Last modified: 2021/01/11 18:46 by derek