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: 94

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 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 #1 The settings and paths below are from my configuration. All scripts are written with the paths used in this guide.
Note #2 I recommend using unRaid 4.6-beta11 or above. There is a significant performance increase with listing large music folders.

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 “/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).
    * 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 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 scripts03.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 almost done.

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 this script 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_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. /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:
./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.

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
----
12,768 artists
7,714 albums
102,570 songs
481.43 GB (~ 7,478 hours)


Last edited by kapz on Mon May 24, 2010 7:51 pm; edited 21 times in total
Back to top
View user's profile Send private message
sindre_mehus



Joined: 29 Nov 2005
Posts: 1446
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: 94

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
----
12,768 artists
7,714 albums
102,570 songs
481.43 GB (~ 7,478 hours)
Back to top
View user's profile Send private message
kapz



Joined: 21 Jun 2006
Posts: 94

PostPosted: Tue Feb 16, 2010 6:02 pm    Post subject: Reply with quote

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
----
12,768 artists
7,714 albums
102,570 songs
481.43 GB (~ 7,478 hours)
Back to top
View user's profile Send private message
daquint



Joined: 23 Apr 2010
Posts: 3

PostPosted: Fri Apr 23, 2010 3:52 am    Post subject: Reply with quote

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 Smile

thanks

mark
Back to top
View user's profile Send private message
Neph2010



Joined: 23 Apr 2010
Posts: 1

PostPosted: Fri Apr 23, 2010 6:24 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
kapz



Joined: 21 Jun 2006
Posts: 94

PostPosted: Fri Apr 23, 2010 4:45 pm    Post subject: Reply with quote

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
----
12,768 artists
7,714 albums
102,570 songs
481.43 GB (~ 7,478 hours)
Back to top
View user's profile Send private message
kapz



Joined: 21 Jun 2006
Posts: 94

PostPosted: Fri Apr 23, 2010 4:51 pm    Post subject: Reply with quote

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
----
12,768 artists
7,714 albums
102,570 songs
481.43 GB (~ 7,478 hours)
Back to top
View user's profile Send private message
daquint



Joined: 23 Apr 2010
Posts: 3

PostPosted: Sat Apr 24, 2010 2:14 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
kapz



Joined: 21 Jun 2006
Posts: 94

PostPosted: Sat Apr 24, 2010 9:53 pm    Post subject: Reply with quote

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
----
12,768 artists
7,714 albums
102,570 songs
481.43 GB (~ 7,478 hours)
Back to top
View user's profile Send private message
daquint



Joined: 23 Apr 2010
Posts: 3

PostPosted: Sun Apr 25, 2010 5:05 am    Post subject: Reply with quote

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!
Back to top
View user's profile Send private message
kapz



Joined: 21 Jun 2006
Posts: 94

PostPosted: Mon Apr 26, 2010 4:13 pm    Post subject: Reply with quote

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
----
12,768 artists
7,714 albums
102,570 songs
481.43 GB (~ 7,478 hours)
Back to top
View user's profile Send private message
SCSI



Joined: 11 Jun 2010
Posts: 1
Location: NY

PostPosted: Fri Jun 11, 2010 1:42 am    Post subject: Reply with quote

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. Very Happy

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!
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