[HOWTO] Install Serviio in Freenas 8.0.x

Status
Not open for further replies.
S

Stefan Reek

Guest
Moderator Note: (Please read to end of thread before trying to follow this tutorial)


I fooled around a bit to see if I could get Serviio to work on Freenas 8.0.1Beta4.
As I noticed a lot of people asking for it, but no one that had actually managed to install it I expected it to be rather difficult, but thankfully it wasn't.

I followed the steps as given in this thread on the serviio forums http://forum.serviio.org/viewtopic.php?f=14&t=2060
But when I wanted to install the Diablo JRE I noticed there wasn't a FreeBSD 8.x version of it. I then read that the 7.x version could be used if the misc/compat7x port was installed.

I haven't tried to install the JRE without this port, so I'm not quite sure if it's needed.
But anyway, this is how you install it:

(Make sure you are root and you have mounted your file system as read/write)
Code:
su
mount -urw /


First you'll have to get the ports by using
Code:
portsnap fetch -d <fetch dir>

The ports have to be downloaded to you data disks as /var on the usb installation
does not have enough space for it, so make sure <fetch dir> is on your data disks.

Then you have to extract the ports using:
Code:
portsnap extract -d <fetch dir> -p <ports dir>

The ports dir should be on your data disks as wel.

now go to <ports dir>/misc/compat7x and run
Code:
 make install clean 


For me, that gave a file not found error that I solved by editing
/usr/share/mk/bsd.port.mk

Change the PORTSDIR? line to
Code:
 PORTSDIR?=<ports dir> 


then run the make command again.

Now you'll need to add a lot of dependencies of serviio, enter the following commands:
Code:
pkg_add -v -r xtrans
pkg_add -v -r xproto
pkg_add -v -r xextproto
pkg_add -v -r javavmwrapper
pkg_add -v -r ffmpeg


When that's done there's only one more dependency to get: the Java JRE
go to this page and download the FreeBSD 7.x JRE for your architecture.
In my case the file was called "diablo-jre-freebsd7.amd64.1.6.0.07.02.tbz"
You'll need to store that somewhere on your data disks as well.
Then go to the place where you stored the file and enter
Code:
pkg_add -v diablo-jre-freebsd7.amd64.1.6.0.07.02

Make sure to change the filename if you got another architecture.

This takes a while and will probably generate some warnings about some of your packages being to new, but you can safely ignore those.

Ok, now that we've gotten all prerequisites of serviio installed we can now install serviio itself.
Go to the serviio site and download the linux tar.gz file.
Place this somewhere on your NAS, I put it in a data directory again.

Go to the directory containing the file and unzip it:
Code:
 tar xvfz serviio-0.5.2-linux.tar.gz 


Now we have to replace the startup script with an edited version of it.
Go to the bin folder and backup your old config file:
Code:
mv serviio.sh serviio.sh.old


Then create a new serviio.sh file, using vi or nano or whatever editor you like and paste the following into it:
Code:
#!/bin/sh
### ====================================================================== ###
##                                                                          ##
##  Serviio start Script                                                    ##
##                                                                          ##
### ====================================================================== ###

DIRNAME=`dirname $0`
PROGNAME=`basename $0`

# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
linux=false;
case "`uname`" in
    CYGWIN*)
        cygwin=true
        ;;

    Darwin*)
        darwin=true
        ;;
        
    Linux)
        linux=true
        ;;
esac

# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
    [ -n "$SERVIIO_HOME" ] &&
        SERVIIO_HOME=`cygpath --unix "$SERVIIO_HOME"`
    [ -n "$JAVA_HOME" ] &&
        JAVA_HOME=`cygpath --unix "$JAVA_HOME"`    
fi

# Setup SERVIIO_HOME
if [ "x$SERVIIO_HOME" = "x" ]; then
    # get the full path (without any relative bits)
    SERVIIO_HOME=`cd $DIRNAME/..; pwd`
fi
export SERVIIO_HOME

# Setup the JVM
if [ "x$JAVA" = "x" ]; then
    if [ "x$JAVA_HOME" != "x" ]; then
	JAVA="$JAVA_HOME/bin/java"
    else
	JAVA="java"
    fi
fi

# Setup the classpath
SERVIIO_CLASS_PATH="$SERVIIO_HOME/lib/serviio.jar:$SERVIIO_HOME/lib/derby.jar:$SERVIIO_HOME/lib/jcs.jar:$SERVIIO_HOME/lib/concurrent.jar:$SERVIIO_HOME/lib/freemarker.jar:$SERVIIO_HOME/lib/httpcore.jar:$SERVIIO_HOME/lib/jaudiotagger.jar:$SERVIIO_HOME/lib/jul-to-slf4j.jar:$SERVIIO_HOME/lib/jcl-over-slf4j.jar:$SERVIIO_HOME/lib/log4j.jar:$SERVIIO_HOME/lib/sanselan.jar:$SERVIIO_HOME/lib/slf4j-api.jar:$SERVIIO_HOME/lib/slf4j-log4j12.jar:$SERVIIO_HOME/lib/org.restlet.jar:$SERVIIO_HOME/lib/org.restlet.ext.xstream.jar:$SERVIIO_HOME/lib/xstream.jar:$SERVIIO_HOME/config"

# Setup Serviio specific properties
JAVA_OPTS="-Djava.net.preferIPv4Stack=true -Dderby.system.home=$SERVIIO_HOME/library -Dserviio.home=$SERVIIO_HOME -Dserviio.remoteHost=192.168.0.188"

# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
    SERVIIO_HOME=`cygpath --path --windows "$SERVIIO_HOME"`
    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
    SERVIIO_CLASS_PATH=`cygpath --path --windows "$SERVIIO_CLASS_PATH"`
fi

# Execute the JVM in the foreground
"$JAVA" -Xmx384M $JAVA_OPTS -classpath "$SERVIIO_CLASS_PATH" org.serviio.MediaServer "$@"         


Make sure to change the ip-address 192.168.0.188 to the ip-address of your NAS.

That's it, you can now run
Code:
 ./serviio.sh & 

And serviio will run.

Use the console from another pc to connect and set it up, you can find instructions to do so here.
 

emb

Cadet
Joined
Jul 14, 2011
Messages
6
A step by step tutorial would be greatly appreciated (when you have time). -- Thanks
 
S

Stefan Reek

Guest
Well I've found some time to expand the tutorial a bit, it now contains all the steps necessary to install serviio on your system.
I hope the steps are clear enough. I'm curious to see if this works for you.

If I have some time I'll try to see if I can make a nice startup script so you don't have to run the script manually everytime the system is rebooted.
 

emb

Cadet
Joined
Jul 14, 2011
Messages
6
I won't have time to try it out until tomorrow evening but I'm excited to give it a go. -- Many thanks.
 

emb

Cadet
Joined
Jul 14, 2011
Messages
6
I tried this last night and was not able to get past the ports install.
I changed the PORTSDIR? to reflect my location and got past the "file not found" error but ended with this:
Code:
freenas02#  make install clean
===>  Installing for compat7x-amd64-7.3.703000.201008_1
===>   Generating temporary packing list
===>  Checking if misc/compat7x already installed
(cd /mnt/vol01/storage/serviio/ports/misc/compat7x/work/compat7x-amd64-7.3.70300 0.201008/lib && install  -o  -g  -m  *.so.* /usr/local/lib/compat)
install: invalid file mode: libalias.so.6
*** Error code 64

Stop in /mnt/vol01/storage/serviio/ports/misc/compat7x.


Any ideas?
 
S

Stefan Reek

Guest
When I run "make install clean" the command is:
Code:
install  -o root -g wheel -m 444 *.so.* /usr/local/lib/compat

A quick look at the makefile shows that for some reason ${INSTALL_DATA} is not correct for you.
You might be able to solve it by adding
Code:
INSTALL_DATA=install -o root -g wheel -m 444

to the top of the Makefile in /mnt/vol01/storage/serviio/ports/misc/compat7x
Or maybe below the line
Code:
.include <bsd.port.pre.mk> 


Let me know if that works

I should also note that after rebooting I had to
Code:
mount -urw /
pkg_add -v -r javavmwrapper

To be able to start serviio again, so the solution is not perfect yet.

I do have serviio and transmission working now on my system :D
 

VNMan

Cadet
Joined
Aug 4, 2011
Messages
5
I use csup to install serviio as serviio is available under fresh ports.

packages needed

xtrans
xproto
xextproto
javavmwrapper
diablojdk.....

then compile and install serviio under /usr/ports/net/serviio...
 

joeschmuck

Old Man
Moderator
Joined
May 28, 2011
Messages
10,994
I use csup to install serviio as serviio is available under fresh ports.

packages needed

xtrans
xproto
xextproto
javavmwrapper
diablojdk.....

then compile and install serviio under /usr/ports/net/serviio...

You make it sound easy. Could you update your posting to include a step by step guide. I know Stefan started this How To guide for which I am grateful. I will try it out next week when I return home.

I am curious on two things: 1) how much of an impact did it have to the free file space on the Flash drive (boot), 2) What sized flash drives are you both using?
 

VNMan

Cadet
Joined
Aug 4, 2011
Messages
5
I think my method is almost the same but...
OK here goes

I find it much easier to ssh to the FreeNAS box than connect directly. I am sure there is a how to install ssh but here is my short version -

First you need to activate ssh service on FreeNAS and create a user that is in the group "wheel". Then this is the only time you need to connect directly to FreeNAS, you need to login to FreeNAS and do

mount -uw /
pkg_add sudo
nano /etc/sudoers (this is to make the user that you created earlier on to use sudo), search for "wheel" comment out # in front of "wheel". Save and exit nano.

Use putty to logon using ssh....

ssh 192.168.0.1 (you need to change the ip according to your FreeNAS ip)
sudo su
mount -uw /
pkg_add -rv xtrans
pkg_add -rv xproto
pkg_add -rv xextproto
pkg_add -rv javavmwrapper
pkg_add -rv ffmpeg

Download Java jre / jdk and install as in the first post.

From now on my method is a little different than Stefan's.

Follow this guide herehttp://www.freebsd.org/doc/handbook/ports-using.html

csup -L 2 /mnt/Data/Temp/ports-supfile

Since you download only portion of ports it is much smaller but you will miss two important directories and they are "Mk" and "Templates". These can be downloaded from FreeBSD website, I downloaded the whole ports.tar.gz file from ftp.freeBSD.org and extract the necessary directories and put them under /usr/ports/.

now to compile serviio

cd /usr/ports/net/serviio
make
make install clean

The Java jre /jdk that you installed is not compatible with FreeNAS 8.x, therefore you need the file lib map.conf under /etc/ which consists of two lines -

[/usr/local/diablo-jdk1.6.0/]
libz.so.4 libz.so.5


Edit /etc/rc.conf for serviio service

nano /etc/rc.conf
and insert these two lines -

serviio_enable="YES"
serviio_args=-Dserviio.remoteHost=192.168.0.1 (this is my Freenas's IP, yours will be different)

To start serviio service -

/usr/local/etc/rc.d/serviio start

You will now need to install serviio-console(client) to configure your serviio Media server !!!

joeschmuck -

1) Since serviio uses the directory /var/db/ to store its database, you need to mount the /var somewhere else. I use a separate memory stick for this.
2) the boot drive that I have is 8.1 GB, modified so that FreeNAS uses 7 GB for first partition. Plus an extra 2GB memory stick especially for the /var/.
 

VNMan

Cadet
Joined
Aug 4, 2011
Messages
5
The contents of ports-supfile

*default host=cvsup.de.freebsd.org
*default base=/usr
*default prefix=/usr
*default release=cvs
*default delete use-rel-suffix
ports-net
 
S

Stefan Reek

Guest
Ah, I didn't know serviio was available under fresh ports.
I might try this method myself if I have some time, thanks VNMan!
The method I used takes about 300M on the USB stick, and some more on the data disks.
The data on the data disks can be removed after the installation though.
I use 8G USB stick, but have not modified it, so it uses only 2G.
 

Nihilator

Cadet
Joined
Aug 17, 2011
Messages
1
VNMan,

Could you tell me how you got "/var" to mount on your 2GB memory stick? I have FreeNAS 8 (Full Install) and it mounts "/var" on a memory device "/dev/md2". What commands do I type if I want to mount "/var" on my memory stick (which is "/dev/da0s1d)?

Once I do mount "/var" to my memory stick, how would I set it up to mount "/var" automatically? I can't use "etc/fstab", because "/etc" is also mounted as a memory device ("/dev/md0") and the changes you make are gone after a reboot.

1) Since serviio uses the directory /var/db/ to store its database, you need to mount the /var somewhere else. I use a separate memory stick for this.
2) the boot drive that I have is 8.1 GB, modified so that FreeNAS uses 7 GB for first partition. Plus an extra 2GB memory stick especially for the /var/.
 

GeoffLee

Dabbler
Joined
Aug 27, 2011
Messages
11
Stefan,

I accidentally installed the wrong version of Java (installed the 6.0 version instead of 7.0). How do I uninstall Java 6.0 from my system now? Sorry for the noob question!
 
A

Athanasios Kakargias

Guest
I needed to add the following file
/etc/libmap.conf
with contents
libz.so.4 libz.so.5
to overcome this java crash:
Error occurred during initialization of VM
Unable to load ZIP library: /usr/local/diablo-jre1.6.0/lib/amd64/libzip.so

No misc/compat7x ports used, actually no ports at all just the packages. no jdk either.
 
D

Damon Opacak

Guest
Thanks, got Serviio installed and working (mostly) due to this tutorial

But for some reason, everytime I restart the Freenas box, I have to redo the 'pkg_add -v -r javavmwrapper' command, otherwise it fails to start Serviio. I'm not full bottle on freebsd, but is it replacing or removing usr on reboot?

Also, is there any way in Freenas 8 I can get it to run the script to run serviio on startup? On freenas 7 I put scripts I wanted to run in advanced|postinit, but cant find in freenas 8. Just means everytime I boot my NAS box, I need to putty in and run ./serviio.sh &

Any ideas?
 
A

Athanasios Kakargias

Guest
java: error: can't find /usr/local/etc/javavms configuration file

If you are on USB you need also before rebooting to

Code:
cp /etc/local/javavm* /conf/base/etc/local/
echo libz.so.4 libz.so.5 > /conf/base/etc/libmap.conf
 
D

Damon Opacak

Guest
Thanks Anthanasios, any idea how to make the './serviio.sh &' command run on startup?
 
A

Athanasios Kakargias

Guest
Thanks Anthanasios, any idea how to make the './serviio.sh &' command run on startup?

seems i totally missed VNMan's post and researched things he already said ;)

anyway
if you are running from usb and untared serviio to /usr/local/serviio or something similar
in the JAVA_OPTS section of serviio.sh add those properties

Code:
-Dderby.stream.error.file=/var/derby.log
-Dderby.system.home=/mnt/some_writable_directory_on_some_disk


and

Code:
cp -R /usr/local/serviio/library/* /mnt/some_writable_directory_on_some_disk


this will keep derby happy for starters..
also

Code:
rm -r /usr/local/serviio/log
ln -s /var /usr/local/serviio/log


to redirect logs to /var


as for autostart as VNMan says we need to play with rc.conf but in our case not the one in /etc/ but in /conf/base/etc... hang on im working on it right now
 
A

Athanasios Kakargias

Guest
autostarting serviio

ok since i couldn't find the rc script anywhere i made my own so if any bsd guru comes by don't be harsh :P

fisrt create this file on /etc/rc.d/serviio and /conf/base/etc/rc.d/serviio
with this content
Code:
#!/bin/sh

# PROVIDE: serviio
# REQUIRE: LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="serviio"
rcvar=`set_rcvar`
eval "${rcvar}=\${${rcvar}:-'NO'}"
serviio_msg=${serviio_msg:-"serviio not serving"}

pidfile="/var/run/${name}.pid" 

start_cmd="${name}_start"
stop_cmd="${name}_stop"

required_files="/usr/local/serviio-0.6/bin/serviio.sh"

load_rc_config $name

serviio_start()
{
    /bin/sh /usr/local/serviio-0.6/bin/serviio.sh &
        echo "serviio up"
}

serviio_stop()
{
    /bin/sh /usr/local/serviio-0.6/bin/serviio.sh -stop
        echo "serviio down"
}


run_rc_command "$1"


file must be rx ie
Code:
chmod +x serviio


and append in /etc/rc.conf and /conf/base/etc/rc.conf
the line
Code:
serviio_enable="YES"


I needed also to pinpoint $JAVA variable in serviio.sh like that
Code:
# Setup the JVM
if [ "x$JAVA" = "x" ]; then
    if [ "x$JAVA_HOME" != "x" ]; then
        JAVA="$JAVA_HOME/bin/java"
    else
        JAVA="/usr/local/bin/java"
    fi
fi


maybe this could done also by exporting JAVA in the rc script but not going back now ;)
 
D

Damon Opacak

Guest
seems i totally missed VNMan's post and researched things he already said ;)

anyway
if you are running from usb and untared serviio to /usr/local/serviio or something similar
in the JAVA_OPTS section of serviio.sh add those properties

Code:
-Dderby.stream.error.file=/var/derby.log
-Dderby.system.home=/mnt/some_writable_directory_on_some_disk


and

Code:
cp -R /usr/local/serviio/library/* /mnt/some_writable_directory_on_some_disk


this will keep derby happy for starters..
also

Code:
rm -r /usr/local/serviio/log
ln -s /var /usr/local/serviio/log


to redirect logs to /var


as for autostart as VNMan says we need to play with rc.conf but in our case not the one in /etc/ but in /conf/base/etc... hang on im working on it right now

Hey mate, cheers, but I installed Serviio onto my mounted volume /mnt/RAID/serviio, so im guessing I dont need to do the changes you suggested?
 
Status
Not open for further replies.
Top