Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

[How To] Install plexconnect for aTV

traxinv

Newbie
Joined
Feb 8, 2014
Messages
21
How to Install PlexConnect (with automatic boot)

Login to your FreeNAS server using the normal IP. Then go to the jails section in the navigation bar and then add jails. Select the following options:



You can give it any IP you prefer. Also make sure you select the following:



Then Click ok!

Next go ahead and open putty (or something similar) and connect directly to your FreeNAS’s IP. Username: root Password: [your password]

First we need to find the jail we just created. Run the following command:
Code:
jls

This will return a list of all your current jails:


Now you want to directly connect to the jail itself using the JID. From the list you look for the hostname PlexConnect (I will be using PlexConnect_test as I don’t want to change my current setup, you should use PlexConnect jail.)

To get into the jail run the following command
Code:
jexec <JID> csh

Where <JID> is the JID of the PlexConnect jail.


Install the required software:

First we are going to have to install all the extra packages PlexConnect requires to work.

1.Pkg manager.
First let’s do some future proofing. Now pkg_add can be used instead of this method. But everyone seems to have a massive problem with it so lets us pkgng, BUT since it is not as standard part of a pluginjail (or is depending on the version of freenas you are running) we need to install it.

Run:
Code:
pkg_add -r pkg

(Note if this is not working skip to the next package)

So then run the command:
Code:
pkg2ng

This will take several minutes just be patient. Now for good measure you can just run:
Code:
pkg update


If it want you to update the pkg manager just say yes.

2.Python

Code:
pkg install python

3.Nano – Text editing
Code:
pkg install nano

4.Bash
Code:
pkg install bash


5.Git
Code:
pkg install git


6.Pillow
Code:
pkg install py27-pillow


Part 1: Get PlexConnect and Configure it

Get PlexConnect

Now we have to fetch the newest PlexConnect from the git repo.
Code:
git clone https://github.com/iBaa/PlexConnect.git
cd PlexConnect/
git pull


Generate the required SSL certificates

Next we need to create the communication certificates. Change directory to the certificates folder
Code:
cd /PlexConnect/assets/certificates


Generate the required SSL certificates
Code:
openssl req -new -nodes -newkey rsa:2048 -out trailers.pem -keyout trailers.key -x509 -days 7300 -subj "/C=US/CN=trailers.apple.com"


This will create 2 files trailers.key and trailers.pem. Next run this:
Code:
openssl x509 -in trailers.pem -outform der -out trailers.cer && cat trailers.key >> trailers.pem 


Create the Settings.cfg file

Go back to the root directory:
Code:
cd / 


Change Directory
Code:
cd PlexConnect/


Start PlexConnect so it creates Settings.cfg
Code:
./PlexConnect.py


When it started Exit using CTRL + C
Code:
nano Settings.cfg


Change the 2 lines below
Code:
ip_pms = 10.0.0.30 # This one you have to change to your Jail IP address
enable_plexgdm = False # This one you have to change from True to False


Test that the basics work:


To start PlexConnect
Code:
bash /PlexConnect/PlexConnect_daemon.bash start


Make sure it starts up:
Code:
bash /PlexConnect/PlexConnect_daemon.bash status


It should return that it is running. Then you can stop the process:
Code:
bash /PlexConnect/PlexConnect_daemon.bash stop


Part 2: Creating Boot Script

Initial Setup:

Creat the boot script

Code:
nano /etc/rc.d/plexconnect


copy and paste the following code and then save and close the file.

Code:
#!/bin/sh
#
#PROVIDE: PlexConnect
#REQUIRE: DAEMON
#KEYWORD: shutdown

. /etc/rc.subr

name=plexconnect
rcvar=plexconnect_enable

start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"
extra_commands="status"
PATH=/usr/local/bin:${PATH}

plexconnect_start()
{
/usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash start
}
plexconnect_stop()
{
/usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash stop
}

plexconnect_status()
{
/usr/local/bin/bash /PlexConnect/PlexConnect_daemon.bash status
}

load_rc_config $name
run_rc_command "$1"


NOTE: if you installed PlexConnect in a different directory change the directory to the bash script.

Next make sure the permissions are the same as the other scripts, run the following script:
Code:
chmod 0555 /etc/rc.d/plexconnect


Register the script:

Run the following command to open the rc.conf file:
Code:
nano /etc/rc.conf

and add the following line:
Code:
plexconnect_enable="Yes"

save and close the file.

Check that the script works:

so when you are in the root dir and you call:
Code:
/etc/rc.d/plexconnect start

and then calling:
Code:
/etc/rc.d/plexconnect status

and it returns:
Code:
PlexConnect is running

so great the script works.
Now just run:

Code:
/etc/rc.d/plexconnect stop

So we make sure plex is not running before we try to start it as a service.

Setup the plexconnect service:

FINALLY:

run the following command:
Code:
service plexconnect status


and it should return:
Code:
PlexConnect is not running


Okay great the service is now working. Thank god. Now just startup plexconnect:
Code:
service plexconnect start


So plexconnect is now running and it is a valid service. Yay.

You can then test if it is working by either rebooting your NAS or toggling the plugins on off switch.

FINAL NOTE:

Update: 2015-05-04 - Changed Boot script to now include the path parameter. Hence you no longer need to edit the bash script. (Thanks @mbaltaks)

Updated: 2015-05-04 - Added the native package manger install procedure for pillow. (also @mbaltaks)


--++00DONE00++--
 

Attachments

Last edited:

Pouper

Newbie
Joined
Jan 15, 2014
Messages
43
This was a great discussion over at the Plex forums so it's nice having it here.

Word of warning if you're on 9.2.1: install for FreeBSD packages seems to be broken. Looking into it further to see what's going on.

Great guide and thank you!
 

lanky8804

Newbie
Joined
Jan 12, 2014
Messages
24
As Pouper said jail packages broken!

Also what jail and options are best for PlexConnect?
 

fracai

FreeNAS Guru
Joined
Aug 22, 2012
Messages
1,205
Can you clarify a bit what this is actually for? I don't see a link to the original post on the Plex forums, so I think I'm missing some context.

Is aTV referring to AppleTV? Is this the hack that replaces the Trailers channel with Plex?
 

traxinv

Newbie
Joined
Feb 8, 2014
Messages
21
Can you clarify a bit what this is actually for? I don't see a link to the original post on the Plex forums, so I think I'm missing some context.

Is aTV referring to AppleTV? Is this the hack that replaces the Trailers channel with Plex?
Yes aTv refers to apple tv and yes it replaces the apple tv's trailer app with plex content.

The link to the original post is in the word <post>
 

fracai

FreeNAS Guru
Joined
Aug 22, 2012
Messages
1,205
Ah, not sure how I missed the link. Thanks.
 

traxinv

Newbie
Joined
Feb 8, 2014
Messages
21
This was a great discussion over at the Plex forums so it's nice having it here.

Word of warning if you're on 9.2.1: install for FreeBSD packages seems to be broken. Looking into it further to see what's going on.

Great guide and thank you!
I am on 9.2.1-Beta no problems with any packages? Might i be missing something?
 
Joined
Feb 26, 2014
Messages
1
Trying to do this but every time I make it to running "./PlexConnect.py" I get the error "env: python: No such file or directory"

I am on FreeNas 9.2.1.1. Is this something to do with the packages seeming to be broken as mentioned above? Everything seemed to install fine before that point.
 

lanky8804

Newbie
Joined
Jan 12, 2014
Messages
24
Just updated to freeNAS 9.2.1.2 previously always installed PlexConnect this way however now pkg_add not supported any chance you can update instructions for pkgng?

Have had a look around but can't figure out the commands i need to use.
 

traxinv

Newbie
Joined
Feb 8, 2014
Messages
21
Just updated to freeNAS 9.2.1.2 previously always installed PlexConnect this way however now pkg_add not supported any chance you can update instructions for pkgng?

Have had a look around but can't figure out the commands i need to use.
Will have a look when I update to the new freenas:)
 
Joined
Sep 13, 2013
Messages
7
Although I've installed PlexConnect I am trying now to install in on another server but when I execute ./PlexConnect.py I get "env: python: No such file or directory".

Any help on this please?
 
Joined
Apr 30, 2014
Messages
2
Hmm, I get to this stage and then something unexpected occurs:

Start PlexConnect so it creates Settings.cfg
Code (text):

./PlexConnect.py

root@plexmediaserver_1:/PlexConnect # ./PlexConnect.py env: python: No such file or directory
root@plexmediaserver_1:/PlexConnect # ls .git PlexConnect_daemon.bash .gitignore PlexConnect_daemon.py ATVSettings.py README.md DNSServer.py Settings.py Debug.py Subtitle.py License.txt Version.py Localize.py WebServer.py PlexAPI.py XMLConverter.py PlexConnect.py assets PlexConnect_WinService.py support root@plexmediaserver_1:/PlexConnect #

Running 9.1.2.5, but this is my first Python experience
 

traxinv

Newbie
Joined
Feb 8, 2014
Messages
21
Hmm, I get to this stage and then something unexpected occurs:

Start PlexConnect so it creates Settings.cfg
Code (text):

./PlexConnect.py

root@plexmediaserver_1:/PlexConnect # ./PlexConnect.py env: python: No such file or directory
root@plexmediaserver_1:/PlexConnect # ls .git PlexConnect_daemon.bash .gitignore PlexConnect_daemon.py ATVSettings.py README.md DNSServer.py Settings.py Debug.py Subtitle.py License.txt Version.py Localize.py WebServer.py PlexAPI.py XMLConverter.py PlexConnect.py assets PlexConnect_WinService.py support root@plexmediaserver_1:/PlexConnect #

Running 9.1.2.5, but this is my first Python experience
Try running pkg_add -r python before you try to run that command.
 

cyberjock

Moderator
Joined
Mar 25, 2012
Messages
19,148
I so can't wait for the old package system to go away... like 4 months or so now. Then all you old pkg_add users will be forced to use the new system.
 

traxinv

Newbie
Joined
Feb 8, 2014
Messages
21
I so can't wait for the old package system to go away... like 4 months or so now. Then all you old pkg_add users will be forced to use the new system.

am rewriting the guide for the new method. Just posted a quick fix :p
 
Joined
Apr 30, 2014
Messages
2
traxinv, I tried this and verified that python version 2.7 is running. Still, I get the same response trying to execute the PlexConnect.py script. BTW, inspecting the script more PlexConnect.py) shows a call to '#!/usr/bin/env python', but I am not sure that is where Python is actually located. From the webgui I use the Display System Processes it shows Python2.7 running. Shouldn't the Python script (I'm not programmer, mind you) be calling on python2.7, and not python?
 
Top