Scripted installation of Plex Media Server


I’ve writen a simple script to automate installation of Plex Media Server. Like other scripts I’ve done, you’ll download the script, create a small configuration file, run the script, and your jail is up and running.

Why bother?

I’ve said for a long time that Plex installation is trivial, requiring only three commands once the jail is created (pkg install plexmediaserver, sysrc plexmediaserver_enable=YES, service plexmediaserver start). While this remains true, it doesn’t account for a few “best practices”:

  • The Plex metadata is stored inside the jail. If the jail needs to be rebuilt for some reason, you’ll lose it.
  • The package repository is by default set to quarterly, meaning that the Plex Media Server package will only be updated that often. Many Plex users have a near-pathological desire to have their installation as up-to-date as possible, so this won’t do.
  • There’s nothing in those three commands that sets up automatic updates to the installed packages.

This script addresses these issues–the Plex metadata is stored outside of the jail, the jail is configured to use the latest repository, and a cron job runs weekly to update the installed packages in the jail.

Installation and use



Looks like a nice alternative to the plugin for those that don’t want to do a manual install.

That’s the idea–and to keep the data out of the jail in case the jail gets hosed and needs to be rebuilt.

Thank you for providing this solution. I’m a newbie and just tried this out but after getting a message saying plex successfully created I get a VNET failure". Please can you point me in the direction of whatever pre-config i need to do?


Sorry for the delay in responding. Networking in iocage jails can be a little tricky–could you post more of the command output (or, better yet, the entire output of the script, along with the contents of the plex-config file)?

Hi Dan,

Thanks for replying and sorry for my very slow response. I wasn’t sure how to get detailed output but found that by adding > filename after the command gave a verbose listing although it didn’t seem to write to file although I could copy/paste it (as you can see I’m a complete newbie on this).

Here is the plex-config file detail:

Here is the output generated
plex successfully created!
Failed to create jail

and here is the verbose output generated onscreen when > filename is used
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/iocage_cli/”, line 164,in cli
basejail=basejail, thickjail=thickjail, empty=empty)
File “/usr/local/lib/python3.6/site-packages/iocage_lib/”, line 611,in create
File “/usr/local/lib/python3.6/site-packages/iocage_lib/”, line 87, in create_jail
return self._create_jail(jail_uuid, location)
File “/usr/local/lib/python3.6/site-packages/iocage_lib/”, line 555, in _create_jail
self.create_install_packages(jail_uuid, location, config)
File “/usr/local/lib/python3.6/site-packages/iocage_lib/”, line 600, in create_install_packages
File “/usr/local/lib/python3.6/site-packages/iocage_lib/”, line 67, in init
File “/usr/local/lib/python3.6/site-packages/iocage_lib/”, line 503, in start_jail
File “/usr/local/lib/python3.6/site-packages/iocage_lib/”, line 90, in logit
_callback(content, exception)
File “/usr/local/lib/python3.6/site-packages/iocage_lib/”, line 64, in callback
raise callback_exception(message)
Stopped plex due to VNET failure

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/iocage", line 10, in <module>
  File "/usr/local/lib/python3.6/site-packages/click/", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/click/", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/click/", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/click/", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/click/", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/iocage_cli/", line 184,in cli
    "message": err
  File "/usr/local/lib/python3.6/site-packages/iocage_lib/", line 90, in logit
    _callback(content, exception)
  File "/usr/local/lib/python3.6/site-packages/iocage_lib/", line 64, in callback
    raise callback_exception(message)
Stopped plex due to VNET failure

Please let me know if you need this in another format or created in another way.


This looks like your problem–the JAIL_IP needs to be on the same subnet as DEFAULT_GW_IP. That is, JAIL_IP needs to be 192.168.86.something if your router’s IP address really is what you say there.

Yes, that worked. I can’t believe /i missed something so obvious. Thanks very much.

Outstanding, nice that it was something simple. Enjoy!

I just tried to use this script and the script fails.
it seems the jail is not getting DNS. outside of the jail DNS works. what am i doing wrong?

root@Atlas[/mnt/Storage/Scripts/freenas-iocage-plex]# ./
plex successfully created!

Testing SRV response to FreeBSD's SRV record could not be verified.

Testing DNSSEC response to FreeBSD could not be reached via DNSSEC.

Testing DNS response to FreeBSD could not be reached via DNS, check your network
Failed to create jail



Which version of FreeNAS are you using?

I am sorry i forgot to say, I am on FreeNAS-11.2-U7