Autostart Plexconnect

When starting the computer(latest Ubuntu) and enter “Trailers” on AT3 it just says “Accessing Trailers”…

➜  ~ sudo service plexconnect status              
[sudo] password for johan: 
● plexconnect.service - LSB: This is the Plex Connect daemon
   Loaded: loaded (/etc/init.d/plexconnect; bad; vendor preset: enabled)
   Active: active (exited) since tis 2016-06-21 20:00:55 CEST; 2min 54s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 855 ExecStart=/etc/init.d/plexconnect start (code=exited, status=0/SU
    Tasks: 0 (limit: 512)

jun 21 20:00:55 s1 systemd[1]: Starting LSB: This is the Plex Connect daemon...
jun 21 20:00:55 s1 plexconnect[855]:  * Starting the process PlexConnect
jun 21 20:00:55 s1 systemd[1]: Started LSB: This is the Plex Connect daemon.
lines 1-10/10 (END)

Also trying to start manual fails(still just “Accessing Trailers”):
sudo service plexconnect start

Only that works is to start manually:
➜ ~ cd /usr/local/lib/PlexConnect/
➜ PlexConnect sudo ./PlexConnect_daemon.bash start
Starting PlexConnect…

Why dose not my auto-start deamon work?

This is how my deamon config looks like:

➜  PlexConnect cat /etc/init.d/plexconnect
#!/bin/bash
### BEGIN INIT INFO
# Provides:          plexconnect
# Required-Start:    networking
# Required-Stop:    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

Because Ubuntu uses systemd: http://forums.plex.tv/discussion/213637/ubuntu-15-debian-8-raspbian-jessie-guide-for-service-installation-autostart

That actually worked. Strange all the googling did not find that one. Thanks!

Been there :slight_smile: