anika200
Contributor
- Joined
- Mar 18, 2013
- Messages
- 113
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.
Once there create a music folder and any other folders you want with the command
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 commandyou should have a command prompt that ends with subsonic.
Now lets get ready for Subsonic by creating a new user and some folders. Typeand 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
2) when you get totype "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
Make a folder to hold your music (we will use it later)and a folder to hold the subsonic install.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.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.
CommandWhen that is doneThen ---- 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
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:Now onward we go:
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.
Please note the dash in the next command, we need it.
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
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:
Copy this inside the file:
Make the /usr/local/etc/rc.d/subsonic executable:
Edit your /etc/rc.conf and add these lines, modifying them for your setup:
Now when you reboot subsonic should autostart or you can start it manually with:
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/
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
Code:
mkdir music
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
Now lets get ready for Subsonic by creating a new user and some folders. Type
Code:
adduser
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? [ ]:
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
Code:
mkdir /home/sonic/subsonic
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
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
Code:
cd /usr/ports/multimedia/ffmpeg
Code:
make
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
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
Code:
chown -R sonic:wheel /home/sonic/subsonic
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/