How to Install Universal Media Server UMS on Ubuntu in Headless mode for 14.04 or 16.04

Updated for Ubuntu 14.04 or 16.04
03-15-18

Universal Media Server is a fork off the very useful PS3 and PS4 Media Server. And although the PS3MediaServer was a great solution, it did have some shortcomings, especially with certain file formats or file containers. I tried UMS and loved it. It is easy to install and, at least for now, streams and transcodes every media file I have to support playback on any device including the PS3, PS4,  and the sony SMP-N200 I use on other TVs.

So, working with any Ubuntu 14.04 or 16.04 server, here is my step by step to get UMS installed and working.

First you must have Java 8 JRE installed on the server. OpenJava will not work.

apt-get install software-properties-common
apt-get update
apt-get install openjdk-8-jre openjdk-8-jre-headless

With Java installed, we now need to add some other pre-reqs:

apt-get install mediainfo dcraw vlc-nox mplayer mencoder

I’m going to use the /opt directory for the install. Then we download the latest UMS package from sourceforge. You can check the UMS webpage to find the latest version. As I write this, the latest is 5.2.3. After the download is complete, unpack the file with tar. I create a softlink using /opt/ums so that when we need to upgrade, we can just point the softlink to the new directory while not touching the config files that we will be using in /etc/ later on.  Note that for 6.8.0, I had to download the file with a browser and scp it over to the media host because of 301 redirects on the download pages.

cd /opt
wget http://sourceforge.net/projects/unimediaserver/files/Official%20Releases/Linux/UMS-5.2.3-Java7.tgz
tar -xvzf UMS-6.8.0.tgz
ln -s /opt/ums-6.8.0 ums
rm UMS-6.8.0.tgz

Next we need to create the init.d script to auto start the app when the server boots, as well as have better control over the service.
We will create /etc/init.d/ums.

nano /etc/init.d/ums

Copy the following into the new file:

#!/bin/bash
#
### BEGIN INIT INFO
# Provides:          ums
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts UMS program.
# Description:       Java Upnp Media Server dedicated to PS3
### END INIT INFO

#set -x

# Author: Papa Issa DIAKHATE <paissad@gmail.com>
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="Universal Media Server"
NAME=ums
UMS_PROFILE=/etc/UMS.conf
DAEMON=/opt/ums/UMS.sh
DAEMON_OPTS="console"
SCRIPTNAME=/etc/init.d/ums
UMS_START=1 # Wether to start or not UMS ver at boot time.
DODTIME=30  # Time to wait for the server to die, in seconds.
            # If this value is set too low you might not
            # let the program to die gracefully and 'restart' will not work

test -x $DAEMON || exit 1

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Include ums defaults if available
if [ -f "/etc/default/$NAME" ] ; then
        . /etc/default/$NAME
fi

# May we run the init.d script ?
[ $UMS_START = 1 ] || exit 1

#--------------------------------------------------------------------------
# Some color codes
txtred=$'\e[0;31m' # Red
txtylw=$'\e[0;33m' # Yellow
txtrst=$'\e[0m'    # Text Reset
#--------------------------------------------------------------------------
warnout(){
    echo >&2 -e ""$txtylw"Warning:$txtrst $1"
}
#--------------------------------------------------------------------------
running(){
    pid=`pgrep -f 'java .*ums.jar.*'`
}
#--------------------------------------------------------------------------
do_start(){
    running && { warnout "$NAME is already running !"; exit 0; }
    echo "Starting $DESC : $NAME"
    UMS_PROFILE="$UMS_PROFILE" start-stop-daemon --start --quiet --background --oknodo \
        --exec $DAEMON -- $DAEMON_OPTS

}
#--------------------------------------------------------------------------
do_stop(){
    running || { warnout "$NAME is NOT running !"; exit 0; }   
    local countdown="$DODTIME"
    echo -e "Stopping $DESC : $NAME \c "
    kill -9 $pid
    while running; do
        if (($countdown >= 0)); then
            sleep 1; echo -n .;
            ((--countdown))
        else
            break;
        fi
    done
    echo
    # If still running, then try to send SIGINT signal
    running && { \
        echo >&2 "Using kill -s SIGINT instead"; \
        echo >&2 "If you see this message again, then you should increase the value of DODTIME in '$0'."; \
        kill -2 $pid; \
    }

    if [ -e "/usr/share/ums/debug.log" ]; then
    count=9
    while [ $count -ge 1 ]
    do
    if [ -e "/usr/share/ums/debug.log.$count" ]; then
        plus=$((count+1))
        mv "/usr/share/ums/debug.log.$count" "/usr/share/ums/debug.log.$plus"
    fi
        count=$((count-1))
    done
    if [ -e "/usr/share/ums/debug.log" ]; then
        mv "/usr/share/ums/debug.log" "/usr/share/ums/debug.log.1"
    fi
    fi

    return 0
}
#--------------------------------------------------------------------------
do_force-stop(){
    running || { warnout "$NAME is NOT running !"; exit 0; }   
    echo "Stopping $DESC : $NAME"
    kill -9 $pid
    if [ -e "/usr/share/ums/debug.log" ]; then
    count=9
    while [ $count -ge 1 ]
    do
    if [ -e "/usr/share/ums/debug.log.$count" ]; then
        plus=$((count+1))
   mv "/usr/share/ums/debug.log.$count" "/usr/share/ums/debug.log.$plus"
    fi
       count=$((count-1))
    done
    if [ -e "/usr/share/ums/debug.log" ]; then
   mv "/usr/share/ums/debug.log" "/usr/share/ums/debug.log.1"
    fi
    fi
}
#--------------------------------------------------------------------------
do_status(){
    echo -n " * $NAME is "
    ( running || { echo "NOT running "; exit 0; } )
    ( running && { echo "running (PID -> $(echo $pid))"; exit 0; } )
}
#--------------------------------------------------------------------------
case "$1" in

    start|stop|force-stop|status)
        do_${1}
        ;;
    restart|reload)
        do_stop
        do_start
        ;;
    force-restart|force-reload)
        do_force-stop
        do_start
        ;;
    *)
        echo "Usage: $SCRIPTNAME {start|stop|force-stop|restart|force-restart|reload|force-reload|status}"
        exit 1
        ;;
esac

Now add execute permissions to the script and add the UMS script to update-rc.d

chmod +x /etc/init.d/ums
update-rc.d ums defaults

A sample conf file that you could use is at /opt/ums/UMS.conf and could be copied into /etc/UMS.conf and edited to fit your needs. It has all the configurable options and is probably more than most will need. You should also copy in the WEB.conf file as well to handle web streams if you use that functionality. (Thanks Wolfgang Hochweller)

cp /opt/ums/UMS.conf /etc/
cp /opt/ums/WEB.conf /etc/

Configuration is done to the /etc/UMS.conf file. At the very least you will want to add the location of the media to share.

folders=/mnt/media/tv, /mnt/media/movies, /mnt/media/music 

Pay attention to the following items, especially for those hosts with multiple NICs.

network_interface=
hostname=
port=
folders=

Now start UMS:yty

service ums start

That’s it, it should be running and advertising itself as UPNP/DLNA on the local network.

Tagged , , , , . Bookmark the permalink.

40 Responses to How to Install Universal Media Server UMS on Ubuntu in Headless mode for 14.04 or 16.04

  1. Wolfgang Hochweller says:

    Just a few corrections :

    – the tar command seems to be wrong , should it not be something like xvzf ?

    /opt/ums-3.6.1 dir should be moved to /opt/ums .
    Otherwise the script will not work at all.

    – Wolfgang

    • Wolfgang Hochweller says:

      Just one more :

      When copying the UMS.conf file to /etc, do not forget to do the same for WEB.conf or it will not start.
      No need to edit, it has just to be there.

      – Wolfgang

      • Mike says:

        UMS actually does start without WEB.conf in etc, but you are correct that if you want web streams, image streams, etc you would need that there.

    • Mike says:

      Yep – Thanks for catching the typo. Already corrected it in the article.

  2. shaul says:

    This does not work on Ubuntu 14.04, probably because the switch to upstart.

  3. erik says:

    Excellent guide and seems to be much more robust then ps3ms option.

    On 14.04(Trusty)
    On the latest build at the time which I ran this I used UMS Version 3.6.2.

    use openjdk-7-jre instead of 6 for trusty:
    apt-get install openjdk-7-jre

    Since ffmpeg package has been removed from trusty repositories, you can opt to add older versions or to move on to the alternative FFmpeg PPA
    add-apt-repository ppa:jcfp/ppa
    apt-get update
    apt-get install ffmpeg
    (don’t forget the prior packages mentioned above – mplayer mencoder mediainfo)

    Or create an upstart script for yourself, something along the lines of /etc/init/UMS.conf with :

    # Universal Media Server

    description “Universal Media Server”

    start on runlevel [2345]
    stop on runlevel [!2345]

    console output

    expect fork
    respawn

    exec /opt/ums/UMS.sh

    ____
    Then type : service UMS start

    -Erik

  4. DudeBud says:

    Thanks for the great guide,

    however i don’t think the line “update-rc.d /etc/init.d/UMS defaults” is working on 14.04

    Thx erik for the upstart script memo.

  5. Johannes says:

    Hey,

    I am running Ubuntu 14.04 and try to get UMS working.
    DudeBud, you mentioned “update-rc.d /etc/init.d/UMS defaults” won’t work on 14.04., so I used “update-rc.de UMS defaults” which returned : “warning: /etc/init.d/UMS missing LSB information”

    Could anyone tell how to change the script above to make it working?

    thanking you in advance!

    Johannes

  6. william says:

    This how to is written for advanced users.
    Many steps are assumed to be knowledge and not mentioned.
    I for one, need more complete step-by-step instructions.
    I’m getting stuck at “Now add execute permissions to the script and add the UMS script to update-rc.d”
    Also at
    cp /opt/ums/UMS.conf /etc/
    cp /opt/ums/WEB.conf /etc/
    Following your instructions after unpacking the tarball I have a folder named UMS plus the version number.

    Since I already invested four hours in this I would like to get it working. Not ending up stuck with half-installed files.

  7. Michael says:

    to add the execute permissions type: chmod +x filename

    for the (Use “update-rc.d UMS defaults” as update-rc.d knows the path) just type: sudo update-rc.d UMS defaults

    for this line just type sudo in front and past in: cp /opt/ums/UMS.conf /etc/
    e.g. : sudo cp /opt/ums/UMS.conf /etc/

    Hope this helps?

  8. Andrey says:

    Mike, thank you for good guidance, but due to actual version of Ubuntu server is 14.04 could you correct something point of this guidance in order to actualize it.

    regards.

  9. Chris says:

    I’m also finding this very difficult to setup on Ubuntu 14.04

    Ubuntu 14.04’s problems with Sun Java JRE and ffmpeg have defeated me. Sad, because I really wanted to try UMS.

    I hope the Ubuntu folk had good reasons for making it so tough 🙁

  10. Thorsten says:

    Works on Ubuntu 14.04 Server LTS. Only a little modification to the startup script is required. Add “.sh” to the following line:

    DAEMON=/opt/ums/$NAME

    so it looks like

    DAEMON=/opt/ums/$NAME.sh

    Then everything works out quite well.

    I installed java using this HowTo:

    http://de.wikihow.com/Installation-von-Oracle-Java-unter-Ubuntu-Linux

    • Stephane says:

      yay ! Thanks Thorsten, I would never have found that!

    • Stephane says:

      FYI, Thorsten’s suggestion allowed me (Ubuntu 14.04.1 LTS) to start/stop the service manually. To have it start on boot, I had to make the additional changes:

      if [[ -f “/etc/default/$NAME” ]] ; then
      becomes
      if [ -f “/etc/default/$NAME” ] ; then

      and
      [[ $UMS_START = 1 ]] || exit 1
      becomes
      [ $UMS_START = 1 ] || exit 1

      Works neat now! Thanks to all!

  11. Stephane says:

    Also, you might want to run the service as a non-root user (as explicitly recommended in UMS’s readme). Add –chuid username to the start-stop-daemon command:

    UMS_PROFILE=”$UMS_PROFILE” start-stop-daemon –start –quiet –background –oknodo –exec $DAEMON — $DAEMON_OPTS

    becomes

    UMS_PROFILE=”$UMS_PROFILE” start-stop-daemon –chuid username –start –quiet –background –oknodo –exec $DAEMON — $DAEMON_OPTS

    where username is to be replaced with your (non-root) user name.
    Note that, in case you ran UMS as root before, you may fail to start it as non root, with a message such as “java.io.IOException: Temp folder is not writeable: /tmp/universalmediaserver”. That’s because /tmp/universalmediaserver has been created with root privileged during your previous runs. Just delete it (as root):

    sudo rm -rf /tmp/universalmediaserver
    sudo rmdir /tmp/universalmediaserver

    and try again as non root.

    Cheers

  12. Joe says:

    You should really just use Plex Media Server… It’s absolutely magical and super functional. Also DLNA compliant and very pretty…

  13. Dims says:

    Doesn’t work on Ubuntu 14.04

    No any messages, no any logs. Just nothing happens on any command to run service

    • Cesare says:

      hi!
      i found the same problem, but i see that in the /etc/init.d script there was an error: DAEMON=/usr/ums/UMS.sh
      this parameter try to find the daemon in the /usr/ folder but we put the sources in the /opt/ folder, so, if you change that line with,
      DAEMON=/opt/ums/UMS.sh the service will start!

  14. Pingback: How to install and/or run Universal Media Server on Ubuntu 14.04? | DL-UAT

  15. Pingback: How to install and/or run Universal Media Server on Ubuntu 14.04? | TUTNEW

  16. MBuraq says:

    Hi there,

    Thanks for the steps, however I am stuck at update-rc.d step. It keeps giving me the following errors:
    insserv: Script UMS is broken: incomplete LSB comment.
    insserv: missing `Provides:’ entry: please add.
    insserv: missing `Required-Start:’ entry: please add even if empty.
    insserv: missing `Required-Stop:’ entry: please add even if empty.
    insserv: missing `Default-Start:’ entry: please add even if empty.
    insserv: missing `Default-Stop:’ entry: please add even if empty.
    insserv: Default-Start undefined, assuming empty start runlevel(s) for script `UMS’
    insserv: Default-Stop undefined, assuming empty stop runlevel(s) for script `UMS’

    I am running this on Debian and I got an error when I tried this command:
    sudo apt-get install update-sun-jre
    Error: unable to locate package

    Please help.

  17. doIhaveTo says:

    I managed to fix mine on 15.04, the above worked but UMS.sh in /opt/ums needed to be renamed as UMS

    service started and all was working.

  18. Alex says:

    I stuck on the screen after i paste & enter script to create /etc/init.d/UMS
    what do i do there?

  19. Ermelinda says:

    This article will help the internet visitors for setting up
    new web site or even a blog from start to end.

  20. Roop says:

    I followed the steps and it worked for me. Thanks Mike

  21. OAC says:

    Hi there, I just used your solution in Raspbian in a model B PI Raspberry, thank you.

    However, there are some issues, for example, mencoder won’t install anymore; I’m able to see all the files of the system through the DNLA client (a SONY BDP-S490); and cannot play the main media file but the trans-coded file or something like that.

    Is there a way you could please update these problems or if possible create a similar set-of-steps for Raspbian??

    Thank you in advance.

  22. thomas says:

    Hi,
    thanks for the guidance

    Did not find a hint to add samba shares as source for shared folders

    How to add those?

    Thanks for the hints

    • mike says:

      Google is your friend here. There are lots of tutorials on how to get a samba share on an Ubuntu directory. Maybe I’ll write a tut for this someday….

  23. Fabien TELL says:

    Hello,
    Thanks for your advices.
    i’ve got a question.
    I have a computer (Ubuntu 14.04 ) which is connected to Internet via a wire.
    So I bought an USB wifi key to be able to make it as a wifi server or a wireless access point.
    I haven’t done that yet.
    For now I can just broadcast wifi signals (from my neighbors) including the one delivered by my sony bravia TV I can connect to.

    When I start UMS, my TV is detected on UMS but I do not see UMS on my TV and I cannot broadcast anything. So I must turn it into an access point ?
    Am I correct ?
    Thanks

    I guess that my computer should be the wifi server to be seen by my TV?

    • mike says:

      You would want to have an Accesspoint that the machine and the TV can use. The linux box can be that access point and could route between the public internet and private network if you like also.

      I don’t have instructions for it, but just search for how to create turn your distro into an internet router and AP.

  24. abds69 says:

    Thanks , works flawlessly, perfect tutorial.
    I just need to tune the transcoding options for FLAC to my sony blu-ray.

  25. uBoTo says:

    Hello,
    This is great tutorial, but unfortunately it is not working Ubuntu 18.04 LTS:

    ● ums.service – LSB: Starts UMS program.
    Loaded: loaded (/etc/init.d/ums; generated)
    Active: failed (Result: exit-code) since Tue 2018-11-27 22:28:41 EET; 5min ago
    Docs: man:systemd-sysv-generator(8)
    Process: 20010 ExecStart=/etc/init.d/ums start (code=exited, status=1/FAILURE)

    systemd[1]: Starting LSB: Starts UMS program….
    systemd[1]: ums.service: Control process exited, code=exited status=1
    systemd[1]: ums.service: Failed with result ‘exit-code’.
    systemd[1]: Failed to start LSB: Starts UMS program..

    Does someone have a solution for latest Ubuntu?

    Regards,
    Ivaylo

  26. John says:

    works great on Debian 10 Buster with a little tweaking to package names, vlc-nox is vlc-bin as noted above. Other than that was up and running in minutes.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve : *
12 − 8 =