Bug 24104 - @syscondir@/mythbackend missing needed environment variables
Summary: @syscondir@/mythbackend missing needed environment variables
Status: RESOLVED FIXED
Alias: None
Product: Mageia
Classification: Unclassified
Component: RPM Packages (show other bugs)
Version: 6
Hardware: All Linux
Priority: Normal normal
Target Milestone: ---
Assignee: All Packagers
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 24099
Blocks:
  Show dependency treegraph
 
Reported: 2019-01-01 00:07 CET by Bit Twister
Modified: 2019-08-18 14:52 CEST (History)
5 users (show)

See Also:
Source RPM: mythtv-0.28.1-20170528.6.mga6.src.rpm
CVE:
Status comment:


Attachments

Description Bit Twister 2019-01-01 00:07:03 CET
Description of problem: Official

/etc/sysconfig/mythbackend is missing MYTHTV_HOME and MYTHCONFDIR environment variables.

Version-Release number of selected component (if applicable):


How reproducible: Always


Steps to Reproduce:

read bug 19127 about needing different mythtv password and files needing the new password. Following will need mysql's root password changed.


1. install mythbackend
2. mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql --user=root --password=Secret_w_pw -D mysql
3.  mysql --user=root --password=Secret_2_pw mysql < /usr/share/mythtv/initialdb/mc.sql
4. mysql --user=root --password=Secret_2_pw mysql < /your/backup_here.sql

5. Modify/edit /var/lib/mythtv/config.xml to have Fully Qualified Domain Name (FQDN) and mythbackend password.

6. mythtv-setup

Note it is not using FQDN and password from /var/lib/mythtv/config.xml

Workaround:
    echo "MYTHTV_HOME=/var/lib/mythtv" >> /etc/sysconfig/mythbackend
    echo "MYTHCONFDIR=/var/lib/mythtv" >> /etc/sysconfig/mythbackend
David Walser 2019-01-01 06:06:42 CET

Depends on: (none) => 24099
Source RPM: mythtv-backend-0.28.1-20170528.6.mga6.tainted => mythtv-0.28.1-20170528.6.mga6.src.rpm

Comment 1 David GEIGER 2019-01-01 11:42:02 CET
So is this still needed in new 29.1 release? and should this fix also bug 19127 adding:

    echo "MYTHTV_HOME=/var/lib/mythtv" >> /etc/sysconfig/mythbackend
    echo "MYTHCONFDIR=/var/lib/mythtv" >> /etc/sysconfig/mythbackend

CC: (none) => geiger.david68210

Comment 2 Bit Twister 2019-01-01 14:02:13 CET
(In reply to David GEIGER from comment #1)
> So is this still needed in new 29.1 release?

Yes.

> and should this fix also bug 19127 adding:
> 
>     echo "MYTHTV_HOME=/var/lib/mythtv" >> /etc/sysconfig/mythbackend
>     echo "MYTHCONFDIR=/var/lib/mythtv" >> /etc/sysconfig/mythbackend

Yes and No. 
At the time I did not know about /etc/sysconfig/mythbackend 

It fixes problem 3 of the bug report and removes the workaround
given in comment 1.

That workaround does not fix trying to get mythtv-setup to get access to
the database. I spent 30+ hours trying to run down why mythtv-setup could
not get database access even though my install script had made all the changes.
William Kenney 2019-01-01 19:24:07 CET

CC: (none) => wilcal.int

Comment 3 Marja Van Waes 2019-01-02 21:02:55 CET
Assigning to all packagers collectively, since the registered maintainer for this package is most likely unavailable.

CC'ing him, though.

@ David 

Feel free to take it ;-)

Assignee: bugsquad => pkg-bugs
CC: (none) => mageia, marja11

Comment 4 Bit Twister 2019-01-03 03:23:10 CET
Ok, I just now rebooted my mga6 system and mythbackend would not come up but
mythtv-setup could connect because of the vars addition to 
/etc/sysconfig/mythbackend.


I placed the two variables into my drop in file workaround and mythbackend
came up.

On mga7 I only need the vars in /etc/sysconfig/mythbackend.
Comment 5 David GEIGER 2019-01-03 07:36:11 CET
Fix in next mythtv-29.1-20181230.1.1.mga6 update and for cauldron too in
mythtv-29.1-20181230.2.mga7
Comment 6 Bit Twister 2019-01-06 10:59:28 CET
/usr/lib/systemd/system/mythbackend.service calls for
   Environment=MYTHCONFDIR=@syscondir@/mythtv
which means there should be a /etc/sysconfig/mythtv file.


Workaround:
  echo MYTHTV_HOME=/var/lib/mythtv >> /etc/sysconfig/mythtv
  echo MYTHCONFDIR=/var/lib/mythtv >> /etc/sysconfig/mythtv

mga7 mythbackend would still not come up until adding MYTHCONFDIR to service file.

Workaround:
  mkdir -p /etc/systemd/system/mythbackend.service.d/
and create
/etc/systemd/system/mythbackend.service.d/xx__mythbackend.conf with

[Service]
Environment=MYTHTV_HOME=/var/lib/mythtv
Environment=MYTHCONFDIR=/var/lib/mythtv
Comment 7 Bit Twister 2019-01-06 11:35:28 CET
> and create
> /etc/systemd/system/mythbackend.service.d/xx__mythbackend.conf with

@ maintainer/packager please use a different name for the above drop in file
if you add it to the backend package.
     Example:
          /mageia__mythbackend.conf 
I use xx__ to be able to locate my drop in/customization files.
Comment 8 David GEIGER 2019-01-06 12:47:37 CET

(In reply to Bit Twister from comment #6)
> /usr/lib/systemd/system/mythbackend.service calls for
>    Environment=MYTHCONFDIR=@syscondir@/mythtv
> which means there should be a /etc/sysconfig/mythtv file.
> 
> 
> Workaround:
>   echo MYTHTV_HOME=/var/lib/mythtv >> /etc/sysconfig/mythtv
>   echo MYTHCONFDIR=/var/lib/mythtv >> /etc/sysconfig/mythtv

Instead of create a new and duplicate /etc/sysconfig/mythtv file as we have already /etc/sysconfig/mythbackend is it not simpler to just change:

Environment=MYTHCONFDIR=@syscondir@/mythtv

by

Environment=MYTHTV_HOME=/var/lib/mythtv
Environment=MYTHCONFDIR=/var/lib/mythtv

in /usr/lib/systemd/system/mythbackend.service file?
Comment 9 Bit Twister 2019-01-06 13:53:53 CET
(In reply to David GEIGER from comment #8)
> 
> (In reply to Bit Twister from comment #6)

> 
> Instead of create a new and duplicate /etc/sysconfig/mythtv file as we have
> already /etc/sysconfig/mythbackend is it not simpler to just change:
> 
> Environment=MYTHCONFDIR=@syscondir@/mythtv
> 
> by
> 
> Environment=MYTHTV_HOME=/var/lib/mythtv
> Environment=MYTHCONFDIR=/var/lib/mythtv
> 
> in /usr/lib/systemd/system/mythbackend.service file?

Ideally you would want one place for a variable definition.
If you were to look through a clean install /var/log/mythtv/mythbackend*.log
the  mythdirs.cpp section of code wants to use @syscondir@/mythtv
After I created it, on next start attempt, that section quit complaining.

A quick glance at /etc/rc.d/init.d/mythbackend suggests having
/etc/sysconfig/mythbackend 

What we are seeing is a bug in mythbackend not being consistent about where to
get its environment variables or maybe a systemd bug not really using
@syscondir@whatever and setting the variables.

I don't know who is the owner of mythbackend.service file, and recommended
the mageia drop in file as a patch.

If Mageia is the owner of mythbackend.service file, then you can do as you
like, but mythbackend would still needs /etc/sysconfig/mythtv

It would be nice if mythtv.org would provide systemd files.
Comment 10 David GEIGER 2019-01-06 14:06:59 CET
Ok I'll apply your proposal fixes in comment #6

And yes Mageia is the owner of mythbackend.service file.
Comment 11 David GEIGER 2019-01-06 17:22:11 CET
Hmmmm! your workaround:

mkdir -p /etc/systemd/system/mythbackend.service.d/
and create
/etc/systemd/system/mythbackend.service.d/xx__mythbackend.conf with

[Service]
Environment=MYTHTV_HOME=/var/lib/mythtv
Environment=MYTHCONFDIR=/var/lib/mythtv


give on Build System:

Submission errors, aborting:
- mythtv-backend-29.1-20181230.3.mga7.i586:
 - systemd-unit-in-etc /etc/systemd/system/mythbackend.service.d/mageia__mythbackend.conf
 - systemd-unit-in-etc /etc/systemd/system/mythbackend.service.d
Comment 12 Bit Twister 2019-01-06 19:00:27 CET
(In reply to David GEIGER from comment #11)
> Hmmmm! your workaround:
> 
> mkdir -p /etc/systemd/system/mythbackend.service.d/
> and create
> /etc/systemd/system/mythbackend.service.d/xx__mythbackend.conf with
> 
> [Service]
> Environment=MYTHTV_HOME=/var/lib/mythtv
> Environment=MYTHCONFDIR=/var/lib/mythtv
> 
> 
> give on Build System:
> 
> Submission errors, aborting:
> - mythtv-backend-29.1-20181230.3.mga7.i586:
>  - systemd-unit-in-etc
> /etc/systemd/system/mythbackend.service.d/mageia__mythbackend.conf
>  - systemd-unit-in-etc /etc/systemd/system/mythbackend.service.d

Weird. Sorry, I have no idea on what to say and that is why I am not a packager.
Directory is following normal drop in location for the service and here
is what I have so I know it works.

Snippet from systemctl status mythbackend

  Drop-In: /etc/systemd/system/mythbackend.service.d
           └─xx__mythbackend.conf
   Active: active (running) since Sun 2019-01-06 11:56:44 CST; 2s ago

$ cat /etc/systemd/system/mythbackend.service.d/xx__mythbackend.conf
#
#  Created by /local/bin/mythtv_changes  Thu 03 Jan 09:20 2019 
#
# https://bugs.mageia.org/show_bug.cgi?id=19127#c1
# https://bugs.mageia.org/show_bug.cgi?id=19127#c12
# https://bugs.mageia.org/show_bug.cgi?id=24104
[Service]
Environment=MYTHTV_HOME=/var/lib/mythtv
Environment=MYTHCONFDIR=/var/lib/mythtv
Comment 13 Bit Twister 2019-01-06 19:32:25 CET
Since /usr/lib/systemd/system/mythbackend.service is owned by Mageia,
the easy fix would be go ahead and add them there.

   [Service]
   Type=simple
   Environment=MYTHCONFDIR=@syscondir@/mythtv
   Environment=MYTHTV_HOME=/var/lib/mythtv
   Environment=MYTHCONFDIR=/var/lib/mythtv
   User=mythtv
   ExecStart=/usr/bin/mythbackend --logpath /var/log/mythtv/

The drop in was assuming upstream owned the service file.
Comment 14 David GEIGER 2019-01-07 13:27:00 CET
So please test next mythtv-29.1-20181230.3.mga7 update!
Comment 15 Bit Twister 2019-01-10 06:11:20 CET
(In reply to David GEIGER from comment #14)
> So please test next mythtv-29.1-20181230.3.mga7 update!

Installed all mga7 updates this date and rebooted.

Removed the mga7 mythtv packages, removed all remaining system myth* files,
deleted  the database, disabled my mythbackend systemd drop in patch, ran my
install/change scripts. status mythbackend showed active and frontend
was able to view a recording.

Above is with myth password change, using a backup copy of database that had
already been converted from 28 to 29. 

No execution of mythtv-setup was done in this test.
Comment 16 David GEIGER 2019-01-10 06:48:14 CET
So can I go with same change for mga6?
Comment 17 Bit Twister 2019-01-10 07:12:30 CET
(In reply to David GEIGER from comment #16)
> So can I go with same change for mga6?

I do not see why not.
I created /etc/sysconfig/mythbackend and /etc/sysconfig/mythtv same as mga7,
Added
    Environment=MYTHTV_HOME=/var/lib/mythtv
    Environment=MYTHCONFDIR=/var/lib/mythtv
to /usr/lib/systemd/system/mythbackend.service, removed them from my drop in 
file, rebooted and backend came up. That would close this bug report as far
as I am concerned.
Comment 18 Thomas Backlund 2019-08-18 14:52:21 CEST
An update for this issue has been pushed to the Mageia Updates repository.

https://advisories.mageia.org/MGASA-2019-0223.html

Status: NEW => RESOLVED
CC: (none) => tmb
Resolution: (none) => FIXED


Note You need to log in before you can comment on or make changes to this bug.