[Tutorial] Installing UMS 3.3.0 on Ubuntu 13.10 Server

For help and support with Linux-specific issues
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
Post Reply
Kayot
Posts: 8
Joined: Tue Jan 07, 2014 8:36 am

[Tutorial] Installing UMS 3.3.0 on Ubuntu 13.10 Server

Post by Kayot » Wed Jan 08, 2014 9:42 am

This was a bit of a pain, so I'm posting what I did here in case I need it in the future.

For this tutorial, I'm installing UMS to /usr/ums simply to keep things simple. I'm not sure if I'm making some sort of Linux etiquette mistake. I've only been serious for about six months and I've only worked with manual installs this week minus webmin which had it's own init.d script.

Please read all steps at least once before attempting to install UMS.

1.You will need root privilages, so "sudo su"
2a. We will need Java to run the program. While the openjava is quaint, it leaves much to be desired. So we'll be using the real thing.

Code: Select all

nano /etc/apt/sources.list
2b. Go to the bottom and add the following line, save and exit nano.

Code: Select all

deb http://www.duinsoft.nl/pkg debs all
2c. Use this command to get the gpg key

Code: Select all

sudo apt-key adv --keyserver keys.gnupg.net --recv-keys 5CB26B26
2d. Now, lets update apt-get and install Java (This will always install the latest and remove the openjava)

Code: Select all

sudo apt-get update
sudo apt-get install update-sun-jre
3. We need some pre-reqs for movie processing:

Code: Select all

apt-get install mplayer mencoder ffmpeg mediainfo
4. Go to an empty directory, in my case it's root home or cd ~
5. Get UMS (Use the front page for this step)
5a. I downloaded it on a windows machine and smb shared it unto the server in question.
5b. You can also use the following though I suggest using SSH and pasting the link since it's huge.

Code: Select all

wget http://sourceforge.net/projects/unimediaserver/files/Official%20Releases/Linux/UMS-3.3.0.tgz

6. Unpack it using "tar -xvzf UMS-3.3.0.tgz"
7. Move the files to /usr with the following command "mv ums-3.3.0 /usr/ums"
8. Time to make an init.d script. I'm lazy so I'll use the one from Mandrakes post #5551, though I'm modifying a few lines. (NAME and DAEMON) "nano /etc/init.d/UMS.sh"

Code: Select all

#!/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.sh
UMS_PROFILE=/etc/$NAME
DAEMON=/usr/ums/$NAME
DAEMON_OPTS="console"
SCRIPTNAME=/etc/init.d/$NAME
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
9. Time to add it to init.d "update-rc.d UMS.sh defaults"
10. Lets turn it on! "service UMS.sh start"

Hopefully it works for you. I'll experiment a bit and see how it works for me. The config file I use is located in "/etc/UMS.sh" That's where I set my folders and what-nots. My /etc/UMS.sh looks like this after I'm done:

Code: Select all

cred.path = /etc/UMS.cred
uuid = [Not sure if I should hide this]
server_name = "Archive"
folders = /mnt/lp/

edit: Added real java install info, thanks goes to Duin of http://www.duinsoft.nl/packages.php?t=en

confusatron
Posts: 1
Joined: Sat May 17, 2014 2:44 pm

Re: [Tutorial] Installing UMS 3.3.0 on Ubuntu 13.10 Server

Post by confusatron » Sat May 17, 2014 2:48 pm

Thank you for posting this!!! Worked great on ubuntu 12.04.4 headless server with UMS 3.6.1

One glitch I ran in to, be sure the init.d script is executable (it will give you "unrecognized service" error if not)

Code: Select all

chmod +x /etc/init.d/UMS.sh

Birdie
Posts: 1
Joined: Sun Aug 20, 2017 6:00 am

Re: [Tutorial] Installing UMS 3.3.0 on Ubuntu 13.10 Server

Post by Birdie » Sun Aug 20, 2017 6:02 am

Thanks! Works great in Mint 18.2 with UMS-6.7.3.

Post Reply