image

Recently I have been looking for a way to stream music from my Ubuntu server to my iOS devices. I've investigated several options, including Plex, StreamToMe, iSub, Ampache, Air Playit, and others. However none of these* provide two features I really want to have:

  • queue tracks as you are listening to one so that your queue just keeps playing as you listen. I love this feature in Rhythmbox because it makes it so easy to listen to exactly what you want on-the-fly
  • download/cache songs on the iOS device so that I can listen to them when I do not have WiFi access. This will allow me to stream and download, the best of both worlds.

*iSub might, but I didn't try it because it is $15.00 after buying the server

Enter Audiogalaxy

I then came across Audiogalaxy, a free app for iOS and Android. You create an account, start an Audiogalaxy helper program on your server, and launch the app on your device. It is easy because the server application is tied to your Audiogalaxy account and automatically connects you to your server, no port forwarding or hostname entering required. There currently isn't a Linux version of the server, though one is in development. The developers have reported a number of people getting the server to work under WINE, so I tried it out and was able to get it running on my Ubuntu 11.04 desktop. However, I want to run it on my Ubuntu server, which does not have X11 installed and thus no graphical environment for WINE. To get around this and get the server working, I used the fake X11 server xvfb.

Initial Server Installation

Initially you need to run the installer and verify that everything is working. This requires that you forward the X packets to your local machine:

  • install the xauth package on the server to forward the X packets
  • open /etc/ssh/sshd_config in a text editor as root and make sure X11Forwarding is set to "yes". If you needed to update this file restart ssh: sevice ssh restart
  • open an ssh connection to the server, using the -X option: ssh -X user@serverhostname

If you are running Linux locally, you are already running an X server. For Mac OS X you need to launch the installed X11 application. For Windows, use xming. Try launching Audiogalaxy using WINE on your Ubuntu server: wine Audiogalaxy.exe. If everything works, you should see an icon appear in your system tray. Audiogalaxy will now be running and scanning your "My Music" folder in the WINE bottle. You now need to point this folder to your music collection:

cd ~/.wine/drive_c/users/yourusernamerm "My Music"ln -s /path/to/your/music "My Music"

Now check the Audiogalaxy web client or mobile client after a few minutes and you should see your songs start to appear.

Permanent Server Configuration

Under normal circumstances you want the fake x server (and thus Audiogalaxy) to remain running when you are not connected to the server. To accomplish this, install xvfb, a fake X server. Then create the init scripts below to start the server using the fake X11 environment.

Init Scripts

Install the following scripts for starting Audiogalaxy (and chmod +x them so they can be executed):

/etc/init.d/audiogalaxy:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
case "$1" in  
    start)        
        echo -n "Starting audiogalaxy"        
        /opt/bin/startag        
        echo "."        
        ;;  
    stop)        
        echo -n "Stopping audiogalaxy"        
        killall Audiogalaxy.exe        
        echo "."        
        ;;  
    status)        
        echo "Showing audiogalaxy processes below:"        
        ps aux | grep -i audiogalaxy | grep -v grep        
        ;;  
    *)        
        echo "Usage: /sbin/service audiogalaxy {start|stop|status}"        
        exit 1
esac
exit 0

/opt/bin/startag:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
######################
# Author: Andrew Martin (andrew "AT" avidandrew.com)
## Description: starts the audiogalaxy server (using WINE)
## Date: 08/30/11
#####################
# start the fake X server
Xvfb :0 -ac -screen 1 800x600x24 &

# set the $DISPLAY variable
export DISPLAY=localhost:0.0

# start audiogalaxywine /opt/bin/Audiogalaxy.exe &

# wait a bit to amke sure it stays going

echo -n "Waiting..."
sleep 10

# test to make sure it is still running
ps aux | grep Audiogalaxy | grep -v grep > /dev/null 2> /dev/null
if [ "$?" = "0" ]; then 
    echo "ok" 
    exit 0
fi

echo "failed"
exit 1

Add /etc/init.d/audiogalaxy to the default runlevels to start when the system boots by running: update-rc.d audiogalaxy defaults. Now, run service audiogalaxy start to start the server. Use service audiogalaxy status to confirm that the server is running and then you can disconnect and enjoy your Audiogalaxy music streaming from a Linux server!!