How to install Subsonic on unRAID

Tutorials, tips and tricks.

Moderator: moderators

How to install Subsonic on unRAID

Postby kapz » 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...
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.
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 (explained below).
    * Runs cron_subsonic_copy_from_memory.sh (explained below).
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. Running cron_subsonic_copy_from_memory_undo.sh will remove the entry from crontab.
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.
subsonic_delete_thumbs_ram.sh
    * 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.
subsonic_exclude.txt
    * 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
2. Create a folder on your flash drive (eg. /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 /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) :D
Last edited by kapz on Tue May 01, 2012 3:20 am, edited 39 times in total.
Paid Subsonic user
----
Love my unRaid (~9.5TB): [url=http://lime-technology.com/forum/index.php?topic=2031.msg40351#msg40351]Pictures Here (Reply #82)[/url]
User avatar
kapz
 
Posts: 124
Joined: Wed Jun 21, 2006 7:23 pm

Postby sindre_mehus » Thu Nov 19, 2009 6:56 pm

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
User avatar
sindre_mehus
 
Posts: 1955
Joined: Tue Nov 29, 2005 6:19 pm
Location: Oslo, Norway

Postby kapz » Thu Jan 28, 2010 6:59 pm

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
----
Love my unRaid (~9.5TB): [url=http://lime-technology.com/forum/index.php?topic=2031.msg40351#msg40351]Pictures Here (Reply #82)[/url]
User avatar
kapz
 
Posts: 124
Joined: Wed Jun 21, 2006 7:23 pm

Postby kapz » Tue Feb 16, 2010 6:02 pm

Path to download v3.9 changed in OP. The new version fixed the playlist order problem.

* Was notified that the crontab script had a wrong path in it. I have fixed this and added scripts03.zip to the OP.

Upgrade from 3.8 to 3.9 is fairly simple...
1) run the "/boot/scripts/subsonic_copy_from_memory.sh" This will save any changes made.

2) replace all the files in /boot/subsonic/standalone" with the new version (keep the subsonic_start_RAM.sh script)

3) delete "/boot/subsonic/tmp-subsonic-ehcache/" and "/boot/subsonic/data/jetty/" directories from the thumb drive if they exist. (only the jetty folder has the web files)

4) and reboot
Paid Subsonic user
----
Love my unRaid (~9.5TB): [url=http://lime-technology.com/forum/index.php?topic=2031.msg40351#msg40351]Pictures Here (Reply #82)[/url]
User avatar
kapz
 
Posts: 124
Joined: Wed Jun 21, 2006 7:23 pm

Postby daquint » Fri Apr 23, 2010 3:52 am

Hi there,


Thanks for the tutorial - but I am bit lost here.

I am editing these files directly on my flash drive and completing these steps through step 7.

It seems my go script is having issues finding the sh scripts its calling, and I am wondering if you could give me a hand (bit of a noob with the Linux stuff)

my go script:

#!/bin/bash
# Start the Management Utility
# JAVA Runtime
installpkg /packages_custom/jre-6u6-i586-3.tgz

# Run Subsonic and add Backup Job.
/scripts/subsonic_start.sh
/scripts/cron_subsonic_copy_from_memory.sh
/usr/local/sbin/emhttp &

Note: I am not using the /boot/ menu as I was a bit confused by steps 3 and 4 not mentioning a /boot/ but your step 5 explaining to copy files to the /boot/ (it is not a default directory for the flash Unraid). Perhaps thats my problem?

Here is my file structure:
Flash Root contains the following folders:
config
packages_custom (created by me for the JRE file)
scripts (the folder I created for your scripts03)
subsonic (folder I created to place the standalone,data, etc directories)

any help is appreciated - i really dont want to keep a windows box up for subsonic :)

thanks

mark
daquint
 
Posts: 3
Joined: Fri Apr 23, 2010 3:44 am

Postby Neph2010 » Fri Apr 23, 2010 6:24 am

kapz, excellent tutorial.

I have Subsonic running on my Unraid box though I do have one issue that I hope either you or someone else can help me figure out. the problem I'm having is the folder directories. I have my music in shares which spread over two drives. How would I add the share to subsonic's settings?

Thanks
Neph2010
 
Posts: 1
Joined: Fri Apr 23, 2010 6:14 am

Postby kapz » Fri Apr 23, 2010 4:45 pm

daquint,

I think I see the confusion. The unRaid system mounts the flash drive to "/boot". It shows up as "flash" on the samba share, but if you used ssh to log into the system /boot would be your flash drive.

You need to add "/boot" to the start of the following lines for the full path to the files.

# 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
Paid Subsonic user
----
Love my unRaid (~9.5TB): [url=http://lime-technology.com/forum/index.php?topic=2031.msg40351#msg40351]Pictures Here (Reply #82)[/url]
User avatar
kapz
 
Posts: 124
Joined: Wed Jun 21, 2006 7:23 pm

Postby kapz » Fri Apr 23, 2010 4:51 pm

Neph2010,

If you are using shares in unRaid, you can just us the path to the share in the folder settings in subsonic. Shares are mounted in unRaid under "/mnt/user/". It does not matter what drives the files are on.

An example of my paths...

/mnt/user/MUSIC/CD ARCHIVE
/mnt/user/MUSIC/OLD SCHOOL

"MUSIC" is my unRaid share and the bold would be the music folder you want to show up in Subsonic.

Remember paths are cAsE SeNsItIve
Paid Subsonic user
----
Love my unRaid (~9.5TB): [url=http://lime-technology.com/forum/index.php?topic=2031.msg40351#msg40351]Pictures Here (Reply #82)[/url]
User avatar
kapz
 
Posts: 124
Joined: Wed Jun 21, 2006 7:23 pm

Postby daquint » Sat Apr 24, 2010 2:14 am

HI - Thanks for the quick reply!

Ive tried it this way as well (with boot) with the same directory structure I noted in previous post and get two errors after it loads the JRE and the transcoding lines:

Please see image

http://img99.imageshack.us/i/201004231901331.jpg/


Thanks for your help and patience!
daquint
 
Posts: 3
Joined: Fri Apr 23, 2010 3:44 am

Postby kapz » Sat Apr 24, 2010 9:53 pm

daquint,

When editing the "/boot/subsonic/standalone/subsonic.sh" file (Step #5) did you save it as "subsonic_RAM.sh"?

The tmp-subsonic-ehcache error is normal the first time and will not happen once you get subsonic running.
Paid Subsonic user
----
Love my unRaid (~9.5TB): [url=http://lime-technology.com/forum/index.php?topic=2031.msg40351#msg40351]Pictures Here (Reply #82)[/url]
User avatar
kapz
 
Posts: 124
Joined: Wed Jun 21, 2006 7:23 pm

Postby daquint » Sun Apr 25, 2010 5:05 am

I did - I now have two files in the

I have both the original 'subsonic.sh' and the new 'subsonic_RAM.sh'

in my directory (editing the flash directly through windows) of

(root of the flash)\subsonic\standalone

Do i need to delete the original subsonic.sh once I rename it to _RAM?

thanks!
daquint
 
Posts: 3
Joined: Fri Apr 23, 2010 3:44 am

Postby kapz » Mon Apr 26, 2010 4:13 pm

No you do not need to delete subsonic.sh. Were you able to get subsonic working? I've had some issues with subsonic sometimes not coming up even when the process has been started correctly.

If there are no errors when you run subsonic_start.sh and subsonic doesn't display a reboot works for me.

Remember the URL is whatever you added to the SUBSONIC_CONTEXT_PATH=/subsonic setting in step #5.

From within the network, this would be http://<IP ADDRESS><COLON><PORT>/subsonic
Paid Subsonic user
----
Love my unRaid (~9.5TB): [url=http://lime-technology.com/forum/index.php?topic=2031.msg40351#msg40351]Pictures Here (Reply #82)[/url]
User avatar
kapz
 
Posts: 124
Joined: Wed Jun 21, 2006 7:23 pm

Postby SCSI » Fri Jun 11, 2010 1:42 am

Thanks for your tutorial which I discovered in the lime-tech forum and I've been hooked to Subsonic on my unRAID server ever since. :D

Are there any tutorial to get HTTPS/SSL configured in Subsonic on unRAID? I would like to access my Subsonic via HTTPS is possible.

Thank you!
SCSI
 
Posts: 4
Joined: Fri Jun 11, 2010 1:36 am

retain settings

Postby jarodtufts » Sun Oct 24, 2010 11:19 pm

I've got this installed and running fine on my unraid server. I purchased a license and am very happy.

But, has anyone figured out how to retain user settings between reboots of the unraid server? It seems to me that the user settings are kept in the database, but I can not figure out how to backup and restore the database properly.
jarodtufts
 
Posts: 1
Joined: Sun Oct 24, 2010 11:16 pm

Postby gabbott » Tue Nov 30, 2010 3:23 am

Not having luck getting flac transcoding to mp3. Logs dont show any errors. I have the precompiled lame codecs from the first post in subsonic/data/transocde and even tried putting them in /var/subsonic/data/transcode

Any ideas? I installed 4.2.
gabbott
 
Posts: 17
Joined: Tue Nov 30, 2010 12:17 am
Location: US

Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests