PlexConnect RPM for Linux (RedHat/CentOS)

I've put together a RPM for PlexConnect, which I hope some of you can use!

The package includes:

  • PlexConnect configuration file for dnsmasq
  • PlexConnect configuration file for httpd
  • PlexConnect configuration file for nginx
  • PlexConnect init script
  • PlexConnect log rotation (high output)
  • PlexConnect sysconfig configuration file
  • PlexConnect spec file
  • Certificates for trailers.apple.com
  • Certificates for secure.marketwatch.com
  • A modified Settings.cfg
The latest update to this package: 07/08/2016

https://github.com/linuxhq/rpmbuild-plexconnect


Hi tkimball83... can you point me in the direction on a step by step to get this RPM set up on CentOS?  

I don't currently have one.  Let me see what I can put together for you!

I used this package last night and it seemed to work great, thanks tkimball83!

For others that aren't familiar with how to do all this (I struggled a bit), here's some rough instructions from what I can remember (FAIR WARNING: Probably not entirely accurate as I'm doing this from memory, but should hopefully get you close):

1) On your server, in your home directory, execute: git clone https://github.com/tkimball83/plexconnect.git

2) Install the necessary rpm-building tools:  yum install rpm-build rpmdevtools

3) Create the file ~/.rpmmacros with contents like so (modify /root/plexconnect to the location you git cloned to):

%packager MYNAME
%_topdir /root/plexconnect
%_tmppath /root/plexconnect/tmp

4) Run: rpmbuild -ba plexconnect/SPECS/plexconnect.spec

5) To install: rpm -ivh plexconnect/RPMS/noarch/plexconnect-0.3-2.el6.noarch.rpm

You'll likely want to do the following files after the install:

Configure plexconnect:

Modify /var/lib/plexconnect/Settings.cfg (configure the port_webserver to the desired port to listen on and verify ip_pms and port_pms are correct for your setup)

Modify /etc/sysconfig/plexconnect (configure the appropriate user you will be running the service as, and possibly the python invocation - see NOTE below about python27)

Setup dnsmasq:

Modify /etc/dnsmasq.conf (make sure the conf-dir=/etc/dnsmasq.d line is uncommented)

Modify /etc/dnsmasq.d/plexconnect.conf (change x.x.x.x with your server's IP address)

Restart dnsmasq (/etc/init.d/dnsmasq restart) and possibly make sure it starts at system startup (chckconfig dnsmasq on)

Setup apache:

Modify /etc/httpd/conf.d/plexconnect.conf (Configure for the appopriate port you have plexconnect listening on if it's not 8080)

Restart apache (/etc/init.d/httpd restart)

Start plexconnect (/etc/init.d/plexconnect start) and possibly make sure it starts at system startup (chkconfig plexconnect on)

Important note: Centos6 does NOT come with python version 2.7 standard, and this is required for plexconnect to run.  I'd recommend using the SCLs (http://dev.centos.org/centos/6/SCL/docs/) to do this:

1) Execute: yum install centos-release-SCL

2) Execute: yum install python27

3) To enable the SCL python 27 environment when plexconnect starts, modify /etc/sysconfig/plexconnect and put this line at the top:

. /opt/rh/python27/enable

and this line at the bottom:

PLEXCONNECT_PYTHON=python

Try restarting plexconnect after doing all this and hopefully it runs (/etc/init.d/plexconnect restart)

Logs go to /var/log/plexconnect for debugging.

If everything seems to work, resume the plexconnect setup instructions to setup your AppleTv.

I used this package last night and it seemed to work great, thanks tkimball83!

For others that aren't familiar with how to do all this (I struggled a bit), here's some rough instructions from what I can remember (FAIR WARNING: Probably not entirely accurate as I'm doing this from memory, but should hopefully get you close):

1) On your server, in your home directory, execute: git clone https://github.com/tkimball83/plexconnect.git

2) Install the necessary rpm-building tools:  yum install rpm-build rpmdevtools

3) Run: rpm-build -ba plexconnect/SPECS/plexconnect.spec

4) To install: rpm -ivh plexconnect/RPMS/noarch/plexconnect-0.3-2.el6.noarch.rpm

You'll likely want to do the following files after the install:

Configure plexconnect:

Modify /var/lib/plexconnect/Settings.cfg (configure the port_webserver to the desired port to listen on and verify ip_pms and port_pms are correct for your setup)

Modify /etc/sysconfig/plexconnect (configure the appropriate user you will be running the service as, and possibly the python invocation - see NOTE below about python27)

Setup dnsmasq:

Modify /etc/dnsmasq.conf (make sure the conf-dir=/etc/dnsmasq.d line is uncommented)

Modify /etc/dnsmasq.d/plexconnect.conf (change x.x.x.x with your server's IP address)

Restart dnsmasq (/etc/init.d/dnsmasq restart) and possibly make sure it starts at system startup (chckconfig dnsmasq on)

Setup apache:

Modify /etc/httpd/conf.d/plexconnect.conf (Configure for the appopriate port you have plexconnect listening on if it's not 8080)

Restart apache (/etc/init.d/httpd restart)

Start plexconnect (/etc/init.d/plexconnect start) and possibly make sure it starts at system startup (chkconfig plexconnect on)

Important note: Centos6 does NOT come with python version 2.7 standard, and this is required for plexconnect to run.  I'd recommend using the SCLs (http://dev.centos.org/centos/6/SCL/docs/) to do this:

1) Execute: yum install centos-release-SCL

2) Execute: yum install python27

3) To enable the SCL python 27 environment when plexconnect starts, modify /etc/sysconfig/plexconnect and put this line at the top:

. /opt/rh/python27/enable

and this line at the bottom:

PLEXCONNECT_PYTHON=python

Try restarting plexconnect after doing all this and hopefully it runs (/etc/init.d/plexconnect restart)

Logs go to /var/log/plexconnect for debugging.

If everything seems to work, resume the plexconnect setup instructions to setup your AppleTv.

Great doc, well done!

I just wanted to note that I use the IUS Community python 2.7 package, which can be found here: https://iuscommunity.org/pages/Repos.html#

Using this package should eliminate the modifications steps for /etc/sysconfig/plexconnect

If you don't mind, I may summarize your steps and put them on github, thoughts?

Feel free, just keep in mind I'm not sure it's entirely 100% accurate, but probably better than nothing (feel free to fix up any issues you identify).

By the way, I noticed you were using some of the theming that was discussed here.  Do you have a strategy for supporting the various forks via your package here, or do you just install them in different locations (or maybe over the top of)?  Just curious.

This worked for me on Centos 7.

The only trouble was an 503 error, which could be resolved by allowing Apache:

setsebool -P httpd_can_network_connect on

SELinux. :rolleyes:

Also, I get an dep error, saying I don't have python27. However, python 2.7 is installed. After forcing yum to install, it worked (not very graceful solution).

Also, I get an dep error, saying I don't have python27. However, python 2.7 is installed. After forcing yum to install, it worked (not very graceful solution).

How did you go about installing python 2.7, source, or via rpm?

By the way, I noticed you were using some of the theming that was discussed here.  Do you have a strategy for supporting the various forks via your package here, or do you just install them in different locations (or maybe over the top of)?  Just curious.

No plans at the moment, but you could change the sources and git commit to pull down their forks.

Feel free, just keep in mind I'm not sure it's entirely 100% accurate, but probably better than nothing (feel free to fix up any issues you identify).

Added some documentation to github, but left out your python27 installation portion as I included the repository that I used for my installation.  If you could try another build using my step by step documentation and provide feedback, that would be great!

Thanks!

How did you go about installing python 2.7, source, or via rpm?

Not from source. It's included in the standard Centos 7 repository (non third party). I assume it was installed automatically as a dependency for some program.

rpm -qi python.x86_64
 

Name        : python
Version     : 2.7.5
Release     : 16.el7
Architecture: x86_64
Install Date: Tue 19 Aug 2014 11:56:44 PM CEST
..
Source RPM  : python-2.7.5-16.el7.src.rpm
Build Date  : Tue 17 Jun 2014 08:43:58 PM CEST
Build Host  : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
..
 

Not from source. It's included in the standard Centos 7 repository (non third party). I assume it was installed automatically as a dependency for some program.

rpm -qi python.x86_64
 

I've updated the spec file to support the python difference in CentOS 7.x.  Please attempt another build and provide feedback.  Thanks!

Thank you for the changes and the detailed how-to. I can clone and rebuild fine. Since it's already installed, how would I test the next step?

Thank you for the changes and the detailed how-to. I can clone and rebuild fine. Since it's already installed, how would I test the next step?

If I'm understanding you correctly, you'll want to remove the the package

rpm -e plexconnect

And then continue down the doc with installing the new package as the first step

Some unexpected behavior:

When I stop PlexConnect (with systemctl or service), the Firewalld and some other services are also stopped . I'm not sure how this happens, but it is reproducible. This could be a problem with PlexConnect and Centos.

Apparently, all python processes are killed, perhaps due to this in "/etc/rc.d/init.d/plexconnect":

PLEXCONNECT_PYTHON=/usr/bin/python
..
killproc ${PLEXCONNECT_PYTHON}

Apparently, all python processes are killed, perhaps due to this in "/etc/rc.d/init.d/plexconnect":

PLEXCONNECT_PYTHON=/usr/bin/python
..
killproc ${PLEXCONNECT_PYTHON}

Please pull down the latest commit and try a rebuild.  This change set should fix your issue.

Hi tkimball83,

This rebuild seemed to fixed the problem. Many thanks for the quick responce.

PS.

To build the rpm I did not rename the plexconnect folder (skipped mv plexconnect rpmbuild ); it would not work otherwise for me.

cd $HOME
git clone https://github.com/tkimball83/plexconnect.git
mv plexconnect rpmbuild
cd rpmbuild/SPECS
rpmbuild -ba plexconnect.spec