Plex Media Server - Linux installation packaging update - Issues

Update:

I’ve been spending time looking through several distros. Handling this migration is going to be problematic.

I am contemplating the following logic:

  1. Look for “override.conf” and use if found
  2. else Look for “local.conf” and use if found.
  3. Error ff both local.conf and override.conf are found (clearly a known conflict)
  4. Print out informative “warning” if files other than the above two are found.

Additional discussion

I’ve talked it over with Engineering and they would like me to pull the value of the Transcoder Temp directory from the Preferences.xml and use it in favor of that which I find in the normal configuration with appropriate warnings should the two values differ. PMS will always use the value in the Preferences.xml over any value specified in the Service definition/override.

May I have input from all reading here?

@ChuckPa

For the first time in years, plex upgrade today did not silently mess up my config! Thanks!

I don’t understand what the problem is exactly. Just remove the check for anything in /etc/systemd and you’re good. The check serves no purpose, it breaks systemd compatibility. All filenames are valid, systemd determines the files it loads.

Might Debian be holding back a bit? This is important for me to understand first and foremost.

I dont think so, Debian 10 comes with systemd v241, latest stable is v244, not too far apart. And I have a hard time believing systemd would break backwards compatibility in this manner.

" If both conf files specify User = as a valid override for User=Plex , and they are different, which one takes residence? "

That’s what I meant with

Some guides even recommend using the priority-number-naming-scheme, e.g. <servicename>.d/10-concern.conf , 20-something.conf to determine the order they’re loaded in.

They’re loaded in alphabetic order. By prefixing filenames with numbers you make sure that higher numbers = higher priority = loaded later, i.e. they can override previous assignments to the directive. Note this is not a feature of systemd in particular, this works with almost all linux programs that can load several configuration files, as they all ignore filenames.

Look for “override.conf” and use if found

What do you mean with “use if found”? To be clear, Plex should not read these files. They are for systemd ONLY. Systemd determines which unit files to load, parses them and starts the service according to the configured directives.

both local.conf and override.conf are found (clearly a known conflict)

How is that a conflict? systemd doesn’t care about the file names at all, which they make clear in the systemd.unit manpage, which is the single source for ground truth systemd documentation. If distributions choose to break systemd compatibility by giving filenames semantics it is their fault and the system administrator has to make sure he follows his distributions rules (I’ve yet to see that though, maybe there are some really old versions that couldn’t handle anything other than that specific filename?). Packages do not need to concern themselves with this either way, because under no circumstances do they have any business in /etc/systemd. Only the administrator may choose to place unit overrides there and then he is the one who must follow the rules of systemd and his distribution.

Proof:

/etc/systemd/system/plexmediaserver.service.d $ ls
local.conf  override.conf
/etc/systemd/system/plexmediaserver.service.d $ sudo systemctl daemon-reload
/etc/systemd/system/plexmediaserver.service.d $ sudo systemctl restart plexmediaserver
/etc/systemd/system/plexmediaserver.service.d $ systemctl status plexmediaserver
● plexmediaserver.service - Plex Media Server
   Loaded: loaded (/lib/systemd/system/plexmediaserver.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/plexmediaserver.service.d
           └─local.conf, override.conf
   Active: active (running) since Tue 2020-02-11 16:56:08 CET; 14s ago

works just fine naming the files whatever. No such thing as a conflict between drop-in files.

I think there is some general confusion on how to approach package installation and service startup on linux here. I’ve never seen such an elaborate ‘installer’ come with any package. I understand you’re targetting several systems with this deb package, but it’s just not necessary to do anything out of the ordinary here. Place a service unit in /lib/systemd/system/, a sysvinit script in /etc/init.d/, create a system user/group in preinst and enable/start the service in postinst, that’s it. I would really appreciate if Plex would not try to do any magic nonsense, break long-established standards for ‘diagnostics’ sake and behave just like every other package.

1 Like

This installer is universal. It supports systemd and SYSV init and containers. It must read the local configuration to determine what the user already has in place and what must still be created. As set forth in the initial discussion in July of last year when first brought to the forums, please read the mission statement;

I will take exception to “Just remove the check for anything in /etc/systemd”.
Why am I only hearing of this objection now?

All the feedback I’ve had to date has been in favor of this amount of detail and checking.

I reviewed the code last night (again). I can and will accommodate changes which improve. I will not, however, nullify what has been done unless overwhelming feedback from the community is voiced. (I know you’re all following along)

HOWEVER,

  1. Linux isn’t meant for just those of us who like “hard core OS’s” anymore. Look at how far Ubuntu has deviated from “standard” yet it’s the #1 distro.

  2. I’m the one who has to support it here in the forums. I can’t count how many NOOB errors I’ve had to deal with.

  3. We all make config errors when setting things up. Isn’t it about time the software point such things out versus beating our heads against the desk trying to find out where we have a typo or bad permissions? How many wasted hours have we all spent trying to track such things down only to find that total PEBKAC moment?

  4. As I’m about to start my day supporting the forums, reviewing the ticket list, I already see several threads which are obvious user configuration problems and not “bugs”. Plex has enough of its own bugs, it doesn’t need the help from the community (lol).

Again,

  1. Work with me. Help me iterate into the absolute best solution for everyone
  2. Don’t tell me how to support my product this late in the game as it won’t happen.
1 Like

It supports systemd and SYSV init

As do hundreds of debian packages.

and containers

I haven’t had a look at your docker containers but I’m not sure why you bother installing the debian package there at all. You can save a lot of complexity by creating the user in the Dockerfile directly with RUN useradd and then just COPYing the PMS files.

It must read the local configuration to determine what the user already has in place and what must still be created

I don’t understand this one. What exactly, in your opinion, does the preinst/postinst script have to read from my configuration? It should create the plex user if it doesn’t exist and add the video/render groups, create the /var directory and chown it to plex and finally enable and start the service.

The installer can’t rely on anything from my configuration, because I can choose to install the package first, then put unit overrides in place or the other way around. In fact, I can change the systemd configuration any time without re-running the package installer, and that’s how it’s supposed to work.

Why am I only hearing of this objection now?

I’m not usually reading the Plex forums and the 1.18.5 update was the first time I encountered the installer script. I didn’t report this bug for 1.18.5 because I thought maybe the installer is doing some first-time sanity check to make sure there are no leftover files from previous installations, which would have been fine with me.

  1. Look at how far Ubuntu has deviated from “standard” yet it’s the #1 distro.

No such thing as standard when it comes to linux distributions. There’s the systemd upstream defining how systemd works. When you want to support systemd you read systemd documentation and create your service file accordingly. Neither Debian nor Ubuntu are deviating significantly from how systemd is defined to work.

  1. I’m the one who has to support it here in the forums. I can’t count how many NOOB errors I’ve had to deal with.
  1. I already see several threads which are obvious user configuration problems

I understand dealing with users of vastly varying expertise is hard, but I fail to see how failing the install when arbitrary files are present in /etc/systemd/system/plexmediaserver.service.d helps.
As I have demonstrated above, arbitrary drop-in filenames work just fine, so I don’t get the point of this check. Please help me understand what you are trying to do.

What are “noobs” doing in the systemd configuration anyway? Is it mostly the USE_SYSLOG thing? systemd overrides are more of an advanced topic and users shouldn’t be pointed to go there really. Advanced users will know when they have to go there.

  1. We all make config errors when setting things up. Isn’t it about time the software point such things out versus beating our heads against the desk trying to find out where we have a typo or bad permissions?

Plex should thoroughly validate its own configuration. Descriptive error messages are very welcome. I do however, not want Plex to parse and validate my systemd configuration, because that is only to be parsed and validated by systemd. Your installer script is clearly violating the systemd standard by refusing to work with completely valid systemd configurations.

Work with me.

I’m really trying to, I wouldn’t have written multiple lengthy posts otherwise, but I have already linked 5 independent pieces of documentation stating that arbitrary filenames can be used for unit overrides. And if you’re still not convinced that your script is wrong, then I don’t know if it’s possible.

Don’t tell me how to support my product this late in the game as it won’t happen.

I really only see this as a bug. From my perspective the Plex package isn’t installing even though it should install just fine. This is due to some faulty logic in the installer script.

1 Like

Hang on - The processor is 64-bit, the OS is the 64-bit version, the .deb is the 64-bit version.

I’ve been running Plex on this machine quite happily for the last 5 years - the only thing it’s not quite up to is transcoding 4K.

I ended up backing up my config, purging plexmediaserver and then reinstalling and moving my config back. All seems to be OK, lets hope the next upgrade goes as smoothly as the last 5 years :slight_smile:

Thanks for your help

I am hearing everything you’re saying and working it out in my head + on paper.

To answer your question: What does preinst / postinst have to read?

  1. It reads and validates all the tunable parameters and validates them so PMS will start. There are a lot of automated installations out there. Part of that process, which is the next step, is to create the configuration you setup in the override if this is a fresh installation (still under discussion). This is because we can’t pass values on GUI installs and passing via the command line is a P.I.T.A.

  2. The same is true of the transcoder temp directory. Can the assigned Plex user write to the transcoder temp directory?

  3. It makes certain there wasn’t a total PEBKAC (Yes, I’m trying to be nice here) and make sure things like the “User=” clause is actually a valid user with access to the AppSupportDir.

  4. It is also tasked with making sure the plex user (whatever it may be) is properly attached to the video group (/dev/dri) if hardware is found . I get a lot of those tickets. Now it reads and configures the plex user to be in the video group as defined by udev (if udev is installed). As primary example is how Ubuntu finally came around to use the render group for the drm. It threw a wrench in everyone’s installation and the packaging in use at that time. This new packaging avoids that. The worst case scenario is: Remove Package + Reinstall Package (to reconfigure the username. (don’t forget all the GUI-only users out there)

  5. It’s cleaning up a lot of the past “slam it in place and forget it” sins which lead to broken / half-half working installations.

With regard to “no standard”, I ask why, when you do systemctl edit <servicename> do you get /etc/systemd/system/<servicename>.service.d/override.conf if that’s not a standard they want? This what drove me to “override.conf”. If I’m wrong, please do correct me.

Regarding the strictness of the contents of the override directory, I have an idea which should work for all the variations out there. I welcome input on this. It’s easily enough changed that I can probably get it into the next PlexPass release.

  1. If both override.conf and local.conf exist, that’s clearly a contradiction and something is wrong – flag as error.

  2. If only override.conf or local.conf is found, use whichever is found.

  3. If anything else is found, issue an Info/Warning (nothing fatal) stating what it found but proceeding otherwise. The intent is solely to let you know it found a potential conflict.

  4. I will only parse local.conf or override.conf. It provides the targeted validation for customized configurations with the ability to backdoor out of it by simply using any other name.

Anything resolved here still needs Engineering approval but if this is what the community wants, I’ll fight for it like I always do.

Additionally, I have a correction to apply which is actually a small enhancement. In the reporting the packaging does, it currently shows the TEMP_DIR. Some users have opted to use the TranscoderTempDir preference in their Preferences.xml. Once I finish this issue, I’ll be adding that (an Engineering request). Adding the mechanism will likely lead to more info being available (such as the selected hardware transcoding device being reported).

EDIT: I forgot to mention that when Ubunt 16.04 came out, which was before I took over packaging, Engineering deprecated support for SYSV init. When PMS 1.15.0 came out, it was completely removed because the vast majority of installations did not have glibc 2.14.1 and they were all SYSV init based. In their eyes, the metrics didn’t warrant keeping it around so it was removed entirely. This packaging brings it all back. I’ve had to recreate it all from scratch so I expect that part to have bumps and surprisingly there haven’t been any reported so far.

“systemctl edit plexmediaserver” edits /etc/systemd/system/plexmediaserver.service.d/.#override.conf08f737a00a410696 or some close variant on CentOS 7.

Correct.

It creates the hidden override file while the service is being edited.
Once editing is complete and changes accepted, override.conf is the resultant name.

The temporary name seems to follow that of rsync naming conventions while files are being processed.

Just installed 1.18.6.2368 on 1 raspberry pi and 3 ubuntu 18.04 LTS systems. The three ubuntu’s are identical setups, 2 of the three installed fine and restarted PMS after installation. 1 of the 3 did NOT restart nor did the raspberry pi restart. All four systems were running PMS before the apt upgrade.

the plexinstaller.log for the two failing systems is attached.
plexinstaller.log (453 Bytes) plexinstaller (1).log (453 Bytes)

If you look at those files;

  • One detected a GPU card of some type at /dev/dri/renderD128 ( HaveHardware=1)
  • Neither were running ( Running=0) so they were not restarted.
  • PMS 1.18.5 and above respects the enabled state. It will no longer force enable it once having migrated to 1.18.5 (“11805”) or higher.
# Plex Media Server installation configuration info:  Tue Feb 11 16:11:25 PST 2020
Init=0
Systemd=1
LinuxContainer=0
NewInstall=0
HaveOverride=0
OverrideFile=""
PlexUser="plex"
PlexGroup="plex"
VideoGroup="video"
AppSuppDir="/var/lib/plexmediaserver/Library/Application Support"
PlexTempDir="/var/lib/plexmediaserver/tmp_transcoding"
LangEncoding="en_US.UTF-8"
ExistingVersion=11805
HaveHardware=1
NeedUser=0
NeedGroup=0
NeedVideo=0
Verbose=1
Running=0

What were the previous versions installed? It would help me a great deal to see all the installer log files

The other two logs are attached. I assure you all four machines had PMS running prior to the upgrade. Tautulli monitors all four and I received server down messages when the upgrades started. So if running is set to zero, then that is the bug. I believe they were all on 2308, is there a way I can confirm that somehow?

plexinstaller (2).log (453 Bytes) plexinstaller (3).log (454 Bytes)

Both 2 & 3 show it running.

I have one possible explanation. Did you install one of the earliest builds of 1.18.5 ?
If so, you might have been caught this one time.

As verification, you can install on top of itself again, with it running. It better come back to running state.

Here is what’s in the package script.

    # Re-start if was previously running or upgrading from pre-1.18.5
    if [ $Running -gt 0 ] || [ $ExistingVersion -lt 11805 ]; then

      # Restart PMS
      Output both "Starting Plex Media Server."
      systemctl start plexmediaserver
      if [ $? -ne 0 ]; then
        Output both "Installation successful but startup has failed.   Please see 'systemctl status plexmediaserver' for details. Error: " $?
        Output user "Additional assistance and support is available in our forums."
        Fail=1
      fi
    fi

You can also go to /var/lib/dpkg/info/plexmediaserver.postinst.
I have development code here so yours might be behind me.

“Output both” means it reports to your screen and to the system log.

Good day guys, I’m not sure if this is the right place to post, so if it’s incorrect please let me know and I’ll create a new post.

The latest update is not working. My system is Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-173-generic x86_64). I’m installing via apt and the plex repo. I’ve not had this issue before. The error I’m receiving is below. I checked and there is no install log in /tmp/. Any thoughts? I’ve not had any issues

The following packages will be upgraded:
plexmediaserver
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/86.5 MB of archives.
After this operation, 368 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database … 520142 files and directories currently installed.)
Preparing to unpack …/plexmediaserver_1.18.6.2368-97add474d_amd64.deb …
plexmediaserver stop/waiting
PlexMediaServer install: Pre-installation Validation.
PlexMediaServer install: Unsupported init/systemd hybrid control configuration.
dpkg: error processing archive /var/cache/apt/archives/plexmediaserver_1.18.6.2368-97add474d_amd64.deb (–unpack):
subprocess new pre-installation script returned error exit status 1
plexmediaserver start/running, process 4862
Processing triggers for libc-bin (2.23-0ubuntu11) …
Errors were encountered while processing:
/var/cache/apt/archives/plexmediaserver_1.18.6.2368-97add474d_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I know what it’s looking for

please perform

  1. cat /proc/1/comm
  2. It should show “init”
  3. now look at ls -la /sbin/init and let me know what it points to.

If it is the init program itself, you are an init based system and good to go
if it is systemd then you are systemd and also good to go.

If it finds neither of those two, e.g. it finds upstart, it will reject it as a hybrid.

Here is my code (if you comfortable with sh)

  # If this looks like init,  be careful of redirectioon
  elif [ "$(cat /proc/1/comm)" = "init" ]; then

    # Verify not a redirected init -> systemd
    if [ "$(readlink /sbin/init)" = "" ]; then
      Init=1
    elif [ $(readlink /sbin/init | grep -c systemd) -gt 0 ]; then
      Systemd=1
    else
      Output both "Unsupported init/systemd hybrid control configuration."
      exit 1
    fi

Just to add more issues to this thread, I get the following issue when installing:

Preparing to unpack .../plexmediaserver_1.18.6.2368-97add474d_amd64.deb ...
Removed /etc/systemd/system/multi-user.target.wants/plexmediaserver.service.
PlexMediaServer install: Pre-installation Validation.
PlexMediaServer install: Error: LC_ALL specifies non UTF-8 encoding
dpkg: error processing archive /var/cache/apt/archives/plexmediaserver_1.18.6.2368-97add474d_amd64.deb (--unpack):
new plexmediaserver package pre-installation script subprocess returned error exit status 1
Created symlink /etc/systemd/system/multi-user.target.wants/plexmediaserver.service → /lib/systemd/system/plexmediaserver.service.
Errors were encountered while processing:
/var/cache/apt/archives/plexmediaserver_1.18.6.2368-97add474d_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

My override.conf:

[Service]
Environment=LC_ALL=en_US.UTF-8
Environment=LANG=en_US.UTF-8

I’m confused… Note how the installer script says that LC_ALL does not use UTF-8, yet there it is in my override.conf…

(btw, override.conf was set this way to work around this issue: Local Media Assets: Metadata fails to load when there are unicode characters in the file path)

In this case, temporarily removing override.conf elsewhere and re-running the install works fine, after which I just move override.conf back in place and restart the service… but this is not a great solution long-term. Maybe the script has an issue checking that UTF-8 is used when it’s specified in the override.conf?

@legoguy

As a test, please apply quotes.

Environment="LC_ALL=en_US.UTF-8"

I did, but I actually think I found the source of the problem;

In your preinst script:

      if [ $( echo "OverrideLang" | grep UTF-8 | wc -l ) -eq 0 ]; then

Pretty sure if this line is reached it will never evaluate properly, because “OverrideLang” is a straight-up string.

1 Like

That’s why I asked you to test. I found that bug.
It’s fixed already and going through QA now.

As fixed:

    # Verify UTF-8 encoding specified if found
    OverrideLang="$(GetValue LC_ALL "$OverrideFile")"
    if [ "$OverrideLang" != "" ]; then
      if [ $(echo "$OverrideLang" | grep UTF-8 | wc -l) -eq 0 ]; then
        Output both "Error: LC_ALL specifies a non UTF-8 encoding: \"$OverrideLang\""
        Fail=1
        Errors=$((Errors + 1))
      else
        LangEncoding="$OverrideLang"
      fi
    fi
2 Likes

As FYI,
I have a bunch of small fixes coming through. The list is:

  1. Tolerance to NON-POSIX environments (spaces in user & group names , etc)
  2. Removing “ERROR” if more than one override file is fround. In order:
    a. If override.conf is found – uses it
    b. If local.conf is found – uses it (quasi-defacto standard observed in many how-tos’)
    c. Use first *.conf found
    d. Issue Warning if more than one *.conf is found but no longer fatal.
  3. Change reporting of TEMP_DIR to extract value found in Preferences.xml if present as it will supersede anything defined in any override.
  4. General cleanup of how I report / print output (less useless verbosity)
1 Like