How to install Subsonic on unRAID
Posted: Wed Nov 18, 2009 8:35 pm
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.
Subsonic has been invaluable to me for many years. 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. I hope this guide helps others try Subsonic on unRaid for themselves.
Just Get It Working…
1. Unzip Subsonic4.4_unRaid.zip to your flash drive and add the following to your go script...
2. Simply telnet into your server and type "/boot/scripts/subsonic_start.sh" or reboot your server.
3. 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.
(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. A cron job was created in subsonic_start.sh to backup subsonic's files 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 your flash "/packages_global/" folder and add a line to your go script to install it at the very top of your go script. (eg. installpkg /boot/packages_global/powerdown-1.02-noarch-unRAID.tgz).
NOTE: I use 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
How to update…
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). Overwrite all the files.
3. Telnet into your server and type "/boot/scripts/subsonic_restart.sh" or reboot your server.
Technical Details…
subsonic_RAM.sh
jre-6u6-i586-3.tgz
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.
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 /codecs/lame-398-2"). Now type each of the commands below, hitting enters after each one.
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 /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.
[b]I want to thank Sindre for a great music streaming application (please donate)
Subsonic has been invaluable to me for many years. 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. I hope this guide helps others try Subsonic on unRaid for themselves.
Just Get It Working…
1. Unzip Subsonic4.4_unRaid.zip to your flash drive and add the following to your go script...
- Code: Select all
installpkg /boot/packages_global/jre-6u20-i586-1.txz
/boot/scripts/subsonic_start.sh
/boot/scripts/shutdown_jobs_add.sh
2. Simply telnet into your server and type "/boot/scripts/subsonic_start.sh" or reboot your server.
3. 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.
(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. A cron job was created in subsonic_start.sh to backup subsonic's files 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 your flash "/packages_global/" folder and add a line to your go script to install it at the very top of your go script. (eg. installpkg /boot/packages_global/powerdown-1.02-noarch-unRAID.tgz).
NOTE: I use 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
How to update…
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). Overwrite all the files.
3. Telnet into your server and type "/boot/scripts/subsonic_restart.sh" or reboot your server.
Technical Details…
subsonic_RAM.sh
- * This file is a copy of /subsonic/standalone/subsonic.sh. You can open it 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).
* Optionally you may change the port number, context path, and increased the memory allocated for JAVA (I have a ton of music). The PID.txt path is used by the “subsonic_stop.sh” script.
* 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 /subsonic/standalone/subsonic.sh 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: Select all
JAVA_HOME=/usr/lib/java
SUBSONIC_HOME=/var/subsonic/data
SUBSONIC_HOST=0.0.0.0
SUBSONIC_PORT=22111
SUBSONIC_HTTPS_PORT=0
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
jre-6u6-i586-3.tgz
- * JAVA JRE runtime needed to run subsonic.
- * 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 (explained below).
* Runs cron_subsonic_copy_from_memory.sh (explained below).
- * 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. Running cron_subsonic_copy_from_memory_undo.sh will remove the entry from crontab.
- * 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.
- * This is the hourly script to clean the thumbnails from ram. Subsonic caches album art and since it’s running in ram, you want to make sure this is not taking up unnecessary ram space.
- * I recently switched to using rsync instead of copy in subsonic_copy_from_memory.sh. The new search index files subsonic makes doesn't seem to be removed and rsync works much better. This file is what directories can be excluded when backing up from ram.
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
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 /codecs/lame-398-2"). Now type each of the commands below, hitting enters after each one.
- Code: Select all
./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 /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.
[b]I want to thank Sindre for a great music streaming application (please donate)