Ubuntu 15+, Debian 8+, Raspbian (Jessie), Arch (or based) Autostart

Prerequisites
This guide assumes you already have Plexmediaserver up and running and am familiar with how to set a static IP (Which is needed for running plexconnect)

Background Story
(New users (fresh install) skip straight to How to install)

I have been running Plexconnect as a service through sysvinit (/etc/init.d/) as explained in this post:

After each reboot i still had to restart the service.

This is because now (After 15.x) Ubuntu uses systemd, naturally Plex Media Server now comes with a unit file (systemd) . So what we need now is a systemd unit file for plexconnect. Ill follow most of the old steps as i have no intention of reinventing the wheel.

It’s also worth mentioning if you have your init.d script running without any issues, you dont need to follow this guide.

Removing the old sysvinit script (/etc/init.d/plexconnect)
(If you never followed the old guide you obviously dont have to do this)

Stop the server:

sudo service plexconnect stop

Backup your current script in case our new unit file does not work for you!

sudo mv /etc/init.d/plexconnect /etc/init.d/plexconnect.bak

Remove the script from rc.d

sudo update-rc.d plexconnect remove

Now you are ready to proceed.

If for some reason our new unit file does not work, you can revert to init.d:

sudo mv /etc/init.d/plexconnect.bak /etc/init.d/plexconnect
sudo update-rc.d plexconnect defaults

How to Install

Part 1

If you have installed plexconnect in the directories specified bellow (/opt/PlexConnect) and it’s up and running/working skip straight to step 2.

Full installation documentation can be found here:

We start by downloading Plexconnect, moving it to a more suitable location, adding some sql keys & certificates for the appletv and then moving the certificates. Do this commands one at a time (Trippel click on each line and copy) .

wget https://github.com/iBaa/PlexConnect/archive/master.zip
unzip master.zip
sudo mv PlexConnect-master/ /opt/PlexConnect
openssl req -new -nodes -newkey rsa:2048 -out ./trailers.pem -keyout ./trailers.key -x509 -days 7300 -subj "/C=US/CN=trailers.apple.com"
openssl x509 -in ./trailers.pem -outform der -out ./trailers.cer && cat ./trailers.key >> ./trailers.pem
mv trailers.* /opt/PlexConnect/assets/certificates/

Part2

Now we are going to make the unit file for the startup process:
(If you have installed Plexconnect somewhere else than “/opt/PlexConnect” you need to replace this path with yours in every step its mentioned)

sudo nano /etc/systemd/system/plexconnect.service

Paste the following: (Look under for Arch)

[Unit]
Description=Plexconnect
After=plexmediaserver.service

[Service]
Type=simple
ExecStart=/usr/bin/python /opt/PlexConnect/PlexConnect.py
User=root
Group=root
Restart=on-failure
RestartSec=15
StartLimitInterval=10s
StartLimitBurst=3


[Install]
WantedBy=multi-user.target

For Arch (or based)

[Unit]
Description=Plexconnect
After=plexmediaserver.service

[Service]
Type=simple
ExecStart=/usr/bin/python2.7 /opt/PlexConnect/PlexConnect.py
User=root
Group=root
Restart=on-failure
RestartSec=15
StartLimitInterval=10s
StartLimitBurst=3


[Install]
WantedBy=multi-user.target

Exit and save with: “Ctrl-x, Y, Enter”

Now we should set the right permissions for our unit file:

 sudo chmod 644 /etc/systemd/system/plexconnect.service

Now we update systemd: (Not so sure this is needed any more but doesn’t hurt)

 sudo systemctl daemon-reload

Start at boot:

sudo systemctl enable plexconnect.service

Now our service is ready and we can start it with:

sudo systemctl start plexconnect.service

You can check your service status with:

sudo systemctl status plexconnect.service

Finally, how to setup your apple-tv:

Sources:




https://wiki.ubuntu.com/SystemdForUpstartUsers

Hi… thanks a lot for this… have been trying to get this done for quite sometime now. i tried the solution outlined by you. however once i restart the system and type in ‘sudo service plexconnect status’, here is what i get -
● plexconnect.service - Plexconnect
Loaded: loaded (/etc/systemd/system/plexconnect.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since Sun 2016-06-12 16:58:03 IST; 1min 48s ago
Process: 1537 ExecStart=/usr/bin/python /usr/local/lib/PlexConnect/PlexConnect.py (code=exited, status=1/FAILURE)
Main PID: 1537 (code=exited, status=1/FAILURE)

Jun 12 16:57:58 ubuntu systemd[1]: plexconnect.service: Main process exited, code=exited, status=1/FAILURE
Jun 12 16:57:58 ubuntu systemd[1]: plexconnect.service: Unit entered failed state.
Jun 12 16:57:58 ubuntu systemd[1]: plexconnect.service: Failed with result ‘exit-code’.
Jun 12 16:58:03 ubuntu systemd[1]: plexconnect.service: Service hold-off time over, scheduling restart.
Jun 12 16:58:03 ubuntu systemd[1]: Stopped Plexconnect.
Jun 12 16:58:03 ubuntu systemd[1]: plexconnect.service: Start request repeated too quickly.
Jun 12 16:58:03 ubuntu systemd[1]: Failed to start Plexconnect.

can you help?

Sorry for the late reply.

Have you tried running it manually =

python /usr/local/lib/PlexConnect/PlexConnect.py

Also try:

python --version

Drop your distro name as well :wink:

I’ve made some changes to the init file making it restart properly if it does not start at boot.
You should implement them if you run this init file. (Just paste the initfile again).

I also changed the directory to /opt/PlexConnect at some point, make sure you add the right path to your plexconnect in the init file

Added arch description.