Jump to content


Photo

Linux install for Plex Connect

PlexConnect Plex Connect install linux init script

70 replies to this topic

#1 wilsoncd2

wilsoncd2

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 June 2013 - 12:44 AM

Hi All,

I thought I would share this for anyone else who may need it.

I am running a Scientific Linux 6.1 server and have both Plex Media Server and Plex Connect running on it quite happily. I have to change the Python WebServer.py script to use a different port as I already have Apache running other services on port 80, e.g. website, repos, etc. I also wanted to start and stop the Plex Connect services as a normal daemon so that it started up and shutdown automatically and kept running if I logged out of the server etc. Here's how I did it.

EDIT: This method does reply upon using the application 'screen' and is therefore a little more complicated than other solutions, but the tradeoff is that it does not require any code changes in a default installation of Plex Connect. This was one of the key requirements of this method so that upgrades would be simpler as you do not need to re-implement the code changes for every release you install. I chose to use screen as it is a commonly used application that has been around for quite a long time and is a mature and stable application that does what I needed to get PlexConnect running as a daemon / service.

EDIT: With some help from others on the forum I have also included instructions for Ubuntu users.

 

Prerequisites: Python 2.x series with being the 2.7 minimum version (Python 3.x is not supported)


Step 1. Install the Plex Connect scripts

Download and extract the Plex Connect Python Scripts into /usr/local/lib/plexconnect. Or use git to sync the files to your server if you prefer.

Do the usual modifications to Settings.cfg after running PlexConnect.py manually for the first time. In my case I modified the the IP of my PMS server, left the PMS port as it was correct for my installation of Plex Media Server and also left the DNS master settings to point to Google's DNS (8.8.8.8) as I was already using Google's DNS anyway and modified the Web Server port to listen on port 8080 in the Settings.cfg file.

Step 2. Some Optional Modifications WebServer.py and PlexConnect.py

Change Plex Connect Web Server Listening Port

EDIT: If you are not running a version of Plex Connect that allows you to configure the Web Server port in Settings.cfg and you need to run the Plex  Connect Web Server on a port other than port 80 then this is relevant for you. But it is probably better to use a more up-to-date release of Plex Connect so that you don't need to modify any code.

 

To change the webserver to listen port to run on a different port, modify WebServer.py as shown below. I changed mine to run on port 8080 as I have repositories and other services running in Apache on port 80.

 

def Run(cmdQueue, param):
    #Protocol     = "HTTP/1.0"
    # todo: IP, port
    try:
        server = HTTPServer(('',8080), MyHandler)
        server.timeout = 1
        sa = server.socket.getsockname()
    except Exception, e:
        dprint(__name__, 0, "Failed to connect to port 8080 (http): {0}", e)
        sys.exit(1)

Modify user-agent Testing in WebServer.py
This is purely optional, I only did this to make it easier to test the installation was working through using a desktop browser. I reduced the user-agent testing in WebServer.py with this modification that I picked up from the forums (sorry I don't remember who originally posted it and couldn't find it again to link here). Once your installation is working you should not need this modification and it is nice to modify as little as possible from the distributed scripts as there is less to remember to change when you do an upgrade. So feel free to skip this step and only come back to it if you are having problems and need to test the installation by connecting directly to the Plex Connect web server with your desktop browser to see the XML output and confirm it is working as intended.


# Comment out original code
#            if self.headers['Host'] == Settings.getHostToIntercept() and \
#               self.headers['User-Agent'].startswith("iTunes-AppleTV"):
# Add the new code below
            if self.headers['User-Agent'].startswith(""):

Modify the log file path in PlexConnect.py
This is a purely optional change that you can make if you want to change the log file path and/or name. If it doesn't concern you then skip this.

I modified PlexConnect.py to make the log go to /var/log/PlexConnect.log because that's where I want my logs for all applications to go so I can manage them in one place using standard utilities such as logrotate etc. To do this make the changers below to PlexConnect.py

if __name__=="__main__":
    param = {}
    #param['LogFile'] = sys.path[0] + sep + 'PlexConnect.log'
    param['LogFile'] = '/var/log/PlexConnect.log'
    dinit('PlexConnect', param, True)  # init logging, new file, main process


Step 3. Create an Apache Vhost

You should skip this step if you are just running the Plex Connect Script purely as shipped (listening on port 80) as it is not relevant for you. This step just makes Apache act as a proxy to accept connections on port 80 and send them to another port and/or host. For example if you are running Plex Connect's web server on a port other than port 80 this will allow your apple TV to connect to it by allowing Apache to accept the connection from the Apple TV on Port 80 and then connecting it to the host and port that you installed the Plex Connect web server on (i.e. Step 2 above).

I had to to add an Apache Name Based Virtual as I can't run PlexConnect on port 80 and therefore I need Apache to proxy connections to trailers.apple.com (on port 80) through to Plex Connect on port 8080 (see step 2 above). This allows Apache to continue hosting my other services and applications on port 80. This does rely on the mod_proxy modules being loaded into Apache. In my case they were already loaded as part of the default install so there was nothing for me to do. But if you have problems with this, refer to the Apache documentation for your Apache release.

Here is an extract of my configuration file (I called mine vhosts.conf) from /etc/httpd/conf.d. You need to modify the "your.server.name", "your.server.name.or.ip", and "your.server.alternate.names" to match your system. In the ProxyPass directives you will see that they point to port 8080. If you changed the port to something other than port 8080 in step 2, then these entries must also be updated to point to the correct port. The important entry is the second VirtualHost as it is the one that will accept the Plex Connect connect's from the redirected calls to trailers.apple.com. The first VirtualHost entry is just a blank one for any other sites you need. You can have multiple's of these as long as you do not re-use names in the ServerName and ServerAlias directives.


 

NameVirtualHost *:80

<VirtualHost *:80>
    # This is the default VHost
    ServerName your.server.name
    ServerAlias your.server.alternate.names
    DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
    # This is the VHost for Plex Connect
    ServerName trailers.apple.com
    ProxyRequests Off
    ProxyPreserveHost On

    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>

    ProxyPass / http://your.server.name.or.ip:8080/
    ProxyPassReverse / http://your.server.name.or.ip:8080/
</VirtualHost>

EDIT: If you are running SELinux in enforcing mode, you will need to ensure that Apache is allowed to make network connections in order for the proxy directives to make Apache connect to Plex Connect. I did this by setting the httpd_can_network_connect flag in SELinux. Here is the command I used.

setsebool -P httpd_can_network_connect=1

 

 

Step 4. Add a init / startup script


Added an init script to start and stop the Plex Connect services as a proper daemon/service.

Note: To do this I used the 'screen' application. If you don't have screen, install it using yum (or it's equivalent on other distributions, e.g. apt-get)

yum install screen

EDIT: RHEL based Linux Distributions
Below is my init script, though I actually pulled out the variables in the top of the script and put them in a file /etc/sysconfig/plexconnect but for simplicity I added it all back to this one script for you. This script is saved as /etc/init.d/plexconnect.

#!/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
   pidofproc -p $PIDFILE > /dev/null 2>&1
   # 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_daemon -u $DAEMON_USER -p $PIDFILE $DAEMON $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
   pidofproc -p $PIDFILE > /dev/null 2>&1
   if [ "$?" = 0 ]; then
    killproc -p $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
   pidofproc -p $PIDFILE > /dev/null 2>&1
   if [ "$?" = 0 ]; then
    log_failure_msg "$NAME PID file exists, but the process dead"
    killproc -p $PIDFILE
    /bin/rm -rf $PIDFILE
   else
    log_success_msg "$NAME process is running"
   fi
  else
   log_failure_msg "$NAME process is not running" #log_end_msg 0
  fi
  ;;
 reload)
  $0 restart
  ;;
 *)
  # For invalid arguments, print the usage message. echo "Usage: $0 {start|stop|restart|reload|status}"
  exit 2
 ;;
esac


Now you need to make sure the script has the correct permissions and add it script as a service / daemon so that it starts automatically. Then start the daemon. To do this, make sure the permissions are correct and use chkconfig. If you are using the root user you do not need the 'sudo' command at the front of the commands below.

sudo chown root:root  /etc/init.d/plexconnect
sudo chmod 755  /etc/init.d/plexconnect
sudo /sbin/chkconfig --add /etc/init.d/plexconnect
sudo /sbin/service plexconnect start

EDIT: Ubuntu based servers

Thanks to @ReneV for testing and modifying the script to work on Ubuntu.

Below is the init script. This script is saved as /etc/init.d/plexconnect.

#!/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


Now you need to make sure the script has the correct permissions and add it script as a service / daemon so that it starts automatically. Then start the daemon. To do this, make sure the permissions are correct and use update-rc.d. If you are using the root user you do not need the 'sudo' command at the front of the commands below.

sudo chown root:root  /etc/init.d/plexconnect
sudo chmod 755  /etc/init.d/plexconnect
sudo update-rc.d plexconnect defaults
sudo /sbin/service plexconnect start

Step 5. Change Your Apple TVs DNS Configuration

In each Apple TV that you want to use Plex Conenct with you need to go into the Settings->General->Networking and then modify your existing network connection to manually configure a DNS server. Enter the IP address of your server that is running the Plex Connect scripts above for the DNS server.

If all this has worked for you then when you open the trailers app on your reconfigured Apple TV you should now see Plex Connect with your Plex Media Server's content.



I have three non-jailbroken Apple TVs that are all working simultaneously without issues that I have noticed. Two of these are Gen 3 1080p Apple TVs and the third is a Gen 2 720p Apple TV. All the Apple TVs are running the latest Apple iOS firmware.

Hopefully this is useful for people and saves time in working out how to get Plex Connect running on Linux. The hardest part for me was working out how to run the PlexConnect.py script as a daemon due to the way it is written to remain open in the shell and stop all the processes again upon a key press. This was not great for running a daemon process as the script dies as soon as it is detached from a console (i.e. nohup). Though it works fine if you want to manually start and stop the processes yourself. Using screen worked well for me, though I daresay there are a bunch of smarter people than I who have worked out better ways to do this.



#2 wilsoncd2

wilsoncd2

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 June 2013 - 03:58 AM

One other change that I forgot to mention is that I modified PlexConnect.py to make the log go to /var/log/PlexConnect.log because that's where I want my logs for all applications to go consistently so I can manage them using standard utilities such as logrotate etc. It would be really good if this was configurable option in the Settings or even in the command line arguments. It would be even better if the logs rotated, e.g. based on file size or date. I could always use a cron to stop the Plex Connect services, move/rename the existing log file and start the services again if the log file becomes a problem. Here is what I did.

if __name__=="__main__":
    param = {}
    #param['LogFile'] = sys.path[0] + sep + 'PlexConnect.log'
    param['LogFile'] = '/var/log/PlexConnect.log'
    dinit('PlexConnect', param, True)  # init logging, new file, main process

 

Oh ... I didn't say it above, but thanks so much to the guys for coming up with Plex Connect, I have been waiting for a solution like this for a long time. It works really well and allows me to reap the benefits of the latest iOS as well as Plex.



#3 f00b4r

f00b4r

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2699 posts

Posted 14 June 2013 - 12:07 PM

Nice guide but you should now be making changes to settings.cfg (generated on first run) rather than settings.py.
:)

Plex @ aTV - think different: PlexConnect

-> the missing link between Plex Media Server and your AppleTV - 2 or 3, jailbroken or not.

How to report an issue: click here

Sources: click here

Wiki: click here

 


#4 wilsoncd2

wilsoncd2

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 June 2013 - 01:22 PM

Nice guide but you should now be making changes to settings.cfg (generated on first run) rather than settings.py.
:)

 

@f00b4r I modified the post accordingly an also added in the information from my second post. I actually did this on the older Plex Connect code originally so Settings.py was correct for that release. But I just re-did it with a newer release and saw what you meant about settings.cfg. Let me know if you suggest any other changes.



#5 wilsoncd2

wilsoncd2

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 June 2013 - 01:59 PM

I figured that if I was going to make suggestions then I should also provide more information about them. My suggestion are;

 

Suggestion 1: Make the PlexConnect.py more friendly to run as a daemon. Here is one possible way that I can see it being done.

 

To run as a nicer daemon process without using the screen application (as per my script above) involves more code changes in the PlexConnect.py script (which I was trying to avoid). Currently the PlexConnect.py script is dependant upon having a console. As soon as you try to run it headless as you would normally do for a daemon or even using nohup and other similar common methods the script dies.

 

Tracing this through the Python it seems to stem from an open read from the console after startup, i.e. if you detach the console the read in the script throws an exception and dies (and the script stops the Plex Connect services and exits). Actually it was this post that first gave me the idea about what to look for. This read ('raw_input()') ties the app to the console in the way I mentioned above. This is what I am talking about in PlexConnect.py;

try:
        key = raw_input()
    except KeyboardInterrupt:
        dprint('PlexConnect', 0, "^C received.")


    finally:
        dprint('PlexConnect', 0,  "Shutting down.")
        cmd_DNSServer.put('shutdown')
        cmd_WebServer.put('shutdown')


        p_DNSServer.join()
        p_WebServer.join() 

 

 

The raw_input() function appears to be the culprit. If you take the code above out then you can execute PlexConnect.py directly to start the daemon and run it headless. The daemon can then store the PID in a pidfile, which is a normal practice for daemons, and executes a kill command on the PID when stopping the daemon. As the PID is the parent process all child processes will also be killed with it. If PlexConnect needs to do anything to shutdown more gracefully than this, then it can trap the system interrupt for a kill in PlexConnect.py and do the graceful shutdown in the trap. If you were unsure about it  or wanted to minimise the changes to the user experience then you could always put in a command-line argument (e.g. -d, -D, --daemon, or all of these, etc) that does this but runs the scripts in the normal interactive way if the argument is not present in the startup command-line.

 

This would avoid the need for the clumsy (and ugly) workaround using the screen application. Screen is only needed so that the application can be started in a console and then the console itself is detached so that it keeps running in the background regardless of what the user does. For this usage it is effectively a nohup for an entire console that just happens to be running PlexConnect.py. It works, but it is an ugly solution.

 

Suggestion 2: It would also be really nice to make the log file configurable so that people like me don't need to make code changes to make the Scripts log into the normal locations for daemons etc.

 

Suggestion 3: Implement log rotation based on date and/or size. This makes it easier to manage the logs on the server, but is probably just a nice to have for now.

 

Suggestion 4: Make the web server listening port configurable so that people like me don't need to make code changes to make the Web Server run on alternative ports when it is absolutely needed and we understand about the need for a proxy on port 80.

 

Suggestion 5: It would also be nice to be able to pass in the configurable elements in Settings.cfg by command-line arguments to override the Settings.cfg file. When there become too many configurable items, this would become impractical, but for the few arguments it has now, it would be useful. This is especially useful when doing upgrades as the config can be kept separate from the rest of the application package that is downloaded (ie. we pass it to the PlexConnect.py script via the daemon/service script).



#6 f00b4r

f00b4r

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2699 posts

Posted 14 June 2013 - 02:44 PM

Some very thoughtful suggestions.
What happens if the daemon process crashes, does it automatically recover?

Plex @ aTV - think different: PlexConnect

-> the missing link between Plex Media Server and your AppleTV - 2 or 3, jailbroken or not.

How to report an issue: click here

Sources: click here

Wiki: click here

 


#7 wilsoncd2

wilsoncd2

    Member

  • Members
  • PipPip
  • 13 posts

Posted 14 June 2013 - 04:46 PM

Some very thoughtful suggestions.
What happens if the daemon process crashes, does it automatically recover?

 

If PlexConnect.py itself died, then the daemon would not recover. The sub-services for the Web Server and DNS etc are under the control of PlexConnect.py so their ability to recover depends on PlexConnect.py. This is actually pretty common behaviour for many daemons. 



#8 leonsio

leonsio

    Member

  • Members
  • PipPip
  • 77 posts

Posted 23 June 2013 - 06:12 PM

if you want to run PlexConnect with user rights, you can allow this script to run with low-level port by this command

 

setcap 'cap_net_bind_service=+ep'  /usr/lib/PlexConnect/PlexConnect.py

 

the just change the user in the start/stop script



#9 crowfan

crowfan

    Member

  • Members
  • PipPip
  • 29 posts

Posted 29 June 2013 - 03:32 PM

Hi all, 

 

I have a Linux server in my house -- it's Fedora 14 running Amahi Home Server. It has both a DNS server and web server, so I can't use ports 53 or 80 for PlexConnect.

 

I took a look at the guide above, and followed the steps. It seemed to help, and PlexConnect seems to be running without errors, but the Trailers app is still showing me trailers, not Plex.

 

Here is my Settings.cfg (sorry I don't know how to copy paste from the terminal):

 

settings.png

 

The 86 address is my Linux server, where PMS and PlexConnect are running.

 

Here is my vhosts file:

 

vhosts.png

 

And lastly, the running PlexConnect. I don't see any errors here, but I'm not sure it's saying what it should be saying:

 

running.png

 

Anybody see anything obviously wrong here? In another thread, f00b4r suggested it might be a DNS setting/configuration issue. 

 

Thanks!



#10 clarifix

clarifix

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 03 July 2013 - 11:18 AM

My 5 cents: change the google dns entry to your own dns server



#11 crowfan

crowfan

    Member

  • Members
  • PipPip
  • 29 posts

Posted 03 July 2013 - 12:28 PM

Thanks.

 

I changed the ip_dnsmaster in the Settings.cfg file to my server's address, and it didn't work. I still get PlexConnect running successfully as seen in the third screenshot, but the Trailers app still serves the trailers.

 

Thanks for the try though! Any other thoughts/feedback? I'm probably missing something obvious.



#12 f00b4r

f00b4r

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2699 posts

Posted 03 July 2013 - 02:30 PM

What i meant was that you setup does not seem to be hijacking the DNS requests for the trailer application (the other DNS entry is for when other aTV apps want to reach the outside world). You have disabled the PlexConnect DNS server so the issue lies with your configuration of the bind(?) DNS server on your Linux device; unfortunately i cannot help you with this but maybe someone more familiar with bind can do.

Plex @ aTV - think different: PlexConnect

-> the missing link between Plex Media Server and your AppleTV - 2 or 3, jailbroken or not.

How to report an issue: click here

Sources: click here

Wiki: click here

 


#13 wilsoncd2

wilsoncd2

    Member

  • Members
  • PipPip
  • 13 posts

Posted 05 July 2013 - 11:59 AM

crofan, in the Settings.cfg file enable the DNS server by changing the enable_dnsserver value to True then restart Plex Connect. After that, make sure the DNS setting in the network configuration on your Apple TV is set to the IP address of the machine running Plex Connect.



#14 deLoco

deLoco

    Member

  • Members
  • PipPip
  • 31 posts

Posted 05 July 2013 - 12:26 PM

Hey there,

I followed the steps to create a service under Ubuntu (located in /etc/init.d/plexconnect). It's possibvle to start PLexConnect via 'sudo service plexconnect start', but that service deosn't get started with the system, so I still have to start it manually… Any solution, or hint on this?



#15 wilsoncd2

wilsoncd2

    Member

  • Members
  • PipPip
  • 13 posts

Posted 05 July 2013 - 04:04 PM

Hey there,

I followed the steps to create a service under Ubuntu (located in /etc/init.d/plexconnect). It's possibvle to start PLexConnect via 'sudo service plexconnect start', but that service deosn't get started with the system, so I still have to start it manually… Any solution, or hint on this?

 

Have you set the service to start automatically ? It is part of the last steps in the post.

 

sudo chown root:root /etc/init.d/plexconnect
sudo chmod
755 /etc/init.d/plexconnect
sudo update
-rc.d plexconnect defaults

 

These instructions will cause update-rc.d to read the comments at the top of the script (shown below) and setup the daemon appropriately. Do you also have a daemon called plexmediaserver on the server that you are installing plexconnect on? If not remove plexmediaserver from the Required-Start and Required-Stop entries or else the daemon won't start since there is not a running plexmediaserver.

 

### 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



#16 darkpassenger

darkpassenger

    Member

  • Members
  • PipPip
  • 37 posts

Posted 05 July 2013 - 06:19 PM

Hi all,

I have a Linux server in my house -- it's Fedora 14 running Amahi Home Server. It has both a DNS server and web server, so I can't use ports 53 or 80 for PlexConnect.

I took a look at the guide above, and followed the steps. It seemed to help, and PlexConnect seems to be running without errors, but the Trailers app is still showing me trailers, not Plex.

Here is my Settings.cfg (sorry I don't know how to copy paste from the terminal):

settings.png

The 86 address is my Linux server, where PMS and PlexConnect are running.

Here is my vhosts file:

vhosts.png

And lastly, the running PlexConnect. I don't see any errors here, but I'm not sure it's saying what it should be saying:

running.png

Anybody see anything obviously wrong here? In another thread, f00b4r suggested it might be a DNS setting/configuration issue.

Thanks!

It is my understanding that it will only work if the webserver is listening on port 80. In case port 80 is already in use, consider using a secondary ip address.
I do the same, it works just fine.

My bad, I see now you are using a virtual host configured in apache.

Edited by darkpassenger, 06 July 2013 - 04:22 AM.


#17 crowfan

crowfan

    Member

  • Members
  • PipPip
  • 29 posts

Posted 05 July 2013 - 11:05 PM

crofan, in the Settings.cfg file enable the DNS server by changing the enable_dnsserver value to True then restart Plex Connect. After that, make sure the DNS setting in the network configuration on your Apple TV is set to the IP address of the machine running Plex Connect.

 

I am running PlexConnect on a server which already had a DNS server running on port 53. I turned it back on, and it failed because port 53 is already being used by the server's DNS. That was one of the problems I was having in the first place. Thanks for the thought though.

 

It is my understanding that it will only work if the webserver is listening on port 80. In case port 80 is already in use, consider using a secondary ip address.

I do the same, it works just fine.

 

As with the other solution above, this is already being used by the webserver on my server. My belief is that this setting in the Settings.cfg file allows you change the port for PlexConnect so it doesn't conflict with the existing webserver. That seems to be what's happening, but something is clearly still missing. 

 

I think f00b4r is right; I think everything is set properly but something is still missing. I'm not sure what else I need to do. I followed the instructions in the OP and thought that would cover it but something is still not working for me. 



#18 darkpassenger

darkpassenger

    Member

  • Members
  • PipPip
  • 37 posts

Posted 06 July 2013 - 04:22 AM

It is my understanding that it will only work if the webserver is listening on port 80. In case port 80 is already in use, consider using a secondary ip address.
I do the same, it works just fine.

My bad, I see now you are using a virtual host configured in apache.



#19 darkpassenger

darkpassenger

    Member

  • Members
  • PipPip
  • 37 posts

Posted 06 July 2013 - 04:25 AM

I am trying to get the RHEL based init script to work on CentOS 6.4, but it does not work so far.

 

[root@plexmediaserver init.d]# sh -x ./plexconnect start
+ . /lib/lsb/init-functions
+ NAME=PlexConnect
+ DAEMON=/usr/bin/screen
+ DAEMON_OPTS='-S PlexConnect -d -m /var/PlexConnect/PlexConnect.py'
+ DAEMON_USER=root
+ PIDFILE=/var/run/PlexConnect.pid
+ test -x /usr/bin/screen
./plexconnect: line 45: syntax error near unexpected token `<'
./plexconnect: line 45: `   while read line ; do [[ $line =~ ([0-9]*).PlexConnect ]] && echo ${BASH_REMATCH[1]} ; done < <(screen -ls) > $PIDFILE'

 

Will investigate and report back, wondering if it is related to the fact that I already have 2 other instances of screen open.



#20 f00b4r

f00b4r

    Plex Star

  • Members
  • PipPipPipPipPipPip
  • 2699 posts

Posted 06 July 2013 - 09:12 AM

I am trying to get the RHEL based init script to work on CentOS 6.4, but it does not work so far.

 

[root@plexmediaserver init.d]# sh -x ./plexconnect start
+ . /lib/lsb/init-functions
+ NAME=PlexConnect
+ DAEMON=/usr/bin/screen
+ DAEMON_OPTS='-S PlexConnect -d -m /var/PlexConnect/PlexConnect.py'
+ DAEMON_USER=root
+ PIDFILE=/var/run/PlexConnect.pid
+ test -x /usr/bin/screen
./plexconnect: line 45: syntax error near unexpected token `<'
./plexconnect: line 45: `   while read line ; do [[ $line =~ ([0-9]*).PlexConnect ]] && echo ${BASH_REMATCH[1]} ; done < <(screen -ls) > $PIDFILE'

 

Will investigate and report back, wondering if it is related to the fact that I already have 2 other instances of screen open.

 

Don't expend too much time on it, we are already playing around with daemon support code for *nix ;)


Plex @ aTV - think different: PlexConnect

-> the missing link between Plex Media Server and your AppleTV - 2 or 3, jailbroken or not.

How to report an issue: click here

Sources: click here

Wiki: click here

 




Reply to this topic



  



Also tagged with one or more of these keywords: PlexConnect, Plex Connect, install, linux, init script

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users