2017-06-02 21:22:00 +00:00
|
|
|
#!/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"
|
|
|
|
|
2017-06-02 21:24:08 +00:00
|
|
|
if [ ! -d "$PLEX_MEDIA_SERVER_CONFIG_DIR" ]
|
2017-06-02 21:22:00 +00:00
|
|
|
then
|
2017-06-02 21:24:08 +00:00
|
|
|
mkdir -p "$PLEX_MEDIA_SERVER_CONFIG_DIR" && \
|
2017-12-15 16:51:41 +00:00
|
|
|
chown $SUID:$SGID "$PLEX_MEDIA_SERVER_CONFIG_DIR"
|
2017-06-02 21:22:00 +00:00
|
|
|
if [ ! $? -eq 0 ]
|
|
|
|
then
|
2017-06-02 21:24:08 +00:00
|
|
|
echo "WARNING COULDN'T CREATE $PLEX_MEDIA_SERVER_CONFIG_DIR, MAKE SURE I HAVE PERMISSON TO DO THAT!"
|
2017-06-02 21:22:00 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2017-12-15 16:43:33 +00:00
|
|
|
if su-exec -e [ ! -w "$PLEX_MEDIA_SERVER_CONFIG_DIR" ]
|
2017-06-02 21:22:00 +00:00
|
|
|
then
|
|
|
|
echo "ERROR: CANNOT WRITE IN $PLEX_MEDIA_SERVER_CONFIG_DIR, MAKE SURE I HAVE PERMISSION TO DO THAT!"
|
|
|
|
exit 2
|
|
|
|
fi
|
2017-06-02 21:24:49 +00:00
|
|
|
if [ ! -e "$PLEX_MEDIA_SERVER_CONFIG_DIR/Preferences.xml" ];
|
|
|
|
then
|
|
|
|
# Create a default config file allowing external access
|
|
|
|
echo -e '<?xml version="1.0" encoding="utf-8"?>\n<Preferences disableRemoteSecurity="1" />' \
|
|
|
|
>> "$PLEX_MEDIA_SERVER_CONFIG_DIR/Preferences.xml"
|
|
|
|
fi
|
2017-06-02 21:22:00 +00:00
|
|
|
|
|
|
|
export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}:$LD_LIBRARY_PATH"
|
|
|
|
export TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR}"
|
|
|
|
|
|
|
|
# Allow Plex group to write to tmpdir
|
2017-12-15 16:51:41 +00:00
|
|
|
chgrp $SGID "$TMPDIR"
|
2017-06-02 21:22:00 +00:00
|
|
|
chmod g+rwx "$TMPDIR"
|
|
|
|
|
|
|
|
PIDFILE="${PLEX_MEDIA_SERVER_CONFIG_DIR}/plexmediaserver.pid"
|
|
|
|
if [ -f "$PIDFILE" ]; then
|
|
|
|
rm -f "$PIDFILE"
|
|
|
|
fi
|
|
|
|
|
2017-08-27 15:46:44 +00:00
|
|
|
tail -F "$PLEX_MEDIA_SERVER_CONFIG_DIR/Logs/Plex Media Server.log" >/proc/1/fd/1 2>/dev/null &
|
|
|
|
|
2017-12-15 16:43:33 +00:00
|
|
|
exec su-exec -e "$PLEX_MEDIA_SERVER_HOME/Plex Media Server"
|