Friday, January 23, 2009

Installing SwissCenter on Ubuntu Server

I got SwissCenter up and running on my fit-PC Slim, which is now running Ubuntu 8.10 Server.

At first I was working off the official SwissCenter Linux install documentation which is for SuSE 9.3. Later on I found this cheatsheet for installing SwissCenter on Ubuntu which is a bit out of date now, but still very useful.

Install apache2 and mysql

I had these installed already, done in the standard way as in the Ubuntu Server Guide, which is to say
$ sudo apt-get install apache2
$ sudo apt-get install mysql-server
Actually, I had the default mysql instance disabled, so re-enable it now and maybe try converging to a single mysql instance later.
$ cd /etc/rc2.d
$ sudo mv K81mysql S19mysql
$ sudo /etc/init.d/mysql start
Install PHP
$ sudo apt-get install php5 libapache2-mod-php5 php5-mysql php5-gd
Install SwissCenter
$ wget http://www.swisscenter.co.uk/downloads/swisscenter.zip
$ sudo mkdir -p /srv/www/swisscenter
$ cd /srv/www/swisscenter/
$ sudo unzip ~/swisscenter.zip
$ sudo chown -R www-data:www-data .
(Using www-data which is the standard apache user/group in Debian-based distributions, rather than wwwrun as specified in the SwissCenter document.)

Enable the site in Apache

Slightly different from the document here... I appended the following to /etc/apache2/sites-available/default
Listen 8080
NameVirtualHost --myhostname--
<virtualhost>
DocumentRoot "/srv/www/swisscenter"
<directory>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</directory>
<ifmodule>
DirectoryIndex index.html index.php
</ifmodule>
</VirtualHost>
Then restarted apache.

Checking and configuring SwissCenter

Point web browser to the SwissCenter Configuration page at http://<servername>:8080/config. On first attempt, the page showed:
Warning: dl() [function.dl]: Dynamically loaded extensions aren't enabled in /srv/www/swisscenter/base/image.php on line 50

Fatal error: Call to undefined function imagecreatetruecolor() in /srv/www/swisscenter/base/image.php on line 251
After a bit of searching, I found I needed to include php5-gd (included in the install command above. I didn't have it originally), so
$ sudo apt-get install php5-gd
$ sudo /etc/init.d/apache2 restart
Better this time. But the page still shows some errors under Installation Checks.
Unable to locate a TrueType font. The "Now Playing" screen will be missing track information.
Google turned up this, which helped me to find Advanced Options / Miscellaneous in the SwissCenter configuration pages where you can set the path to a TT font. I entered /usr/share/fonts/truetype/freefont/FreeSans.ttf.

That left a warning that database is not created yet. You create it from the SwissCenter Create Database page. On first attempt, I got
Unable to create database - Is your MySQL "Root" password correct?
Umm... Looks like I changed the default mysql root password when I installed mysql. I've forgotten it now. So I had to reset the root password. Now I can create the database successfully.

Back on the main Configuration page,
Unable to write to the SwissCenter playlists directory (playlists)
Under Media Management / Playlists, you enter a full path to a dir (which must be writeable by www-data user), i.e. created something like
$ sudo -u www-data mkdir <some_dir>
After all that, SwissCenter is up and ready to load some content. I pointed it to my photos and music directories for a start.

Accessing SwissCenter from the Popcorn Hour

The simplest way for a start is to add the SwissCenter URL to the Web Services page in the Popcorn Hour, i.e. create an entry pointing to http://servername:8080.

But you can run an additional service on the server to broadcast the SwissCenter's UPnP interface. With that running, SwissCenter shows up automatically in the Popcorn Hour's Media Sources page.

There's a nice custom broadcast script and a Debian init script to start and stop this broadcast service automatically. I modified the init.d script slightly to make it run in the background:
$ diff -upN broadcast.orig broadcast
--- broadcast.orig 2008-09-11 17:02:03.000000000 +0100
+++ broadcast 2009-01-11 02:00:52.011883945 +0000
@@ -46,7 +46,7 @@ do_start()
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
|| return 1
- start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
@@ -95,7 +95,7 @@ do_reload() {

case "$1" in
start)
- [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ log_daemon_msg "Starting $DESC" "$NAME"
do_start
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
@@ -103,7 +103,7 @@ case "$1" in
esac
;;
stop)
- [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ log_daemon_msg "Stopping $DESC" "$NAME"
do_stop
case "$?" in
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;

And that's about it.

Thursday, January 8, 2009

I got a Popcorn Hour

I got a Popcorn Hour A-110 (AKA Networked Media Tank) media player just before Christmas.

I've had my Squeezebox network music player for a couple of years now, and along the way I've got hooked on
  • the idea of storing my digital media centrally

  • running a low power server

  • hacking around with Linux
So now I'm going to have a go at streaming video. The Popcorn Hour seems like a good device to do it with.

My video content is DVDs ripped in full to ISOs using DVDFab (free version). I'm not compressing or discarding any of the non-movie content yet. But as each title takes 6-8GB, I might look into one or both soonish...

So far, I've had perfect success viewing this content on my TV in these ways:
  1. From an external disk (NTFS formatted), connected to a USB port on the Popcorn Hour.

  2. From an NFS share hosted on my fit-PC mini server, with the content stored on it's internal disk.

  3. As previous, but with the content on the external disk, connected to a USB port on the fit-PC.

  4. As previous, but using Samba instead of NFS.
For options 2-4 this is streaming via a pair of Devolo Homeplug AV adapters (AKA powerline networking). One adapter is connected to my router in the "server room". The other is connected to the Popcorn Hour in the TV room.

I hadn't expected the Homeplug setup to work. Quite a few people have reported problems with powerline networking on the Popcorn Hour forums. (And I had previously been unsuccessful streaming this way to a Hauppauge MVP box - it stuttered badly whatever I tried.) So was resigned to somehow running a cable from one end of the house to the other. But happy day, it is working flawlessly for me - at least for this standard-def content.

And my fit-PC handles streaming the video over NFS and Samba without breaking sweat.

Loads of scope for geeky time suckage with this. So more posts may follow.

(It took me absolutely feckin' ages to successfully export an NFS shared from a directory mounted from the NTFS formatted USB disk, but that's a whole other story.)