Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

[How To] Install Subsonic 4.8 on FreeNAS 9.1.1

anika200

Member
Joined
Mar 18, 2013
Messages
112
This post will help you set up Subsonic Music and Video server on your FreeNAS box. It may also be helpful to some new users of FreeNAS as a supplement to the information already provided in the FreeNAS manual.

If you find this post useful please click the "like" button, It keeps me motivated and helps me gauge the usefulness of the thread. Thanks.
Please pay attention: to all the words, there are many steps and they are all important.
Note: It is really easy, really... no kidding.
Do not : Use this in a jail with no users or only root user or any other such nonsense, this will cause problems.
Remember:
I tried to cover things from a beginner perspective.
I am using FreeNAS unix (of course) as the server and openSUSE Linux as the client.
If you follow this guide:
You will have Subsonic server installed into its own jail.
You will have a separate folder for your music outside of the jail.
Read The Manual:
I try to use the same terminology as in the FreeNAS manual so if you see something you are unfamiliar with read up in the manual.
Here we Go:
Get a volume/Dataset ready to hold your music
Using WebGUI
Lets say you created a zfs volume with your disks and named it "nas1". In the left pane of the webgui click >> Storage > Volumes > /mnt/nas1, now select "Create ZFS Dataset". Name the Dataset something like "media" and set compression level and atime to "off" leave the rest at defaults and hit save.
Make some folders inside your Dataset
Using WebGUI
Open the Shell and navigate to your new Dataset.
Code:
cd /mnt/nas1/media
Once there create a music folder and any other folders you want with the command
Code:
mkdir music
Done, close the shell.
Set Permissions on your Dataset
Click on the large storage icon (Top) in webgui and then highlight your Dataset "media". At the bottom of the window you will click on the icon with the key and set the permissions for "media" and all the folders (music) you created inside that Dataset. Basically set the user and group to ones you have created (You did create some right? Think about using global groups/permissions on your entire little home lan, it will make life easier) which will have id and gid of greater than 1000 and give the owner and group Read, Write, Execute and only let others Read and Write. Make sure you check the box for "set permissions recursively" and click change.
Make a jail for Subsonic
Using WebGUI
Make sure your jails creation is configured by clicking >> Jail > configuration and set the jail root to /mnt/nas1 and your networking per your setup. At the very least you will need something like 10.0.100.0/24 in the first box and maybe 10.0.100.30 in the second box and then 10.0.100.40 in the last. If this is your first jail it will end up with an IP of 10.0.100.31 or something, you get the idea. Click Save.
Click add Jail and give it a name "Subsonic" and then hit the advanced tab and and un-check "Vanilla" (make sure you have standard selected and VIMAGE ticked, probably a good idea to put in gateway too) and click ok.
Enter your Subsonic jail and prepare it.
Using WebGUI
Open the shell and enter your Subsonic jail (covered in manual) basically the command
Code:
jexec X /bin/csh
you should have a command prompt that ends with subsonic.

Now lets get ready for Subsonic by creating a new user and some folders. Type
Code:
adduser
and hit enter, give the Username: sonic ( obviously use whatever name you want ) and enter. Follow the prompts accepting the all defaults Except :

1) when you get to below Enter csh
Code:
Shell (sh csh tcsh bash rbash nologin) [sh]:

2) when you get to
Code:
Invite sonic into other groups? [ ]:
type "wheel" and any other groups you want your user to belong too
and enter defaults for the rest.
Now change the shell to your new user with the command
Code:
su - sonic

Make a folder to hold your music (we will use it later)
Code:
mkdir /music
and a folder to hold the subsonic install.
Code:
mkdir /home/sonic/subsonic
Exit from the shell, you need to type "exit and hit return" twice and then close the window. Done
Add your Dataset ( Media ) to your Subsonic Jail
Using WebGUI
Click/highlight your new jail and at the bottom of the page select the folder icon for "add storage". Make sure subsonic is listed as the jail and in the source box navigate to the /mnt/nas1/media Dataset. In the destination box click on the new folder you created in the subsonic jail, in my case "music". Click ok and you are done.
What you have basically done is link your Dataset "media" to a folder inside your subsonic jail named music. Now when you fill up the media dataset with flac files they can be used by your jail and subsonic media server.

Reboot the Server
In both of my test cases I found I had to reboot here to get the network in the jail to settle in, your mileage may vary.
Enter Subsonic jail and install needed programs
Using SSH from linux terminal or from shell in webgui
Working as root in your Subsonic jail install the following software with the pkg install command as below.
Code:
pkg install xtrans xproto xextproto javavmwrapper lame flac openjdk-7.25.15
Note: You will need to do a pkg search for what version of openjdk is currently in the repo otherwise you will get a not found error. Note2: Some people have reported the need to install a file manager named "mc" which brings in perl as part of its install, just add it to the end of the above pkg list. ( I am monitoring the need for this and may make it a step based on more feedback).
Now we need to compile and install ffmpeg to get it to transcode files to mp3 on the fly with lame.
This will take a while get a coffee and relax.
Command
Code:
portsnap fetch extract
When that is done
Code:
cd /usr/ports/multimedia/ffmpeg
Then
Code:
make
----
Important ---- At this point you will be presented a list of options, make sure you an X in the LAME section. I also turn on AAC support (top).
Then
Code:
make install clean

Install Subsonic
Still working inside the jail from ssh or shell but you should still be root user here and then we will change everything back to sonic users with the chown command below >> Please take note of below.
Note: You can always check who you are with the command:
Code:
id
Now onward we go:
Code:
mkdir -p /home/sonic/subsonic/transcode
Code:
mkdir /home/sonic/subsonic/standalone
Code:
cp /usr/local/bin/lame /home/sonic/subsonic/transcode/

Code:
cp /usr/local/bin/flac /home/sonic/subsonic/transcode/

Code:
ln /usr/local/bin/ffmpeg /home/sonic/subsonic/transcode/ffmpeg
Note: You need to have rolled your own group here (referred to above in Set permissions on your dataset) to get global permissions working properly Or just use the wheel group.
Code:
chown -R sonic:wheel /home/sonic/subsonic
Please note the dash in the next command, we need it.
Code:
su - sonic

Code:
cd /tmp

Code:
wget http://heanet.dl.sourceforge.net/project/subsonic/subsonic/4.8/subsonic-4.8-standalone.tar.gz

Code:
tar xvzf /tmp/subsonic-4.8-standalone.tar.gz -C /home/sonic/subsonic/standalone

Edit File /home/sonic/subsonic/standalone/subsonic.sh and change these lines to match your setup:
> SUBSONIC_HOME=/home/sonic/subsonic
> SUBSONIC_DEFAULT_MUSIC_FOLDER=/music
> SUBSONIC_DEFAULT_PODCAST_FOLDER=/music/Podcast
> SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/music/playlists
Start subsonic and check log for errors
Command
Code:
sh /home/sonic/subsonic/standalone/subsonic.sh

That is it, you are done and can now log into Subsonic server via its web gui.

========================================================================

To start the server automatically at every freenas reboot see below.
Start subsonic automatically at boot time (shamefully stolen from another forum)
working from inside your jail via webgui shell or ssh sonic@10.0.100.32 (obviously you need to use your own ip here)
Stop subsonic server if it is running by finding the pid and then use "kill pid" command.
As root inside the sonic jail create a new file with nano or your favorite editor:
Code:
nano /usr/local/etc/rc.d/subsonic

Copy this inside the file:
Code:
#!/bin/sh
#
# PROVIDE: subsonic
# REQUIRE: LOGIN DAEMON NETWORKING
# KEYWORD: shutdown
#
# To enable subsonic, add this line to your /etc/rc.conf:
#
# subsonic_enable="YES"
#
# And optionally these line:
#
# subsonic_user="username" # Default is "root"
# subsonic_bin="/path/to/subsonic.sh" # Default is "/usr/local/sbin/subsonic.sh"
 
. /etc/rc.subr
 
name="subsonic"
rcvar="subsonic_enable"
 
load_rc_config $name
 
required_files=$subsonic_bin
 
: ${subsonic_enable="NO"}
: ${subsonic_user="root"}
: ${subsonic_bin="/usr/local/sbin/subsonic.sh"}
 
command=$subsonic_bin
 
run_rc_command "$1"

Make the /usr/local/etc/rc.d/subsonic executable:
Code:
chmod ug+x /usr/local/etc/rc.d/subsonic

Edit your /etc/rc.conf and add these lines, modifying them for your setup:
Code:
# subsonic start up
subsonic_enable="YES"
subsonic_user="sonic"
subsonic_bin="/home/sonic/subsonic/standalone/subsonic.sh"

Now when you reboot subsonic should autostart or you can start it manually with:
Code:
/usr/local/etc/rc.d/subsonic start

To test it out you can locate the subsonic process with Top and kill it, then issue the above command and it should start subsonic and give you the pid of the process.

Thanks to user dalys over at btsync for showing me how to do the start up stuff.

Most of this stuff was gathered from the web blogs, thanks to everyone.
http://geekfreely.blogspot.com/2013/04/installing-subsonic-server-on-nas4free.html
http://www.parmeter.net/ben/2011/02/02/installing-subsonic-on-freenas-and-bonus-upgrade-instructions/
 

Jason Sousa

Newbie
Joined
Nov 17, 2012
Messages
3
Thank you for this! I spent the majority of the day freaking out after upgrading to 9.1.

A couple of notes that I have:
Then "make config" ---- Important ---- At this point you will be presented a list of options, make sure you an X in the LAME section. I also turn on AAC support (top).

I had to: "make" instead of "make config" which was a VERY LONG process.

"tar xvzf /tmp/subsonic-4.8-standalone.tar.gz -C /home/subsonic/standalone"

should be: "tar xvzf /tmp/subsonic-4.8-standalone.tar.gz -C /home/sonic/subsonic/standalone"

Trying to get it to autostart now. I tried "jexec 3 /home/sonic/subsonic/standalone/subsonic.sh" as a postinit command but I do not think the jail loads before the command is issued. The command itself works when I SSH in, so it is a timing thing that I do not have the desire to suss it out tonight.
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
Thank you for this! I spent the majority of the day freaking out after upgrading to 9.1.

A couple of notes that I have:
Then "make config" ---- Important ---- At this point you will be presented a list of options, make sure you an X in the LAME section. I also turn on AAC support (top).

I had to: "make" instead of "make config" which was a VERY LONG process.

"tar xvzf /tmp/subsonic-4.8-standalone.tar.gz -C /home/subsonic/standalone"

should be: "tar xvzf /tmp/subsonic-4.8-standalone.tar.gz -C /home/sonic/subsonic/standalone"

Trying to get it to autostart now. I tried "jexec 3 /home/sonic/subsonic/standalone/subsonic.sh" as a postinit command but I do not think the jail loads before the command is issued. The command itself works when I SSH in, so it is a timing thing that I do not have the desire to suss it out tonight.
Glad it helped you out :).

I noted your observations and made changes to the original post, thanks for the help. I remember having a few issues with startup, first the jail number had changed at one point and then I think it took a couple reboots to get everything going good.
 

thorndike

Neophyte
Joined
Sep 23, 2013
Messages
11
Forgive my ignorance, as I am brand new to FreeNas and BSD. I am a debian kind of guy.
When I got to the pkg install step, I was unable to install any of the packages. I would get:

Updating repository catalogue
Repository catalogue is up-to-date, no need to fetch fresh copy
pkg: Package 'xtrans' was not found in the repositories
pkg: Package 'xproto' was not found in the repositories
pkg: Package 'xextproto' was not found in the repositories
pkg: Package 'javavmwrapper' was not found in the repositories
pkg: Package 'lame' was not found in the repositories
pkg: Package 'flac' was not found in the repositories
pkg: Package 'openjdk-7.25.15' was not found in the repositories

I've tried searching for these packages using "pkg search xtrans" for example and nothing appeared. Do I need to add repository servers or am I not doing something correctly? I am able to reach the outside world on the network, so it should be able to reach the repositories. Any thoughts?
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
Forgive my ignorance, as I am brand new to FreeNas and BSD. I am a debian kind of guy.
When I got to the pkg install step, I was unable to install any of the packages. I would get:

Updating repository catalogue
Repository catalogue is up-to-date, no need to fetch fresh copy
pkg: Package 'xtrans' was not found in the repositories
pkg: Package 'xproto' was not found in the repositories
pkg: Package 'xextproto' was not found in the repositories
pkg: Package 'javavmwrapper' was not found in the repositories
pkg: Package 'lame' was not found in the repositories
pkg: Package 'flac' was not found in the repositories
pkg: Package 'openjdk-7.25.15' was not found in the repositories

I've tried searching for these packages using "pkg search xtrans" for example and nothing appeared. Do I need to add repository servers or am I not doing something correctly? I am able to reach the outside world on the network, so it should be able to reach the repositories. Any thoughts?

I seem to remember some weirdness like this, did you reboot the server? Are you the root user inside your subsonic jail?

Please verify your jail settings and read the manual on jails to make sure you can install pkg or pkgng from freebsd.
 

thorndike

Neophyte
Joined
Sep 23, 2013
Messages
11
Make a folder to hold your music (we will use it later) with "mkdir /music" and a folder to hold the subsonic install "mkdir /home/sonic/subsonic".

This command is making a music directory directly off of / and thus will need to have root access correct? I created my user and added to the wheel group, but am unable to create the /music directory under that account. Should this be done as root and then change the permissions?
 

Repié

Newbie
Joined
Sep 25, 2013
Messages
3
Hello,

Thanks a lot for this how to. It works fine for me. Maybe you could just add that we must type the jail ip (and not the nas ip) to reach the subsonic gui.
Unfortunately I have the same problem with autostart than Jason. Doesn't work with the post init command while the same command works perfectly in the shell :/
I'll keep an eye here in case of someone find the cause of this annoying issue.
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
Hello,

Thanks a lot for this how to. It works fine for me. Maybe you could just add that we must type the jail ip (and not the nas ip) to reach the subsonic gui.
Unfortunately I have the same problem with autostart than Jason. Doesn't work with the post init command while the same command works perfectly in the shell :/
I'll keep an eye here in case of someone find the cause of this annoying issue.

Yes of course you would use the jail ip, thanks for pointing this out.
I have no problem starting subsonic from the webgui post init command, make sure you declare the current correct jail, it can change for various reasons. Check the jail by reboot and then in the webgui shell issue the "jls" what does it say and compare to your init command.
There may be some simple thing I forgot to document, maybe someone can catch it.
 

Repié

Newbie
Joined
Sep 25, 2013
Messages
3
Hello,
Thank you but I've already checked the jail number. Must be something else.
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
Make a folder to hold your music (we will use it later) with "mkdir /music" and a folder to hold the subsonic install "mkdir /home/sonic/subsonic".

This command is making a music directory directly off of / and thus will need to have root access correct? I created my user and added to the wheel group, but am unable to create the /music directory under that account. Should this be done as root and then change the permissions?

Now change the shell to your new user with the command "su sonic".
Make a folder to hold your music (we will use it later) with "mkdir /music" and a folder to hold the subsonic install "mkdir /home/sonic/subsonic".
If you follow the write up you will "su sonic" so there is no way you are creating anything as root at this point. Please check every step to make sure you have not missed something.
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
Hello,
Thank you but I've already checked the jail number. Must be something else.
Have you checked that the exact path matches what you have done?

In the webgui:
Click on System>>init/shutdown scripts>>add init/shutdown scripts
Type: Command
Command: jexec 2 /home/sonic/subsonic/standalone/subsonic.sh
Type: post init

Of course your path to subsonic.sh and the jail number may vary and you will have adjust to what you actually did.
 

Repié

Newbie
Joined
Sep 25, 2013
Messages
3
Hello.
Yes, as I said, the same exact command written in a shell works perfectly. Like Jason I feel a timing problem.
 

thorndike

Neophyte
Joined
Sep 23, 2013
Messages
11
Well, after teaching myself quite a bit, I was able to get it running per the directions above! I didn't realize how long the make command would take, but other than that, it seems good to go. Thanks for the help.
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
Hello.
Yes, as I said, the same exact command written in a shell works perfectly. Like Jason I feel a timing problem.

This is now happening on my machine, I rarely reboot so I guess I had not noticed. I have a solution and will post it tomorrow as soon as I make sure it is working good.
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
Update: I added the Std method for starting apps at log-in to the bottom of the original post, remember to remove the FreeNAS init command from the webgui before you use this method. It has been working for me here but I have only rebooted once with it, any feed back is appreciated.
 

Jason Sousa

Newbie
Joined
Nov 17, 2012
Messages
3
Success! It would be a good idea to stop subsonic prior to setting up the script to start it and backup the db folder. First reboot resulted in HTTP Error 503 so I had to move/delete the db folder (/home/sonic/subsonic/db) and then set it all up again. Not a deal breaker by any means, but still inconvenient. Thanks for the help!
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
I noticed some errors in my /usr/local/etc/rc.d/subsonic script and have corrected them so please copy over the changes on lines 25,26,27. They probably will not be used but you never know.
 

Mathewr

Neophyte
Joined
Sep 29, 2013
Messages
7
Hello,

Thanks for putting this together anika200, I have been looking around everywhere for getting Subsonic into freenas 9.x.

I have a been hitting a problem though. I can't get the directories created by the sonic user during step "Enter your Subsonic jail and prepare it."

Here us a set by step of the shell inputs:

Code:
[root@Blackbox ~]# jls                                                                                                             
  JID  IP Address      Hostname                      Path                                                                         
    1  -              bit_1                        /mnt/Blackbox/jails/bit_1                                                   
    2  -              Subsonic                      /mnt/Blackbox/Subsonic                                                       
[root@Blackbox ~]# jexec 2 /bin/csh                                                                                               
root@Subsonic:/ # adduser                                                                                                         
Username: sonic                                                                                                                   
Full name:                                                                                                                         
Uid (Leave empty for default):                                                                                                     
Login group [sonic]:                                                                                                               
Login group is sonic. Invite sonic into other groups? []: wheel                                                                   
Login class [default]:                                                                                                             
Shell (sh csh tcsh nologin) [sh]:                                                                                                 
Home directory [/home/sonic]:                                                                                                     
Home directory permissions (Leave empty for default):                                                                             
Use password-based authentication? [yes]: no                                                                                       
Lock out the account after creation? [no]:                                                                                         
Username  : sonic                                                                                                                 
Password  : <disabled>                                                                                                           
Full Name  :                                                                                                                       
Uid        : 1001                                                                                                                 
Class      :                                                                                                                       
Groups    : sonic wheel                                                                                                           
Home      : /home/sonic                                                                                                           
Home Mode  :                                                                                                                       
Shell      : /bin/sh                                                                                                               
Locked    : no                                                                                                                   
OK? (yes/no): yes                                                                                                                 
adduser: INFO: Successfully added (sonic) to the user database.                                                                   
Add another user? (yes/no): no                                                                                                     
Goodbye!                                                                                                                           
root@Subsonic:/ #                                                                                                                 
root@Subsonic:/ # su sonic
$ mkdir /music                                                                                                                     
mkdir: /music: Permission denied                                                                                                   
$  


I have gone through the steps three times with the same results. If anyone can offer some advice I would be grateful.

Thanks!
 

anika200

Member
Joined
Mar 18, 2013
Messages
112
Hello,

Thanks for putting this together anika200, I have been looking around everywhere for getting Subsonic into freenas 9.x.

I have a been hitting a problem though. I can't get the directories created by the sonic user during step "Enter your Subsonic jail and prepare it."

Here us a set by step of the shell inputs:

Code:
[root@Blackbox ~]# jls                                                                                                         
  JID  IP Address      Hostname                      Path                                                                     
    1  -              bit_1                        /mnt/Blackbox/jails/bit_1                                               
    2  -              Subsonic                      /mnt/Blackbox/Subsonic                                                   
[root@Blackbox ~]# jexec 2 /bin/csh                                                                                           
root@Subsonic:/ # adduser                                                                                                     
Username: sonic                                                                                                               
Full name:                                                                                                                     
Uid (Leave empty for default):                                                                                                 
Login group [sonic]:                                                                                                           
Login group is sonic. Invite sonic into other groups? []: wheel                                                               
Login class [default]:                                                                                                         
Shell (sh csh tcsh nologin) [sh]:                                                                                             
Home directory [/home/sonic]:                                                                                                 
Home directory permissions (Leave empty for default):                                                                         
Use password-based authentication? [yes]: no                                                                                   
Lock out the account after creation? [no]:                                                                                     
Username  : sonic                                                                                                             
Password  : <disabled>                                                                                                       
Full Name  :                                                                                                                   
Uid        : 1001                                                                                                             
Class      :                                                                                                                   
Groups    : sonic wheel                                                                                                       
Home      : /home/sonic                                                                                                       
Home Mode  :                                                                                                                   
Shell      : /bin/sh                                                                                                           
Locked    : no                                                                                                               
OK? (yes/no): yes                                                                                                             
adduser: INFO: Successfully added (sonic) to the user database.                                                               
Add another user? (yes/no): no                                                                                                 
Goodbye!                                                                                                                       
root@Subsonic:/ #                                                                                                             
root@Subsonic:/ # su sonic
$ mkdir /music                                                                                                                 
mkdir: /music: Permission denied                                                                                               
$  


I have gone through the steps three times with the same results. If anyone can offer some advice I would be grateful.

Thanks!
Hmmm, not sure what the problem could be. Did you change the password-based authentication from the default yes to "no"? Try creating a test jail and choose the defaults for creating a new user instead of the ones you used and see if that makes a difference. I seem to remember reading something about that setting and would recommend the defaults for authentication.
 
Top