Upgraded PMS from 1.18.6.2348 to 1.19.1.2589. That changed some stuff in regards of the init.d-script, and in turn, the “PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR” variable. Previously this was set to “/var/lib/plexmediaserver/Library/Application Support”, while now being set to “/usr/lib/plexmediaserver/Library/Application Support” (“var” versus “usr”).
Fixed that by moving the old folder, to where it now expects it to be.
PMS starts fine, however all of the libraries are gone, and many settings. One example being “Network -> LAN Networks”, which is present with a value in the Preferences.xml file (“LanNetworksBandwidth”).
I’m suspecting that it does not actually read/use that folder after all.
My setup runs in an LXC container, so there is no systemd (only init).
Even though irrelevant, the content of “/etc/systemd/system/plexmediaserver.service” is pasted below. Keep in mind that this file has not changed since September 2019, so the upgrade did not alter this.
[Unit]
Description=Plex Media Server for Linux
After=network.target
[Service]
Environment="PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR=/var/lib/plexmediaserver/Library/Application Support"
Environment=PLEX_MEDIA_SERVER_HOME=/usr/lib/plexmediaserver
Environment=PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS=6
Environment=PLEX_MEDIA_SERVER_TMPDIR=/tmp
Environment=LD_LIBRARY_PATH=/usr/lib/plexmediaserver
ExecStartPre=/bin/sh -c '/usr/bin/test -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" || /bin/mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}"'
ExecStart=/bin/sh -c '/usr/lib/plexmediaserver/Plex\ Media\ Server'
Type=simple
User=plex
Group=plex
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3
[Install]
WantedBy=multi-user.target
/etc/init.d/plexmediaserver when running 1.19.1.2589 (that does not work);
#!/bin/sh
### BEGIN INIT INFO
# Provides: plexmediaserver
# Required-Start: $remote_fs $syslog $networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Plex Media Server
# Description: Plex Media Server for Linux,
# More information at http://www.plexapp.com
# Author: Plex Packaging team
# Version: 1.4
### END INIT INFO
# Set Crash Reporting identification variables
export PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= '{print $2}' | tr -d \" )"
export PLEX_MEDIA_SERVER_INFO_DEVICE="PC"
export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= '{print $2}' | tr -d \" )"
# Change these parameters in /etc/default/plexmediaserver
export PLEX_MEDIA_SERVER_USER=plex
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"
echo "LOL: $(date)" > /tmp/testlol
# Read configuration variable file if it is present
[ -r /etc/default/plexmediaserver ] && . /etc/default/plexmediaserver
Running=$(ps -ef | grep 'Plex Media Server'| grep -v grep | wc -l)
case "$1" in
start)
if [ $Running -gt 0 ]; then
echo "Plex is already running."
exit 0
fi
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
# Silently support PLEX_USER if provided as override
if [ "$PLEX_USER" != "" ]; then
export PLEX_MEDIA_SERVER_USER="$PLEX_USER"
fi
# Create AppSuppDir if not present
if [ ! -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]; then
mkdir -p "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR"
if [ $? -eq 0 ]; then
chown "${PLEX_MEDIA_SERVER_USER}"."${PLEX_MEDIA_SERVER_USER}" "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR"
else
echo "ERROR: Couldn't create \"$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR\" "
exit 1
fi
fi
export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}/lib"
export TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR}"
ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE
# Add sleep - for those who launch with this script
echo "Starting Plex Media Server. "
su -m $PLEX_MEDIA_SERVER_USER -s /bin/sh -c "exec ${PLEX_MEDIA_SERVER_HOME}/Plex\ Media\ Server &" >/dev/null 2>&1
sleep 3
;;
stop)
if [ $Running -eq 0 ]; then
echo "Plex Media Server is not running."
exit 0
fi
echo "Shutting down Plex Media Server: "
# Ask nicely
pids="$(ps -ef | grep 'Plex Media Server' | grep -v grep | awk '{print $2}')"
kill -15 $pids
sleep 5
# Stuck
pids="$(ps -ef | grep /usr/lib/plexmediaserver | grep -v grep | awk '{print $2}')"
if [ "$pids" != "" ]; then
kill -9 $pids
sleep 2
fi
;;
restart)
$0 stop
sleep 5
$0 start
;;
status)
if [ $Running -gt 0 ]; then
echo "Plex Media Server is running."
else
echo "Plex Media Server is stopped."
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
/etc/init.d/plexmediaserver when running 1.18.6.2348 (that does work);
#!/bin/sh
### BEGIN INIT INFO
# Provides: plexmediaserver
# Required-Start: $remote_fs $syslog $networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Plex Media Server
# Description: Plex Media Server for Linux,
# More information at http://www.plexapp.com
# Author: Plex Packaging team
# Version: 1.3
### END INIT INFO
# Read configuration variable file if it is present
[ -r /etc/default/plexmediaserver ] && . /etc/default/plexmediaserver
IsRunning=$(ps -ef | grep 'Plex Media Server'| grep -v grep | wc -l)
case "$1" in
start)
if [ $IsRunning -gt 0 ]; then
echo "Plex is already running."
exit 0
fi
echo "Starting Plex Media Server. "
su -l $PLEX_MEDIA_SERVER_USER -s /bin/sh -c "/usr/sbin/start_pms &" >/dev/null 2>&1
sleep 3
;;
stop)
if [ $IsRunning -eq 0 ]; then
echo "Plex Media Server is not running."
exit 0
fi
echo "Shutting down Plex Media Server: "
# Ask nicely
pids="$(ps -ef | grep 'Plex Media Server' | grep -v grep | awk '{print $2}')"
kill -15 $pids
sleep 5
# Stuck
pids="$(ps -ef | grep /usr/lib/plexmediaserver | grep -v grep | awk '{print $2}')"
if [ "$pids" != "" ]; then
kill -9 $pids
sleep 2
fi
;;
restart)
$0 stop
sleep 5
$0 start
;;
status)
if [ $IsRunning -gt 0 ]; then
echo "Plex Media Server is running."
else
echo "Plex Media Server is stopped."
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0
Content of /usr/sbin/start_pms when running 1.18.16.2348;
#!/bin/sh
#
# Plex Media Server - Manual start script.
#
# Set Crash Reporting identification variables
export PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release|awk -F= '{print $2}'|tr -d \" )"
export PLEX_MEDIA_SERVER_INFO_DEVICE="PC"
export PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)"
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release|awk -F= '{print $2}'|tr -d \" )"
# Change these parameters in /etc/default/plexmediaserver
export PLEX_MEDIA_SERVER_USER=plex
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
# Silently support PLEX_USER if provided as override
if [ "$PLEX_USER" != "" ]; then
export PLEX_MEDIA_SERVER_USER="$PLEX_USER"
fi
# Create AppSuppDir if not present
if [ ! -d "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR" ]; then
mkdir -p "$PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR"
if [ ! $? -eq 0 ]; then
echo "ERROR: Couldn't create $PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR "
exit 1
fi
fi
export LD_LIBRARY_PATH="${PLEX_MEDIA_SERVER_HOME}/lib":"${PLEX_MEDIA_SERVER_HOME}"
export TMPDIR="${PLEX_MEDIA_SERVER_TMPDIR}"
ulimit -s $PLEX_MEDIA_SERVER_MAX_STACK_SIZE
# Add sleep - for those who launch with this script
sleep 3
(cd /usr/lib/plexmediaserver; ./Plex\ Media\ Server)
Since “/var/lib/plexmediaserver/” doesn’t seem to be present in the init.d-file for 1.18.6.2348, but PMS successfully uses the content of “/var/lib/plexmediaserver” regardless, I’m going to assume that there is some hardcoded path or similar, somewhere else in the Plex files, that is changed between 1.18.6.2348 and 1.19.1.2589.
It is removed, as the logic contained within it, is moved into the init.d-script itself (as you can see by the content of those files that I posted in my previous comment).
Well that’s no fun for my build as I use the start_pms script to run plexmediaserver on Slackware LXC. I copied the script from my previous build and i’m able to run 1.19.1.2589.
Please help me figure out what doesn’t work for you with regard to /etc/init.d/plexmediaserver in 1.18.9 ?
What I’ve done is taken out start_pms script because /etc/init.d/plexmediaserver is now the full functionality of both in one. start_pms was redundant.
start_pms was a fully manual-start script from long long ago. /etc/init.d/plexmediaserver is the full init-based service control. Calling /etc/init.d/plexmediaserver manually has the same result.
Did I omit something?
This should be nothing more than shifting the invocation to /etc/init.d/plexmediaserver start and the variables in /etc/defaults/PlexMediaServer. (proper SYSV style)
You are right that there should be no difference between the "/etc/init.d/plexmediaserver + start_pms" -combo (in 1.18) and the new /etc/init.d/plexmediaserver in 1.19 (that has the logic of start_pms). I just assumed that this was the issue, before I actually looked at the content within the init.d-script of 1.18.
Where does /var/lib/plexmediaserver come into the picture? This was the library path before, and works in 1.18, even though all paths in both /etc/init.d/plexmediaserver and start_pms points to /usr/lib/plexmediaserver. I can see that it’s present in the /etc/systemd/system/plexmediaserver.service file, but that is never used when using init (which is the case for me).
The default HOME directory for user plex is /var/lib/plexmediaserver.
I use this as the foundation then supersede using /etc/default/plexmediaserver if you’ve customized and moved the APPLICATION_SUPPORT_DIR elsewhere (due to space)
I run it in LXC-container, with only init (no systemd). It’s run as the user plex, that has /var/lib/plexmediaserver set as the home folder. I’ve never specified any overrides for path in /etc/default/plexmediaserver. In 1.18 it works, in 1.19 it does not work. If I upgrade to 1.19, it stops working. If I downgrade to 1.18, it immediately starts working. This is repeatable/reproducible.
I’m pretty sure that combining /etc/init.d/plexmediaserver and start_pms broke it. The variables that you export in start_pms is available when you launch PMS with ./Plex\ Media\ Server. However, when you launch it via the su command, it does not work;
The above mimics what you essentially do with the init.d-script in 1.19, which clearly does not seem to work as intended (i.e. the PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR variable is never available in that shell).
The -m option is what does preserve the environment.
From man su:
-m, -p, --preserve-environment
Preserve the entire environment, i.e. it does not set HOME, SHELL, USER nor LOG‐
NAME. This option is ignored if the option --login is specified.
If this isn’t working for you, we need to dig deeper.
However, I found the real culprit. In 1.18 you launch start_pms as the plex user, causing export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}/Library/Application Support" to become /var/lib/plexmediaserver/Library/Application Support.
In the init script of 1.19, you run the export in the init-file (which is run as the root user), causing PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR to become /root/Library/Application Support.
This is also confirmed by the fact that I now have the /root/Library/Application Support folder (created just after I did my first upgrade to 1.19).
I maintain the floating nature of the control mechanism by evaluating just prior to launch.
If all are agreed, I’ll modify /etc/init.d/plexmediaserver and issue the patch here.
Concurrently, I will make the change to the source package scripts and push them up for inclusion in the next PMS release.
# Change these parameters in /etc/default/plexmediaserver
export PLEX_MEDIA_SERVER_USER=plex
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"
… with this;
# Change these parameters in /etc/default/plexmediaserver
export PLEX_MEDIA_SERVER_USER=plex
# Silently support PLEX_USER if provided as override
if [ "$PLEX_USER" != "" ]; then
export PLEX_MEDIA_SERVER_USER="$PLEX_USER"
fi
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
PLEX_USER_HOME=`eval echo "~${PLEX_MEDIA_SERVER_USER}"`
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${PLEX_USER_HOME}/Library/Application Support"
(and remove that PLEX_USER logic in the start-section)