Install failure due to broken scripts in spec file and MigratePlexServerConfig.sh

Looks like the current install routine in the CentOS 6 x64 rpm is a complete dogs breakfast.

I have asked before that the spec file be fixed to cope with the selinux status, and it now looks like the RPM is barfing when it tries to restart systemd and doesn’t bother to check whether it is installed in the upgrade script.

When I tried to do an update today I got the following errors. This is just plain amateurish - did the devs actually test this ?

CentOS 6 does not have systemd installed (thank heavens). This is simple scripting stuff for kids and I seriously expect better from so called professional developers, especially when I PAY for a product.

[root@plex-server plex]# rpm -Uvh plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm
Preparing… ########################################### [100%]
Stopping PlexMediaServer: [ OK ]
Stopped PlexMediaServer[ OK ]
1:plexmediaserver ########################################### [100%]
/var/tmp/rpm-tmp.d0CRmD: line 21: systemctl: command not found
/var/tmp/rpm-tmp.d0CRmD: line 22: systemctl: command not found
/var/tmp/rpm-tmp.d0CRmD: line 26: systemctl: command not found
/usr/lib/plexmediaserver/MigratePlexServerConfig.sh: line 349: systemctl: command not found
/usr/lib/plexmediaserver/MigratePlexServerConfig.sh: line 350: systemctl: command not found
semodule: SELinux policy is not managed or store cannot be accessed.
warning: %post(plexmediaserver-1.0.3.2461-35f0caa.x86_64) scriptlet failed, exit status 1

First error is due to you not bothering to do a check on the SElinux status.

Second is you blindly assume that systemd is installed in /usr/lib/plexmediaserver/MigratePlexServerConfig.sh

348 # Reload systemctl config
349 systemctl -q disable plexmediaserver.service
350 systemctl -q enable plexmediaserver.service

You even bother to check for systemd here

139 # We are done with the user file, move it out of the way (abandon in place) if on systemd based systems
140 if [ -f /proc/1/comm ] && [ “cat /proc/1/comm” = “systemd” ]; then

But then ignore your own checks… That is just awful.

I work a lot on a ‘simple to use’ community distro and would recommend people installing plex, but I can’t when the RPMs are broken like this. We have a reputation that things ‘just work’ and we’ll just get a flood of complaints that it is broken. I can write better spec files and scripts than this and I am not a professional dev.

Can someone PLEASE have a look at this and get it fixed. It’s a few lines of bash code in the spec file and upgrade script. It is not rocket science.

Rgds
John

Riddle me this… including me fat fingering the commands

[root@centos6 Downloads]# yum remove plexmediaserver
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package plexmediaserver.x86_64 0:1.0.3.2461-35f0caa will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
 Package                     Arch               Version                           Repository                                               Size
================================================================================================================================================
Removing:
 plexmediaserver             x86_64             1.0.3.2461-35f0caa                @/plexmediaserver-1.0.3.2461-35f0caa.x86_64             199 M

Transaction Summary
================================================================================================================================================
Remove        1 Package(s)

Installed size: 199 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing    : plexmediaserver-1.0.3.2461-35f0caa.x86_64                                                                                    1/1 
  Verifying  : plexmediaserver-1.0.3.2461-35f0caa.x86_64                                                                                    1/1 

Removed:
  plexmediaserver.x86_64 0:1.0.3.2461-35f0caa                                                                                                   

Complete!
[root@centos6 Downloads]# rpm -Uvh plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm 
Preparing...                ########################################### [100%]
   1:plexmediaserver        ########################################### [100%]
[root@centos6 Downloads]# rpm -e plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm 
error: package plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm is not installed
[root@centos6 Downloads]# rpm -e plexmediaserver
yum -y [root@centos6 Downloads]# yum -y install plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm 
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Examining plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm: plexmediaserver-1.0.3.2461-35f0caa.x86_64
Marking plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm to be installed
Loading mirror speeds from cached hostfile
 * base: mirrors.mit.edu
 * extras: mirrors.maine.edu
 * updates: mirror.umd.edu
Resolving Dependencies
--> Running transaction check
---> Package plexmediaserver.x86_64 0:1.0.3.2461-35f0caa will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================
 Package                      Arch                Version                         Repository                                               Size
================================================================================================================================================
Installing:
 plexmediaserver              x86_64              1.0.3.2461-35f0caa              /plexmediaserver-1.0.3.2461-35f0caa.x86_64              199 M

Transaction Summary
================================================================================================================================================
Install       1 Package(s)

Total size: 199 M
Installed size: 199 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : plexmediaserver-1.0.3.2461-35f0caa.x86_64                                                                                    1/1 
  Verifying  : plexmediaserver-1.0.3.2461-35f0caa.x86_64                                                                                    1/1 

Installed:
  plexmediaserver.x86_64 0:1.0.3.2461-35f0caa                                                                                                   

Complete!
[root@centos6 Downloads]#

Thanks. The spec file issue has been there since I first used Plex. It’s such a simple fix.

The migrate script is a new one and I guess you wrote it for CentOS 7 and guessed it would work on 6, which it won’t as there is no systemd in 6.

Happy to test if required.

B. Rgds
John

Look at my output. I did presume you were correct… Then i pulled up the VMs and tested.

As for the Migrate script. It will get the appropriate update for everything since there is an obvious need for it.

Sorry - I missed your first post as I was on my phone.

The selinux issue is caused by the selinux status not being checked at all. It could be resolved as per my linked post above…

“It would be easy enough to add a check of either /etc/selinux/config, sestatus or getenforce ?”

[root@plex-server ~]# getenforce
Disabled

[root@plex-server ~]# sestatus
SELinux status: disabled

That’s pretty easy to check in the spec file here :

Add SELinux rsync policy file on CentOS/Fedora

semodule -i /usr/lib/plexmediaserver/plexrsync.pp

Re systemd on my server /etc/redhat-release does not report redhat, not fedora, nor centos, even though it is centos 6

[root@plex-server ~]# cat /etc/redhat-release
SME Server 9.1

:slight_smile: And that may change name as well as it is being slowly rebranded to Koozali…

You would be better to check directly rather than using a bit of script e.g.

cat /proc/1/comm

If that doesn’t read systemd then you know you have an issue :slight_smile:

or have a read of something like this :

Just checking /etc/redhat-release is not always the best idea.

HTH

B .Rgds
John

I’ve just concluded a review and installation retesting with our QA and development folks.

Yes, there is the issue in the migration script which I’m working on currently.

With respect to reproducing your errors when installing via rpm or yum, these cannot be recreated by QA or myself.

I would like to conclude this as ‘Cause unknown, not reproducible’ with the caveat we will keep an eye on. I personally will keep close watch during my current tasking.

It’s perfectly reproducible and the cause is known as I described. I’ve given it to you on a plate.

The selinux error will occur if selinux is disabled as %postin does not check the status. Easy fix.

The migration script fails if it misdiagnoses the system type and blindly falls back to assume systemd is present and attempts to restart the service.

It really isn’t that hard. I’m out again now but I can do you some examples of what happens tomorrow if you need some more proof.

Rgds
John

We took 3 different systems, 1 running and 2 fresh installations and could not reproduce it.
Is your system up to date?

selinux and SYSV/Systemd will be handled. I refer to the errors you asserted with the direct rpm invocation.

Yes it is, always…

I’ll run some tests tomorrow and post logs.

B. Rgds
John

So here it is for you - I did a force reinstall to check :

[root@plex-server plex]# rpm -Uvh --force plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm
Preparing… ########################################### [100%]
Stopping PlexMediaServer: [ OK ]
Stopped PlexMediaServer[ OK ]
1:plexmediaserver ########################################### [100%]
/var/tmp/rpm-tmp.uFrzzM: line 21: systemctl: command not found
/var/tmp/rpm-tmp.uFrzzM: line 22: systemctl: command not found
/var/tmp/rpm-tmp.uFrzzM: line 26: systemctl: command not found
semodule: SELinux policy is not managed or store cannot be accessed.
warning: %post(plexmediaserver-1.0.3.2461-35f0caa.x86_64) scriptlet failed, exit status 1

So lines 21,22,26 in POSTIN fail to notice that systemd is not installed as they just check /etc/redhat-release which is not reliable. You already have the a script to check for systemd in the MigratePlexServerConfig.sh so that could be used everywhere:

if [ -f /proc/1/comm ] && [ “cat /proc/1/comm” = “systemd” ];

You also do not check if selinux is disabled here in the POSTIN section

# Add SELinux rsync policy file on CentOS/Fedora
semodule -i /usr/lib/plexmediaserver/plexrsync.pp

This could be checked easily e.g.

if [ ! /usr/sbin/getenforce |grep -i Disabled ]; then
semodule -i /usr/lib/plexmediaserver/plexrsync.pp
fi

To fix the systemd issue you could do this

elif [ -f /etc/redhat-release ]; then
if [[ -n grep -i fedora /etc/redhat-release && cat /etc/redhat-release|sed 's/[^0-9]*\([0-9]\+\).*/\1/' -lt 15 ]] || [[ -n grep -i CentOS /etc/redhat-release && cat /etc/redhat-release | cut -d"." -f1|sed 's/[^0-9]*\([0-9]\+\).*/\1/' -lt 7 ]] || [ -f /proc/1/comm ] && [ ! cat /proc/1/comm = “systemd” ]; then

Or just use the last section without the redhat-release check:

[ -f /proc/1/comm ] && [ ! cat /proc/1/comm = “systemd” ]

Note this should also be added to the prein/preun/postun sections as required - from the looks of those sections they are topsy turvy and inconsistent as well, sometimes checking for systemd and doing then ‘else’, and sometimes vice versa.

I haven’t bothered to go through the whole thing.

Once I fixed the POSTIN sections and rebuilt your RPM I get

[root@plex-server x86_64]# rpm -Uvh --force plexmediaserver-1.0.3.2461-35f0caa.x86_64.rpm
Preparing… ########################################### [100%]
1:plexmediaserver ########################################### [100%]

I’ve even done you a diff of the POSTIN section to make your lives easier

[root@plex-server plex]# diff -ruN POSTIN POSTIN.new
— POSTIN 2016-07-28 00:00:00.000000000 +0200
+++ POSTIN.new 2016-07-31 00:00:00.000000000 +0200
@@ -15,7 +15,7 @@
fi
[ -x /bin/systemctl ] && systemctl daemon-reload
elif [ -f /etc/redhat-release ]; then

  • if [[ -n grep -i fedora /etc/redhat-release && cat /etc/redhat-release|sed 's/[^0-9]*\([0-9]\+\).*/\1/' -lt 15 ]] || [[ -n grep -i CentOS /etc/redhat-release && cat /etc/redhat-release | cut -d"." -f1|sed 's/[^0-9]*\([0-9]\+\).*/\1/' -lt 7 ]]; then
  • if [[ -n grep -i fedora /etc/redhat-release && cat /etc/redhat-release|sed 's/[^0-9]*\([0-9]\+\).*/\1/' -lt 15 ]] || [[ -n grep -i CentOS /etc/redhat-release && cat /etc/redhat-release | cut -d"." -f1|sed 's/[^0-9]*\([0-9]\+\).*/\1/' -lt 7 ]] || [ -f /proc/1/comm ] && [ ! cat /proc/1/comm = “systemd” ] ;then
    chkconfig --add plexmediaserver
    else
    if [ systemctl list-unit-files|grep plex.service|wc -l -eq 0 ]; then
    @@ -32,6 +32,8 @@
    fi

    fi

  • # Add SELinux rsync policy file on CentOS/Fedora
  • semodule -i /usr/lib/plexmediaserver/plexrsync.pp
  • if [ ! /usr/sbin/getenforce |grep -i Disabled ]; then
  •  # Add SELinux rsync policy file on CentOS/Fedora
    
  •  semodule -i /usr/lib/plexmediaserver/plexrsync.pp
    
  • fi
    fi

Hope that helps…

Rgds
John

Sorry about the messy post - I’m not au fait with markdown…

Still here…

I explained the why in the above post and I am damned if I am writing it out for you again.

systemd and selinux are NOT ‘handled’.

It still fails because your spec postin script does not run sufficiently good checks and makes dumb assumptions. I really expect more from a supposedly professional company whose services I have paid for. I’ve even done you job for you, and shown you how to fix it. What more do you want ?

Just to blindly say ‘it works on our systems’ is just unacceptable especially when I have told you what is wrong, why, and given you a solution.

[root@plex-server plex]# rpm -Uvh plexmediaserver-1.3.0.3059-6277334.x86_64.rpm
warning: plexmediaserver-1.3.0.3059-6277334.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 3adca79d: NOKEY
Preparing… ########################################### [100%]
Stopping PlexMediaServer: [ OK ]
Stopped PlexMediaServer[ OK ]
1:plexmediaserver ########################################### [100%]
/var/tmp/rpm-tmp.rDMiqX: line 21: systemctl: command not found
/var/tmp/rpm-tmp.rDMiqX: line 22: systemctl: command not found
/var/tmp/rpm-tmp.rDMiqX: line 26: systemctl: command not found
semodule: SELinux policy is not managed or store cannot be accessed.
warning: %post(plexmediaserver-1.3.0.3059-6277334.x86_64) scriptlet failed, exit status 1

Before you go pointing fingers at selinux…

/var/tmp/rpm-tmp.rDMiqX: line 21: systemctl: command not found
/var/tmp/rpm-tmp.rDMiqX: line 22: systemctl: command not found
/var/tmp/rpm-tmp.rDMiqX: line 26: systemctl: command not found

What OS version are you on? There are several rpm distros. It’s easy to grab the wrong one and they all have the same ‘generic’ name once downloaded.

show me uname -a, cat /etc/os-release and cat /proc/1/comm

If you read above you might have gleaned it is CentOS 6 based.

I use Koozali SME server. Straight forward CentOS 6 base but with various scripts to make it easy to manage. I happen to have worked with them for years and do various bits of dev work there.

No systemd for starters… (AFAIAA it was only introduced on RH/Cent 7) nor SE Linux.

It does not report a standard redhat-release response in /etc - I have said above what the issues are.

That is probably the same for a lot of RPM based distros… hence you should make some better checks before making assumptions.

If I had the source/spec file I’d rewrite and rebuild it myself. This is not rocket science.

[root@plex-server ~]# uname -a
Linux plex-server 2.6.32-642.11.1.el6.x86_64 #1 SMP Fri Nov 18 19:25:05 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

[root@plex-server ~]# cat /etc/os-release
cat: /etc/os-release: No such file or directory

[root@plex-server ~]# cat /proc/1/comm
init

[root@plex-server ~]# cat /etc/redhat-release
SME Server 9.1

As I said… I’ve done the hard work for you above…

Spinning up a 9.1 VM now

PS - I’d have happily set up a Plex web page at our contribs.org site for Plex with a HowTo, but I can’t if your install falls on it’s butt every install/upgrade. I’m not prepared to answer the same questions over and over.

Silly as Koozali SME makes a great base for Plex…

Thanks Chuck.

If you can fix it I’ll build a ‘contrib’ rpm to setup a service, create any template fragments to configure it eg ports to open, and pull/install your rpms.

Note we have been working on v10 which is CentOS 7 based and will have systemd

FYI I have a link to the init file in in /etc/rc.d/rc7.d and the following db config entry which opens the ports… these are picked up by scripts for certain events such as changes to the the firewall etc.

[root@plex-server ~]# config show plexmediaserver
plexmediaserver=service
TCPPort=32400
access=public
status=enabled

I can set these up in my own ‘contrib’ rpm which will configure the right things on the server for the user.

Then just make your RPM a dependency and job done.

I have had it running on a VM for a number of years without issues, apart from the upgrades…

I have script to check for updates and download the latest version, so the rest is like falling off a log.

Sorry. On Euro time so need some kip. Let me know how you get along.

Identified. Tracking back to the master redhat installer, I’ve identified it. I don’t know where the changes went but you found they aren’t there.

Thanks John, I’m putting them in again.

C.