Install Subsonic on Ubuntu Server

Subsonic is a free, web-based media streaming application. After evaluating it alongside Jinzora and Sockso, I selected it for use on my servers. Internally, I have been using Firefly Media Server (previously called mt-daapd) to make music available to different desktop music players. Subsonic had several features that made it a good choice including allowing music from several different directories, Last.fm scrobbling support/integration, and multiple users with passwords and support for LDAP integration.

I installed Subsonic on a server running Ubuntu Hardy Heron Server. I built on a previous tutorial for installing Subsonic on Ubuntu.

First, I install the necessary Java packages, Tomcat, and Lame. I broke it into three installs to be safe. It could probably be done in one.

apt-get install java-common sun-java6-bin sun-java6-jdk sun-java6-jre
apt-get install tomcat5.5
apt-get install lame

Next, I stopped Tomcat before changing the Tomcat configuration and installing the Subsonic web application.

/etc/init.d/tomcat5.5 stop

Next, I disabled the Tomcat security stuff. It’s required for Subsonic to work. You could do this by editing the file directly (/etc/init.d/tomcat5.5), but I use Sed so that I can automate the installation process in a script.

cd /etc/init.d/
mv tomcat5.5 tomcat5.5.bak
sed "s/TOMCAT5_SECURITY=yes/TOMCAT5_SECURITY=no/" tomcat5.5.bak > tomcat5.5
chmod +x tomcat5.5
rm tomcat5.5.bak

Next, I downloaded, decompressed, and installed the subsonic application.

cd /tmp/
wget http://superb-east.dl.sourceforge.net/sourceforge/subsonic/subsonic-3.6-war.zip
unzip subsonic-3.6-war.zip -d subsonic
mv subsonic/subsonic.war /var/lib/tomcat5.5/webapps/

Subsonic expects certain directories to exist. The following creates those directories and sets the permissions.

mkdir /var/subsonic
mkdir /var/subsonic/playlists
mkdir /var/subsonic/transcode
chown -R tomcat55:nogroup /var/subsonic

Subsonic uses Lame to transcode/compress mp3s for streaming. The next two lines make Lame available to Subsonic.

cd /var/subsonic/transcode
ln -s /usr/bin/lame lame

Now we can start Tomcat again.

/etc/init.d/tomcat5.5 start

I always like to clean up after my installs. This removes the files we downloaded and no longer need any more.

rm -R /tmp/subsonic*

Subsonic should now be running and available at http://localhost:8180/subsonic/. The port might vary depending on the installation of Tomcat. Log in. You can change the password by clicking on “Settings” and then “Users” and then selecting the admin account.

Next, I configured LDAP authentication. It was as simple as clicking on “Settings” and then “Advanced” and then “Enable LDAP authentication.” I then filled in the following:

  • LDAP URL: ldap://athos.lund:389/dc=lund
  • LDAP search filter: (uid={0})

I left the “LDAP manager DN” and “Password” blank. I checked “Automatically create users in Subsonic” so that any user in LDAP can automatically log into Subsonic.

If you would like to make Subsonic available on port 80 like most web applications instead of port 8180, check out my post on Reverse Proxies.

Configuring a Mail Server with Postfix

I gave a presentation about Postfix to the Marquette University ACM chapter. It should be a useful starting point for configuring a Postfix mail server. I include details about much of the configuration including canonical maps which was something that I initially found difficult to figure out.

Rather than creating my presentation in Microsoft PowerPoint or OpenOffice.org Impress, I decided to check out the LaTeX Beamer package for my presentation. Since I’ve been using LaTeX for a while, it wasn’t too difficult to figure out, and it worked particularly well because most of the presentation is Postfix configuration text which I could easily include in the presentation.

The presentation is available as a PDF for download.

Resizing LVM Partitions

My brother Ben has installed quite a few games and other things on his Ubuntu desktop. Because most of these are programs are available as packages, his 6 GB root partition started getting a bit small. He has a 500 GB hard drive partitioned into root, swap, and home. Ben and I decided to transfer 20 GB from his home partition to his root partition. The drive was configured with LVM which is supposed to make this procedure simple. It turns out it was mildly more complicated than simple, but it wasn’t too bad.

The first step is to boot from a CD like GParted. GParted provides the necessary LVM command line tools to resize the partitions. We need to boot from a CD or another drive because we will be modifying the root partition.

Because I was booted from a CD, I did not capture the output from the commands that I used. The first step is to find the name of the LVM volume group:

lvdisplay

On Ben’s computer, the volume group was “loki”. Next, we make that volume group available:

vgchange --available y loki

Then we decrease the size of the home partition. First we resize the EXT3 file system and then we resize the LVM partition. The “e2fsck” commands check and repair the file system as we go. We are resizing the home partition from 440 GB down to 420 GB.

e2fsck -f /dev/loki/home
resize2fs /dev/loki/home 420G
e2fsck -f /dev/loki/home
lvreduce --size 420G /dev/loki/home
e2fsck -f /dev/loki/home

Once the 20 GB is available, we increase the size of the root partition. We do this in reverse order. First we increase the size of the LVM partition and then increase the size of the file system.

e2fsck -f /dev/loki/root
lvextend --size +20.15G /dev/loki/root
e2fsck -f /dev/loki/root
resize2fs /dev/loki/root 26G
e2fsck -f /dev/loki/root

We rebooted Ben’s computer again, and he now had 26 GB root partition.

OWA Sync on Ubuntu

Update: OWA Sync V0.6 (the current version) is not compatible with Exchange 2007. When I set this up, I was connecting to Exchange 2003.

I use OWA Sync to get all of my calendar information onto my Ubuntu desktop. I recently rediscovered the Little Brother’s Database and decided to make my OWA contacts available in Mutt on my Ubuntu desktop, too. (I used lbdb to make my contacts in Apple Address Book available to Mutt when I was still using Mac OS X as my primary operating system.)

The OWA Sync website has a decent explanation of creating a owaSyncrc file. After I created that, I wrote a script that runs as a cron job.

#! /bin/bash

export PATH=$PATH:/usr/local/bin/

/usr/local/bin/owaSync.kit -update

cat $HOME/.owa/Calendar/*.ics > $HOME/.calendar.ics
cat $HOME/.owa/Contacts/*.vcf > $HOME/.contacts.vcf

After a bit of trial and error, I figured out that “/usr/local/bin/” needed to be in the path for the owaSync.kit script to run. After the synchronization is complete, I then concatenate all of the calendar events into a single file and all of the contact cards into a single file. I now have a single calendar file that I can use with PHP iCalendar and a single contacts file that I can use with lbdb. It requires a fairly simple rc file that looks something like this:

METHODS="$METHODS m_vcf m_muttalias"

VCF_FILES="$HOME/.contacts.vcf"
MUTTALIAS_FILES="$HOME/.mutt/aliases"

I add “m_vcf” and “m_muttaliases” to the “METHODS” and then I specify the locations of my OWA contacts and my Mutt aliases. Now when I launch Mutt, I can query for addresses that I downloaded from OWA.

Adobe Flash 10 on Ubuntu Hardy Heron

I finally got sick of having to use Hulu on my MacBook Pro instead of my Ubuntu desktop and decided to see if I could fix the Flash player problems. It turns out that the fix was simple. This article from Ubuntu Geek makes it easy. Since I am running a 64-bit OS, I used the 64-bit instructions:

wget http://queleimporta.com/downloads/flash10_en.sh
chmod +x flash10_en.sh
sudo bash ./flash10_en.sh

Now Hulu works just fine in Firefox on Ubuntu.

April Fools Prank

Inspired by Upside-Down-Ternet, I decided to get two of my housemates back for the Tabasco and Whiskey shot that they gave me when we went out for my birthday. Flipping all of the images upside down was a little too subtle though. I prefer the all-out, in-your-face kind of April Fools revenge prank.

It turns out all I had to do was find the IP addresses for my housemates’ computers, create the awesome pwned page, and issue two commands on my DD-WRT router:

root@Madrona:~# iptables -t nat -I PREROUTING -s 192.168.1.187 -p tcp -j DNAT --to-destination 192.168.1.42
root@Madrona:~# iptables -t nat -I PREROUTING -s 192.168.1.190 -p tcp -j DNAT --to-destination 192.168.1.42

When those two housemates went to check Facebook (or any site) this morning, they were greeted with this instead:

Pwned by the Zaxor!

Pwned by the Zaxor!

Their reactions made it worth it. Tyler said, “Pwned? What is pwned?” David said, “What the hell is a Zaxor?”

Even though I downed the entire Tabasco and Whiskey shot, let this be a lesson that I always take my revenge convey my thanks in kind.

(Lack of) Time Warner Internet Problems

I first started having intermittent connection issues with my Time Warner Internet connection sometime in May of 2008. After dealing with a total of 15 different individuals in Time Warner Technical Support over the course of 8 months, I finally got the issue resolved on February 3rd, 2009. On February 3rd, a technician came out and replaced our modem for the second time. I’m not sure what made this change different, but our connection has behaved itself since. I posted the scripts I use to monitor my connection, reboot the modem, and parse the log file on my personal website a while back. Now that things appear to be working correctly, I decided to parse my logs and see what they show.

Jul 2008: 472
Aug 2008: 507
Sep 2008: 188
Oct 2008: 217
Nov 2008: 1084
Dec 2008: 935
Jan 2009: 348
Feb 2009: 160
Mar 2009: 144

Downtime is counted in minutes. That means that in February and March, we experienced around 5 minutes of downtime per day. Most likely these minutes were non-conservative and were not noticeable. During the worst months of November and December, we experienced more than a half hour of downtime each day. This was quite noticeable and often occurred in 3, 6, or 9 minute blocks of downtime.

The best conclusion to take away from this is that pinging a server every minute to check connection availability is not granular enough to be overly useful statistics, but it was very useful to ensure that our Internet connection did not remain down for hours at a time.

svn switch

I’ve struggled with this command for a while. It should let me change the URL of a directory in a repository, but I’ve never had any luck. It turns out it wasn’t so hard. Running “svn info” shows the current URL and that it ends in “cosc170″.

zlund@kastria:~/compilers$ svn info
Path: .
URL: svn+ssh://dakara/home/zac/repositories/marquette/cosc170
Repository Root: svn+ssh://dakara/home/zac/repositories/marquette
Repository UUID: e0bd8123-bfd5-445b-929b-77a6dd82f418
Revision: 29
Node Kind: directory
Schedule: normal
Last Changed Author: zac
Last Changed Rev: 27
Last Changed Date: 2009-01-31 15:06:57 -0600 (Sat, 31 Jan 2009)

I want to change “cosc170″ to “cosc/170″ because I already made this change in the repository and the URL is out of date on this working copy. Therefore, I type “svn switch” followed by the new URL and then a “.” to specify the current directory.

zlund@kastria:~/compilers$ svn switch svn+ssh://dakara/home/zac/repositories/marquette/cosc/170 .
At revision 36.

It updates the URL and the working copy. Now a “svn info” shows the correct URL and the updated revision number.

zlund@kastria:~/compilers$ svn info
Path: .
URL: svn+ssh://dakara/home/zac/repositories/marquette/cosc/170
Repository Root: svn+ssh://dakara/home/zac/repositories/marquette
Repository UUID: e0bd8123-bfd5-445b-929b-77a6dd82f418
Revision: 36
Node Kind: directory
Schedule: normal
Last Changed Author: zac
Last Changed Rev: 33
Last Changed Date: 2009-03-09 23:18:47 -0500 (Mon, 09 Mar 2009)

When the directory structure of a repository changes, it isn’t necessary to check out a new copy. The existing working copy can be updated to reflect the change to the repository.

Recording Cell Phone Voicemails

My girlfriend Clarissa asked me if it is possible to save a voicemail message that is stored by her mobile provider’s voicemail system. The short answer is no, but I figured I could do better.

Google released Google Voice which replaces GrandCentral. I went ahead and upgraded my GrandCentral account to a Google Voice account. It went smoothly, and now my Gmail account is integrated with my old GrandCentral account. I have my Google Voice account configured to ring my office phone, my mobile phone, and a Gizmo5 SIP account.

Back to saving a mobile voicemail message. Since it costs to dial out through Gizmo, I figured I could place the call through Google Voice and answer it with the Gizmo client on my laptop. Then I could use Gizmo to record the voice mail message and then send it to Clarissa. I entered her mobile number on Google Voice and hit dial. I answered it on the Gizmo client, but pressing # did not prompt me to enter her PIN to check her messages. When I tried doing the same thing on my office phone, it worked fine. After a bit of creative thinking, here is the solution that I came up with:

  1. Dial my Google Voice phone number on my office phone, and then answer the call in the Gizmo client.
  2. Start a new call on my office phone, and dial Clarissa’s mobile number.
  3. When Clarissa’s recorded greeting starts playing, hit #. When prompted for her PIN, enter her PIN.
  4. Conference the two calls together on my office phone, and mute myself on the office phone and in the Gizmo client.
  5. Hit record in the Gizmo client.
  6. When the message is done playing, hang up the conference call on my office phone, and hang up the call in the Gizmo client.
  7. Edit the recording to remove unnecessary audio from the beginning and end of the message.

There you have it, an elaborate solution to record voicemails stuck in your mobile voicemail inbox. I have been using YouMail to avoid this problem, and I plan on helping Clarissa switch to it soon.

Bad Bash Sourcing

A while back I switched such that my .bash_profile sources my .bashrc instead of the reverse. Based on a few sources, this seems to be the preferred approach. Today I decided to push those files to a few servers that haven’t been updated lately. I transferred my .bash_profile and then my .bashrc:

zac@dakara:~$ scp ~/.environment/bash/bash_profile lansky:~/.bash_profile
bash_profile                                  100%  120     0.1KB/s   00:00
zac@dakara:~$ scp ~/.environment/bash/bashrc lansky:~/.bashrc
lost connection

What happened? My .bash_profile sources my .bashrc, but since I hadn’t yet replaced the .bashrc, it still sources my .bash_profile. That means infinite loop and that I am an idiot. SSH, rsync, and scp are all broken. There is no way to remove or replace either of those files without another account. I guess it’s time to open a support ticket at DreamHost.

The moral of the story is to always be careful how you source those files. I usually try to keep an SSH session open on the remote machine when I modify those files in case I break login, but this time I didn’t. A few searches didn’t reveal any solutions. I’d love to know if someone has a way of resolving this without access to another account on the remote machine.