Install on Ubuntu Server

I am new to Plex, Plex Connect, and Ubuntu. So, this may be a newb question, but how do I install Plex Connect on Ubuntu Server? Sorry, if this is a dumb question, but, I have looked all over and can't find anything that says it can be done. Please help!

https://github.com/iBaa/PlexConnect/wiki/Install-Guide-Linux ?

Installation instructions are found here:
https://github.com/iBaa/PlexConnect/wiki/Install-Guide-Linux
But they are more geared towards those with a desktop distro.

wget https://github.com/iBaa/PlexConnect/archive/master.zip
unzip master.zip
sudo mv PlexConnect-master/ /usr/local/lib/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.* /usr/local/lib/PlexConnect/assets/certificates/

After that you can run plexconnect manually with

sudo /usr/local/lib/PlexConnect/PlexConnect.py

If you want plexconnect to start automatically you need to create a startup script.
Run

sudo nano /etc/init.d/plexconnect

and input this into the file

#!/bin/bash
### BEGIN INIT INFO
# Provides:          plexconnect
# Required-Start:    plexmediaserver networking
# Required-Stop:     plexmediaserver networking
# Default-Start:     3 4 5
# Default-Stop:      0 1 6
# Short-Description: This is the Plex Connect daemon
# Description:       This script starts the Plex Connect
#                    Python scripts in a detached screen.
### END INIT INFO

Using the lsb functions to perform the operations.

. /lib/lsb/init-functions

Process name ( For display )

NAME=PlexConnect

Daemon name, where is the actual executable

DAEMON="/usr/bin/screen"
DAEMON_OPTS="-S PlexConnect -d -m /usr/local/lib/PlexConnect/PlexConnect.py"
DAEMON_USER=“root”

pid file for the daemon

PIDFILE=/var/run/PlexConnect.pid

If the daemon is not there, then exit.

test -x “$DAEMON” || exit 5

case $1 in
start)

Checked the PID file exists and check the actual status of process

if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE “$DAEMON $DAEMON_OPTS” “$NAME process” && status=“0” || status="$?"

If the status is SUCCESS then don’t need to start again.

if [ $? = “0” ]; then
log_success_msg “Starting the process $NAME”
exit # Exit
fi
fi

Start the daemon.

Start the daemon with the help of start-stop-daemon

Log the message appropriately

if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --startas $DAEMON -p $PIDFILE – ${DAEMON_OPTS}; then
while read line ; do [[ $line =~ ([0-9]*).PlexConnect ]] && echo ${BASH_REMATCH[1]} ; done < <(screen -ls) > $PIDFILE
log_success_msg “Starting the process $NAME”
else
log_failure_msg “Starting the process $NAME”
fi
;;
stop)

Stop the daemon.

if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE “$DAEMON DAEMON_OPTS” “Stoppping the $NAME process” && status=“0” || status="$?"
if [ “$?” = 0 ]; then
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
/bin/rm -rf $PIDFILE
log_success_msg ““Stopping the $NAME process””
fi
else
log_failure_msg “$NAME process is not running”
fi
;;
restart)

Restart the daemon.

$0 stop && sleep 2 && $0 start
;;
status)

Check the status of the process.

if [ -e $PIDFILE ]; then
status_of_proc -p $PIDFILE “$DAEMON $DAEMON_OPTS” “$NAME process” && exit 0 || exit $?
log_success_msg “$NAME process is running”
else
log_failure_msg “$NAME process is not running”
fi
;;
reload)
$0 restart
;;
*)

For invalid arguments, print the usage message.

echo “Usage: $0 {start|stop|restart|reload|status}”
exit 2
;;
esac

(Script taken from this post.)
 
After that run



sudo apt-get -y install screen
sudo chown root:root /etc/init.d/plexconnect
sudo chmod 755 /etc/init.d/plexconnect
sudo update-rc.d plexconnect defaults
sudo service plexconnect start

Done.
Go and setup your appletv.
https://github.com/iBaa/PlexConnect/wiki/Install-Guide

First off, thanks for your help, it worked 99% flawlessly. The only issue I have is this:

When I type:

sudo update-rd.d plexconnect defaults
I get:
insserv: Service plexmediaserver has to be enabled to start service plexconnect
insserv: exiting now!
update-rc.d: error: insserv rejected the script header
PMS IS running, I have tried stopping it and restarting it. Any suggestions or thoughts what I may be doing wrong?

First off, thanks for your help, it worked 99% flawlessly. The only issue I have is this:
When I type:

sudo update-rd.d plexconnect defaults
I get:
insserv: Service plexmediaserver has to be enabled to start service plexconnect
insserv: exiting now!
update-rc.d: error: insserv rejected the script header
PMS IS running, I have tried stopping it and restarting it. Any suggestions or thoughts what I may be doing wrong?

Strange. It did work fine for me.

You could try editing the /etc/init.d/plexconnect file and change

# Required-Start:    plexmediaserver networking
# Required-Stop:     plexmediaserver networking

to

# Required-Start:    networking
# Required-Stop:     networking

I highly suggest that this guide be renamed and sticked to “Install as a service in Ubuntu”.

Following the last post this works perfectly on 15.10 as well.

I wish i knew about this a long time ago, this is genius…

Does anyone else have a problem with a reboot? My plexconnect then starts as:

Active (exited)

After a restart its back to:

Avtice (Running)

@AltonV said:

Strange. It did work fine for me.

You could try editing the /etc/init.d/plexconnect file and change

Required-Start:    plexmediaserver networking

Required-Stop:    plexmediaserver networking

to

Required-Start:    networking

Required-Stop:    networking

It worked with this edit for me! Didn’t work before. Thanks for the script!

@tommyprevatt said:

@AltonV said:

Strange. It did work fine for me.

You could try editing the /etc/init.d/plexconnect file and change

Required-Start:    plexmediaserver networking

Required-Stop:    plexmediaserver networking

to

Required-Start:    networking

Required-Stop:    networking

It worked with this edit for me! Didn’t work before. Thanks for the script!

I take that back, after reboot it does not start…

Isn’t there just some way to make linux run “./usr/local/lib/PlexConnect_daemon.bash start” upon boot??
Because that command works every time…

@tommyprevatt said:

@tommyprevatt said:

@AltonV said:

Strange. It did work fine for me.

You could try editing the /etc/init.d/plexconnect file and change

Required-Start:    plexmediaserver networking

Required-Stop:    plexmediaserver networking

to

Required-Start:    networking

Required-Stop:    networking

It worked with this edit for me! Didn’t work before. Thanks for the script!

I take that back, after reboot it does not start…

Isn’t there just some way to make linux run “./usr/local/lib/PlexConnect_daemon.bash start” upon boot??
Because that command works every time…

You could use cron.

Run “crontab -e” and it will open a file in your prefered editor.
Add the line “@reboot ./usr/local/lib/PlexConnect_daemon.bash start” without the quotes.

Take a look here: