My ongoing experiences with Ubuntu, and later Mythbuntu, as a media center with MythTV. I'm also using the system for a virtual machine server, a mediawiki server and a general all around home infrastructure base.

Thursday, October 30, 2008

Installing apt-cacher

In preparation for upgrading to 8.10 I decided to install a apt-cacher on my home network. Basically I followed the directions at the link in the prior sentence with some tweaks as described below.

First, install:
# apt-get install apt-cacher

Then configure the deamon to always be on by editing /etc/default/apt-cacher and changing AUTOSTART=0 to AUTOSTART=1:
vi /etc/default/apt-cacher

Then I edited /etc/apt-cacher/apt-cacher.conf to restrict access to my local network. I also added the path_map directive, though I'm pretty sure I'm not using it right now.
# cd /etc/apt-cacher
# cp apt-cacher.conf apt-cacher.conf.orig
# diff apt-cacher.conf.orig apt-cacher.conf
< allowed_hosts=* --- > allowed_hosts=,
> path_map = debuntu ; ubuntu; ubuntu-updates ; ubuntu-security

Ok, first addition to the directions here. Later when the anacron job /etc/cron.daily/apt-cacher ran, I got the following errors:
Use of uninitialized value in concatenation (.) or string at /usr/share/apt-cacher// line 169, <$listpipe> line 244.
Use of uninitialized value in concatenation (.) or string at /usr/share/apt-cacher// line 169, <$listpipe> line 245.

I found this bug report describing the error. Following the report, I edited /usr/share/apt-cacher/ as described in the bug report.

Ok, now you are ready to fire up apt-cacher. The missing log messages happen the first time and then went away.
# /etc/init.d/apt-cacher restart
Restarting Apt-Cacher: apt-cacherWarning: /var/log/apt-cacher/access.log missing. Creating.
Warning: /var/log/apt-cacher/error.log missing. Creating.

At this point you should be able to point your web broser at http://cache-host:3142/ (replace "cache-host" with the actual IP or hostname of your host) and see the apt-cacher status page. You can also visit http://cache-host:3142/report/ to get a report of how well your cacher is doing, though it won't have any interesting content until it's been running for a day.

Then I imported existing package from /var/cache/apt/archives/ to apt-cacher repository:
# /usr/share/apt-cacher/ /var/cache/apt/archives

Ok, now to configure the client systems, including the system on which apt-cacher is running, I followed the advice from EWB's comment and created /etc/apt/apt.conf.d/90local-proxy on each system (again, replace cache-host with your actual IP address or hostname):

# vi /etc/apt/apt.conf.d/90local-proxy
# cat /etc/apt/apt.conf.d/90local-proxy
Acquire::http::Proxy "http://cache-host:3142";

Now you can do a apt-get update. Expect this to take a while the first time you run it.

# apt-get update

That's it. Just sit back and enjoy the caching.

Update: After upgrading 5 systems (1 server, 3 VMs and my laptop) to 8.10 using the cacher, here the stats from the report for the day showed it saved me 48% of my apt-get traffic (956MB out of 1980MB).

Monday, October 27, 2008

WPA on Dell Inspiron 6000: No luck

My other system is a Dell Inspiron 6000 laptop on which I also have Ubuntu 8.04 running. I tried moving my wireless to WPA today and had no luck getting the laptop working. Every time I entered the WPA passphrase, it would try to connect for 10 seconds and then prompt for the passphrase again.

I tried these directions to no avail.

I tried following the directions here and installing the latest and greatest network manager, but to no avail.

I tried disabling the Gnome Network Manager and following these directions, but no luck either.

This guy apparently just thinks I'm an idiot.

Anyone got WPA working on a Dell Inspiron 6000 with Ubuntu 8.04? Getting wireless working was a snap, but WPA is eluding me so far...

In case it maters, I have d a Broadcom BCM4318:
% lspci | grep Wireless
03:03.0 Network controller: Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller (rev 02)

Update: Well the youtube guy was right, I'm an idiot :-) Turns out I must have had a cut'n'paste error when I set the password on my WPA network, so it worked from the machine I set it on (pasted the same password), but somehow I transcribed it wrong into my KeePass database. Once I got the right password, things work fine.

Saturday, October 25, 2008

Turning off screen saving (one more time)...

I've been wrangling with the screensaver and DPMS on my Mythbuntu box (see here and here).

At this point I've got DPMS off but still have one nagging issue - some screensaver is kicking on and I have to press a button on the remote to get it to turn off. Better than having to hit a key on the keyboard, but still not what I want - I just want to turn on the monitor and see my MythTV dammit.

First, I figured out that I could disable DPMS with the ~/.xsessionrc file, e.g:
$ cat ~/.xsessionrc
xset s noblank
xset s off
xset -dpms

Now, that should turn off the X screensaver too, but seems like something is still running. Ah, poking around I find I have gnome-screensaver running:
$ ps auxwww | grep gnome-screensaver
user 6086 0.0 0.1 15420 4908 ? Ss Oct19 0:32 gnome-screensaver

Poking around the net, I came across this thread, and I followed the directions to kill the gnome-screensaver:
$ killall gnome-screensaver
$ ps auxwww | grep gnome-screensaver
user 32499 0.0 0.0 3004 764 pts/1 R+ 08:34 0:00 grep gnome-screensaver

After that I played around a little and that did the trick - no more screensaver kicking on! So, following the directions a little further down in the thread I turned it off permanently:
$ gconftool-2 --type boolean -s /apps/gnome_settings_daemon/screensaver/start_screensaver false

So at this point I think I finally have all the screensavers, DPMS, etc. turned off on my MythBuntu box using the directions above.

Update 11/3/2008: Well, the gconftool-2 command above didn't persist through a reboot. So following these directions, I did the following (will update when I've confirmed if it worked or didn't):

gconftool-2 --type bool --set /apps/gnome-screensaver/idle_activation_enabled false

Update 1/10/2009: Well, the above didn't work. Next I tried directions in this post. First, I ran "gconf-editor" from a command-line. Then I selected "Apps" and "gnome-screensaver". Under the options for "gnome-screensaver" I deselected the option for "idle_activation_enabled".

After that, I rebooted and re-ran gconf-editor to make sure the "idle-activation_enabled" variable was still de-selected and it was. I've been watching my mythtv system idle now for over an hour and no screensaver. Success finally.

Sunday, October 19, 2008

Creating ssh-only account

I wanted to create some accounts that could only be accessed via ssh key authentication. These would be accessed via cron jobs on another system for backing things up. Here's my process.

On the target host, create the account:
# useradd -m web-server-backup

You can verify this account has no password by the prescence of the "!" in the second field in /etc/shadow:
# grep web-server-backup /etc/shadow

Now, back on the system that will be accessing the account, create a ssh key pair. Since this will be running unattended from cron, I will leave the password empty (i.e. just hit return):
# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): just hit return
Enter same passphrase again: just hit return
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
d3:ac:99:5f:9c:30:69:98:ad:ab:e9:e5:ef:34:38:bf root@web-server

Copy the public key you just created into your clipboard:
# cat ~/.ssh/
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArh6BSw0F1Li/Oh1GbqF6uTv34P4e0Ow7NMco962aHe070vGjlyqIE3CrOU9d3/ztoL7QgalegWj7WfWQ44I8Jz0WGTzLcssYhvluaHzBp5z8QKVvmSpj39f43kAYP0b2GdUwGZL9AER72MRZSxmaybzGoVK12bPr6t18gaAWl9c3b1Ng8MFbp7vvNptfb6NwikfOaL4vTqRfNuVWv6vxaw3xfE+8iuI8ubckUCqrNfayVmfgCmxNS5o9GauHSAZdXhH1xDkZ0ikjo4SAjYz83/eyNdrwef6GTQj+FXwsaiGSpz9B0IOWt613+MhI/uoXRTO2jNzJstBcQa19GbX0Hw== root@web-server

Now on the target account, create ~/.ssh:and copy the public key into ~/.ssh/authorized_keys:
# sudo -u web-server-backup -i
$ mkdir ~/.ssh
$ chmod 700 ~/.ssh
$ cat > ~/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArh6BSw0F1Li/Oh1GbqF6uTv34P4e0Ow7NMco962aHe070vGjlyqIE3CrOU9d3/ztoL7QgalegWj7WfWQ44I8Jz0WGTzLcssYhvluaHzBp5z8QKVvmSpj39f43kAYP0b2GdUwGZL9AER72MRZSxmaybzGoVK12bPr6t18gaAWl9c3b1Ng8MFbp7vvNptfb6NwikfOaL4vTqRfNuVWv6vxaw3xfE+8iuI8ubckUCqrNfayVmfgCmxNS5o9GauHSAZdXhH1xDkZ0ikjo4SAjYz83/eyNdrwef6GTQj+FXwsaiGSpz9B0IOWt613+MhI/uoXRTO2jNzJstBcQa19GbX0Hw== root@web-server
$ chmod 600 ~/.ssh/authorized_keys

Now back on the accessing account, you should be able to access the target account without a password. The first time you do this you will be prompted to trust the host key of the target system, so you should do this once to make this process without prompt.

# ssh -l web-server-backup file-server date
The authenticity of host 'file-server (' can't be established.
RSA key fingerprint is 4c:7a:f0:ba:0f:60:45:4b:b8:f1:cc:17:88:59:74:f0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'file-server,' (RSA) to the list of known hosts.
Sun Oct 19 13:06:52 CDT 2008

Now it should work seamlessly:
# ssh -l web-server-backup file-server date
Sun Oct 19 13:08:19 CDT 2008

Sunday, October 12, 2008

sbackup without GUI

I recently wanted to install and run sbackup without using the GUI interface (this was on my mythbuntu system and I didn't want to interrupt my show). Not that the sbackup package unfortunately requires X11 and Gnome, so you can't use it on a lean server system.

Start by installing it:

# apt-get install sbackup

The configuration is in /etc/sbackup.conf, edit this file. Basically you want to set your target and then under [dirconfig] set what paths you want backed up.

# cp /etc/sbackup.conf /etc/sbackup.conf.orig
# vi /etc/sbackup.conf
# diff /etc/sbackup.conf.orig /etc/sbackup.conf
< target=/var/backup
< #target=ssh://
> #target=/var/backup
> target=ssh://casey-backup@file-server/mnt/backups/casey
< /usr/local/=1
< /var/=1
> /usr/local/=0
> /var/=0

You can test your configuration by running /usr/sbin/sbackupd (this returns nothing for me, which apparently indicates success):
# /usr/sbin/sbackupd

Now install a cron job to run it (this one runs it every night at 12:30):
# cat /etc/cron.d/sbackup
30 12 * * * root test -x /usr/sbin/sbackupd && /usr/sbin/sbackupd


Just a quick entry about getting music playing working on MythBuntu. Basically just follow the directions at the MythTV MythMusic page.

Some configuration I did:
  1. Under Utilities/Setup->Setup->Media Settings->Music Settings ->Player Settings->screen 1 check "show entire music tree"
  2. On screen 3 set up some vizualizers
  3. Under Utilities/Setup->Setup->Media Settings->Music Settings ->Ripper settings->screen 2, set the following:
    • Encoding: Lame (MP3)
    • Default Rip Quality: Medium
    • Enable "Use variable bitrates"
That's it for playing. I still can't import CD's at this point - it causes mythtv-frontend to crash! Looks like this bug.

Auto-updates under mythbuntu

Seems like mythbuntu doesn't install any sort of auto-update process, so I did the following to set one up.

First, I installed cron-apt:

# apt-get install cron-apt

Then, I created the following cron job:
# crontab -e
# crontab -l | tail -1
0 1 * * * /usr/bin/cron-apt && /usr/bin/apt-get -y dist-upgrade

Adding more space for MythTV

I noticed that my mythtv data directory was almost full:
# df | grep data
/dev/sda6 190957912 176125932 5208248 98% /mnt/data

Since I had 256GB of disk I wasn't using, I decided to add that as a second data directory for MythTV. So I mounted this partition as /mnt/data2 and then created /mnt/data2/mythtv

I then made sure mythtv owned the new directory:
# chown mythtv:mythtv /mnt/data2/mythtv

Then I added this directory to the default MythTV storage group, which was the usual MythTV menu hell:

  1. Select "Utilities/Setup"

  2. Select "Setup"

  3. Select "MythBuntu" and enter root password when prompted

  4. Select "MythTV Configuration"

  5. Select "Launch MythTV Setup"

  6. Select "Storage Directories"

  7. Select "Default"

  8. Select "Add New Directory"

  9. Enter the name of the new directory (e.g. "/mnt/data2/mythtv")

  10. Hit Escape 3 times to start exiting out

  11. At this point I was presented with a warning that *none* of my mythtv data directories were writable. After double checking that I entered it right and that the directories were actually writable by themythtv user, I selected "No, I know what I'm doing"
  12. Continue to exit out of menus by selecting "OK"

  13. I canceled running mythfilldatabase

  14. At this point things seemed to hang for 20-30 seconds with me just starting at a blank MythTV background. I think you just wait it out. I hit escape a couple times, but don't know that actually did anything.

  15. Select "Quit"

  16. Hit Escape until you get back to the top-level MythTV menu and then select "Information Center"

  17. Select "System Status"

  18. Under "Machine" you should now see the second directory listed.

Sunday, October 5, 2008

More memory and another hard disk...

Running the VMs, I was concerned about memory, being that the system only had a GB, which doesn't got far with VMs running. Looking in the system I saw it had two free slots, so I found 2 GB cheap and intstalled them and all looked good after booting:

$ dmesg | grep Memory
[ 19.312226] Memory: 3041212k/3079040k available (2177k kernel code, 36516k reserved, 1006k data, 368k init, 2161536k highmem)

I also installed another hard drive. I had already filled to the two bays at the bottom front (the original drive plus one more), but I found that a third drive could be put into an open bay under the CD-rom drive. I don't see any way of nicely adding a fourth though...

Friday, October 3, 2008

Upgrading Mediawiki

There was an announcement of a security update to mediawiki, so I upgraded. Here are the steps that worked for me, based on the directions at

Download the latest version:
# cd /tmp
# wget

Stop Apache:

# /etc/init.d/apache2 stop

Backup the database:

# mysqldump --all-databases --xml -p > db-backup.xml
Enter password:
root@web-server:~# ls -l db-backup.xml
-rw-r--r-- 1 root root 6008760 2008-10-03 06:34 db-backup.xml

Backup my current wiki directory:

# cd /var/www
# tar cvfz wiki-backup.tar.gz wiki/

Installed the new software:

# tar xvfz /tmp/mediawiki-1.13.2.tar.gz -C wiki/ --strip-components=1

I didn't have AdminSettings.php, so I created that, setting values for wgDBadminuser and wgDBadminpassword:

# cd wiki
# cp AdminSettings.sample AdminSettings.php
# vi AdminSettings.php

Ran update.php:
# cd maintenance/
# php update.php
MediaWiki 1.13.2 Updater

Going to run database updates for wikidb-mw_
Depending on the size of your database this may take a while!
Abort with control-c in the next five seconds...0
...have ipb_id field in ipblocks table.
Deleting old default messages (this may take a long time!)...Done
Checking site_stats row...ok.
Purging caches...done.

Restart Apache:

# /etc/init.d/apache2 start
* Starting web server apache2

And fired up a web browser and tested. Everything looked good.