2
0
mirror of https://github.com/spritsail/plex-media-server.git synced 2024-12-20 11:34:36 +00:00

Swap start_pms patch for complete script

This commit is contained in:
Joe Groocock 2017-06-02 22:22:00 +01:00
parent daa2e1172d
commit 4ebce5f2a8
3 changed files with 41 additions and 66 deletions

View File

@ -2,7 +2,7 @@ FROM adamant/busybox:libressl
MAINTAINER Adam Dodman <adam.dodman@gmx.com> MAINTAINER Adam Dodman <adam.dodman@gmx.com>
ENV UID=900 GID=900 ENV UID=900 GID=900
ADD start_pms.patch /tmp/start_pms.patch ADD start_pms /usr/sbin/start_pms
WORKDIR /tmp WORKDIR /tmp
@ -17,8 +17,7 @@ RUN wget http://ftp.de.debian.org/debian/pool/main/g/gcc-4.9/libstdc++6_4.9.2-10
&& dpkg-deb -x plexmediaserver.deb . \ && dpkg-deb -x plexmediaserver.deb . \
# Move usr/lib and start_pms. Everything else is useless # Move usr/lib and start_pms. Everything else is useless
&& mv usr/lib/plexmediaserver /usr/lib \ && mv usr/lib/plexmediaserver /usr/lib \
&& mv usr/sbin/start_pms /usr/sbin \ && chmod +x /usr/sbin/start_pms \
&& patch /usr/sbin/start_pms < /tmp/start_pms.patch \
&& find /tmp -mindepth 1 -delete && find /tmp -mindepth 1 -delete
WORKDIR /usr/lib/plexmediaserver WORKDIR /usr/lib/plexmediaserver

39
start_pms Normal file
View File

@ -0,0 +1,39 @@
#!/bin/sh
# Default values
export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="${PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS:-6}"
export PLEX_MEDIA_SERVER_HOME="${PLEX_MEDIA_SERVER_HOME:-/usr/lib/plexmediaserver}"
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
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
fi
fi
if su-exec $UID:$GID [ ! -w "$PLEX_MEDIA_SERVER_CONFIG_DIR" ]
then
echo "ERROR: CANNOT WRITE IN $PLEX_MEDIA_SERVER_CONFIG_DIR, MAKE SURE I HAVE PERMISSION TO DO THAT!"
exit 2
fi
export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}:$LD_LIBRARY_PATH"
export TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR}"
# Allow Plex group to write to tmpdir
chgrp $GID "$TMPDIR"
chmod g+rwx "$TMPDIR"
PIDFILE="${PLEX_MEDIA_SERVER_CONFIG_DIR}/plexmediaserver.pid"
if [ -f "$PIDFILE" ]; then
rm -f "$PIDFILE"
fi
exec su-exec $UID:$GID "$PLEX_MEDIA_SERVER_HOME/Plex Media Server"

View File

@ -1,63 +0,0 @@
--- start_pms
+++ /usr/bin/start_pms
@@ -1,36 +1,39 @@
#!/bin/sh
-#change these parameters in /etc/default/plexmediaserver
-export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
-export PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
-export PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000
-export PLEX_MEDIA_SERVER_TMPDIR=/tmp
-export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}/Library/Application Support"
-if [ -f /etc/default/locale ]; then
- export LANG="`cat /etc/default/locale|awk -F '=' '/LANG=/{print $2}'|sed 's/"//g'`"
- export LC_ALL="$LANG"
-fi
-
-test -f /etc/default/plexmediaserver && . /etc/default/plexmediaserver
+# Default values
+export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="${PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS:-6}"
+export PLEX_MEDIA_SERVER_HOME="${PLEX_MEDIA_SERVER_HOME:-/usr/lib/plexmediaserver}"
+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
- 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
fi
fi
+if su-exec $UID:$GID [ ! -w "$PLEX_MEDIA_SERVER_CONFIG_DIR" ]
+then
+ echo "ERROR: CANNOT WRITE IN $PLEX_MEDIA_SERVER_CONFIG_DIR, MAKE SURE I HAVE PERMISSION TO DO THAT!"
+ exit 2
+fi
-export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}"
+export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}:$LD_LIBRARY_PATH"
export TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR}"
-echo $PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS $PLEX_MEDIA_SERVER_MAX_STACK_SIZE $PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
-
-ulimit -s $PLEX_MAX_STACK_SIZE
-
-# Add sleep - Possible fix for start on boot.
-sleep 3
+# Allow Plex group to write to tmpdir
+chgrp $GID "$TMPDIR"
+chmod g+rwx "$TMPDIR"
+
+PIDFILE="${PLEX_MEDIA_SERVER_CONFIG_DIR}/plexmediaserver.pid"
+if [ -f "$PIDFILE" ]; then
+ rm -f "$PIDFILE"
+fi
-(cd /usr/lib/plexmediaserver; ./Plex\ Media\ Server)
+exec su-exec $UID:$GID "$PLEX_MEDIA_SERVER_HOME/Plex Media Server"