2017-05-14 16:51:33 +00:00
|
|
|
--- start_pms
|
|
|
|
+++ /usr/bin/start_pms
|
2017-05-14 20:41:46 +00:00
|
|
|
@@ -1,36 +1,39 @@
|
2016-08-26 21:26:39 +00:00
|
|
|
#!/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"
|
2016-11-14 23:09:37 +00:00
|
|
|
-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
|
2016-08-26 21:26:39 +00:00
|
|
|
-
|
|
|
|
-test -f /etc/default/plexmediaserver && . /etc/default/plexmediaserver
|
|
|
|
+# Default values
|
|
|
|
+export PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="${PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS:-6}"
|
2017-05-11 09:42:22 +00:00
|
|
|
+export PLEX_MEDIA_SERVER_HOME="${PLEX_MEDIA_SERVER_HOME:-/usr/lib/plexmediaserver}"
|
2016-08-26 21:26:39 +00:00
|
|
|
+export PLEX_MEDIA_SERVER_MAX_STACK_SIZE="${PLEX_MEDIA_SERVER_MAX_STACK_SIZE:-3000}"
|
|
|
|
+export PLEX_MEDIA_SERVER_TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR:-/tmp}"
|
2017-04-08 20:31:13 +00:00
|
|
|
+export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR:-/config}"
|
2017-05-14 16:51:33 +00:00
|
|
|
+export PLEX_MEDIA_SERVER_CONFIG_DIR="${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}/Plex Media Server"
|
2016-08-26 21:26:39 +00:00
|
|
|
|
|
|
|
if [ ! -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]
|
|
|
|
then
|
2017-05-14 20:41:46 +00:00
|
|
|
- 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!"
|
2017-05-11 09:42:22 +00:00
|
|
|
exit 1
|
2016-08-26 21:26:39 +00:00
|
|
|
fi
|
|
|
|
fi
|
2017-05-14 20:41:46 +00:00
|
|
|
+if su-exec $UID:$GID [ ! -w "$PLEX_MEDIA_SERVER_CONFIG_DIR" ]
|
2017-05-11 09:42:22 +00:00
|
|
|
+then
|
2017-05-14 16:51:33 +00:00
|
|
|
+ echo "ERROR: CANNOT WRITE IN $PLEX_MEDIA_SERVER_CONFIG_DIR, MAKE SURE I HAVE PERMISSION TO DO THAT!"
|
2017-05-11 09:42:22 +00:00
|
|
|
+ exit 2
|
|
|
|
+fi
|
2016-08-26 21:26:39 +00:00
|
|
|
|
|
|
|
-export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}"
|
2017-05-11 09:42:22 +00:00
|
|
|
+export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}:$LD_LIBRARY_PATH"
|
2016-08-26 21:26:39 +00:00
|
|
|
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
|
2017-05-11 09:42:22 +00:00
|
|
|
-
|
2016-08-26 21:26:39 +00:00
|
|
|
-ulimit -s $PLEX_MAX_STACK_SIZE
|
2017-05-11 09:42:22 +00:00
|
|
|
-
|
2016-08-26 21:26:39 +00:00
|
|
|
-# Add sleep - Possible fix for start on boot.
|
|
|
|
-sleep 3
|
2017-05-14 20:41:46 +00:00
|
|
|
+# Allow Plex group to write to tmpdir
|
|
|
|
+chgrp $GID "$TMPDIR"
|
|
|
|
+chmod g+rwx "$TMPDIR"
|
|
|
|
+
|
2017-05-14 16:51:33 +00:00
|
|
|
+PIDFILE="${PLEX_MEDIA_SERVER_CONFIG_DIR}/plexmediaserver.pid"
|
|
|
|
+if [ -f "$PIDFILE" ]; then
|
|
|
|
+ rm -f "$PIDFILE"
|
2016-08-26 21:26:39 +00:00
|
|
|
+fi
|
|
|
|
|
|
|
|
-(cd /usr/lib/plexmediaserver; ./Plex\ Media\ Server)
|
2017-05-14 20:41:46 +00:00
|
|
|
+exec su-exec $UID:$GID "$PLEX_MEDIA_SERVER_HOME/Plex Media Server"
|