Ubuntu 20.04 install guide / headless / running as a service

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
Post Reply
ro55mo
Posts: 1
Joined: Tue Jun 16, 2020 3:00 am

Ubuntu 20.04 install guide / headless / running as a service

Post by ro55mo »

So I have stumbled across this application while researching something for work. Wanted to have a go at installing it. Was surprised to see so many questions about the application running as a service

Got it up and running on a headless Ubuntu 20.04 server and running as a service

I know the optional section might seem a bit redundant but I just wanted to test it worked okay with the media on a separate device

The user running the service is called ums-user which was created during server installation

*** INSTRUCTIONS ***

# ssh into new Ubuntu 20.04 server (headless) server

ssh -p 22 [email protected]

# Install updates pre-reqs

sudo apt-get update

sudo apt-get upgrade

sudo apt-get install openjdk-8-jre openjdk-8-jre-headless

sudo apt-get install mediainfo dcraw vlc mplayer mencoder

# Download onto my PC

https://www.fosshub.com/Universal-Media ... x86_64.tgz

# Copy over to the server

scp -P 22 UMS-9.6.2-x86_64.tgz [email protected]:/home/ums-user/UMS-9.6.2-x86_64.tgz

Unpack

tar xzvf UMS-9.6.2-x86_64.tgz

cd ums-9.6.2

# Test application

./UMS.sh

# Control C to stop application

# Create unit file

sudo nano /etc/systemd/system/ums.service

[Unit]
Description=Run UMS as ums-user
DefaultDependencies=no
After=network.target

[Service]
Type=simple
User=ums-user
Group=ums-user
ExecStart=/home/ums-user/ums-9.6.2/UMS.sh
TimeoutStartSec=0
RemainAfterExit=yes

[Install]
WantedBy=default.target

# Exit and save the file

sudo systemctl daemon-reload

sudo systemctl enable ums.service

sudo systemctl start ums.service

# Check service is running

sudo systemctl status ums.service

ums-user@ums:~$ sudo systemctl status ums.service
● ums.service - Run UMS as ums-user
Loaded: loaded (/etc/systemd/system/ums.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-06-15 14:40:52 UTC; 27s ago

Main PID: 2277 (java)
Tasks: 58 (limit: 9451)
Memory: 153.4M
CGroup: /system.slice/ums.service
└─2277 jre14/bin/java -Xmx1280M -Xss2048k -Dfile.encoding=UTF-8 -Djava.net.preferIPv4Stack=true -Djna.nosys=true -classpath update.jar:ums.jar net.pms.PMS

Jun 15 14:40:53 ums UMS.sh[2277]: INFO 14:40:53.296 [main] Transcoding engine "DCRaw" is available
Jun 15 14:40:53 ums UMS.sh[2277]: INFO 14:40:53.297 [main] Using address /192.168.0.111 found on network interface: name:enp0s3 (enp0s3)
Jun 15 14:40:53 ums UMS.sh[2277]: INFO 14:40:53.297 [main] Created socket: /192.168.0.111:5001
Jun 15 14:40:53 ums UMS.sh[2277]: INFO 14:40:53.320 [main] WEB interface is available at: http://192.168.0.111:9001
Jun 15 14:40:53 ums UMS.sh[2277]: INFO 14:40:53.333 [main] A tiny cache admin interface is available at: http://192.168.0.111:5001/console/home
Jun 15 14:40:54 ums UMS.sh[2277]: INFO 14:40:54.839 [HTTPv2 Request Worker 5] Media renderer was not recognized. Possible identifying HTTP headers:
Jun 15 14:40:54 ums UMS.sh[2277]: User-Agent: DAFUPnP
Jun 15 14:40:54 ums UMS.sh[2277]: Cache-Control: no-cache
Jun 15 14:40:54 ums UMS.sh[2277]: Pragma: no-cache
Jun 15 14:40:55 ums UMS.sh[2277]: INFO 14:40:55.832 [main] Universal Media Server is now available for renderers to find

# Go to application

http://192.168.0.111:9001

# Test service starts after a reboot

sudo reboot

# Check application

http://192.168.0.111:9001

# Success!

# OPTIONAL SECTION

# ssh into Ubuntu 20.04 server (headless) server

ssh -p 22 [email protected]

# Install nfs-common to allow mounting of NFS shares

sudo apt-get install nfs-common

# Edit hosts file so server can locate my FreeNAS media storage

sudo nano /etc/hosts

192.168.0.10 freenas

# Create mount point

sudo mkdir /mnt/FreeNAS

# Edit stab file

sudo nano /etc/fstab

# Add path

freenas:/mnt/Pool /mnt/FreeNAS nfs defaults 0 0

# Reboot server

sudo reboot

# ssh into Ubuntu 20.04 server (headless) server

ssh -p 22 [email protected]

# Check disk space

df -h

Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 797M 1.3M 795M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 125G 8.0G 111G 7% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda2 976M 103M 806M 12% /boot
/dev/loop0 55M 55M 0 100% /snap/core18/1754
/dev/loop1 55M 55M 0 100% /snap/core18/1705
/dev/loop2 69M 69M 0 100% /snap/lxd/14804
/dev/loop3 31M 31M 0 100% /snap/snapd/7777
/dev/loop4 28M 28M 0 100% /snap/snapd/7264
/dev/loop5 70M 70M 0 100% /snap/lxd/15457
freenas:/mnt/Pool 2.1T 972G 1.2T 47% /mnt/FreeNAS
tmpfs 797M 24K 797M 1% /run/user/121
tmpfs 797M 4.0K 797M 1% /run/user/1000

# Success. Storage is mounted

# Setup conf file

nano /home/ums-user/.config/UMS/UMS.conf

# Set "Shared folders"

folders=/mnt/FreeNAS/Movies

# Exit and save the file

Restart UMS

sudo systemctl restart ums.service

# You can now access your media on the server after a couple of minutes. Assume this is UMS scanning the new directories.

# Server level configurations are held at

nano /home/ums-user/ums-9.6.2
SVMartin
Posts: 13
Joined: Tue Jul 21, 2020 9:50 am

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by SVMartin »

Thanks for sharing, works nicely for me!

Note however that it is not required to install openjdk-8-jre and openjdk-8-jre-headless as UMS comes with its own java which has been tested and is up-to-date (v 14).

I'm now trying to add a max heap size setting to the systemd file!
SVMartin
Posts: 13
Joined: Tue Jul 21, 2020 9:50 am

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by SVMartin »

That was easy, just add the following line to the Service section of the systemd file:

Environment="UMS_MAX_MEMORY=768M"
xmechanic
Posts: 1
Joined: Mon Nov 23, 2020 10:32 am

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by xmechanic »

I understand the majority of this, but I would like to do this on a self-contained machine with a 160 gb. boot drive (dev/sda) and a 3 TB secondary drive (plenty for what I've got!). The 3 TB drive will be split into 2 partitions (/dev/sdb/storage1 and /dev/sdb/storage 2) on the initial install of Ubuntu 20.04 server LTS, so they should show up in /etc/fstab as such. I also plan on running this headless and can use WinSCP to do file transfers, etc. and puTTY for general management. I'm a first-timer for UMS so I want to make sure there actually IS a way to get the system to recognize the 2 partitions on /dev/sdb/ and actually be able to upload local content and be able to access it with the UMS interface. ;)
I've been through 3 or 4 'media management' interfaces on this machine now, including the Turnkey version of Jellyfin, Kodi on Debian, and a couple others, none of which really did what I wanted (namely upload local content and have it show up and be accessible). I have XigmasNAS on a separate machine, but it's more or less dedicated for local machine backups and such, so I wanted my media server to be standalone. Any ideas/solutions appreciated, so I can get this right the first time! :) Thanks!
carpler
Posts: 6
Joined: Wed Jul 19, 2023 2:59 am

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by carpler »

With the guide in this thread, I was able to successfully install and boot UMS on Ubuntu Server 22.04 (headless PC).
However, I still have a few questions.

1) At the start you install additional applications (pre-reqs) with the command:
apt-get install mediainfo dcraw vlc mplayer mencoder
But are all these applications also necessary for a server without a graphic interface? The one that seems most 'strange' to me is VLC: is it the player? Isn't there a component or libraries that can be installed to replace this application, of which I imagine only a part will be used?
I would also like to point out that it would be a good idea to update the wiki page on github as it seems to me to be out of date (or is it?). For example: there it is reported to install tsMuxeR and P7Zip, which are not mentioned in this thread: perhaps because they are no longer useful?

2) In my opinion, this guide lacks instructions for when to update the software. Is there an automatic update procedure that can be done from the webgui?
If not, I think the following steps should be carried out (tell me if I am wrong):
- download the new version
- stop ums.service
- unpack and overwrite the files except the configuration files (they should be: UMS.sh, UMS.conf, UMS.cred, SHARED.conf. Have I forgotten any?)
- restart ums.service
I don't know how to write the linux command for the third step: if any expert would be willing to do so, it would be much appreciated!

3) I have a problem with the webgui. When I try to add a folder containing media files, I am not given the option to locate the folder, i.e. the File Manager does not open. It returns a generic error and all I can do is close.
I can still add the folder by manually editing the SHARED.conf file, but I don't understand why the GUI doesn't work...
I am on Ubuntu 22.04 and UMS 13.4.1.
User avatar
mik_s
Moderator
Posts: 1170
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by mik_s »

I have very little knowledge about Linux so can't help with specific issues. I think @boss knows more about it and might be able to be of more help.

1) VLC is used for a transcoding engine as an alternative to FFmpeg. This is optional though but best to have it installed, I don't know if some of its components are used for anything else. tsMuxeR is another transcoding engine and I think P7Zip will be needed if you want to open .zip files to play its contents without extracting them first (will need "Browse compressed archives (zip, rar, etc.)" option enabled). I think it is also used for packing debug files.

2) There is an option to check for updates but I don't know exactly how it works as I update from the latest build directly from GitHub. I don't know if its just a notification of a new update or if it can automatically update. When it does update it will not overwrite your configuration files as they will be in your profiles home folder.

3) Don't know about Linux but on windows when adding folders it does not use the system filemanager instead uses a custom one like this
Clipboard Image.jpg
Clipboard Image.jpg (12.4 KiB) Viewed 5428 times
I would assume it to be the same on any system as it is web based. If you are getting an error could you post a screenshot and your logs and I'll see what is causing it. It may be a permissions issue.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
carpler
Posts: 6
Joined: Wed Jul 19, 2023 2:59 am

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by carpler »

Thanks for the reply!
mik_s wrote: Wed Jul 26, 2023 1:58 am 2) There is an option to check for updates but I don't know exactly how it works as I update from the latest build directly from GitHub. I don't know if its just a notification of a new update or if it can automatically update. When it does update it will not overwrite your configuration files as they will be in your profiles home folder.
I have a very particular configuration and to start and manage UMS I use a user who has no home, so all configuration files are in the programme folder.
I guess then that to do the update, all the files except the configuration files have to be overwritten.
The files to be maintained should therefore be:
- UMS.sh
- UMS.conf
- UMS.cred
- SHARED.conf
Please can you tell me if there are any others that I am forgetting?

Another problem.
I noticed that when I restart the system, the UMS service does not restart automatically, but I have to restart it manually.
Is there anything that needs to be changed in the configuration described in the first post?
User avatar
mik_s
Moderator
Posts: 1170
Joined: Wed Aug 23, 2017 11:03 pm
Location: UK

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by mik_s »

If you don't have a home folder for that user where is the database located? I think those files are the important ones but are usually stored one folder up from the database (at least on windows where everything is in C:\ProgramData\UMS)

I don't know very little about auto starting services on Linux. It may be something you have to add to one of the system statup scripts.
I had to do something similar setting up octoprint on an old laptop for my 3D printer but had never used Linux before that.

This is from the installation guide I had used so you could do something similar with UMS.
Then add the script to autostart using sudo systemctl enable octoprint.service.

This will also allow you to start/stop/restart the OctoPrint daemon via

sudo service octoprint {start|stop|restart}
It may be as simple as replacing octoprint with UMS but I am guessing.
Logs are important for us to help, Please follow This Link before asking for support. Just a forum cleaner, Will help if I can but no expert.
carpler
Posts: 6
Joined: Wed Jul 19, 2023 2:59 am

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by carpler »

Thank you for the reply!
mik_s wrote: Thu Aug 10, 2023 10:16 am If you don't have a home folder for that user where is the database located? I think those files are the important ones but are usually stored one folder up from the database (at least on windows where everything is in C:\ProgramData\UMS)
I modified the UMS.sh file to leave all configuration files in the folder where UMS resides.
Anyway, I gave it a try:
1) stopped the UMS service
2) overwritten all the files of the new version except the configuration files (the database is not overwritten)
3) restarted the service
Everything seems to work, although the procedure is a bit cumbersome. It would be nice if it were possible to do the update more conveniently...
mik_s wrote: Thu Aug 10, 2023 10:16 am I don't know very little about auto starting services on Linux. It may be something you have to add to one of the system statup scripts.
I had to do something similar setting up octoprint on an old laptop for my 3D printer but had never used Linux before that.

This is from the installation guide I had used so you could do something similar with UMS.
Then add the script to autostart using sudo systemctl enable octoprint.service.

This will also allow you to start/stop/restart the OctoPrint daemon via

sudo service octoprint {start|stop|restart}
It may be as simple as replacing octoprint with UMS but I am guessing.
What you indicated to do to start the service at boot is already stated in the guide in the first post. However, I did not understand why the service does not start automatically on reboot...
MFP
Posts: 1
Joined: Sat May 18, 2024 8:43 pm

Re: Ubuntu 20.04 install guide / headless / running as a service

Post by MFP »

many thanks for the guide, worked great on a RPi5 with Raspian Bookworm (Debian 12).
Post Reply