MythTV Ubuntu Installation Guide


Introduction

Here are some general tips to get the most out of your Ubuntu or MythTV system.

Log in Automatically

To log in automatically on startup (handy for a MythTV box), go to System->Administration->Login Screen. Here, you can specify which user should be logged in automatically and a number of seconds timeout to allow other usres to log in first. Note that the length of time specified here will obviously delay the startup of your box.

Run MythTV Frontend Automatically

mythfrontend can be run automatically by adding it to System->Preferences->Startup Applications

Alternatively, you can add it to your .gnomerc file. If this file exists in your home directory, it is run on login. Create the file:

gedit /home/mythtv/.gnomerc

Add the following lines:

sleep 10 && mythfrontend > /tmp/mythfrontend.log 2>&1 &

Save the script and make it executable:

chmod 755 .gnomerc

Protecting MythWeb

I use simple apache security to prevent unauthorised access to my MythWeb connection. It presents a dialog box asking for a username and password.

Do the following as root or using sudo. Edit the file: /etc/apache2/apache2.conf. Add the following section (just search for Directory and add it somewhere near there). "ripley" is the name of my MythTV box:

<Directory /var/www>
  AuthType Basic
  AuthName "ripley"
  AuthUserFile /etc/apache2/htpasswd
  Require valid-user
</Directory>

Create a password file:

cd /etc/apache2
htpasswd -c htpasswd garry

Automatically Restarting Mythbackend

Even though the mythbackend task is usually very stable, it has been known to crash now and again due to driver issues on certain builds. This can be very frustrating if it causes you to miss a recording. There is a utility called monit which can be configured to monitor and restart the backend process:

Make the LIRC Device Static

If your remote control uses a /dev/input/eventN device, you may have a problem where the event number is assigned differently after each reboot, forcing you to change your LIRC config each time. On newer kernels, the solution to this is quite simple...

Udev will create a static link to each event device which will never change. These links go into the directory /dev/input/by-path/:

$ ls -l /dev/input/by-path/
lrwxrwxrwx 1 root root 9 Jun 27 21:01 pci-0000:00:02.0-usb-0:3:1.0-event-kbd -> ../event2
lrwxrwxrwx 1 root root 9 Jun 27 21:01 pci-0000:00:02.0-usb-0:3:1.1-event-mouse -> ../event3
lrwxrwxrwx 1 root root 9 Jun 27 21:01 pci-0000:00:02.0-usb-0:3:1.1-mouse -> ../mouse0
lrwxrwxrwx 1 root root 9 Jun 27 21:01 pci-0000:02:07.0-event-ir -> ../event6
lrwxrwxrwx 1 root root 9 Jun 27 21:01 pci-0000:02:09.2-event-ir -> ../event4

In the output above, event4 and event6 are the IR devices for my 2 tuner cards. Run cat /proc/bus/input/devices to determine which is which. Once you have done that, just tell LIRC to use that device in /etc/lirc/hardware.conf:

START_LIRCD=true
START_LIRCMD=false
LOAD_MODULES=false

REMOTE_DRIVER="dev/input"
REMOTE_DEVICE="/dev/input/by-path/pci-0000:02:09.2-event-ir"

Make the LIRC Device Static - older kernels

If you are on an older kernel which does not create /dev/input/by-path links, you can use a udev rule to tell udev to identify the device and create a symbolic link to it each time. This is not quite as hard as it sounds...

First of, all determine your IR device:

$ cat /proc/bus/input/devices

I: Bus=0001 Vendor=0070 Product=9002 Version=0001
N: Name="cx88 IR (Hauppauge Nova-T DVB-T"
P: Phys=pci-0000:02:09.2/ir0
S: Sysfs=/devices/pci0000:00/0000:00:0e.0/0000:02:09.2/input/input6
U: Uniq=
H: Handlers=kbd event6 
B: EV=100003
B: KEY=100fc312 214a802 0 0 0 0 18000 41a8 4801 9e1680 0 0 10000ffc

We can see that my remote is currently using event6. We now need to find the vendor ID of the device by using the following command (be sure to change the device number to the one identified in the previous step):


$ udevadm info -a -p $(udevadm info -q path -n /dev/input/event6)

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.2/input/input6/event6':
    KERNEL=="event6"
    SUBSYSTEM=="input"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.2/input/input6':
    KERNELS=="input6"
    SUBSYSTEMS=="input"
    DRIVERS==""
    ATTRS{name}=="cx88 IR (Hauppauge Nova-T DVB-T"
    ATTRS{phys}=="pci-0000:02:09.2/ir0"
    ATTRS{uniq}==""
    ATTRS{modalias}=="input:b0001v0070p9002e0001-e0,1,14,k71,72,73,74,77,80,8B,8E,A3,A5,A7,A8,AE,CF,D0,161,16B,16D,16F,172,174,179,181,184,188,189,18E,18F,190,191,192,193,19C,ramlsfw"

  looking at parent device '/devices/pci0000:00/0000:00:0e.0/0000:02:09.2':
    KERNELS=="0000:02:09.2"
    SUBSYSTEMS=="pci"
    DRIVERS=="cx88-mpeg driver manager"
    ATTRS{vendor}=="0x14f1"
    ATTRS{device}=="0x8802"
    ATTRS{subsystem_vendor}=="0x0070"
    ATTRS{subsystem_device}=="0x9002"
    ATTRS{class}=="0x048000"
    ATTRS{irq}=="17"
    ATTRS{local_cpus}=="ff"
    ATTRS{local_cpulist}=="0-7"
    ATTRS{modalias}=="pci:v000014F1d00008802sv00000070sd00009002bc04sc80i00"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00/0000:00:0e.0':
    KERNELS=="0000:00:0e.0"
    SUBSYSTEMS=="pci"
    DRIVERS==""
    ATTRS{vendor}=="0x10de"
    ATTRS{device}=="0x00ed"
    ATTRS{subsystem_vendor}=="0x0000"
    ATTRS{subsystem_device}=="0x0000"
    ATTRS{class}=="0x060400"
    ATTRS{irq}=="0"
    ATTRS{local_cpus}=="ff"
    ATTRS{local_cpulist}=="0-7"
    ATTRS{modalias}=="pci:v000010DEd000000EDsv00000000sd00000000bc06sc04i00"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}=="1"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

The output is a bit confusing, but you should be able to see your device and get a unique identifier such as the vendor ID. Note that you can match using any of the attributes which are unique to the card. Now all you need to do is create a file called /etc/udev/rules.d/10-local.rules and add the following (here using the vendor ID):

KERNEL=="event*",ATTRS{vendor}=="0x14f1",SYMLINK="input/irremote"

Restart udev using:

/etc/init.d/udev restart

You should now see a symlink to your event device:

$ ls -l /dev/input
total 0
crw-rw---- 1 root root 13,  64 2006-10-02 22:27 event0
crw-rw---- 1 root root 13,  65 2006-10-02 22:27 event1
crw-rw---- 1 root root 13,  66 2006-10-02 22:27 event2
crw-rw---- 1 root root 13,  67 2006-10-02 22:27 event3
crw-rw---- 1 root root 13,  68 2006-10-02 22:27 event4
lrwxrwxrwx 1 root root       6 2006-10-02 22:27 irremote -> event6
crw-rw---- 1 root root 13,  63 2006-10-02 22:27 mice
crw-rw---- 1 root root 13,  32 2006-10-02 22:27 mouse0
crw-rw---- 1 root root 13, 128 2006-10-02 22:27 ts0

Now simply change your LIRC config (/etc/lirc/hardware.conf) to use the new device:

LIRCD_ARGS=""

#Don't start lircmd even if there seems to be a good config file
START_LIRCMD=false

#Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="dev/input"
# If DEVICE is set to /dev/lirc and devfs is in use /dev/lirc/0 will be
# automatically used instead
#DEVICE="/dev/input/event2"
DEVICE="/dev/input/irremote"
MODULES=""

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""

Reboot and check that the symlink is created and that LIRC is working.