Saturday, January 31, 2009

How to add a Buffalo Linkstation Live to your network

This little beauty is one of those how-did-I-live-without-this gadgets. If you have the means, I highly suggest picking one up (and they aren't very expensive, I got a 500GB Linkstation Live for $160).


So, what is it? It's basically just a hard drive in an enclosure...BUT! The novelty is that it has an ethernet jack, and it's running a customized version of linux. Jack this badboy into your network, and you have an always-on storage solution that is accessible to all of your machines. Extra bonus: if you move your iTunes library onto this disk, it will automagically appear as a shared library on any computer running itunes on your network. Sweet. And for your non-itunes linux box, the same library appears as a hierarchical directory of mp3's so you're golden there too.

Making it work on OS X and iTunes


I set it up on my MacBook Pro first, and it was dead easy. Just use the installation CD that comes with the drive. It was a little unclear how the iTunes thing was going to work, but I just reset the library location in iTunes, then used the "Consolidate library" function to move all of my music to the Linkstation (this took several hours). This procedure is outlined by Apple here. After this completed, it "just worked".

Making it work on Linux


You will be shocked to learn that there's less "it just worked" in this description. However, it wasn't too bad. Basically, you need to mount the drive as a Samba share (which is odd, since samba is for mounting Windows disks, and the Linkstation is running Linux!). However! Samba is apparently no longer called "smbfs", it's now called "cifs". I don't know why, and I don't care enough to find out. Anyway, the relevant command (issued as root) is:


mkdir /mnt/netdisk (only need to do this once </obvious>)
mount -t cifs -o user=admin,password=your_password 192.168.1.127:/share /mnt/netdisk


(where "user" and "password" params should be replaced with the login info for your Linkstation, as set in the drive's installation program, and the IP address is set to the correct value as well...it's shown in the Linkstation config tool). Assuming that worked, the final step is to have it auto-mount by adding a line to your /etc/fstab:


192.168.1.127:/share /mnt/netdisk cifs credentials=/root/.creds,rw,uid=mythtv 0 0

and create the /root/.creds, make it look like:
username = admin
password = your_password


Again, this is the login information for your Linkstation. The "uid" param in the fstab line is the name of a user which will have read/write access to the disk.

Making it work on Windows


This is also quite easy. Open My Computer, then click on "My Network Places" on the left. Then click on "Add a network place" in the "Network Tasks" menu on the left. This opens the "Add Network Place Wizard", in which you will step through the following screens:






Wednesday, January 28, 2009

How to get MythTV-0.21 to wake up and shutdown automatically

MythTV is a Linux-based roll-your-own Tivo, and will probably be a major topic in this here blog.


I recently upgraded to version 0.21, and had a dickens of a time getting automatic wakeup/shutdown working. The problem is typical of linuxy things: there are many poorly described options, some of which seem to be redundant but interact in subtle and nefarious ways. Plus, while there is a huge amount of documentation online, a lot of it is contradictory or only applicable to specific (but often unstated) setups.


With that latter datum in mind: this is for Myth-0.21, and I am using ACPI for wakeup/shutdown, rather than NVRAM. Okay? Okay.


Step the First: Make sure acpi works on your machine



  • Find out what timezone your BIOS clock is using. There are ways to find out from within linux, but let's go straight down to the metal and ask the BIOS. So, reboot your box (bye-bye uptime!), and press Del or whatever to get into the BIOS. Check the clock time; hopefully it's either your local time or UTC. Make a note of it.
  • Boot into linux. If myth starts automatically, get out of it (keep pressing Esc until it asks if you're sure you want to exit...if that gets you the mythwelcome screen, press "M", then select Exit from the menu). At this point you should be in a desktop session of some kind.
  • Attempt a manual ACPI wakeup. I'm going to assume that your kernel has ACPI stuff set up already, so if this step fails you may need to do some kernel recompilin' (hooray!). Open a terminal. We want to send the BIOS a message to boot the machine in about five minutes from now, so query the current time by typing date, or date -u if your BIOS clock uses UTC. Then, we just need to write a time string set for five minutes from now into a particular file. For example, say that date -u returns "Wed Jan 28 12:35:42 2009". In that case, we would next type the following: echo "2009-01-28 12:41:00" > /proc/acpi/alarm. You should, of course modify the time string.


    Next, shutdown the machine. Quickly now, you only have 5 minutes! sudo shutdown -h now should do the trick. Wait five minutes. The machine should power on all by itself! Spooky! If it doesn't...like I said, you could be in for some serious tweaking. Google around for more detailed docu.



Step the Second: Configure MythTV


All right, we've verified that ACPI works and the system can auto-boot given a properly-formatted timestamp sent to /proc/acpi/alarm. Next, we will set up MythTV to enable auto wakeup/shutdown.


In an ideal world, the MythTV configuration for auto wakeup/shutdown would simply be a checkbox, tagged with the simple query "Would you like MythTV to automatically shutdown when idle and wakeup when it's time to record?". This is evidently not an ideal world, so prepare yourself for something rather more labyrinthine...


First of all, get out of MythTV if it's running. Just keep pressing "Esc" until it asks if you want to exit, then select "Yes"! If that gets you to mythwelcome, press "m", then select "Exit" from the menu. You should now be looking at a desktop session of some kind. Before we begin, kill the backend program by typing sudo /etc/init.d/mythtv-backend stop.


There are two screens full of options that you'll need to tweak. The first is in the backend config tool. Open an xterm (on KnoppMyth, you right-click the desktop, then select "XShells", "xterm". Since the default font is unreadable on a TV, I usually Ctrl-right-click on the xterm and select the "Huge" font). Now type mythtv-setup in the xterm to invoke the config tool. Select "General" from the menu, then skip to page 5 (press Enter 4 times). Make it look like this:




In particular:


  • Startup command: /usr/bin/mythwelcome
  • Block shutdown before client connected: checked
  • Wakeup time format: yyyy-MM-ddThh:mm:ss
  • Command to set Wakeup Time: sudo mythshutdown --setwakeup $time
  • Server halt command: sudo mythshutdown --shutdown
  • Pre Shutdown check-command: sudo mythshutdown --check

Set the time intervals to whatever you're comfortable with. I should probably change my "Max. wait for recording" to 30 minutes, because a 30-minute gap between recordings is relatively common. After you're done here, page through the rest of the config's many, many pages until you reach the Finish button (hooray!)


The next step is to run mythwelcome --setup. This tool is thankfully, only one page. Make it look like this:




That first line is truncated in the screenshot. In full, it reads:

sudo /usr/local/bin/convert_utc.sh $time; sleep 1; sudo /usr/local/bin/convert_utc.sh $time

This is an ugly belt-and-suspenders redundancy just to make sure that the convert_utc.sh script does its thing before the shutdown process begins. It would probably be more elegant to add the sleep 1 command to the script itself. (Note to self: do that!)


The other parameters are pretty straightforward. The "Command to shutdown" parameter is a useful place for some kung-fu if you need to diagnose shutdown problems. Just replace that command with killall mythwelcome and instead of shutting down, you'll simply get booted back to your desktop where you can check logs or console output (assuming you had started mythwelcome from an xterm). Pretty useful!


Step the Third: write convert_utc.sh


The convert_utc.sh script just takes the wakeup time string sent from MythTV (in Local time format), converts it to UTC, reformats it, and writes it to /proc/acpi/alarm. Here is my convert_utc.sh:




#!/bin/bash
stamp_file=/tmp/timestamp
#echo $1\ $2 > $stamp_file
echo $1 | sed "s/T/ /" > $stamp_file
# Add TZ info to the timestamp
datum=$(/bin/date -f $stamp_file +%F\ %T\ %z)
echo $datum > $stamp_file
#Express as UTC time
utcdatum=$(/bin/date -u -f $stamp_file +%F\ %T)

#uncomment for testing
#echo $utcdatum > $stamp_file

#uncomment to commit to /proc/acpi/alarm:
rm -f $stamp_file
echo $utcdatum > /proc/acpi/alarm
echo $utcdatum




Step the Fourth: Test Drive


Restart the backend (in an xterm or virtual terminal, type: sudo /etc/init.d/mythtv-backend restart). Next, type mythwelcome to start MythTV. Navigate to "Manage Recordings", "Schedule Recordings", "Program Guide", and pick something to record that's going to start relatively soon (but not too soon: if it starts within the "Max wait for recording" time interval, then MythTV will refuse to shutdown...for this reason, it's a good idea to keep Max-wait short while debuigging things). After clicking on the desired program, you get an extensive menu of recording/storage options. Set the program to record, then be sure to select "Save these settings". You should see an icon in the Program guide indicating that MythTV will record that program. Then exit MythTV (keep pressing Esc until you see the "Are you sure you want to exit???" question).


You should now see the mythwelcome screen, with status messages telling you that the system is currently idle, and that your selected program is the next thing to be recorded. You should see the idle timer counting down to trigger the ssytem shutdown. You can either let the timer run down, or press "m" to get a menu and select "shutdown now" from the menu. Hopefully, in either case your system will then shut itself off.


Now comes the real nail-biter. Will your system wake itself up to record the selected program? The wakeup time is controlled by the "startup before rec" option in mythtv-setup. So if that was set to 600 sec, then 10 minutes prior to the recording time, your computer should boot itself. Go grab yourself a sandwich, read a book, take a walk, ponder your existence, whatever. At the appointed time, you will hopefully hear the beeps and whirrs of your system waking up!


Step the Fifth: What if it doesn't work?


TBCompleted...

Tuesday, January 27, 2009

How to use iSync with a Motorola RIZR Z3

This is based on a fairly old tutorial I wrote in Aug 2007...however, that page is from my old job and could disappear at any moment.


Before you begin, you should quit out of iSync if you have it open (thanks for the tip, Levi!)


The driver can be downloaded from this page
(direct link to the driver). OS X wil automatically unzip the file, giving you a folder named MOTZ3.phoneplugin. Place this file in your /Library/PhonePlugins directory. Note: this is the root Library directory, not the one under your personal directory. Also, I had to create the PhonePlugins directory on my machine. YMMV.


Now, open System Preferences and go to the Bluetooth page. Select the Devices tab. If you've already attempted to pair wih your RIZR, delete its entry from the list (I'm not sure this is necessary, but it doesn't hurt).


Next, we need to activate the RIZR's bluetooth. Open the Main Menu, and select Settings, then Bluetooth Link. Select the [Find Me] entry. This will make your phone "discoverable" for three minutes.


Back on the mac, click the Set Up New Device... button in the SysPref | Bluetooth | Devices page. This launches the Bluetooth Setup Assistant:


  • Click Continue on the Intrduction page
  • Select Mobile phone from the list, click Continue
  • Select your Motorola Z3 from the list of detected phones, click Continue
  • Wait for it to "gather additional information", click Continue
  • Enter the numeric code that appears into your phone
  • Make sure Set up iSync to transfer contacts and events is checked. If this checkbox does NOT appear, then the Z3 plugin was not detected. Make sure you followed the plugin installation instructions.



Now launch iSync. If you don't have a Motorola Z3 button in the toolbar, select Add Device... from the Devices menu, and choose your Z3 from the list. Now you should be able to select the Z3 from the toolbar, and click on the Sync Devices button to sync your contacts and calendar events.


A Caveat



The sync will not copy your contact images over to the RIZR. Or at least, it didn't do so for me. This is a bit disappointing, and I can only hope that Apple's Z3 plugin will work better, assuming they eventually get around to publishing one.

Sunday, January 25, 2009

Manifesto

In which I document my efforts, failures and successes in trying to make my technology work.

These accounts will tend to document small, focused tasks (like "manually inserting videos into a mythtv database"), not huge projects (like "installing and using mythtv").