Serviio DLNA server with headless Java

Preface

After installing the ALARM on the Pogoplug E02, there was now a need to have all the media content moved to the server properly displayed on a LCD TV. As I use a Samsung FD-5100 Bluray1 player which can connect to various media servers using a DLNA2 certified interoperability, I was in the lookout for a DLNA solution to place on the Pogoplug E02.

There are quite some popular solutions out there like commercial Plex3 or minidlna4, which is free, but not a single one could properly display external subtitles on my equipment. There was one who could, since I’ve been using it on my Windows PC, called Serviio5. Being available on Windows, Mac and Linux, I’ve started looking into bringing it on the Pogoplug E02.


Requirements

Since Serviio runs on Java, at first I had to make sure it’s properly installed on the system. I’ve looked into packages available for ALARM, but at the time there was no simple install available for it in the package repository. There were also issues reported with the openJRE stack, so Oracle Java was a preffered package.

headless Java

We have to visit the Oracle website and find the correct package for the Pogoplug E02. It runs on ARMv5 architecture, SoftFP ABI, Little Endian3, so the correct one at time of writing is ejdk-8u33-fcs-linux-arm-sflt.tar.gz. We download the package on PC (can’t be done on the Pogoplug E02 via wget), then transfer it via the Samba share.

We connect to our box via SSH and move the downloaded package (I’ve placed it into the Samba share) to the user /home directory.

$ mv /media/hdd1/ejdk-8u33-fcs-linux-arm-sflt.tar.gz /home/user

Then we create the directory to include the installed Java package in /opt/java.

$ sudo mkdir -p -v /opt/java

After that we unpack the download package in there.

$ sudo tar xvzf ~/ejdk-8u33-fcs-linux-arm-sflt.tar.gz -C /opt/java

We now need to set the path to the Java binary. This is done in /etc/profile, which we edit with any text editor. At the end it must look like this.

# Set our default path
  PATH="/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/java/ejdk1.8.0_33/linux_arm_sflt/jre/bin"
  JAVA_HOME="/opt/java/ejdk1.8.0_33/linux_arm_sflt/jre"
  export PATH JAVA_HOME

We log out and back in to try the changes with running java -version.

$ java -version
java version "1.8.0_33"
Java(TM) SE Embedded Runtime Environment (build 1.8.0_33-b05, headless)
Java HotSpot(TM) Embedded Client VM (build 25.33-b05, mixed mode)

All set, we can proceed to installing Serviio.

Serviio

Best practice for running Serviio is that it runs as a separate user, so we go and create it. We also make a separate group for and put the user into that group.

$ groupadd serviio
$ useradd -g serviio serviio

Note: we could create the user without its own /home directory, but Java requires one for it to work.

Now we can download the Serviio package from the official website.

$ wget http://download.serviio.org/releases/serviio-1.5-linux.tar.gz

We extract the package to /opt.

$ sudo tar -zxcf ~/serviio-1.5-linux.tar.gz -C /opt

After that we give the installed Serviio package proper permissions, with the user we created before.

$ sudo chown -R serviio:serviio /opt/serviio-1.5

All we need to do now is edit the serviio.sh starting script, placed in /opt/serviio-1.5/bin/ as following.

# Setup the JVM
#if [ "x$JAVA" = "x" ]; then
#    if [ "x$JAVA_HOME" != "x" ]; then
#       JAVA="$JAVA_HOME/bin/java"
#    else
#       JAVA="$JAVA_HOME/bin/java"
#    fi
#fi
JAVA="/opt/java/ejdk1.8.0_33/linux_arm_sflt/jre/bin/java"

Despite having $JAVA_HOME set before, Serviio doesn’t recognize it and refuses to start. This way we can hardcode the Java binary location.

Being on a Arch Linux installation, a systemd run script is convenient to run a service. We create one using a desired text editor, for example here vim.

$ sudo vim /etc/systemd/system/serviio.service

This opens an empty serviio.service file in /etc/systemd/system/. We paste following content inside it.

#  /etc/systemd/system/serviio.service
[Unit]
Description=Serviio 1.5 Media Server
After=network.target

[Service]
User=serviio
ExecStart=/opt/serviio-1.5/bin/serviio.sh
ExecStop=/opt/serviio-1.5/bin/serviio.sh -stop
KillMode=none

[Install]
WantedBy=multi-user.target

Now we can start and stop the Serviio DLNA server simply by using the systemctl command and also enable it to run at boot.

$ sudo systemctl start serviio
$ sudo systemctl enable serviio

Configuring Serviio

Being only a server, it needs a separate console or a client to be configured. There’s a console available in the Mac and Windows package, or we can use a free Android app called ServiiDroid6.

ServiiDroid app for configuring Serviio.

The configuration is pretty straightforward and requires setting the monitored directory for audio, video and music files.

After that the content is seen in a DLNA client, like the Bluray player.