Help installing PlexPy

I was able to reinstall Plexpy using the Sudo su - technique, and installed it into the @appstore directory. I can get it to start if I run it manually using SSH; but I cant get it to start automatically after a restart; any suggestions? I have the same start script in user/local/start.

@dankster said:
@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!

@dankster - To answer your question, I logged in with admin user and sudo to root as you did. Good to hear you got it sorted

@rjblake said:
@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.

Thank you for all your help. I have been banging my head against the wall since upgrading to DSM 6.0. All my other apps work, except for this.

I updated my S99plexpy.sh file and changed the kill line you updated.

What other changes did you make to S99plexpy.sh or plexpy.start.sh?

When I manually execute ./S99plexpy.sh start as root PlexPy starts, however it doesn’t on boot up…

Also if I execute the command ./S99plexpy.sh start twice, it should tell me PlexPy is already running…

Any thoughts on auto starting on boot up?

Thank you for your help!

@artiss said:

@rjblake said:
@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.

Thank you for all your help. I have been banging my head against the wall since upgrading to DSM 6.0. All my other apps work, except for this.

I updated my S99plexpy.sh file and changed the kill line you updated.

What other changes did you make to S99plexpy.sh or plexpy.start.sh?

When I manually execute ./S99plexpy.sh start as root PlexPy starts, however it doesn’t on boot up…

Also if I execute the command ./S99plexpy.sh start twice, it should tell me PlexPy is already running…

Any thoughts on auto starting on boot up?

Thank you for your help!

Have just noticed that it didn’t start on my Syno box; but am remote so cannot look into this right now. I’ll try to take a look later and see what needs modifying.

@rjblake said:
@dankster

Have just noticed that it didn’t start on my Syno box; but am remote so cannot look into this right now. I’ll try to take a look later and see what needs modifying.

That;d be great! Thanks.

@artiss said:

@rjblake said:
@dankster

Have just noticed that it didn’t start on my Syno box; but am remote so cannot look into this right now. I’ll try to take a look later and see what needs modifying.

That;d be great! Thanks.

@artiss - checked my script which had an error (rewritten courtesy of the PlexConnect script). This should be in /usr/syno/etc.defaults/rc.sysv, but not sure it will work because of the su -c (can’t reboot my box to test). As a workaround, I’ve added a task to the Task Scheduler to run this at boot. Perhaps I should create another non-root user and run as such…

Revised script as follows:

! #!/bin/sh
!
! # Package
! PACKAGE=“plexpy”
! DNAME=“PlexPy”
!
! # Others
! INSTALL_DIR=“/volume1/@appstore/${PACKAGE}”
! PYTHON=“/usr/bin/env python”
! RUNAS=“${PACKAGE}”
! PROG_PY=“${INSTALL_DIR}/PlexPy.py”
! PID_FILE=“/var/run/PlexPy.pid”
! # DATA_DIR=“${INSTALL_DIR}”
! # LOG_FILE=“${INSTALL_DIR}/var/PlexConnect.log”
!
! start_daemon ()
! {
! # Launch the application in the background as root
! su -c “${PYTHON} ${PROG_PY} --pidfile ${PID_FILE} --daemon --nolaunch”
! }
!
! stop_daemon ()
! {
! kill cat ${PID_FILE}
! wait_for_status 1 20 || kill -9 cat ${PID_FILE}
! rm -f ${PID_FILE}
! }
!
! daemon_status ()
! {
! if [ -f ${PID_FILE} ] && kill -0 cat ${PID_FILE} > /dev/null 2>&1; then
! return
! fi
! rm -f ${PID_FILE}
! return 1
! }
!
! wait_for_status ()
! {
! counter=$2
! while [ ${counter} -gt 0 ]; do
! daemon_status
! [ $? -eq $1 ] && return
! let counter=counter-1
! sleep 1
! done
! return 1
! }
!
! case $1 in
! start)
! if daemon_status; then
! echo ${DNAME} is already running
! else
! echo Starting ${DNAME} …
! start_daemon
! fi
! ;;
! stop)
! if daemon_status; then
! echo Stopping ${DNAME} …
! stop_daemon
! else
! echo ${DNAME} is not running
! fi
! ;;
! status)
! if daemon_status; then
! echo ${DNAME} is running
! exit 0
! else
! echo ${DNAME} is not running
! exit 1
! fi
! ;;
! log)
! echo ${LOG_FILE}
! ;;
! *)
! exit 1
! ;;
! esac

@rjblake said:

@artiss said:

@rjblake said:
@dankster

Have just noticed that it didn’t start on my Syno box; but am remote so cannot look into this right now. I’ll try to take a look later and see what needs modifying.

That;d be great! Thanks.

@artiss - checked my script which had an error (rewritten courtesy of the PlexConnect script). This should be in /usr/syno/etc.defaults/rc.sysv, but not sure it will work because of the su -c (can’t reboot my box to test). As a workaround, I’ve added a task to the Task Scheduler to run this at boot. Perhaps I should create another non-root user and run as such…

Gret will give it a shot and see what happens.

Why is the script in the /usr/syno/etc.defaults/rc.sysv folder rather then the /usr/syno/etc.defaults/rc.d/ or /usr/syno/etc/rc.d?

@artiss said:

@rjblake said:

@artiss said:

@rjblake said:
@dankster

Have just noticed that it didn’t start on my Syno box; but am remote so cannot look into this right now. I’ll try to take a look later and see what needs modifying.

That;d be great! Thanks.

@artiss - checked my script which had an error (rewritten courtesy of the PlexConnect script). This should be in /usr/syno/etc.defaults/rc.sysv, but not sure it will work because of the su -c (can’t reboot my box to test). As a workaround, I’ve added a task to the Task Scheduler to run this at boot. Perhaps I should create another non-root user and run as such…

Gret will give it a shot and see what happens.

Why is the script in the /usr/syno/etc.defaults/rc.sysv folder rather then the /usr/syno/etc.defaults/rc.d/ or /usr/syno/etc/rc.d?

I disabled the task in Task Scheduler and rebooted. PlexPy started up with the reboot (so no su/sudo issue), but I’ll need to check exactly what script files are working and which are not (I’ve also added a call in /etc/rc.local). It might also make sense to use a different account (e.g. the ‘plex’ user).

I’ve taken a look at the Synology DSM Developer Guide and will have a go at creating an SPK package to do the install through DSM (will be a while as a bit busy at present). It states that the scripts should be “put in /usr/local/etc/rc.d/”; but this document only goes as far as DSM5.2. On the Syno forum, there is a post that states “the new directory is /usr/syno/etc.defaults/rc.sysv”.

** Updated ** - I have checked this on my install and successfully rebooted with PlexPy starting automatically with the file located /usr/local/etc/rc.d/S99plexpy.sh

@rjblake said:
Updated ** - I have checked this on my install and successfully rebooted with PlexPy starting automatically with the file located /usr/local/etc/rc.d/S99plexpy.sh

You are awesome! Once I used your modified script and placed the S99plexpy.sh file in /usr/local/etc/rc.d/S99plexpy.sh it worked.

Guess /usr/syno/etc/rc.d/S99plexpy.sh and /usr/syno/etc.defaults/rc.d/S99plexpy.sh are no longer working for startup scripts.

Thank you again.

@trumpy81 said:
@rjblake I would certainly look forward to an .spk installer from you. If my Linux skills were better, I’d have a crack at it, but my skills suck … :))

Anyhow, please let me know if/when you can get that happening. :slight_smile:

@trumpy81 - Ok - so I’ve hacked together a quick .spk to install PlexPy. A couple of know issues with it…

  1. The Syno Package Center reports its running status as ‘stopped’, although it is running
  2. PlexPy reports that you are running an unknown version, but an update sorts this
  3. It is configured to run on port:8181 (default, although I use a different one)
  4. You can Stop/Restart through the PlexPy settings screen

If anyone wants it in this state (little time to debug the status reporting - for some reason not returning the correct code), I can/will make it available

@trumpy81 said:
Yes, please do make it available. :slight_smile:

You can always update it when you get the time. :wink: :))

And thanks, it is very much appreciated. :smiley:

Here you go - download the plexpy.spk from here.

NOTE: Use at own risk - I have not tested an install where user has existing install, database or configs

Please let me know of any issues

You guys rock! Thank you for making an .spk!!

@trumpy81 said:
PlexPy Installed and Running!!! :smiley:

A couple of notes:

  1. On initial startup, clicked on update PlexPy pop-up, It counted down and restarted, but it took about 5 minutes before I could access it again? I thought I broke it :(( PlexPy still reports unknown version. :frowning:
  2. Clicking on ‘check for updates’ under settings, returns you to the home page, why?
  3. No text based link in package center to open PlexPy in a browser.
  4. No icon/link in DSM start menu.
  5. And of course, the run status.

None of these are critical issues and so far at least, all is working well. :slight_smile:

Thanks again for creating this package. :slight_smile:

  1. Will check into this - the ‘update’ fixed it on mine. The length of time is down to PlexPy (out of my control)
  2. Normally this is where notifications of updates appear. This is a PlexPy thing as well
  3. Link only active/visible when package is ‘running’
  4. This is linked to the ‘stopped’ status being reported. Icons/links only appear for ‘running’ packages
  5. This may take some time - think I might need to ‘daemonize’ PlexPy.py for this, as the bash script isn’t returning a value when queried by looks of things

@trumpy81 said:
5. I was thinking the opposite. Maybe the start-stop-status script should resemble the Plex start-stop-status script?

I am only guessing though, my Linux skills really do suck … :))

The rest is noted and understood. Thanks :wink:

@trumpy81 & @artiss - I have fixed the ‘running issue’ - was a damn permission incorrectly set on a file. New version has been added (same link as before). I’m not sure what updating over the top will do, as I haven’t put any code in the scripts to backup a copy of the config.ini and plexpy.db. On another note, I can sort the version problem, but doubles the size of the package. What I might do when I’ve got time is set it up to pull the git-master directly from github and just install the required Syno scripts from my spk. Will look into this when I’ve got a spare moment

@trumpy81 said:
Before I could install the update, I needed to open PlexPy and shut it down, because package center complained of the port being in use.

Once I did that I was able to install the updated package and low and behold it runs and points 3, 4, 5 from my previous post have all been taken care of.

I also ran an update in PlexPy and it counted down and rebooted, but this time it came up with the setup wizard and after completing the wizard again, it no longer complains about being an unknown version.

WooHoo! Success!! :smiley:

Thank you so much for putting this together. :slight_smile:

Not sure why Package Center complained about the port, as it shuts PlexPy down before an update. I don’t have that happening here on my system (but I’ve got a bunch of files all over the place).

I’ve updated the installer script to do the following:

  1. Make a backup copy of the config.ini and plexpy.db before updating
  2. Restore the backup copies after the update
  3. Include a version file for the version of PlexPy being installed/updated

I believe it has now gotten rid of the ‘Unknown version’ problem and keeps you database and config safe. Think I’m done :)…at least for now

So awesome! Thank you!

I’m on DSM 6.0. I’ve installed rjblake’s .SPK and everything seems to be functional except that PlexPy doesn’t appear to have permissions to the Plex log folder. I’m not exactly sure how to determine what user PlexPy is running as, or how to correct the folder permissions. Can anyone help?

Always wondered why there is no dedicated .spk done by PlexPy developers.

Thanks for your work, keep on!

@sock said:
I’m on DSM 6.0. I’ve installed rjblake’s .SPK and everything seems to be functional except that PlexPy doesn’t appear to have permissions to the Plex log folder. I’m not exactly sure how to determine what user PlexPy is running as, or how to correct the folder permissions. Can anyone help?

@sock - PlexPy is currently setup to run as root, so should generally have the required permissions (assuming root/admin has access to your Plex folder), as per Trumpy81’s reply above. In addition, you need to correctly specify the Plex log path (mine is /volume1/Plex/Library/Application Support/Plex Media Server/Logs - no quotes needed). This was a problem I had some time back when I ran PlexPy in a Docker environment, but finally figured it out.

Some other info: The .spk install of PlexPy needs to be updated to create another user, but Synology changed things a bit that made this more of an issue. I am looking into sorting this and will provide and update once done. A possible thought is to use the “plex” user account to install/launch/run PlexPy, as it is created during the PMS install and since PlexPy works with Plex, why not use the same account instead of creating yet another account. In addition, I’m trying to sort the install/.spk for SickRage (or SickGear) so that it too installs without issue on DSM6.0; and possibly using the same Plex account.

@rjblake said:

@sock said:
I’m on DSM 6.0. I’ve installed rjblake’s .SPK and everything seems to be functional except that PlexPy doesn’t appear to have permissions to the Plex log folder. I’m not exactly sure how to determine what user PlexPy is running as, or how to correct the folder permissions. Can anyone help?

@sock - PlexPy is currently setup to run as root, so should generally have the required permissions (assuming root/admin has access to your Plex folder), as per Trumpy81’s reply above. In addition, you need to correctly specify the Plex log path (mine is /volume1/Plex/Library/Application Support/Plex Media Server/Logs - no quotes needed). This was a problem I had some time back when I ran PlexPy in a Docker environment, but finally figured it out.

Some other info: The .spk install of PlexPy needs to be updated to create another user, but Synology changed things a bit that made this more of an issue. I am looking into sorting this and will provide and update once done. A possible thought is to use the “plex” user account to install/launch/run PlexPy, as it is created during the PMS install and since PlexPy works with Plex, why not use the same account instead of creating yet another account. In addition, I’m trying to sort the install/.spk for SickRage (or SickGear) so that it too installs without issue on DSM6.0; and possibly using the same Plex account.

Ugg! :frowning: I had capitalized “Volume” when I entered the log path. All good now, thanks for the help!