Plex Media Server - Linux installation packaging update - Issues

While a bit out of the norm,

Is there anyone interested helping me test the upcoming changes I have?

I don’t yet have permission from management but first want to see if there is community interest in double checking my work before it gets committed to production. If we find an issue, I can correct and repost in very short cycle time.

To share what it will look like: (please ignore the version of PMS used)

chuck@plexdev:~/git/output-all$ sudo dpkg -i plexmediaserver_1.18.5.2194-74214c250_amd64.deb
(Reading database ... 187293 files and directories currently installed.)
Preparing to unpack plexmediaserver_1.18.5.2194-74214c250_amd64.deb ...
PlexMediaServer install: Pre-installation Validation.
PlexMediaServer install: Warning:  Multiple override files found in "/etc/systemd/system/plexmediaserver.service.d". PMS may not function as expected.
PlexMediaServer install:           Files found are:  01.conf a file.conf local.conf one-dummy.conf override.conf two-dummy.conf
PlexMediaServer install:           Selected: "/etc/systemd/system/plexmediaserver.service.d/override.conf".
PlexMediaServer install: Warning:  "/var/lib/plexmediaserver/Library/Application Support" isn't owned by "chuck", UID: 1026.  Found "plex", UID: 998 instead. Continuing.
PlexMediaServer install: Pre-installation Validation complete.  Errors: 0, Warnings: 2
Unpacking plexmediaserver (1.18.5.2194-74214c250) over (1.18.5.2194-74214c250) ...
Setting up plexmediaserver (1.18.5.2194-74214c250) ...
PlexMediaServer install:  
PlexMediaServer install: Now installing based on:
PlexMediaServer install:   Installation Type:   Update
PlexMediaServer install:   Process Control:     Systemd
PlexMediaServer install:   Plex User:           chuck
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  (set in Preferences.xml)
PlexMediaServer install:   Lang Encoding:       en_US.UTF-8
PlexMediaServer install:   Config file used:    /etc/systemd/system/plexmediaserver.service.d/override.conf
PlexMediaServer install:   Transcoding HW:      Found
PlexMediaServer install:  
PlexMediaServer install: Completing final configuration.
PlexMediaServer install: PlexMediaServer-1.18.5.2194-74214c250 - Installation successful.  Errors: 0, Warnings: 2
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
chuck@plexdev:~/git/output-all$

Sure, I’d be down to help you test this.

I’m putting together the final CM commits now and preparing everything.
I will PM you a download link when I have one.

I’d also be interested in testing it.

Sorry for the delay in getting back to this. Work yanked me away for a bit. You’re right on in all regards. It is indeed an upstart system. Does that mean upgrades won’t be supported in the short term? I don’t know what the previous installations did, but I do see the plex media server service in the systemd path (/etc/systemd/system/plexmediaserver.service). The output surrounding what you asked is below.

Much appreciated!

jimmy@jester:~ cat /proc/1/comm init jimmy@jester:~ ls -la /sbin/init
lrwxrwxrwx 1 root root 7 May 19 2016 /sbin/init -> upstart

I’m afraid that I can’t support upstart. Ubuntu dropped all support for it in April 2016 when Ubuntu 15 was made obsolete.

All I can suggest now is a proper migration to either init or systemd.

Back in here as an update knocked my server offline and I had to go manually set LinuxContainer=1 in plexinstaller.log again.

systemd seems to think it is, based on https://github.com/systemd/systemd/blob/a859abf062cef1511e4879c4ee39c6036ebeaec8/src/basic/virt.c#L473 which is the container-detecting code for the systemd-detect-virt command. It looks like that still might not be exhaustive, but egrep -zi "^container=.+$" /proc/1/environ seems like it should pick up the ones that set the container variable without caring much what flavor of container it is.

I cannot use systemd-detect-virt as not all systems will have systemd. Some will have init.

What you should find in the *preinst script is:

  # Independently,  evaluate if in a LXC.  This is used later in installation to avoid UDEV trigger bug
  if [ "$(grep -i 'container=lxc' /proc/1/environ )" != "" ]; then
    LinuxContainer=1
  fi

  # Validate the override file contents if it exists
  if [ $HaveOverride -eq 1 ]; then

Which containerization do you use for the LXC ?
I can minimize the grep to be container= and accept that.

Yeah, I wasn’t intending to suggest that. Would be nice if you could, but I get that you’re trying to support a lot of different environments.

As above, using systemd-nspawn. /proc/1/environ still contains container=systemd-nspawn. My only hesitation with just looking for container= is that the systemd code implies that the var being empty is an indication that we are in fact not in a container, hence my suggestion for grep -zi '^container=.\+$' to avoid a false positive.

Thanks, I like that.

I’m playing here with it.

root@chuck-container:/# if [ "$(grep -zi '^container=.\+$' /proc/1/environ)" != "" ]; then echo Yes, this is valid; fi
bash: warning: command substitution: ignored null byte in input
Yes, this is valid
root@chuck-container:/# 

Looking good.

I might drop the -zi to make 100% certain.

Yeah, that seems sensible. I added the -z flag assuming it would be necessary to get whole variables with the file being NUL byte separated, but it does seem to work just fine without it.

Hi i need some help to update my plexmediaserver.
It’s a reasonable new installed Ubuntu 18.04.4 LTS 64 bit but the PlexMediaServer folder is moved from an older server.
it run on a Intel® Core™ i5-7400T CPU with hardware trancode enabled.

sudo dpkg -i plexmediaserver_1.18.8.2468-5d395aa9d_amd64.deb 
[sudo] password for plex: 
(Reading database ... 159641 files and directories currently installed.)
Preparing to unpack plexmediaserver_1.18.8.2468-5d395aa9d_amd64.deb ...
Removed /etc/systemd/system/multi-user.target.wants/plexmediaserver.service.
PlexMediaServer install: Pre-installation Validation.  
dpkg: error processing archive plexmediaserver_1.18.8.2468-5d395aa9d_amd64.deb (--install):
 new plexmediaserver package pre-installation script subprocess returned error exit status 2
Created symlink /etc/systemd/system/multi-user.target.wants/plexmediaserver.service → /lib/systemd/system/plexmediaserver.service.
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Errors were encountered while processing:
 plexmediaserver_1.18.8.2468-5d395aa9d_amd64.deb

I always get the error 2 in the Pre-installation Validation
it does not create an /tmp/plexinstall.log

/lib/systemd/system/plexmediaserver.service looks like

[Unit]
Description=Plex Media Server
After=network.target network-online.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
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 '\
PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )" \
PLEX_MEDIA_SERVER_INFO_DEVICE="PC" \
PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)" \
PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )" \
LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib \
"/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

and

/etc/systemd/system/multi-user.target.wants/plexmediaserver.service looks like

[Unit]
Description=Plex Media Server
After=network.target network-online.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
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 '\
PLEX_MEDIA_SERVER_INFO_VENDOR="$(grep ^NAME= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )" \
PLEX_MEDIA_SERVER_INFO_DEVICE="PC" \
PLEX_MEDIA_SERVER_INFO_MODEL="$(uname -m)" \
PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION="$(grep ^VERSION= /etc/os-release | awk -F= "{print \\$2}" | tr -d \\" )" \
LD_LIBRARY_PATH=/usr/lib/plexmediaserver/lib \
"/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

Any clue on what i need to do so i can update my plexmediaserver ?

Do you have a service override in place?

/etc/systemd/system/plexmediaserver.service.d/override.conf

No, do i need to create one ?
do I need to do it manually or ?

No, you don’t need one. I’m trying to understand where the error status “2” is coming from.

Do have any IPA services running (e.g. LDAP) ?

If you’d like, we can extract the modules from the DEB file and run it manually to see where it’s causing problems. That will also help me to improve the packaging.

I don’t think i have some IPA service running but I am not sure
I will gladly run it manually if it can help, Just let me know what i need to do.

Do this in a terminal window

  1. Create a temporary directory for this
  2. Copy the DEB file into it
  3. cd tempory-directory (if needed)
  4. ar x plexmediaserver*.deb
  5. ls -la (you should now see the control.tar.gz
  6. tar xf control.tar.gz
  7. ls -la (now you’ will see the preinst, postinst and other package routines were extracted.
  8. sudo ./preinst

This manual invocation of the preinst module just as occurs during normal installation.
It should produce an error to the console.

Please copy/paste it here.

when i run sudo ./preinst

plex@plex:~/Desktop/Plex$ sudo ./preinst
PlexMediaServer install: Pre-installation Validation.  
plex@plex:~/Desktop/Plex$ 

that’s it

Interesting. I saw the same behavior last evening with a degenerate case.

In that case,

  1. getent of user plex failed completely (no plex in/etc/passwd)
  2. The UID/GID assigned to /var/lib/plexmediaserver were random (from old install)
  3. The permissions of /var/lib/plexmediaserver were 777 for everything. below it.

I would like you to test in the same regard:

  1. getent passwd plex
  2. getent group plex
  3. ls -la /var/lib/plexmediaserver

Let me know what those report (copy/paste works well here)

plex@plex:~/Desktop/Plex$ getent passwd plex
plex:x:1000:1000:plex,,,:/home/plex:/bin/bash
plex@plex:~/Desktop/Plex$ getent group plex
plex:x:1000:
plex@plex:~/Desktop/Plex$ ls -la /var/lib/plexmediaserver
total 20
drwxr-xr-x  5 plex plex  4096 May 15  2016 .
drwxr-xr-x 85 plex plex  4096 Feb 28 22:47 ..
drwxrwxrwx  3 1024 users 4096 Jan 31  2014 Library
drwxr-xr-x  3 1024 users 4096 Mar 25  2014 .python-eggs
drwx------  2 1024 users 4096 May 15  2016 .ssh
plex@plex:~/Desktop/Plex$