Sorta Fresh Plex in iocage

Status
Not open for further replies.

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
FN10 Docker convert here - jumping into iocage because warden is going away. I liked the Plex container in FN10 because it would pull the latest release when you restarted the container. I haven't gotten there yet (because I'm writing these for all of my old containers), but this is better than relying on the TrueOS people to provide an updated package.

This was written from the perspective of an existing installation and to keep the config files outside of the jail so that it can be rebuilt whenever. Not tested as a fresh install.

I will come back to this one and work on getting it to be the latest build of plex.

Code:
#!/bin/sh
# stop the jail nicely
iocage stop plex
# delete the jail
iocage destroy -f plex
# make temp file that will cause iocage to install some packages
echo '{"pkgs":["compat9x-amd64"]}' > /tmp/pkg.json
# create jail
iocage create --name "plex" -p /tmp/pkg.json -r 11.1-RELEASE ip4_addr="vnet0|[PLEX_IP]/24" vnet="on" allow_raw_sockets="1" defaultrouter="[GATEWAY_IP]" boot="on" host_hostname="plex"
# remove the temp file
rm /tmp/pkg.json
# map common portsnap storage outside of jail
iocage fstab -a plex /mnt/[zpool_not_iocage]/portsnap/ports /usr/ports nullfs rw 0 0
iocage fstab -a plex /mnt/[zpool_not_iocage]/portsnap/db /var/db/portsnap nullfs rw 0 0
# update ports as needed
iocage exec plex "if [ -z /usr/ports ]; then portsnap fetch extract; else portsnap auto; fi"
# install plex and clean up
iocage exec plex make -C /usr/ports/multimedia/plexmediaserver-plexpass install clean BATCH=yes
# map media and plex confg outside of jail
iocage fstab -a plex /mnt/[zpool_not_iocage]/path/to/videos /videos nullfs rw 0 0
iocage fstab -a plex /mnt/[zpool_not_iocage]/plex/Transcode /transcode nullfs rw 0 0
iocage fstab -a plex /mnt/[zpool_not_iocage]/plex/Library /config nullfs rw 0 0
# change ownership on plex files to the new plex user, but this could take a long time so not doing it by default
# iocage exec plex chown -R plex /config
# configure plex to use our mapped path instead of default
iocage exec plex sysrc -f /etc/rc.conf plexmediaserver_plexpass_support_path="/config/Application Support"
# make sure plex is enabled to run on startup
iocage exec plex sysrc -f /etc/rc.conf plexmediaserver_plexpass_enable="YES"
# restart the jail
iocage restart plex
 
 
Last edited:

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
Updated this to be a little slimmer on the work and added more comments to explain what it is doing. Because I'm building at least 3 jails based on ports, I decided to map the port storage outside of the jails as well and allow for a full extract instead of only extracting what was needed to build the package.
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I am curious about this. It looks interesting, but I am not sure what this does. Can you give some more explanation?

Are you using FreeNAS 11.1 now or still using FreeNAS 10?

Is there a way to convert a warden jail to an iocage jail?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,458
It looks interesting, but I am not sure what this does.
It creates an iocage jail for Plex and installs it, with storage (both for data and configuration) mapped to the main pool rather than in the jail. Though it looks like the idea is that it could be scripted to run regularly to blow away the jail and recreate it from scratch (with the newest versions, of course). I confess I don't see what benefit there is to this approach compared to just doing a periodic pkg upgrade within the jail.
 

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
It creates an iocage jail for Plex and installs it, with storage (both for data and configuration) mapped to the main pool rather than in the jail. Though it looks like the idea is that it could be scripted to run regularly to blow away the jail and recreate it from scratch (with the newest versions, of course). I confess I don't see what benefit there is to this approach compared to just doing a periodic pkg upgrade within the jail.

Yup, thanks for explaining it. The reason I'm doing it this way is because the current version in the 11.1 pkg repo is months old whereas the version in Ports is only about two weeks old.
 

Chuck Remes

Contributor
Joined
Jul 12, 2016
Messages
173
@danb35 If @kjake is anything like me, he had scripts to setup his dockers in FN10. I'm still on FN10 and am awaiting delivery of a new SATADOM so I can swap it in and do the 11.1 upgrade. I plan to do something very similar to the OP because I like to script all of my "vm" creation.

So, that's one reason to use the above script rather than just a pkg upgrade. However, I'll likely take a hyrbrid approach. I'll use the script to setup the jail and then upgrade packages going forward.
 

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
I'll use the script to setup the jail and then upgrade packages going forward.

I think you were typing your message while I was :)
Just re-iterating that the version of Plex in the pkg repo is terribly old. I do intend to re-visit this script and find a way to always pull the latest, but the Ports version is usually fairly up-to-date (around 2 weeks old right now).
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
I think you were typing your message while I was :)
Just re-iterating that the version of Plex in the pkg repo is terribly old. I do intend to re-visit this script and find a way to always pull the latest, but the Ports version is usually fairly up-to-date (around 2 weeks old right now).
Is there any prerequisite to running this script to create a Plex instance using iocage? I have been using Plex in a warden jail for years but I have no experience with iocage and I would really like to be able to keep my current configuration instead of needing to start from scratch. That is why this looks interesting is because it stores the Plex config outside the jail. I am trying to figure out what I need to do to get my config out of the warden jail so I can switch to an iocage jail like this for my Plex.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,458
I am trying to figure out what I need to do to get my config out of the warden jail so I can switch to an iocage jail like this for my Plex.
If you installed it from pkg, just tar up /usr/local/plexdata/ (or /usr/local/plexdata-plexpass/, if appropriate), and untar it in the desired location. I think the .pbi plugin now stores it there as well (there was a time when it was stored elsewhere, but I think that was changed a while back).

Edit: According to the Plex docs, it looks like the plugin would have it at /var/db/plexdata/ instead.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Anyone have any issues with Plex transcoding/playback? I setup an IOCAGE jail and installed the latest Plex version through PKG (used updated repo not quarterly) but when I attempt to play a file it does not start. I did have Plex running in a Warden jail without issues with the same version. I receive the following error.

Also I do notice that the transcoding process is running in the background when attempting to play a file.

 
Last edited:

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
Anyone have any issues with Plex transcoding/playback? I setup an IOCAGE jail and installed the latest Plex version through PKG (used updated repo not quarterly) but when I attempt to play a file it does not start. I did have Plex running in a Warden jail without issues with the same version. I receive the following error.

Also I do notice that the transcoding process is running in the background when attempting to play a file.

Make sure that the process in the jail (owned by a plex uid usually) has permissions to write to the transcode path (/transcode in my example)
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Make sure that the process in the jail (owned by a plex uid usually) has permissions to write to the transcode path (/transcode in my example)

That is what I am thinking it is, but what is the default transcode path?
 

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
That is what I am thinking it is, but what is the default transcode path?

Default path for FreeBSD is /usr/local/plexdata/Plex Media Server/, so I suspect it would be at /usr/local/plexdata/Plex Media Server/Transcode

You can also look in your Plex settings: Plex > Settings > Transcoder, Click the Show Advanced button.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
When I moved from warden to IOCAGE I kept permissions intact by taring the data folder. But I did just check and it does have the correct user/group which is the defualt plex.


EDIT: I even tried creating a new folder under tmp and pointed Plex to that but same issue. Literally the only difference is the IOCAGE jail.

Sent from my Pixel 2 XL using Tapatalk
 
Last edited:

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
When I moved from warden to IOCAGE I kept permissions intact by taring the data folder. But I did just check and it does have the correct user/group which is the defualt plex.
EDIT: I even tried creating a new folder under tmp and pointed Plex to that but same issue. Literally the only difference is the IOCAGE jail.

hmm, looks like you're not the only one with this issue: https://forums.plex.tv/discussion/300476/plex-will-not-play-media-error-shaka1001-network

If your PKG config is the same as mine, it installed Plex 1.9.2.xxxx.
Release notes from Plex 1.9.7 suggest a transcoder fix for FreeBSD. 1.10.1.4602 is the latest Public version.

I suggest switching the the Ports tree for a more up-to-date Plex installation.
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
hmm, looks like you're not the only one with this issue: https://forums.plex.tv/discussion/300476/plex-will-not-play-media-error-shaka1001-network

If you're PKG config is the same as mine, it installed Plex 1.9.2.xxxx.
Release notes from Plex 1.9.7 suggest a transcoder fix for FreeBSD. 1.10.1.4602 is the latest Public version.

I suggest switching the the Ports tree for a more up-to-date Plex installation.
I update the PKG repo address so that I can download later packages then the default quarterly. So my current Plex version is 1.11.0.4666.



Sent from my Pixel 2 XL using Tapatalk
 

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
I update the PKG repo address so that I can download later packages then the default quarterly. So my current Plex version is 1.11.0.4666.

Perfect! That's the same version that I'm running and it is working for me... Unfortunately, it seems that this error is pretty common and points to a myriad of possible causes.

Resolved with port forwarding for some reason...
https://www.reddit.com/r/PleX/comments/6ul3kv/cascading_shaka1001_playback_error_when_using/
I'm not doing any explicit port forwarding, but I did set my jail up with VNET so that UPnP would work for Remote Access. Shared IP didn't seem to work for that, but I don't recall playback issues.

This thread suggests is it the Pre-Roll feature causing it:
https://www.reddit.com/r/PleX/comments/7caiv9/shaka_1001_error_with_playing_preroll/

Not seeing a pattern in this thread:
https://forums.plex.tv/discussion/2...ed-trying-to-play-this-item-shaka1001-network

Same error with DVD file structures (VIDEO_TS):
https://forums.plex.tv/discussion/3...-device-but-can-play-it-via-windows-media-ctr

Another FreeNAS user - seems permissions were their problem:
https://www.reddit.com/r/PleX/comments/7hv0eh/upgraded_to_110_and_now_i_cant_play_anything_plex/

3 days ago, suggests corrupted files, no follow-up:
https://www.reddit.com/r/PleX/comments/7mo1gw/plex_app_v_3322_help_with_shaka_1001_error/
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
Perfect! That's the same version that I'm running and it is working for me... Unfortunately, it seems that this error is pretty common and points to a myriad of possible causes.

Resolved with port forwarding for some reason...
https://www.reddit.com/r/PleX/comments/6ul3kv/cascading_shaka1001_playback_error_when_using/
I'm not doing any explicit port forwarding, but I did set my jail up with VNET so that UPnP would work for Remote Access. Shared IP didn't seem to work for that, but I don't recall playback issues.

I have always used port forwarding without issue. But I did not enable VNET and did not think anything of it because the remote connection was working without issues. I attempted to enable VNET in the new UI but after starting the jail I could not access Plex. Is there a particular format for the ipv4 address in order for VNET to function properly? For example for my jails to function I need to provide the correct ipv4 interface like: igb0|192.168.1.5/24. I suspect with Vnet I need to bridge the connection maybe or modify the ipv4 field to reflect this.
 

kjake

Dabbler
Joined
Mar 17, 2017
Messages
29
Is there a particular format for the ipv4 address in order for VNET to function properly?

I use ip4_addr="vnet0|[PLEX_IP]/24" vnet="on" allow_raw_sockets="1" defaultrouter="[DEFAULT_GW_IP]" to enable VNET. You're correct then that your main interface needs to be added to bridge0 (which should be auto-created).

There's some detail in the old iocage docs for VNET to persist: https://iocage.readthedocs.io/en/latest/networking.html#vimage-vnet
You can add these in your System > Tunables area. I detail these steps in my Crashplan setup: https://github.com/kjake/freenas-iocage-crashplan#steps-for-use
 

raidflex

Guru
Joined
Mar 14, 2012
Messages
531
I use ip4_addr="vnet0|[PLEX_IP]/24" vnet="on" allow_raw_sockets="1" defaultrouter="[DEFAULT_GW_IP]" to enable VNET. You're correct then that your main interface needs to be added to bridge0 (which should be auto-created).

There's some detail in the old iocage docs for VNET to persist: https://iocage.readthedocs.io/en/latest/networking.html#vimage-vnet
You can add these in your System > Tunables area. I detail these steps in my Crashplan setup: https://github.com/kjake/freenas-iocage-crashplan#steps-for-use

Thanks for the help I did get it working. So Plex does require VNET in order to function, all my other jails including one with Emby do not require this. I just needed to add the tunables in order for the bridge to function properly with VNET.
 
Status
Not open for further replies.
Top