Help installing PlexPy

Hi,

I’ve been asking around for help with installing PlexPy. I tried to use docker, but I could not get the settings to save properly on a reboot of NAS. I tried to install via PlexPys Linux instructions but on a reboot I can no longer find the /opt/PlexPy directory.

Would like some step by step help.

@timstephens24 provided the fix.
Solution:

I did all this from root.
First thing I did was install git, so I could git clone the repo. I did that by installing the Git Server from Synology. Then I made a folder called repos in root’s home directory:

cd; mkdir repos; cd repos
git clone https://github.com/drzoidberg33/plexpy.git
I made this file to run the command to start PlexPy: /usr/local/start/plexpy.start.sh

/usr/bin/python /root/repos/plexpy/PlexPy.py > /dev/null 2>&1 &
I made a startup script: /usr/syno/etc.defaults/rc.d/S99plexpy.sh

RETVAL=0
start() {
echo -n "Starting PlexPy: "
ps | grep PlexPy.py | grep python
RETVAL=$?
[ $RETVAL -eq 0 ] && echo “PlexPy already running: Exiting” && exit 1
/bin/sh /usr/local/start/plexpy.start.sh > /dev/null 2>&1 &
RETVAL=$?
[ $RETVAL -eq 0 ] && echo -n “done”
echo
return $RETVAL
}
stop() {
echo -n “Stopping PlexPy: "
kill -9 ps |grep PlexPy.py |grep python | awk -F” " ‘{print $1}’
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && echo -n “done”
echo
return $RETVAL
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
RETVAL=$?
;;
*)
echo “Usage: $0 [start|stop|restart]”
exit 1
esac
exit $RETVAL

And lastly make both of them executable

chmod +x /usr/syno/etc.defaults/rc.d/S99plexpy.sh /usr/local/start/plexpy.start.sh
Now it will start at boot, and you can also start/stop/restart it with the following commands:

/usr/syno/etc.defaults/rc.d/S99plexpy.sh start
/usr/syno/etc.defaults/rc.d/S99plexpy.sh stop
/usr/syno/etc.defaults/rc.d/S99plexpy.sh restart

Glad it helped you!

Thanks for this. I found a straight copy paste of S99plexpy.sh resulted in the stop command not working. It was failing to extract the correct pid to kill. I fixed it by replacing the following line:

kill -9 ps |grep PlexPy.py |grep python | awk -F" " ‘{print $1}’

with the below

kill -9 $(ps | grep PlexPy.py | grep python | awk -F " " ‘{ print $1 }’)

Otherwise, thanks for figuring this out!

A follow up question - have you managed to get HTTPS working? It appears that PlexPy needs the pyOpenSSL module installing separately, any idea how to do that?

@benadderson said:
Thanks for this. I found a straight copy paste of S99plexpy.sh resulted in the stop command not working. It was failing to extract the correct pid to kill. I fixed it by replacing the following line:

kill -9 ps |grep PlexPy.py |grep python | awk -F" " ‘{print $1}’

with the below

kill -9 $(ps | grep PlexPy.py | grep python | awk -F " " ‘{ print $1 }’)

Otherwise, thanks for figuring this out!

I can not take credit for this. A fellow user (@timstephens24) in the PlexPy thread provided the guide.

Thanks for noticing an issue, guess I haven’t tried to stop it yet :slight_smile:

@benadderson said:
A follow up question - have you managed to get HTTPS working? It appears that PlexPy needs the pyOpenSSL module installing separately, any idea how to do that?

I would ask and follow this post - it’s a Q&A for PlexPy.

@benadderson said:
Thanks for this. I found a straight copy paste of S99plexpy.sh resulted in the stop command not working. It was failing to extract the correct pid to kill. I fixed it by replacing the following line:

kill -9 ps |grep PlexPy.py |grep python | awk -F" " ‘{print $1}’

with the below

kill -9 $(ps | grep PlexPy.py | grep python | awk -F " " ‘{ print $1 }’)

Otherwise, thanks for figuring this out!

Apparently the forums stripped out part of the command and I didn’t notice it. My command was yours but I used the backticks instead of $().

I think I did a poor job of cutting and pasting. If you want to double check go to the bottom of this post. :slight_smile:

can any one confirm this works on sinology patflorm

@artiss said:

@benadderson said:
A follow up question - have you managed to get HTTPS working? It appears that PlexPy needs the pyOpenSSL module installing separately, any idea how to do that?

I would ask and follow this post - it’s a Q&A for PlexPy.

you can use pip to install python modules that are needed using something like ‘pip install pyOpenSSL’

Hi, if you use docker (https://github.com/linuxserver/docker-plexpy) you need to map the /config directory to a directory on your filesystem, otherwise the settings will be lost on each pull of a new docker image.

@CornholioLU said:
Hi, if you use docker (GitHub - linuxserver/docker-tautulli) you need to map the /config directory to a directory on your filesystem, otherwise the settings will be lost on each pull of a new docker image.

Can you explain how to do that please? Unfortunately I have no idea what I’m doing.

Before I saw this thread I came up with a simpler solution that works fine for me. But might not be as technically correct as some of the ones posted here.

I just extracted the PlexPy file from the downloaded archive on git into a folder onto my NAS, and then I made a simple script that I also placed somewhere on the NAS and named it “PlexPy_Start.sh”:

#!/bin/sh
# Check if already running, if not then run
if  ps | grep -v grep | grep -q PlexPy.py; then
    :            # do nothing if already running
else
    python "/volume1/Plex/PlexPy/PlexPy.py" &
fi

In the Task Scheduler in the DSM interface I made a task which runs this script every 5 minutes or so, making sure that the PlexPy restarts if it for some reason would crash it also starts it on reboot (worst case with a delay of 5 minutes after boot).

Regarding updating the PlexPy you do not need git on the NAS since the PlexPy interface will tell you when there is a new version and it also gives you a button to press to automatically update to the latest version.

Hi,

I’ve been trying to get this to work all day and having no success at all. Running Xpenology / Synology DSM 5.2 on HP MicroServer Gen8.

Running /usr/syno/etc.defaults/rc.d/S99plexpy.sh start
or
/usr/syno/etc.defaults/rc.d/S99plexpy.sh

Results in:

: not foundtc.defaults/rc.d/S99plexpy.sh: line 7:
: not foundtc.defaults/rc.d/S99plexpy.sh: line 10: echo
/usr/syno/etc.defaults/rc.d/S99plexpy.sh: return: line 11: Illegal number: 127

This is very odd… line 10 is just “echo” and line 11 is just “return $RETVAL”

Please help!!

Thanks

deleted wrong thread

@TJ1816 said:
Can you explain how to do that please? Unfortunately I have no idea what I’m doing.

Assuming you have Docker installed on your NAS.

  • Open Docker in DSM
  • Go to “Image” tab
  • Click Add, Add From URL, enter Docker, then click Add
  • Make a folder somewhere that PlexPy can keep its saved config. I made a plexpy folder in the docker shared folder (/volume3/docker/plexpy). I also make a textfile /volume3/docker/timezone containing just your TZ, in my case “Pacific/Auckland” (no quotes) so that the docker container would pick up the correct time (see volume mapping below).
  • SSH into your Synology and run the following,
    docker run \ --name="plexpy" \ -p 8183:8181 \ --volume=/etc/localtime:/etc/localtime:ro \ --volume=/volume3/docker/timezone:/etc/timezone:ro \ --volume=/volume3/docker/plexpy/config:/config \ --volume="/volume3/Plex/Library/Application Support/Plex Media Server/Logs":/logs:ro \ -e PUID=1026 \ -e PGID=100 \ --restart=always \ --detach \ linuxserver/plexpy

Notes

  • Be aware of users and permissions.
  • Change and names, paths and ports to suit your environment.
  • -p, exposed port:internal port, i.e. connect to http://nas-ip:8183
  • --volume=/volume3/docker/plexpy:/config, is where you want plexpy to save it’s config so it persists between reboots
  • --volume="/volume3/Plex/Library/Application Support/Plex Media Server/Logs":/logs:ro, is the location of your PMS log folder and mapped location in the docker container (/logs)
  • -e PUID=1026, a user’s uid to run the docker container as with read/write to plexpy config folder and read access to the PMS logs, you may have set some permission either in the DSM Control Panel or via SSH
  • -e PGID=100, a gid (groupid) for the UID above
  • --restart=always, so that if the container exits, Docker will restart it.
  • --detach run in background
  • linuxserver/plexpy, the docker image

Give it a minute or two to get fired up and it’ll show in your Docker Container tab where you can then stop/start/edit to your heart’s content. Open PlexPy in your browser on http://nas-ip:8183 and configure as required. Be sure to set your Settings for Plex Media Server → Plex IP or Hostname to the IP address/hostname of the machine running PMS - 127.0.0.1 won’t do as the docker container isn’t running Plex. Also be sure Logs Folder is set to /logs. Set your Plex.tv Account by fetching a token (you’ll see on the Plex.tv Account setting page).

@artiss The method you describe above is not working on the latest DSM 6 beta 2. It worked flawlessly on DSM 5 but something changed. I know its a beta but if anyone has a heads up on what needs to change to get it to work on DSM 6, we can get ahead of the curve here. Thanks!

@dankster - I have pretty much the above running on DSM6.0RC without problem. A few mods to the S99 script and created some symlinks to git, but working fine…

Spoke to soon. Updated DSM6.0RC to full version and wiped out my PlexPy. Guess I should have not used the defaults directories. Any how, reinstalled and all working again. Some details as follows:

did the ‘git pull’ into this directory: /volume1/@appstore/plexpy/PlexPy.py
created start script here: /usr/local/start/plexpy.start.sh
and added startup script here: /usr/syno/etc.defaults/rc.d/S99plexpy.sh

Also changed the line:
kill -9 $(ps | grep PlexPy.py | grep python | awk -F " " ‘{ print $1 }’)
to
kill -9 $(ps -ef | grep PlexPy | grep -v grep | awk ‘{print $2}’)

Now running just fine. Have Plex, PlexPy and SickRage all doing their job happily. Only thing I haven’t sorted is PlexConnect for ATV3 yet.

@rjblake thanks for the follow up my man. can you tell me which user you logged in via ssh with? i think my issue is the symlinks or something…

UPDATE:
i was able to get it to run by sshing in as Admin then “Sudo su -” which switched me to root. i then followed the directions above and it seems to be working!