Saturday, February 16, 2013

MDL: Some More XBMC Tweaks

I’m now running two instances of XBMC Frodo each sharing a single MySQL database.  Frodo has allowed me to strip out some of the bandaids I put in place to make the experience as seamless as possible.
The box that I have in my family room is an Acer Aspire running Ubuntu.  That is also where MySQL is running.  The box I have in the basement is a Raspberry Pi running RaspBMC.
I used to have to store all of my thumbnails on an NFS mount and create linked directories on every box because XBMC wouldn’t regenerate thumbs locally if the content was already defined in the database.  Now with Frodo that isn’t necessary as XBMC will create thumbnails locally regardless of the existence in the database.
The other piece that I was able to strip out was a kludge of a script that attempted to force regeneration of  metadata and thumbnails when I made changes after the initial discovery.  MediaElch now allows me to edit metadata and force XBMC discovery of those change.
My tweaking is now limited to:
  • Creating symlinked NFS mounts for my content so that they show up in local paths (this is a work around so that I can use both Windows and Linux as XBMC hosts).
  • Some keymap customizations to work around limited remote functionality using Raspberry Pi and CEC.
  • Creating some dependencies for MySQL and XBMC.
Creating the database dependency in my family room was easy since the database was local.  I just needed to edit /etc/init/xbmc-live.conf and add:
start on started mysql 
pre-start script
while [ `mysqladmin ping -h 192.168.1.130 -uxbmc -pxbmc -s | grep -c alive` -eq$
do
  sleep 1
done
end script
sleep 5

Creating the dependency on the Pi was a bit more challenging.  After installing mysql-client via apt-get I added this code to the top of /scripts/xbmc-watchdog.sh.
#check to see if mySQL is running on the family room PC
while [ `mysqladmin ping -h 192.168.1.130 -uxbmc -pxbmc -s | grep -c alive` -eq 0 ]
do
  sleep 1
done

sleep 5

I’m reasonable sure that storing your password cleartext in a configuration script is dumb, but I doubt anyone will be trying to break in and sabotage my music collection.  I also don’t know if this is precisely the correct place to put the delay – but it seems to work so I’m declaring success.

edited to add pre-start script to family room config