Fix Plex running as root

This commit is contained in:
Joe Groocock 2017-05-14 17:51:33 +01:00
parent 47ccdf64dc
commit f31ab482d8
2 changed files with 11 additions and 9 deletions

View File

@ -24,4 +24,4 @@ RUN wget http://ftp.de.debian.org/debian/pool/main/g/gcc-4.9/libstdc++6_4.9.2-10
WORKDIR /usr/lib/plexmediaserver
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["su-exec", "$UID:$GID", "start_pms"]
CMD exec su-exec $UID:$GID start_pms

View File

@ -1,6 +1,6 @@
--- plexmediaserver/usr/sbin/start_pms
+++ start_pms
@@ -1,17 +1,11 @@
--- start_pms
+++ /usr/bin/start_pms
@@ -1,17 +1,12 @@
#!/bin/sh
-#change these parameters in /etc/default/plexmediaserver
@ -21,16 +21,17 @@
+export PLEX_MEDIA_SERVER_MAX_STACK_SIZE="${PLEX_MEDIA_SERVER_MAX_STACK_SIZE:-3000}"
+export PLEX_MEDIA_SERVER_TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR:-/tmp}"
+export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR:-/config}"
+export PLEX_MEDIA_SERVER_CONFIG_DIR="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}/Plex Media Server"
if [ ! -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]
then
@@ -22,15 +16,17 @@
@@ -22,15 +17,18 @@
exit 1
fi
fi
+if [ ! -w "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]
+if [ ! -w "$PLEX_MEDIA_SERVER_CONFIG_DIR" ]
+then
+ echo "ERROR: CANNOT WRITE IN $PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR, MAKE SURE I HAVE PERMISSION TO DO THAT!"
+ echo "ERROR: CANNOT WRITE IN $PLEX_MEDIA_SERVER_CONFIG_DIR, MAKE SURE I HAVE PERMISSION TO DO THAT!"
+ exit 2
+fi
@ -44,8 +45,9 @@
-
-# Add sleep - Possible fix for start on boot.
-sleep 3
+if [ -f /config/Plex\ Media\ Server/plexmediaserver.pid ]; then
+ rm -f /config/Plex\ Media\ Server/plexmediaserver.pid
+PIDFILE="${PLEX_MEDIA_SERVER_CONFIG_DIR}/plexmediaserver.pid"
+if [ -f "$PIDFILE" ]; then
+ rm -f "$PIDFILE"
+fi
-(cd /usr/lib/plexmediaserver; ./Plex\ Media\ Server)