Resource icon

Scripted Plex installation

Redcoat

MVP
Joined
Feb 18, 2014
Messages
2,924
Please configure your default gateway - also you can put the same address in for the three nameservers (at least for now) while you are at it - in the Global Configuration page. and post the new Network Summary when done.
 

nikinp

Contributor
Joined
Sep 7, 2014
Messages
116
Please configure your default gateway - also you can put the same address in for the three nameservers (at least for now) while you are at it - in the Global Configuration page. and post the new Network Summary when done.
 

Attachments

  • 1C525A94-2844-4060-A1FB-94ABD09FBD37.png
    1C525A94-2844-4060-A1FB-94ABD09FBD37.png
    188.3 KB · Views: 343

Redcoat

MVP
Joined
Feb 18, 2014
Messages
2,924
Looks good.

Can you ping 192.168.0.10 from the4 shell command line?

What's in your plex-config file?
 

nikinp

Contributor
Joined
Sep 7, 2014
Messages
116
Yes I can ping it.

Config-file

JAIL_IP="192.168.0.11"
DEFAULT_GW_IP="192.168.0.1"
POOL_PATH="/mnt/tank"
USE_HW_TRANSCODE=''1"

I have re-set the server, following network change. Let me know if I should re-try the script
 

Redcoat

MVP
Joined
Feb 18, 2014
Messages
2,924
Yes, definitely. This all looks OK.
 

nikinp

Contributor
Joined
Sep 7, 2014
Messages
116
Thanks so much.
Script setup Plex (although not HW acceleration, says it has to be manual).
Although when the jail stops or starts, it re-starts the GUI.
Do you have any idea why that would be the case?
 

Redcoat

MVP
Joined
Feb 18, 2014
Messages
2,924
Although when the jail stops or starts, it re-starts the GUI.
Well, glad you have made some progress!!!

Do you mean that the server reboots when you say "it restarts the GUI"? Assuming you are starting and stopping it from the GUI, what happens when you do so.

And what version of FreeNAS/TrueNAS are you running?
 

nikinp

Contributor
Joined
Sep 7, 2014
Messages
116
Truenas 12.0-U2.1
Server doesnt re-boot. Instead, the GUI shows a splash screen and then re-logs back in. Its as if I am logged out of the GUI and then logs back in
 

Redcoat

MVP
Joined
Feb 18, 2014
Messages
2,924

tf5bassist

Cadet
Joined
May 2, 2021
Messages
6
Edit: Issue solved, it was a permissions issue with the Plex Media Server folder copied over from my Win10 box. Renaming and starting the service built its own Plex Media Server folder. Undid this and chown and chmod to match the generated version and it did pull my library data over as expected.

Have a weird issue going on with this script. On TrueNAS 12.0 U4, and this is my first FreeNAS/TrueNAS install so I'm still pretty new to this all. I did get my SABnzbd, Sonarr, etc, and all that set up and running (config may not be right, but one step at a time haha), but Plex is being problematic.

It looks like the script completes successfully, and maybe I'm just really tired and am missing something but I don't see any errors in the script output:

Code:
root@truenas[~/freenas-iocage-plex]# ./plex-jail.sh
Netmask not set, defaulting to /24 (255.255.255.0)
Plex metadata path not set, defaulting to /mnt/Coruscant/plex_data
Plex media path not set, please mount media directory manually when done
Not configuring hardware transcode
Using stable-release plexmediaserver code
Creating jail pms. This may take a minute, please be patient.
pms successfully created!
No default gateway found for ipv6.
* Starting pms
  + Started OK
  + Using devfs_ruleset: 1007 (iocage generated default)
  + Configuring VNET OK
  + Using IP options: vnet
  + Starting services OK
  + Executing poststart OK
Successfully added mount to pms's fstab
Successfully added mount to pms's fstab
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:12:amd64/latest, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
[pms] Installing pkg-1.16.3...
[pms] Extracting pkg-1.16.3: 100%
Updating FreeBSD repository catalogue...
[pms] Fetching meta.conf: 100%    163 B   0.2kB/s    00:01
[pms] Fetching packagesite.txz: 100%    6 MiB   6.5MB/s    00:01
Processing entries: 100%
FreeBSD repository update completed. 30704 packages processed.
All repositories are up to date.
Updating database digests format: 100%
The following 1 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
    plexmediaserver: 1.22.3.4392

Number of packages to be installed: 1

The process will require 235 MiB more space.
79 MiB to be downloaded.
[pms] [1/1] Fetching plexmediaserver-1.22.3.4392.txz: 100%   79 MiB  10.4MB/s    00:08
Checking integrity... done (0 conflicting)
[pms] [1/1] Installing plexmediaserver-1.22.3.4392...
===> Creating groups.
Creating group 'plex' with gid '972'.
===> Creating users
Creating user 'plex' with uid '972'.
[pms] [1/1] Extracting plexmediaserver-1.22.3.4392: 100%
=====
Message from plexmediaserver-1.22.3.4392:

--
multimedia/plexmediaserver includes an RC script:
/usr/local/etc/rc.d/plexmediaserver

TO START PLEXMEDIASERVER ON BOOT:
sysrc plexmediaserver_enable=YES

START MANUALLY:
service plexmediaserver start

Once started, visit the following to configure:
http://localhost:32400/web

@@@ INTEL GPU OFFLOAD NOTES @@@

If you have a supported Intel GPU, you can leverage hardware
accelerated encoding/decoding in Plex Media Server on FreeBSD 12.0+.

The requirements are as follows:

* Install multimedia/drm-kmod: e.g., pkg install drm-fbsd12.0-kmod

* Enable loading of kernel module on boot: sysrc kld_list+="i915kms"
** If Plex will run in a jail, you must load the module outside the jail!

* Load the kernel module now (although reboot is advised): kldload i915kms

* Add plex user to the video group: pw groupmod -n video -m plex

* For jails, make a devfs ruleset to expose /dev/dri/* devices.

e.g., /dev/devfs.rules on the host:

[plex_drm=10]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_jail
add path 'dri*' unhide
add path 'dri/*' unhide
add path 'drm*' unhide
add path 'drm/*' unhide

* Enable the devfs ruleset for your jail. e.g., devfs_ruleset=10 in your
/etc/jail.conf or for iocage, iocage set devfs_ruleset="10"

Please refer to documentation for all other FreeBSD jail management
utilities.

* Make sure hardware transcoding is enabled in the server settings

@@@ INTEL GPU OFFLOAD NOTES @@@
plexmediaserver_enable:  -> YES
plexmediaserver_support_path:  -> /config
Successfully removed mount from pms's fstab
* Stopping pms
  + Executing prestop OK
  + Stopping services OK
  + Tearing down VNET OK
  + Removing devfs_ruleset: 1007 OK
  + Removing jail process OK
  + Executing poststop OK
Installation Complete!
Mount your media folder into the jail, then start the jail.
Log in and configure your server by browsing to:
http://192.168.0.200:32400/web


There's nothing at the end of that web URL, but the rest of my apps do load fine. All the networking config looks identical.

I tried manually starting the service, but no luck:

Code:
root@pms:~ # service plexmediaserver start
Starting plexmediaserver.
root@pms:~ # service plexmediaserver status
plexmediaserver is not running.
root@pms:~ # service plexmediaserver onestart
Starting plexmediaserver.
root@pms:~ # service plexmediaserver status
plexmediaserver is not running.


I have my main data and jails on my main pool /mnt/Coruscant. I have my media folder and the initial location of my plex_data folder on my secondary pool /mnt/Batuu. When I first ran the script, I had the pool_path set to /mnt/Batuu, but then realized that there didn't seem to be any files installed within the jail for Plex. Super weird.

I rsync'd my plex_data/Plex Media Server folder (which, I should note, I copied from my Win10 install of PMS) over to a new plex_data dataset on /mnt/Coruscant, updated the plex-config file to reflect that, temporarily renamed the jail to pms-old and re-ran the script (the copy from above). It does seem that there's now files inside the pms jail for Plex, but the service just won't start.

I can't find any logs within the jail for the service, and there's no entries within the plex_data/Plex Media Server/logs folder either.

I followed Yorick's video and I don't know what I may have done wrong, but any ideas would be very much appreciated. Thanks!
 
Last edited:

Mastakilla

Patron
Joined
Jul 18, 2019
Messages
202
Thanks a lot for the script! I managed to get it working on my TrueNAS12.0-U4...

I'm wondering if the Plex update mechanism is working as expected though?

Code:
root@Plex-Jail /]# crontab -l
#Upgrade all installed packages and restart Plex
18 3 * * 0 pkg upgrade -y && service plexmediaserver restart

I suppose this does a weekly 'pkg upgrade', which should include the Plex package.

However, is it normal that Plex notifies me that an update is available, while pkg upgrade doesn't find anything?

Code:
[root@Plex-Jail /]# pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (1 candidates): 100%
Processing candidates (1 candidates): 100%
Checking integrity... done (0 conflicting)
Your packages are up to date.


1624724086836.png
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,455
However, is it normal that Plex notifies me that an update is available, while pkg upgrade doesn't find anything?
Very common. Plex pushes out new releases pretty frequently, and there's often a bit of a delay (not usually more than a week or so) before a FreeBSD package is available.
 
Joined
Jan 27, 2020
Messages
577
I just noticed my hardware supports hw transcode and i didn't set it ip accordingly, duh... Any pointers to turn on hw transcode or just one just re-run the script?

nvm: https://github.com/kern2011/Freenas-Quicksync#manually

aaaand my hw is not supported. SuperMicro decided to give my specific board just the C224 chipset instead of the C226 chipset.
 
Last edited:

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912
It's probably worth pointing out once more:

- Plex support for hw transcode on FreeBSD is not great. TN SCALE/Linux is the far better bet here.
- hw transcode has extremely limited utility to begin with. 4k HDR to 1080p/720p SDR transcode looks horrible, it's better to keep a HDR and SDR version alongside each other; and transcode at 1080p/720p can easily be done on CPU or "optimized" by Plex ahead of time.
 

ThatGuyAZ

Dabbler
Joined
Apr 28, 2021
Messages
32
Very new to TN but this is one of the main reasons I am using this and getting rid of my ReadyNAS.
If I'm using this tool/script, should I have already installed the plugin from the GUI? If I already did that do I need to delete/remove/cancel that somehow?

Also have some questions regarding setup:
Here is how I currently have it configured:
pool = tank
dataset1 = armored (all media, software, backups, data I need/want backed up)
dataset2 = turret (apps)
dataset2.1 = plex

If I want plex configuration to be in in my "plex" dataset while also accessing the media files located in my "collective" dataset; is that possible using this script?
 

elorimer

Contributor
Joined
Aug 26, 2019
Messages
194
Very new to TN but this is one of the main reasons I am using this and getting rid of my ReadyNAS.
If I'm using this tool/script, should I have already installed the plugin from the GUI? If I already did that do I need to delete/remove/cancel that somehow?

Also have some questions regarding setup:
Here is how I currently have it configured:
pool = tank
dataset1 = armored (all media, software, backups, data I need/want backed up)
dataset2 = turret (apps)
dataset2.1 = plex

If I want plex configuration to be in in my "plex" dataset while also accessing the media files located in my "collective" dataset; is that possible using this script?
Get rid of the plug in.
Put the media you want to access through plex in its own dataset.
Install the jail in a different dataset--there are other posts about that.
Follow the instructions to edit the configuration file.

Then you will be set up to delete the jail and reinstall, over and over, in minutes.
 

ThatGuyAZ

Dabbler
Joined
Apr 28, 2021
Messages
32
Get rid of the plug in.
Put the media you want to access through plex in its own dataset.
Install the jail in a different dataset--there are other posts about that.
Follow the instructions to edit the configuration file.

Then you will be set up to delete the jail and reinstall, over and over, in minutes.
Got it and removed the plugin. I've downloaded the git and created the config. Does this look correct based on the scenario I gave above:

Code:
JAIL_IP="192.168.1.155"
DEFAULT_GW_IP="192.168.1.1"
POOL_PATH="/mnt/tank"
PLEX_MEDIA_PATH="/mnt/tank/armored/media"
USE_HW_TRANSCODE=1
PLEX_CONFIG_PATH="/mnt/tank/turret/plex"

 
Joined
Jan 4, 2014
Messages
1,644
This dataset structure works for me...
tn07.jpg

...which would make...
Code:
PLEX_MEDIA_PATH="/mnt/tank/media"
PLEX_CONFIG_PATH="/mnt/tank/apps/plex"

Notes:
  1. These are datasets and child datasets under tank, not directories.
  2. Doing it this way, from the storage UI it's easy to see how much space each type of media is occupying.
  3. It's good practice to have the config data for each application stored under a root dataset like apps.
 

elorimer

Contributor
Joined
Aug 26, 2019
Messages
194
  1. These are datasets and child datasets under tank, not directories.
  2. Doing it this way, from the storage UI it's easy to see how much space each type of media is occupying.
  3. It's good practice to have the config data for each application stored under a root dataset like apps.
@ThatGuyAZ: It wasn't clear from your post whether you were following footnote #1 above, which would have been my only comment. The other reason for having child datasets under /tank/armored is that you can set up different snapshot/replication and permission scenarios within your main pool. My main pool is about 12 TB, 35% utilized, but my /Movies dataset is 1.7TB, so I can replicate it to a 2TB local backup pool monthly. The rest of the datasets are snapshotted daily and backed up to a 4TB local backup pool. The plex user doesn't have permission for those other datasets.
 

ThatGuyAZ

Dabbler
Joined
Apr 28, 2021
Messages
32
@ThatGuyAZ: It wasn't clear from your post whether you were following footnote #1 above, which would have been my only comment. The other reason for having child datasets under /tank/armored is that you can set up different snapshot/replication and permission scenarios within your main pool. My main pool is about 12 TB, 35% utilized, but my /Movies dataset is 1.7TB, so I can replicate it to a 2TB local backup pool monthly. The rest of the datasets are snapshotted daily and backed up to a 4TB local backup pool. The plex user doesn't have permission for those other datasets.
@elorimer I appreciate your help, I'm used receiving and giving (as I can) help on online communities. So let me first say thank you. I understood what you were saying and yes I have one pool (tank) and three datasets (armored, turret, and plex). My armored dataset contains all my media (photos, movies, tv shows), and is nested under the tank pool. plex is a dataset that is nested under the armored dataset, which is nested under the tank pool.

So based on that and the image that Basil posted, I think I have this set up the way it is recommended. I went through the install and the first time it had an error about the IP address:
Code:
root@TrueNAS[~]# cd /mnt/tank/armored/software/freenas-iocage-plex
root@TrueNAS[...rmored/software/freenas-iocage-plex]# ls
.git            configs         plex-config     README.md
.gitignore      LICENSE         plex-jail.sh
root@TrueNAS[...rmored/software/freenas-iocage-plex]# plex-config
zsh: command not found: plex-config
root@TrueNAS[...rmored/software/freenas-iocage-plex]# ./plex-jail.sh
Netmask not set, defaulting to /24 (255.255.255.0)
, the script will mount this into /media inside the Plex jail
This script only knows how to enable hardware transcode in FreeNAS 11.3 and TrueNAS 12.0
Not configuring hardware transcode automatically, please do it manually.
Using stable-release plexmediaserver code
Creating jail pms. This may take a minute, please be patient.
Please provide a valid ip: Only decimal digits permitted in '155\r' in '192.168.1.155\r'
Failed to create jail


I don't know what was up with that, but after checking the config file and restarting it seems to have installed correctly.

Does anyone know why Hardware Transcode was not enabled using this script? I'm using:
Version:
TrueNAS-12.0-U4
 
Last edited:
Top