Subsonic Forum Forum Index Subsonic Forum

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   SmartFeedSmartFeed   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to install Subsonic on unRAID

 
Post new topic   Reply to topic    Subsonic Forum Forum Index -> Tutorials
View previous topic :: View next topic  
Author Message
kapz



Joined: 21 Jun 2006
Posts: 81

PostPosted: Wed Nov 18, 2009 8:35 pm    Post subject: How to install Subsonic on unRAID Reply with quote

unRAID Server is a Network Attached Storage server operating system designed to boot from a USB Flash device and specifically designed for digital media storage. More information can be found on the website.

I recommend using unRaid 4.6-beta11 or above. There is a significant performance increase with listing large music folders.

I have been a Subsonic user for many years. I have found it to be invaluable to me. I see no reason to be limited by a portable mp3 player (or waste money). Most cell phones these days can play music anyhow. Subsonic allows access to your entire music collection, not just what you have on the internal memory of your ipod/whatever. And there is only one device to carry around. My unRaid hardware consists of a 2.7GHz single-core and 2GB RAM. This runs Subsonic great (even better than WinXP/Apache on a faster computer). I’m new to linux/unRaid, but I hope this guide helps others try Subsonic on unRaid for themselves.

Remember, unRaid runs completely in memory and files need to be copied to non-volatile memory before rebooting/shutdown. I’ve written these scripts to make life easy.

Just Get It Working…
NOTE: The settings and paths below are from my configuration. All scripts are written with the paths used in this guide.

1. Download Subsonic Stand-alone.

2. Unpack subsonic-x.x-standalone.tar.gz files to “/subsonic/standalone/” on the flash drive (you must unzip the .tar to get the real files).

3. Extract the all files in transcode.zip (these are codecs I’ve compiled on unRaid) to “/subsonic/data/transcode/” on the flash drive.

4. Download the Java JRE Package jre-6u6-i586-3.tgz and copy it to a directory called “/packages_custom/” on the flash drive (no need to unzip it).

5. On your flash drive, open “/boot/subsonic/standalone/subsonic.sh” with your favorite unix editor (here is one: metapad). At the top of the file you will see Subsonic's configuration variables. Add "JAVA_HOME=/usr/lib/java" to the top (see below). This will be where the JRE package installs its libraries. I changed my port number, context path (optional), and increased the memory allocated for JAVA (I have a ton of music). I also set a PID.txt path so I can see what process Subsonic started (“subsonic_stop.sh” script reads this file). The default podcast and music folder are not needed and can be set later in the Subsonic interface. The Playlist path should be set to a non-volatile memory location. I am saving mine in on the flash drive. Save this file as “subsonic_RAM.sh” in the same directory (eg. /subsonic/standalone/subsonic_RAM.sh). It is important to save this file in unix format (metapad will display this in the status bar).
Code:
JAVA_HOME=/usr/lib/java
SUBSONIC_HOME=/var/subsonic/data
SUBSONIC_HOST=0.0.0.0
SUBSONIC_PORT=22111
SUBSONIC_CONTEXT_PATH=/subsonic
SUBSONIC_MAX_MEMORY=256
SUBSONIC_PIDFILE=/boot/subsonic/PID.txt
SUBSONIC_DEFAULT_MUSIC_FOLDER=
SUBSONIC_DEFAULT_PODCAST_FOLDER=/boot/subsonic/Podcast
SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/boot/subsonic/playlists

6. Extract the files in scripts02.zip (these are my scripts) to a “/scripts” directory on the flash drive.

7. Add the following lines to you go script located in the “/config” folder on the flash drive.
Code:
# JAVA Runtime
installpkg /boot/packages_custom/jre-6u6-i586-3.tgz

# Run Subsonic and add Backup Job.
/boot/scripts/subsonic_start.sh
/boot/scripts/cron_subsonic_copy_from_memory.sh

You are done. You can reboot or type the above 3 lines in a telnet session (assuming you placed files in the same paths).

8. (VERY IMPORTANT) All settings in Subsonic will be lost if the files are not copied back to flash before a reboot. It is vital the "subsonic_copy_from_memory.sh" script is run before a shutdown/reboot. So far, the cron job in step #7 will run "subsonic_copy_from_memory.sh" once a day at 7pm (for people who rarely shutdown their server).
    * If you do not have unMenu installed (everyone should) with the Clean Powerdown package enabled then you should download the package to "/boot/packages_custom/" folder and add a line to your go script to install it (eg. installpkg /boot/packages_custom/powerdown-1.02-noarch-unRAID.tgz).
    * Lastly, add “/boot/scripts/shutdown_jobs_add.sh” to your go script (at the bottom make sense).

You are done. Reboot your server and all scripts will run and set everything up. Be a little patient, copying from flash can take a few minutes.

Open a browser and type the URL http://tower:22111/subsonic/ from within your network (default server name). Just replace “tower” in the URL with your IP (or DDNS) to access Subsonic from outside the network. You may need to forward the port (22111) on your router if you are behind a firewall.

Technical Details…
jre-6u6-i586-3.tgz
    * JAVA JRE runtime needed to run subsonic.

subsonic_start.sh
    * Creates the path “/var/subsonic/data” and recursively copies the “/boot/subsonic/data” files here. It then creates symlinks for the transcode dependencies. There is a step to remove thumbnails which I will explain later. This folder needs to be copied back to non-volatile memory.
    * Creates “/var/subsonic/standalone” and recursively copies “/boot/subsonic/standalone” files here. This does not need to be copied back to non-volatile memory.
    * Creates “/tmp/subsonic/ehcache” and copies “/boot/subsonic/tmp-subsonic-ehcache” files. These files are created when Subsonic runs the first time. This folder should to be copied back to non-volatile memory.
    * Copies subsonic_delete_thumbs_ram.sh script to the hourly cron job. Subsonic caches album art and since it’s running in ram, you want to make sure this is not taking up unnecessary ram space.

cron_subsonic_copy_from_memory.sh
    * Subsonic needs to be copied back to non-volatile memory to maintain settings between reboots. This script adds a cron task which runs subsonic_copy_from_memory.sh. It is scheduled at 7pm daily.

shutdown_jobs_add.sh
    * This hooks into the reboot/shutdown process and runs “shutdown_jobs.sh" before the server shuts down. shutdown_jobs.sh simply calls "subsonic_copy_from_memory.sh" (very important), but other tasks can be added here if needed.

NOTE: I have Joe L’s cache_dir script installed which is a great tool to prevent the drives from spinning up when just browsing files. It can be found at http://lime-technology.com/forum/index.php?topic=4500.0

Compiling your own codecs for transcoding...
I have attached a few already compiled encoders to this post. The instructions are here if you want to add other encoders. Maybe someone can create a slackware package for these? These instructions are for lame, but can be used for each codec.

1. Download the packages needed to compile. Most of them I found at http://www.filewatcher.com/b/ftp/ftp.slackware.org.uk/absolute/absolute-12.2.0/absolute/d.0.0.html. A lot of the main links are broken. I had to use the newest mirror links.
    - binutils-2.18.50.0.9-i486-1.tgz
    - cxxlibs-6.0.8-i486-4.tgz
    - gcc-4.2.4-i486-1.tgz
    - gcc-g++-4.2.4-i486-1.tgz
    - glibc-2.7-i486-17.tgz
    - kernel-headers-2.6.27.7_smp-x86-1.tgz
    - make-3.81-i486-1.tgz

2. Create a folder on your flash drive (eg. /boot/packages_compile/) and copy all the packages above to it (no need to unpack these).

3. In a telnet session change to the package directory in step 2 (type: "cd /boot/packages_compile"). Now install each package by typing "installpkg" and the name of the package (type: “binutils-2.18.50.0.9-i486-1.tgz”. Remember <TAB> is your friend. You can simply type "installpkg<space>" and the first few letters of the filename then hit the TAB key to auto complete. Repeat this for each .tgz file from step 1.

4. Download the source code for encoders. Here are links to the pre-compiled ones in the transcode.zip file.

5. Create a folder on your flash drive (eg. /boot/codecs/) and unpack each codec here.

6. In a telnet session, change directory to (type: "cd /boot/codecs/lame-398-2"). Now type each of the commands below, hitting enters after each one.
Code:
./configure
make
make install

7. In a telnet session change directory to “/usr/local/bin” path (type: "cd "/usr/local/bin"). You should see a file called "lame" (no extension). Copy the file to the transcode folder inside your SUBSONIC_HOME path. (type: "cp lame /boot/subsonic/data/transcode/lame")

8. You should now be able to set a maximum bitrate per user within Subsonic.

Both FLAC and FAAD required a little more work.

Repeat step 6 and 7 for each encoder. Change directories to “/usr/local/lib/” and move all the codec related files to your flash folder (eg. /boot/subsonic/data/transcode/usr-lib/). My subsonic.start.sh handles creating symlinks to these files in “/usr/lib/”. Use symlinks and don’t copy the files. For FLAC, you need to all files that start with “libFLAC” (you are in “/usr/local/lib/” type: “mv libFLAC* /boot/subsonic/data/transcode/usr-lib/”). And for FAAD you need all files that start with “libfaad” and “libmp4ff.a”. LAME also has library files, but they didn’t seem to be needed for Subsonic to transcode. It only needs to be in the transcode directory.

NOTE: There was a bug introduced in Lame 3.98 (and was not fixed in 3.98-2) which will sometimes cause an error to show up in the Subsonic log “can't update LAME-tag frame”. The lame version included here is version 3.97.

Current Issues…
The loaded play lists are not displayed in alphabetical order (works on windows). The developer is aware of this issue.

I want to thank Sindre for a great music streaming application (please donate) and everyone on the unRaid forums who helped this linux n00b get his favorite application up and running. Very Happy
_________________
Paid Subsonic User
----
11,822 artists
7,563 albums
97,863 songs
438.56 GB (~ 6,812 hours)


Last edited by kapz on Thu Jan 28, 2010 6:56 pm; edited 15 times in total
Back to top
View user's profile Send private message
sindre_mehus



Joined: 29 Nov 2005
Posts: 1138
Location: Oslo, Norway

PostPosted: Thu Nov 19, 2009 6:56 pm    Post subject: Reply with quote

Thanks for your hard work, kapz!

I've added a link to this tutorial on the http://subsonic.sourceforge.net/installation.php page.
_________________
Subsonic developer
Back to top
View user's profile Send private message Visit poster's website
kapz



Joined: 21 Jun 2006
Posts: 81

PostPosted: Thu Jan 28, 2010 6:59 pm    Post subject: Reply with quote

I found a typo in one of my scripts. It's nothing that would cause Subsonic to not work. The cron_subsonic_copy_from_memory.sh script was scheduling to run the subsonic_copy_from_memory.sh script at 7pm. I used * for the rest of the values which made all the minutes between 7:00pm-7:59pm valid (essentially running the script 60 times). I have fixed this and uploaded scripts02.zip in the original instructions.

WRONG:
* 19 * * * /scripts/subsonic_copy_from_memory.sh

CORRECTED:
0 19 * * * /scripts/subsonic_copy_from_memory.sh

I also updated the subsonic_copy_from_memory.sh script to create the destination folders if they don't exist and to exclude copying the Subsonic source files from RAM (since they don’t change).
_________________
Paid Subsonic User
----
11,822 artists
7,563 albums
97,863 songs
438.56 GB (~ 6,812 hours)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Subsonic Forum Forum Index -> Tutorials All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group