MythTV: Tuners not initialized following a restart of the server

There is currently a bug whereby some tuners are not initialized before the MythTV backend service has started thus causing MythTV to assume there are no tuners present. The current “fix” is to force the MythTV startup script to wait a moment to give the tuners time to initialize:

So, type the following command to open the MythTV startup script:

sudo vim /etc/init/mythtv-backend.conf

Then press the [Insert] key once to switch into edit-insert mode and add a couple of blank lines by pressing the [Enter] key. Now type or paste the following lines just below the #expect fork respawn lines:

pre-start script
# wait for listen on port 80
while [ ! -e /dev/dvb/adapter0 ] ; do
sleep 1;
done
end script

So, the script should read as follows:

# MythTV Backend service

description "MythTV Backend"
author "Mario Limonciello superm1@ubuntu.com"

start on (local-filesystems and net-device-up IFACE=lo)
stop on starting shutdown

# expect fork
respawn

pre-start script
# wait for listen on port 80
        while [ ! -e /dev/dvb/adapter0 ] ; do
               sleep 1;
         done
end script

script
      USER=mythtv
      ARGS="--logfile /var/log/mythtv/mythbackend.log --user $USER"
      test -f /etc/default/mythtv-backend && . /etc/default/mythtv-backend || true
      /usr/bin/mythbackend $ARGS
end script

Once you’ve edited the file press the [Esc] key once and type :wq to save and quit out of the file. If you make a mistake editing the file then issue :q! instead of :wq to abort your changes.

Then restart the server to test:

sudo reboot -h now