From 4ebce5f2a86d6b7904585b1f611d325fee0aa09b Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Fri, 2 Jun 2017 22:22:00 +0100 Subject: [PATCH] Swap start_pms patch for complete script --- Dockerfile | 5 ++-- start_pms | 39 ++++++++++++++++++++++++++++++ start_pms.patch | 63 ------------------------------------------------- 3 files changed, 41 insertions(+), 66 deletions(-) create mode 100644 start_pms delete mode 100644 start_pms.patch diff --git a/Dockerfile b/Dockerfile index 5601f1e..8dd5add 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM adamant/busybox:libressl MAINTAINER Adam Dodman ENV UID=900 GID=900 -ADD start_pms.patch /tmp/start_pms.patch +ADD start_pms /usr/sbin/start_pms 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 . \ # Move usr/lib and start_pms. Everything else is useless && mv usr/lib/plexmediaserver /usr/lib \ - && mv usr/sbin/start_pms /usr/sbin \ - && patch /usr/sbin/start_pms < /tmp/start_pms.patch \ + && chmod +x /usr/sbin/start_pms \ && find /tmp -mindepth 1 -delete WORKDIR /usr/lib/plexmediaserver diff --git a/start_pms b/start_pms new file mode 100644 index 0000000..54d8268 --- /dev/null +++ b/start_pms @@ -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" diff --git a/start_pms.patch b/start_pms.patch deleted file mode 100644 index 5a6e611..0000000 --- a/start_pms.patch +++ /dev/null @@ -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"