Lester Burnham's Blog

Mythbuntu 16.04 – My First Spin

Hello again after a long break from posting.  With the impending change over to Mythbuntu 16.04 looming, I needed to do some homework.  The box is actually being built for a friend, using my old hardware, plus some items from eBay, which will be perfect for testing with a combined Backend / Frontend.  I have a feeling the change to systemd from upstart will bring with it a few bugs, plus different ways of doing certain things I was comfortable with.

The hardware in the box is as follows:Mythtv Box

  • Gigabyte H55M motherboard
  • i5 750 CPU
  • 4 Gb Generic RAM
  • GT 730 Low Profile Video Card
  • Kingston SSD 120Gb
  • 4Tb HDD
  • Sony Play TV x 2
  • MCE remote and receiver
  • Silverstone ML-03 Case
  • 430w Bronze PSU

I installed the Mythbuntu 16.04 ISO, setting the remote to Windows Media Centre (all) and installing the Nvidia driver. Then changed to my local repository and installed all the updates.  From now on, the Mythbuntu Control Centre will be referred to as MCC.

My list of things to do:

  1. Un-tick “Automatically start Mythtv Frontend” in MCC
  2. Other MCC settings
  3. Change the SSH port to non standard
  4. Install Wake On LAN, configure and test
  5. Edit the Sudoers file to allow Mythtv permissions to shutdown, reboot etc.
  6. Copy my MythShutdownCheck file to /usr/bin/
  7. Create a setwakeup.sh
  8. Install Kodi (via PPA if required)
  9. Install pavucontrol to set the correct audio output device (for Kodi)
  10. Setup the Mythbackend (mythtv-setup)
  11. Setup ACPI Wake

 

Open Applications>System>Mythbuntu Control Centre and go to:

Start-up Behaviour.  Un-tick “Automatically start Mythtv Frontend”

MySQL.  enable the MySQL Service to allow other remote Frontends to connect to this Backend.  Optimize Tables, Enable daily MySQL DB Optimize/Repair cron job and Enable MySQL performance Tweaks.  ***BEWARE ENABLE THE PERFORMANCE TWEAKS ABOVE AND FIX THE FILE FIRST*** otherwise MySQL will not start and you will be chasing your tail trying to work out why. See this Bug or this thread for details. What you need to do is edit /etc/mysql/conf.d/mythtv-tweaks.cnf

sudo nano /etc/mysql/conf.d/mythtv-tweaks.cnf

and change

"table_cache = 128" to "table_open_cache = 128"

Repositories.  I normally activate the “Mythtv Updates” Repo and the “Mythbuntu Updates” Repo.

Services.  I normally enable SSH & Samba.  That’s it in MCC now.

SSH.  Lets change the SSH port.

sudo nano /etc/ssh/sshd_config

Port 22   #Change this to something higher up in the 1000's

WOL.  Install ethtool to enable Wake on LAN

sudo apt-get install ethtool

**This is still a work in progress** ie. not working

SUDOERS FILE.  Edit the sudoers file using nano (I hate vi)

export EDITOR=nano && sudo -E visudo

and add the following below the last group entry in the same format.

# mythtv group

%mythtv ALL = NOPASSWD: /sbin/shutdown, /usr/bin/setwakeup.sh, /usr/bin/MythtvShutdownCheck

To exit and save file. ctrl +x, then y for yes, enter.

MythtvShutdownCheck.  Download the MythtvShutdownCheck.zip file to your Downloads folder and extract it. Copy my MythtvShutdownCheck file to /usr/bin/ and make it executable.

sudo cp ~/Downloads/MythtvShutdownCheck /usr/bin/MythtvShutdownCheck

chmod +x /usr/bin/MythtvShutdownCheck

setwakeup.sh  The next file to create is /usr/bin/setwakeup.sh NOTE: After some wakeup issues on restoration of a database from a retired backend, I changed to the lower version of the script.

sudo nano /usr/bin/setwakeup.sh
#!/bin/bash
#$1 is the first argument to the script. It is the time in seconds since 1970
#this is defined in mythtv-setup with the time_t argument

echo 0 > /sys/class/rtc/rtc0/wakealarm      #this clears your alarm.
echo $1 > /sys/class/rtc/rtc0/wakealarm     #this writes your alarm.
#!/bin/sh
#
# set ACPI Wakeup time
# usage: setwakeup.sh seconds
#    seconds - number of seconds from epoch to UTC time (time_t time format)
#
# set UTCBIOS to true if bios is using UTC time
# set UTCBIOS to false if bios is using local time

UTCBIOS=true

if $UTCBIOS
then
    #utc bios - use supplied seconds
    SECS=$1
else
    #non utc bios - convert supplied seconds to seconds from
    #epoch to local time
    SECS=`date -u --date "\`date --date @$1 +%F" "%T\`" +%s`
fi

echo 0 > /sys/class/rtc/rtc0/wakealarm    # clear alarm
echo $SECS > /sys/class/rtc/rtc0/wakealarm   # write the waketime

Set execute permissions

chmod +x /usr/bin/setwakeup.sh

KODI.  Add the team-xbmc PPA and install KODI.

sudo apt-add-repository ppa:team-xbmc/ppa
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install kodi kodi-pvr-mythtv

pavucontrol.  Install PulseAudio Volume Control

sudo apt-get install pavucontrol

Go through output devices and set the connected one as default. Hopefully you have it connected to your TV already via HDMI.

mythtv-setup.  Now to setup mythtv for shutting down.

(use these instructions for a dedicated backend system)

Select the backend’s “General” options and on the “Shutdown/Wakeup Options” page, make the following settings:

  • Block shutdown before client connected: (un-checked. I leave this un-checked, because if the machine wakes to record, I want it to go back to sleep after. It will not, if it is waiting for the frontend to connect)
  • Idle shutdown timeout (secs): 200 (if you set this to 0, it will disable auto shutdown)
  • Max. wait for recording (min): 15
  • Startup before rec. (secs): 600 (If you have not disabled the occasional disk check on boot, make this time long enough to complete the boot & disk check before the recording should start)
  • Wakeup time format: time_t
  • Command to set Wakeup Time: sudo sh -c “/usr/bin/setwakeup.sh $time”
  • Server halt command: sudo shutdown -h now
  • Pre Shutdown check-command: /usr/bin/MythtvShutdownCheck

Capture Cards  Select “DVB-T/S/C, ATSC or ISDB-T tuner card” as the capture card type. Do this for each tuner. (2 x Play TV = 4 tuners)

  • Signal Timeout = 3000
  • Tuning Timeout = 7000

Recording Options

  • Max Recordings = 2
  • Open DVB card on demand (tick)
  • DVB tuning delay = 1

Video Sources.  Give the source a name. I use free then select EIT for guide data type and set your region.

Input Connections.  Set a display name. I normally use T1, T2 etc. Add a video source for each tuner which you named in the previous step. Do an initial full scan for channels, add them all and set a starting channel.

Storage Directories.  Now you need to set your storage directory for where you like to save your recordings. Preferably to a spinning HDD for longer life of the SSD.

ACPI Wake.  For ACPI Wake to work, all I had to do was set the following. Make sure you have wake DISABLED in the BIOS.

/usr/sbin/rtcwake -mode no

HDMI video output.  I ran into a problem where the box would wake up to record without the TV turned on, but the HDMI connection was not active. So, if it’s still recording and you want to turn on the TV to watch a recording, the TV would say there’s no connection on HDMI 1. At first I thought it was the xfsettingsd bug, but after having setup the box to kill that when mythtv starts in /etc/mythtv/session-settings it was still happening.

I remembered an issue I had with an el cheapo LCD with a 1366×768 resolution that could display 1080 & 720, so I went back and found the post on the Ubuntu forums > Mythbuntu forum. A friend Phil had created a post about common issues like that above. I followed the post and installed arandr, a GUI front end for xrandr. I fired it up with the TV displaying the correct resolution over the HDMI connection and set the connection as “primary” from the menu items at the top and hit apply. It saves a script to set the resolution each reboot. So I turned the box and TV off, then restarted the box without the TV on, waited a bit then turned TV on, it detected a connection and all was good.

That should be about it!

Leave a Reply