stokkes / plex_rcs

Plex rclone cache scanner
27 stars 6 forks source link

permission issues #1

Open chienb opened 6 years ago

chienb commented 6 years ago

plexrcs is having issues while running as non plex user:

Starting to monitor /var/log/syslog with pattern for rclone cache
Detected new file: tv/Billions/Season 01/Billions - S01E01 - Pilot.mkv

Processing section 1, folder: /home/omanko/plex/mount/tv/Billions/Season 01
terminate called after throwing an instance of 'std::runtime_error'
  what():  Codecs: Initialize: 'boost::filesystem::create_directory: Permission denied: "/var/lib/plexmediaserver/Plex Media Server/Codecs/4b51335-1293-linux-ubuntu-x86_64"'

Permissions:

plex@THERMALTAKE:~/Library/Application Support/Plex Media Server$ ls -la
total 48
drwxr-xr-x 10 plex plex 4096 May  4 02:16 .
drwxr-xr-x  3 plex plex 4096 Apr  8 14:08 ..
drwxr-xr-x  5 plex plex 4096 May  4 09:19 Cache
drwxr-xr-x  3 plex plex 4096 May  4 01:53 Codecs
drwxr-xr-x  4 plex plex 4096 May  4 01:53 Crash Reports
drwxr-xr-x  3 plex plex 4096 May  4 02:16 Logs
drwxr-xr-x  3 plex plex 4096 Apr  8 14:21 Media
drwxr-xr-x  4 plex plex 4096 Apr 10 19:17 Metadata
-rw-r--r--  1 plex plex    3 May  4 02:15 plexmediaserver.pid
drwxr-xr-x  3 plex plex 4096 Apr 30 05:19 Plug-ins
drwxr-xr-x  7 plex plex 4096 Apr  8 14:08 Plug-in Support
-rw-------  1 plex plex 1498 May  4 02:16 Preferences.xml

Tried logging in as plex but can't screen. Also tried:

plex@THERMALTAKE:~$ script /dev/null
Script started, file is /dev/null
plex@THERMALTAKE:~$ export LD_LIBRARY_PATH="/usr/lib/plexmediaserver" 
plex@THERMALTAKE:~$ /usr/bin/screen -dmS plexrcs /home/omanko/plex/tools/plex_rcs/plex_rcs.py
plex@THERMALTAKE:~$ screen -r plexrcs
There is no screen to be resumed matching plexrcs.
plex@THERMALTAKE:~$ 
stokkes commented 6 years ago

@chienb

Thanks for the issue. I believe there are problems running Plex Media Scanner as a user other than the owner.

It's possible the plex user doesn't have access to your home folder /home/omanko which is why the screen fails. When you run screen with -dmS, if the command fails, the screen will terminate immediately.

Try this and report back (switch to root user, via sudo -i):

screen -S plexrcs
/home/omanko/plex/tools/plex_rcs/plex_rcs.py --config /home/omanko/plex/tools/plex_rcs/config.yml --directory "/home/omanko/plex/mount/tv/Billions/Season 01"

Since root has all permissions, it should work. If it does, we know plex_rcs is working in your environment, and the next step will be to get it working for your setup. I am close to releasing the systemd service, so you could technically run this as any user you want.

You could also try the above commands as the plex user to confirm the permission issue.

Thanks, let me know.

chienb commented 6 years ago

i got this

root@THERMALTAKE:~# /home/omanko/plex/tools/plex_rcs/plex_rcs.py --config /home/omanko/plex/tools/plex_rcs/config.yml --directory "/home/omanko/plex/mount/tv/Billions/Season 01"
Traceback (most recent call last):
  File "/home/omanko/plex/tools/plex_rcs/plex_rcs.py", line 9, in <module>
    import yaml
ImportError: No module named 'yaml'
stokkes commented 6 years ago

Ah, appears the documentation is wrong on my behalf.

Please do sudo pip3 install -r requirements.txt from the plex_rcs folder.

Then retry as root and as plex.

Let me know!

chienb commented 6 years ago

I'm getting the section doesn't exist error as root and plex:

root@THERMALTAKE:~# /home/omanko/plex/tools/plex_rcs/plex_rcs.py --config /home/
omanko/plex/tools/plex_rcs/config.yml --directory "/home/omanko/plex/mount/tv/Bi
llions/Season 01"
Processing section 1, folder: /home/omanko/plex/mount/tv/Billions/Season 01
Error: Section doesn't exist.
stokkes commented 6 years ago

Ok, that usually means that it doesn't know / can't find your library.

Please post your config.yml (remove the token please)

chienb commented 6 years ago

plex_rcs:

  host: localhost
  port: 32400
  token: XXXXX
  docker: false
  container: plex
  media_root: /home/omanko/plex/mount
  env:
    LD_LIBRARY_PATH: "/usr/lib/plexmediaserver"
    PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR: "/var/lib/plexmediaserver"

I can also confirm via file manager and ls the section and files exist.

root@THERMALTAKE:/home/omanko/plex/mount/tv/Billions/Season 01# ls
banner.jpg
Billions - S01E01 - Pilot.chi.srt
Billions - S01E01 - Pilot.idx
Billions - S01E01 - Pilot.mkv
Billions - S01E01 - Pilot.sub
Billions - S01E02 - Naming Rights.chi.srt
Billions - S01E02 - Naming Rights.eng.srt
Billions - S01E02 - Naming Rights.idx
Billions - S01E02 - Naming Rights.mkv
hacktek commented 5 years ago

I don't have the permission issue but I do have the "Section doesn't exist" error. I run plex a root and it gives me the same issue from the root user as well as some other random user:

Processing section 32, folder: /mnt/cache/experimental/Mr. Smith Goes to Washington (1939)
Error: Section doesn't exist.

Section 32 clearly exists:

root@plexy:~# export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application\ Support
root@plexy:~# export LD_LIBRARY_PATH=/usr/lib/plexmediaserver
root@plexy:~# $LD_LIBRARY_PATH/Plex\ Media\ Scanner --list
 36: Anime
 38: Anime (Oldies)
 32: Movies
 33: TV

Manually scanning works:

root@plexy:~# $LD_LIBRARY_PATH/Plex\ Media\ Scanner --scan --refresh --section 32 -d "/mnt/cache/experimental/Mr. Smith Goes to Washington (1939)"
GUI: Scanning Mr. Smith Goes to Washington (1939)