Serviio DLAN Server on Debian
Posted by Kaya Kupferschmidt • Wednesday, December 28. 2011 • Category: Workstations
If you want to share your media collection (that is music, videos and pictures) in your LAN on multimedia devices like tablets, smartphones, TVs and consoles, you end up using either DLNA or UPnP. Because my devices support DLNA, I decided to give it a try to install a DLNA service on a Debian server. Googling around, I found some different implementations of which Serviio media server looked most primising. Implemented in Java it surely uses some more resources than some native C/C++ implementation, but it offers some nice features like plugins and device profiles. And it offers a pure server implementation without a GUI, which was very important to me for running it on a headless server.
First you need a properly configured debian system with Java installed. For accessing an optional web ui for administrating the server you'll also need an apache2 with php5 installed on your box. You can ensure that both are installed by running apt-get.
Then you need to download the latest version from www.serviio.org, which comes as a .tar.gz file for linux. Unzip it into your /opt folder:
Because I do not want to run the service as root, I create a special linux user for running saviio
Then we need some init script for starting serviio, so we'll create the file /etc/init.d/serviio with our favorite editor (for example nano)
Now we can install and start the service:
First you need a properly configured debian system with Java installed. For accessing an optional web ui for administrating the server you'll also need an apache2 with php5 installed on your box. You can ensure that both are installed by running apt-get.
$ apt-get install openjdk-6-jre-headless apache2 libapache2-mod-php5 php5-xmlrpc php5-curl
Then you need to download the latest version from www.serviio.org, which comes as a .tar.gz file for linux. Unzip it into your /opt folder:
$ cd /opt
$ tar xvzf serviio-0.6.0.1-linux.tar.gz
$ mv serviio-0.6.0.1 serviio
Because I do not want to run the service as root, I create a special linux user for running saviio
$ useradd -r -d /opt/serviio -U serviio
$ chown -R serviio:serviio serviio
Then we need some init script for starting serviio, so we'll create the file /etc/init.d/serviio with our favorite editor (for example nano)
#! /bin/sh
#
# /etc/init.d/serviio
#
#
### BEGIN INIT INFO
# Provides: serviio
# Required-Start: $network
# Required-Stop: $network
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: Start the serviio DLNA server in headless mode
### END INIT INFO
SERVIIO_HOME="/opt/serviio"
SERVIIO_DAEMON="serviio.sh"
SERVIIO_BIN="$SERVIIO_HOME/bin/$SERVIIO_DAEMON"
SERVIIO_USER="serviio"
# Source function library.
. /lib/lsb/init-functions
RETVAL=0
check() {
# Check that we're a privileged user
[ $(id -u) = 0 ] || exit 4
# Check if SERVIIO_HOME exists
test -d "$SERVIIO_HOME" || exit 5
# Check if SERVIIO_BIN is executable
test -x "$SERVIIO_BIN" || exit 5
}
start() {
check
echo -n "Starting Serviio DLNA server: "
/usr/bin/sudo -u $SERVIIO_USER -H $SERVIIO_BIN -headless &
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
touch /var/lock/serviio
log_end_msg 0
else
log_end_msg 1
fi
echo
return $RETVAL
}
stop() {
check
echo -n "Shutting down Serviio DLNA daemon: "
killproc "$SERVIIO_BIN"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/serviio
echo
return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
force-reload)
restart
;;
restart)
restart
;;
condrestart)
if [ -f /var/lock/serviio ]; then
restart
fi
;;
status)
status serviio.sh
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|force-reload}"
RETVAL=2
esac
exit $RETVAL
Now we can install and start the service:
$ chmod a+rx /etc/init.d/serviio
$ chkconfig --add serviio
$ service serviio start



0 Comments
Add Comment