Skip to content

Instantly share code, notes, and snippets.

@Drowze
Last active September 23, 2021 14:09
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Drowze/edb37f14746f0db2c1b3cf4b506a06c6 to your computer and use it in GitHub Desktop.
Save Drowze/edb37f14746f0db2c1b3cf4b506a06c6 to your computer and use it in GitHub Desktop.
Setting up a Plex Media Server VM (tested with Virtualbox) with ubuntu server (tested on 16 LTS)
#!/bin/sh
# Installs Anidb Metadata Agent (HAMA) and Absolute Series Scanner (ASS)
# Credits: https://github.com/ZeroQI/Hama.bundle/wiki/Installing-Hama-and-ASS-on-Ubuntu
service plexmediaserver stop
PMS_PATH='/var/lib/plexmediaserver/Library/Application Support/Plex Media Server'
# HAMA
cd "$PMS_PATH/Plug-ins"
git clone https://github.com/ZeroQI/Hama.bundle.git
chown -R plex:plex "$PMS_PATH/Plug-ins/Hama.bundle"
chmod 775 -R "$PMS_PATH/Plug-ins/Hama.bundle"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/AniDB"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/Plex"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/OMDB"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TMDB"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/blank"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/_cache/fanart/original"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/episodes"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/fanart/original"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/fanart/vignette"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/graphical"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/posters"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/seasons"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/seasonswide"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/TVDB/text"
mkdir -p "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama/DataItems/FanartTV"
chown -R plex:plex "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama"
chmod 775 -R "$PMS_PATH/Plug-in Support/Data/com.plexapp.agents.hama"
# ASS
mkdir -p "$PMS_PATH/Scanners/Series"
wget -O "$PMS_PATH/Scanners/Series/Absolute Series Scanner.py" https://raw.githubusercontent.com/ZeroQI/Absolute-Series-Scanner/master/Scanners/Series/Absolute%20Series%20Scanner.py
chown -R plex:plex "$PMS_PATH/Scanners"
chmod 775 -R "$PMS_PATH/Scanners"
service plexmediaserver restart

DISCLAIMER

Tested under Windows 10 Pro host (1709), Ubuntu server 16 LTS guest, VirtualBox 5.2.4.
Hardware: AMD FX 6300, 8GB Ram (VGA should not matter).

Step-by-step

  • Download Virtualbox and set up a VM with Ubuntu Server (I used 16 LTS). Take note of the VM name.
  • With the VM closed, configure the network adapter as bridged.
  • Install the Ubuntu server normally. Take note of your username (duh!).
  • Add the plex repositories and add the key as trusted:
# reference: https://support.plex.tv/articles/235974187-enable-repository-updating-for-supported-linux-server-distributions/
echo deb https://downloads.plex.tv/repo/deb ./public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
curl https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
sudo apt update
  • Install Virtual Box Guest Additions (mandatory for file sharing), openssh (optional but recommended), and the Plex Media Server:
sudo apt install openssh-server plexmediaserver virtualbox-guest-dkms
  • Allow your user and plex user to view VirtualBox shared files.
gpasswd -M <YOUR_USERNAME>,plex vboxsf
  • Shutdown, setup your shared folders through VirtualBox GUI
  • Try to launch the VM, check its IP with ifconfig
  • On the host, go to http://YOUR-IP:32400/web and check if you can view the shared folders on Plex and you're golden.

BONUS

  • You can also use VBoxHeadless to even forget what is running Plex (to access the server though you will need to ssh into it). Sample .bat script:
cd "C:\Program Files\Oracle\VirtualBox\"
VBoxHeadless -s "Plex server"
  • If you're like me and watch anime, you probably want to watch anime on you Plex server. Simply run the included install-hama-absolute-series-scanner.sh script.
@martinandersen3d
Copy link

hi Drowze.. this is for ubuntu 16.. does it still work? or what solution does u use today?

@Drowze
Copy link
Author

Drowze commented Jul 3, 2021

It should still work alright I suppose (with exception of the anime script). Maybe the plex repositories URL changes too, idk.

These days I simply run Plex using docker and definitely recommend that. It's much easier to maintain and more automated than the setup above. See https://hub.docker.com/r/linuxserver/plex

I also don't use Windows anymore, but I guess Plex should also work on docker for Windows.

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