Upgrade to 1.19.1 removes /usr/sbin/start_pms

Hi,

I just tried to upgrade Plex on my Ubuntu server to plexmediaserver_1.19.1.2621-b249be3b0_amd64.deb. After upgrading I tried to run ‘sudo start plexmediaserver’ and this did not do anything (I checked process tree etc.)

I did ‘tail /var/log/upstart/plexmediaserver.log’ and saw:
start-stop-daemon: unable to stat /usr/sbin/start_pms (No such file or directory)
start-stop-daemon: unable to stat /usr/sbin/start_pms (No such file or directory)
start-stop-daemon: unable to stat /usr/sbin/start_pms (No such file or directory)
start-stop-daemon: unable to stat /usr/sbin/start_pms (No such file or directory)

I double checked by running both of these:

  1. dpkg -c plexmediaserver_1.19.1.2621-b249be3b0_amd64.deb | egrep pms
  2. dpkg -c plexmediaserver_1.18.9.2571-e106a8a91_amd64.deb | egrep pms

And running 2) gave me expected output:
-rwxr-xr-x root/root 1697 2020-03-24 22:27 ./usr/sbin/start_pms

So I have now downgraded to 1.18.9 and my plex server is working fine again.

Can I request that start_pms be added back to the dpkg?

Thanks

start_pms was removed because /etc/init.d/plexmediaserver was completed to fully contain all the functionality of /usr/sbin/start_pms. That made start_pms which was previously called by /etc/init.d/plexmediaserver redundant and no longer needed.

If you wish to have /usr/sbin/start_pms, all you need do is create it to call /etc/init.d/plexmediaserver start and launch PMS as the service it should be.

It will use all the same values from /etc/default/plexmediaserver

Discussion thread is here:

We did find one timing issue with it which I’ve corrected and is coming as a hotfix.

Ah interesting!

I had a quick look and the dpkg does not contain /etc/init.d/plexmediaserver:

$ dpkg -c plexmediaserver_1.19.1.2621-b249be3b0_amd64.deb | egrep etc

-rw-r--r-- root/root       452 2020-04-03 20:11 ./usr/lib/plexmediaserver/Resources/Python/lib/python2.7/lib2to3/fixes/fix_getcwdu.py
-rw-r--r-- root/root        75 2020-04-03 20:11 ./usr/lib/plexmediaserver/Resources/Python/lib/python2.7/ctypes/macholib/fetch_macholib.bat
-rwxr-xr-x root/root        84 2020-04-03 20:11 ./usr/lib/plexmediaserver/Resources/Python/lib/python2.7/ctypes/macholib/fetch_macholib
drwxr-xr-x root/root         0 2020-04-03 20:51 ./etc/
drwxr-xr-x root/root         0 2020-04-03 20:51 ./etc/apt/
drwxr-xr-x root/root         0 2020-04-03 20:51 ./etc/apt/sources.list.d/
-rw-r--r-- root/root       226 2020-04-03 20:51 ./etc/apt/sources.list.d/plexmediaserver.list

$

Correct!

I include plexmediaserver.service and plexmediaserver.init separately with the program code.

After I’ve determined the control process type, I push those files to their correct location.

I’m making some changes to the init script now (user request).

You might want to join us over here?

What about in Docker where we don’t include either of plexmediaserver.service or plexmediaserver.init?

I currently copied the old start_pms to set the right variables but that doesn’t sounds like a long term plan :smiley:

Docker (svscan, binhex, and tini) are left alone to use their start mechanisms as they are in control. The installer performs no checks when any of these three are detected because they are in control of the runtime environment.

LXC’s (which are init or systemd based) use what I already provide.

Any other container environment is deemed custom.

I do provide for everyone, in /usr/lib/plexmediaserver/lib,

plexmediaserver.service - Backup copy of the systemd service
plexmediaserver.default, - Base template of /etc/default/plexmediaserver
plexmediaserver.init - Backup copy of /etc/init.d/plexmediaserver

These are provided for use as anyone deems appropriate post installation.

If these are going to be used, I suggest the use of symbolic links.
Symlinks will allow me to freely update as PMS evolves without anyone needing to worry.

My goal is to make it as easy as possible to run PMS in just about any way which can be imagined, providing a bit of structure, with a touch of validation, in order to save hours of head-banging against the keyboard (yes I’ve been there too)

1 Like

Thanks for your reply. So I got some time today to dig around a bit more.

I re-install 1.19.1:

$ sudo dpkg -i plexmediaserver_1.19.1.2621-b249be3b0_amd64.deb

(Reading database ... 67875 files and directories currently installed.)
Preparing to replace plexmediaserver 1.18.9.2571-e106a8a91 (using plexmediaserver_1.19.1.2621-b249be3b0_amd64.deb) ...
stop: Unknown instance: 
PlexMediaServer install: Pre-installation Validation.
PlexMediaServer install: Pre-installation Validation complete.
Unpacking replacement plexmediaserver ...
Setting up plexmediaserver (1.19.1.2621-b249be3b0) ...
PlexMediaServer install: PlexMediaServer-1.19.1.2621-b249be3b0 - Installation starting.
PlexMediaServer install: 
PlexMediaServer install: Now installing based on:
PlexMediaServer install:   Installation Type:   Update
PlexMediaServer install:   Process Control:     init
PlexMediaServer install:   Plex User:           plex
PlexMediaServer install:   Plex Group:          plex
PlexMediaServer install:   Video Group:         video
PlexMediaServer install:   Metadata Dir:        /var/lib/plexmediaserver/Library/Application Support
PlexMediaServer install:   Temp Directory:      /tmp 
PlexMediaServer install:   Lang Encoding:       en_US.UTF-8
PlexMediaServer install:   Config file used:    /etc/default/plexmediaserver
PlexMediaServer install:   Transcoding HW:      Not found
PlexMediaServer install: 
PlexMediaServer install: Completing final configuration.
 System start/stop links for /etc/init.d/plexmediaserver already exist.
PlexMediaServer install: PlexMediaServer-1.19.1.2621-b249be3b0 - Installation successful.
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

$ diff /etc/init.d/plexmediaserver /usr/lib/plexmediaserver/lib/plexmediaserver.init
$ #no diff was reported

This means that /etc/init.d/plexmediaserver was correctly replaced. All good. My initial understanding was incorrect!

However running sudo /etc/init.d/plexmediaserver start still didn’t work despite repeated attempts. So I dug around to debug /etc/init.d/plexmediaserver and identified the issue at this line in the file:
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}/Library/Application Support"

$HOME here is getting evaluated too early - before we’ve called su to switch the user over to
$PLEX_MEDIA_SERVER_USER.

I was able to successfully start the server after I replaced that line with:
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/var/lib/plexmediaserver/Library/Application Support"

So I guess this looks like a bug that should be fixed in that script?

I had a quick look at /etc/init.d/plexmediaserver.prev since it was stored during package update and I see that PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR is not set anywhere in that script. In that original code I see the line su -l $PLEX_MEDIA_SERVER_USER -s /bin/sh -c "/usr/sbin/start_pms &" >/dev/null 2>&1 so I assume start_pms would have created/evaluated that variable - in which case it would evaluate correctly since su had already been called.
`

You’ll see the update shortly. I’ll post here what’s coming if you / anyone wants to see it.

This is the problem I corrected.

There was a timing problem.

  1. init runs as root
  2. /etc/init.d/plexmediaserver is invoked as root
  3. ${HOME} gets root home :man_facepalming:
  4. PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR pointed off in La-La land.

I fixed that.

chuckpa-final-plexmediaserver-init-v-1-6.tar.gz (2.2 KB)

Thanks. Had a quick look at the tar.gz and that looks like it’ll work. I’m not going to test it - I’ll just wait for the next release. I think this solves my problem so I’ll mark this as solved :slight_smile:

what? you’re going to trust me? :scream: lol

So if I want to continue using the newest builds, and step away from using start_pms, like I have been for years, what are the steps I need to take to resolve?

All you need do is:

  1. Customize /etc/default/plexmediaserver to represent your desired runtime configuration

  2. if you don’t want it to start automatically at reboot, remove the /etc/rcX.d/S*plexmediaserver links

  3. Manually invoke /etc/init.d/plexmediaserver {start|stop|restart|status}

Now that start_pms has been removed from the manifest, if you want to put it back manually, that’s up to you. Maintenance of it will be your responsibility. I will no longer support it.

Cool, everything looks good but I have noticed it isn’t starting automatically. Any insight as to why when I run it manually I get the following?

~$ /etc/init.d/plexmediaserver status
-bash: /etc/init.d/plexmediaserver: No such file or directory

:confused:

That’s not right.

cat /proc/1/comm for me please ?
sudo cat /proc/1/environ as well ?
Distro & Version ?

Here ya go, gonna mask my username and host to X’s cause I’m weird like that - :slight_smile:

XX@XX:~$ cat /proc/1/comm
systemd

XXi@XX:~$ sudo cat /proc/1/environ
HOME=/init=/sbin/initNETWORK_SKIP_ENSLAVED=TERM=linuxBOOT_IMAGE=/boot/vmlinuz-5.6.3-050603-genericdrop_caps=PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binPWD=/rootmnt=/root

XX@XX:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 19.10
Release: 19.10
Codename: eoan

If I rollback to 1.18.9.2578 everything works without issue once again.

Thanks for the help Chuck.

That’s not right. It has never failed to detect Init on Ubuntu.
I have Ubuntu on my desktop (19.10 at present).
I have all the supported Ubuntu and Debian versions in VM.

Which actual 1.19.1 DEB did you install ?

I’ll give you the proper /et/init.d/plexmediaserver. I’m more concerned with why it went sideways at this point.

here are 3 files.

  1. plexmediaserver.preinstall
  2. plexmediaserver.init (for /etc/init.d/plexmediaserver)
  3. plexmediaserver.default (for /etc/default/plexmediaserver)

As root, please run preinst. show me the contents of /tmp/plexinstaller.log ?

plexmediaserver_1.19.1.2645-ccb6eb67e_amd64.deb

To confirm what should be seen - readlink /sbin/init
Please let me know what you get.

If it returns what I show here, it’s not init anymore, it’s systemd.

[chuck@lizum /tmp.297]$ which init
/sbin/init
[chuck@lizum /tmp.298]$ readlink /sbin/init
/lib/systemd/systemd
[chuck@lizum /tmp.299]$