Noticed a number of minor issues in the /usr/sbin/start_pms script. Here's the original script
#!/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"test -f /etc/default/plexmediaserver && . /etc/default/plexmediaserver
if [ ! -d “$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR” ]
then
mkdir -p "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
fiexport LD_LIBRARY_PATH="{PLEX_MEDIA_SERVER_HOME}" 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
(cd /usr/lib/plexmediaserver; ./Plex\ Media\ Server)
First off, the guide here strongly implies that you can just export variables and that will change how plex works. Not only does this guide need an update (and to perhaps include debian/ubuntu), but the script above will completely overwrite all of these variables. Here is a better alternative that actually utilizes the environment variables if the user has set them. This is posix-compliant and should work with any /bin/sh
# Setup default parameters # Either with environmental variables, or defaults if variables are unset 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:-"${HOME}/Library/Application Support"}Load any always-set defaults
test -f /etc/default/plexmediaserver && . /etc/default/plexmediaserver
Note that this only works if ./etc/default/plexmediaserver doesn't overwrite the environment values. The convention for /etc/default/* files is to be fully-commented out. Plex currently violates this convention, e.g. here's the default file:
# default script for Plex Media Serverthe number of plugins that can run at the same time
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE
PLEX_MEDIA_SERVER_MAX_STACK_SIZE=3000
where the mediaserver should store the transcodes
PLEX_MEDIA_SERVER_TMPDIR=/tmp
uncomment to set it to something else
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}/Library/Application\ Support"
the user that PMS should run as, defaults to ‘plex’
note that if you change this you might need to move
the Application Support directory to not lose your
media library
PLEX_MEDIA_SERVER_USER=plex
This is wrong - the entire file should be commented out by default, and then the user can change it if desired.
These two changes together allow stuff like this, wehre the user sets a variable and start_pms uses it.
$ PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=1 /usr/sbin/start_pms
Finally, the last line of the start_pms script says this:
(cd /usr/lib/plexmediaserver; ./Plex\ Media\ Server)
It should say this (if plex wanted to be fancy they could use exec to get rid of the now-useless current shell, but it's not a big deal)
(cd $PLEX_MEDIA_SERVER_HOME; ./Plex\ Media\ Server)