Fix permissions issue on boot

This commit is contained in:
Joe Groocock 2017-05-14 21:41:46 +01:00
parent f31ab482d8
commit daa2e1172d
2 changed files with 14 additions and 5 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 WORKDIR /usr/lib/plexmediaserver
ENTRYPOINT ["/sbin/tini", "--"] ENTRYPOINT ["/sbin/tini", "--"]
CMD exec su-exec $UID:$GID start_pms CMD ["start_pms"]

View File

@ -1,6 +1,6 @@
--- start_pms --- start_pms
+++ /usr/bin/start_pms +++ /usr/bin/start_pms
@@ -1,17 +1,12 @@ @@ -1,36 +1,39 @@
#!/bin/sh #!/bin/sh
-#change these parameters in /etc/default/plexmediaserver -#change these parameters in /etc/default/plexmediaserver
@ -25,11 +25,16 @@
if [ ! -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ] if [ ! -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]
then then
@@ -22,15 +17,18 @@ - mkdir -p "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR"
+ mkdir -p "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" && \
+ chown $UID:$GID "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR"
if [ ! $? -eq 0 ]
then
echo "WARNING COULDN'T CREATE $PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR, MAKE SURE I HAVE PERMISSON TO DO THAT!"
exit 1 exit 1
fi fi
fi fi
+if [ ! -w "$PLEX_MEDIA_SERVER_CONFIG_DIR" ] +if su-exec $UID:$GID [ ! -w "$PLEX_MEDIA_SERVER_CONFIG_DIR" ]
+then +then
+ echo "ERROR: CANNOT WRITE IN $PLEX_MEDIA_SERVER_CONFIG_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 + exit 2
@ -45,10 +50,14 @@
- -
-# Add sleep - Possible fix for start on boot. -# Add sleep - Possible fix for start on boot.
-sleep 3 -sleep 3
+# Allow Plex group to write to tmpdir
+chgrp $GID "$TMPDIR"
+chmod g+rwx "$TMPDIR"
+
+PIDFILE="${PLEX_MEDIA_SERVER_CONFIG_DIR}/plexmediaserver.pid" +PIDFILE="${PLEX_MEDIA_SERVER_CONFIG_DIR}/plexmediaserver.pid"
+if [ -f "$PIDFILE" ]; then +if [ -f "$PIDFILE" ]; then
+ rm -f "$PIDFILE" + rm -f "$PIDFILE"
+fi +fi
-(cd /usr/lib/plexmediaserver; ./Plex\ Media\ Server) -(cd /usr/lib/plexmediaserver; ./Plex\ Media\ Server)
+exec "$PLEX_MEDIA_SERVER_HOME/Plex Media Server" +exec su-exec $UID:$GID "$PLEX_MEDIA_SERVER_HOME/Plex Media Server"