# Autostart Plexconnect on Raspberry Pi

**URL:** <https://forums.plex.tv/t/autostart-plexconnect-on-raspberry-pi/122754>\
**Category:** Apps & Creations\
**Created:** [November 10, 2015, 10:13am UTC](https://forums.plex.tv/t/autostart-plexconnect-on-raspberry-pi/122754 "2015-11-10T10:13:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcmax](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@mcmax](https://forums.plex.tv/u/mcmax)\
**Post date:** [November 10, 2015, 10:13am UTC](https://forums.plex.tv/t/autostart-plexconnect-on-raspberry-pi/122754/1 "2015-11-10T10:13:36Z")

</div>

Hello,

want to have the Plexconnect on autostart on my Pi.

Using thiis script, I can manually start it and stop it, but it just won’t start on boot using either rc.d, rc.local or cron.

any ideas?

EDIT: I apologize for the horrible formatting, can’t get it to show up as code for some reason. Help appreciated^^

```auto
@SingleServingSociety said:
Make sure you have screen installed:
sudo apt-get install screen
Create a file called plexconnect in /etc/init.d:
sudo nano /etc/init.d/plexconnect

Give it the following content (update the DAEMON_OPTS="-S PlexConnect -d -m /usr/local/lib/PlexConnect/PlexConnect.py" line so it will point to your installation of 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

```

Make the file executable  
sudo chmod 755 /etc/init.d/plexconnect  
And check whether it works (make sure plexconnect is not running before starting this one):  
sudo service plexconnect start  
Make sure the script starts automatically when you reboot:  
sudo update-rc.d plexconnect defaults

---

<div class="post-metadata">

**Author:** ![baa](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/baa/32/2026_2.png) [@baa](https://forums.plex.tv/u/baa)\
**Post date:** [November 10, 2015, 11:22am UTC](https://forums.plex.tv/t/autostart-plexconnect-on-raspberry-pi/122754/2 "2015-11-10T11:22:30Z")

</div>

fixed the formatting for you - see also: “You can use Markdown in your post”

---

<div class="post-metadata">

**Author:** ![mcmax](https://avatars.discourse-cdn.com/v4/letter/m/ea5d25/32.png) [@mcmax](https://forums.plex.tv/u/mcmax)\
**Post date:** [November 10, 2015, 5:41pm UTC](https://forums.plex.tv/t/autostart-plexconnect-on-raspberry-pi/122754/3 "2015-11-10T17:41:19Z")

</div>

thx for that - help still very much appreciated

---

<div class="post-metadata">

**Author:** ![pblgmz](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/pblgmz/32/18407_2.png) [@pblgmz](https://forums.plex.tv/u/pblgmz)\
**Post date:** [February 13, 2016, 1:45pm UTC](https://forums.plex.tv/t/autostart-plexconnect-on-raspberry-pi/122754/4 "2016-02-13T13:45:24Z")

</div>

thanks. This was a great useful post.  
I had an issue that I solved myself (although I am new on this). I post the info just in case someone else can used it.  
When rebooting, the plexconnect was not launched, I got following message:  
\__start runlevel arguments do not match default start values_  
Then I modified the script with deafult-start: 2 3 4 5  
After removing and cretaing from cero the rc.d everything is working.  
Thank you again.  
I am running minibian on raspberry pi 2.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [January 8, 2020, 7:07pm UTC](https://forums.plex.tv/t/autostart-plexconnect-on-raspberry-pi/122754/5 "2020-01-08T19:07:51Z")

</div>


