[mythtv-users] No STB channels on Live TV after adding HDHR

Stephen Worthington stephen_agent at jsw.gen.nz
Mon Jul 1 17:41:58 UTC 2019

On Mon, 1 Jul 2019 09:35:50 -0700, you wrote:

>On Sun, Jun 30, 2019, 10:14 PM Stephen Worthington <stephen_agent at jsw.gen.nz>
>> On Sun, 30 Jun 2019 17:28:07 -0700, you wrote:
>> >Ok this is strange.  I added a couple channels on schedules direct, ran
>> >mythfilldatabase, and restarted the Myth machine. Now the STB channels are
>> >there on watch live TV.  This makes no sense. It has been restarted
>> several
>> >times since I had this problem, and mythfilldatabase runs daily (I think).
>> >So go figure.
>> Just checking, do you have the systemd fix that makes mythbackend only
>> start when the network is up and it can access the networked tuners?
>> ____________________________________
>If it's something I had to install separately, no.

In that case, every time you boot, you will be suffering from a race
condition.  Mythbackend tests all the tuners at startup, and if it can
not get a good response from a tuner when it tests it, that tuner is
marked as bad and is never used until mythbackend is restarted.
Systemd is able to start mythbackend faster and faster with each new
version of systemd and Ubuntu.  This is the default systemd unit file
for mythbackend:

root at mypvr:/lib/systemd/system# cat mythtv-backend.service
Description=MythTV Backend
After=mysql.service network.target

ExecStart=/usr/bin/mythbackend --quiet --syslog local7


It starts mythbackend as soon as mysql is started, and
"network.target" is reached.  Unfortunately, "network.target" happens
when any network interface is available, so as soon as the localhost
( interface is available, "network.target" happens and
mythbackend is started.  But at that time, the Ethernet interface(s)
and all the other network interface(s) that you may have are still
starting up.  By the time mythbackend tries to test the first network
tuner, the Ethernet interfaces are not up yet, so mythbackend marks
that tuner bad and goes on to try the next tuner.  Since testing a
tuner takes a while, at some point in the process of testing all the
tuners, the Ethernet interface may come up, and after that, the
testing of the network tuners succeeds.

This was a problem in 16.04 with most people still booting from hard
disk.  Now that we are running 18.04 and above, and booting from SSD,
mythbackend it getting started much earlier, and the chance that the
network tuners will fail testing is increased significantly.

Whether this is your actual problem, I am not sure, but it is a good
candidate and something you (and anyone who uses network tuners)
really need to fix anyway.

The fix is a bit complicated - you have to make a systemd unit that
tests for the Ethernet interface actually being up and able to pass
traffic, and then have mythbackend wait on that unit before it is
started.  The tools to do this are on my web server.  If you are not
running a server version of Ubuntu and have not disabled
NetworkManager, run the following commands to set it all up.  Watch
out for line wrapping - my email client does that with longer lines
such as the wget commands, so the wget and the URL after it should be
on one line.

sudo su
cd /usr/local/bin
wget http://www.jsw.gen.nz/mythtv/wait-until-pingable.py
chmod u=rwx,g=r,o=r wait-until-pingable.py
systemctl enable NetworkManager-wait-online.service
systemctl start NetworkManager-wait-online.service
cd /etc/systemd/system
mkdir mythtv-backend.service.d
chmod u=rwx,g=rx,o=rx mythtv-backend.service.d
cd mythtv-backend.service.d
chmod u=rw,g=r,o=r mythtv-backend-wait-until-pingable.conf
cd ..
wget http://www.jsw.gen.nz/mythtv/local-network-pingable.service
chmod u=rw,g=r,o=r local-network-pingable.service

Here you will need to change the text in
local-network-pingable.service where it says "switch.jsw.gen.nz" and
replace that with the IP address or DNS name of your first network
tuner (if the tuner is pingable), or otherwise something on your
network such as your switch or router that is normally pingable when
your MythTV box is booting.

Use nano or your favourite editor:

nano local-network-pingable.service

Then save the change and exit from nano or your editor and do these

systemctl enable local-network-pingable.service
systemctl start local-network-pingable.service
systemctl status local-network-pingable.service

The systemctl status command should show that the
local-network-pingable.service has started and the ping worked.  If
not, fix that before proceeding.  Then do these commands:

systemctl daemon-reload

After that, on boot mythbackend will wait for either the ping to work,
or the 30 second timeout specified in the
local-network-pingable.service file.  If you want to change that
timeout, it is the "30" after the ping address.

Since I just typed out all of the above commands, it is possible I may
have a typo somewhere, so please let me know if I have.

More information about the mythtv-users mailing list