The logic is still there (in my example). It just has to happen after the first PLEX_MEDIA_SERVER_USER export, and before the PLEX_USER_HOME logic. So you are essentially only moving it out from the start block, together with the initial exports.
You have getent ?
e.g.
getent passwd "$PLEX_USER"
Yes, but you have to “parse” the output (i.e. awk, cut, or similar). That’s why I suggested the eval route. In the end it does not really matter that much.
I need getent anyway for IPA environments. This was a big part of 1.19.1 packaging upgrade.
I had to harden for non-POSIX environments as well as support those IPA (LDAP, etc).
Something like this, then;
--- plexmediaserver.old 2020-04-02 19:33:58.639142381 +0200
+++ plexmediaserver.new 2020-04-02 19:36:13.583042391 +0200
@@ -20,11 +20,16 @@
# 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
-export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}/Library/Application Support"
+PLEX_USER_HOME=`getent passwd ${PLEX_MEDIA_SERVER_USER} | awk -F: '{print $6}'`
+export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${PLEX_USER_HOME}/Library/Application Support"
# Read configuration variable file if it is present
[ -r /etc/default/plexmediaserver ] && . /etc/default/plexmediaserver
@@ -43,11 +48,6 @@
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"
that’s where I’m at now too.
I’m also including the error handling so it doesn’t degenerate to null strings or “UNKNOWN” and crash if the username isn’t defined. I’ll reject the change if the username specified isn’t legit.
That sounds like a plan (-:
Thanks VERY much for working with me on this. I put a lot of effort into recreating all this support. I want it perfect so I can move on to QNAP (which needs some love too)
I will reply back here in a bit after I’ve written and tested
No problem!
I can confirm that the above fix makes 1.19.1.2589 work for me (just tested).
I am going to apply a nice big
to this.
If you look at the preinstaller /var/lib/dpkg/info/plexmediaserver.preinst,
you’ll see how I have my own set of default variables I start with.
I then update them after validating the given input.
I’m going to use the same coding technique here.
As I come through PLEX_USER / PLEX_MEDIA_SERVER_USER , which get their “default” home directories…
… and can be superseded by PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR
I’ll collect it up coming through those couple variables then build the final launch environment right before perform the su. By doing this, I won’t allow any bad values to get through and leave you hanging.
PlexUser and PlexAppSuppDir will be the two I have defined at this point.
Any further requests? 
Looks similar to issues I was having when upgrading from 1.18.6.x to 1.19.1.x.
Have reverted back to my older version and will try again once a fix is in, or can you share the whole start script?
Thx.
There is a simple change.
Go into /etc/init.d/plexmediaserver
See where it uses
export PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="${HOME}/Library/Application Support"
Resolve that manually for now to point to truth.
I’ve made all the corrections locally but this will get you running now.
I have updated it. Initial testing looks good but it needs more testing.
I’ll give it here as the full replacement to those who wish it.
Didn’t work, noticed this when installing tagt the metadata oath is wrong, is that the same issue? Sorry Linux newbie.
When installing - plexmediaserver_1.18.3.2129-41af4e729_amd64.deb*
PlexMediaServer install: Now installing based on:
PlexMediaServer install: Process Control: Init
PlexMediaServer install: Plex User: plex
PlexMediaServer install: Plex Group: plex
PlexMediaServer install: Video Group: video
PlexMediaServer install: Metadata Dir: /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: HW transcoding: Found
PlexMediaServer install:
PlexMediaServer install: Completing final configuration.
When installing - plexmediaserver_1.19.1.2589-2de7f3266_amd64.deb
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: Found
PlexMediaServer install:
Would you mind creating a new thread for your issue?
The issue being worked here is strictly /etc/init.d/plexmediaserver (the service script).
What you appear to show me is a parsing error / problem with reading /etc/default/plexmediaserver.
In your new thread (which I’d like you to ping me in), Please also include your /etc/default/plexmediaserver and the contents of /tmp/plexinstaller.log (which will tell me everything the installer had to work with.
Also please tell me as much about the environment as you can.
Distro, container or not, etc. It helps me to know what we’re working with.
I’d also be interested in seeing if there are any warnings, errors, or other output from the dpkg session.
To all reading here experiencing the $HOME variable timing problem
I have done as much testing as I can here in VM. It looks ready for a broader test base.
I very much like input about how everyone wants some known error conditions handled and what to do, if anything, with the system logging of these errors.
What I’ve done:
- Using the same variable management technique as
plexmediaserver.preinst, I read the variables given; perform rudimentary test on the critical ones.
a. Username exists (Supports PLEX_USER now as well)
b. Given AppSuppDir exists
c. TempDir exists (Supports TEMPDIR, TMPDIR, and TMP forms as well now)
d. MaxPluginProcs & MaxStackSize must be a legitimate digit value (if given) - While validating, I transform the given values into their “will be” state for when PMS does launch as the given user (this was my oversight).
- Just prior to
su - execlaunch, I export the shell variables back into the environment variables.
Here’s the candidate replacement for /etc/init.d/plexmediaserver
Please notice I have changed the name so there can be no confusing it with the production version.
Feedback would be greatly appreciated. I would very much like to know I’ve solved the problem fully before closing the bug report I’ve opened for this. I don’t want anyone to endure this again.
To all reading here.
I worked with @discosrule .
I corrected most of the problems with his system.
- It is Ubuntu 14 and the
serviceprogram itself has issues. (primary concern). - PMS 1.19.1, with updated. The
/etc/init.d/plexmediaserverscript (my ver 1.5) is running flawlessly now on his system (manually installed) in spite ofservicemisbehaving.
I welcome input from others who’ve tried it.
upgraded from 1.18.9 => 1.19.1, replaced the init-script and restarted 1.19.1.
works for me.
thx!
I run Plex on FreeNAS, this morning did the usual, pkg upgrade on plex jail but after service -R plex never came back.
After a short conversation with Google I ended up here, but unfortunately after replacing the script my plex did not come back to life.
Any help much appreciated.
This thread focuses on Debian/Ubuntu Linux systems (.DEB) installation file.
FreeNAS is FreeBSD.
Also, you have a Jail situation. This is everything else.
This script won’t be of help to you at al.