You are not logged in.

#1 2016-11-16 13:57:20

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 768

Auto starting minidlna as user without login

I'm trying to set up minidlna (readyMedia) to run as a user to simplify permissions issues.  I've followed the instructions in the wiki and that all seems to be working.

The problem, however, is that I'm running this on a box that's serving as a NAS and I don't want to have to log in to start minidlna (as suggested by the wiki).  I tried tweaking the .service file to start it as my user, but that failed - is there a way to run the startup command automatically as a user - without explicitly logging in as that user?

Offline

#2 2016-11-16 16:22:44

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,627

Re: Auto starting minidlna as user without login

You can also tell a system service to run as a specified user, post your current service file.

Offline

#3 2016-11-17 12:02:23

nambot
Member
Registered: 2016-11-05
Posts: 12

Re: Auto starting minidlna as user without login

my service file looks like this:

[Unit]
Description=minidlna server
After=network.target

[Service]
Type=simple
User=minidlna
Group=minidlna
ExecStart=/usr/bin/minidlnad -S
ProtectSystem=full
ProtectHome=on
PrivateDevices=on
NoNewPrivileges=on

[Install]
WantedBy=multi-user.target

Offline

#4 2016-11-17 15:00:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,517
Website

Re: Auto starting minidlna as user without login

Your ExecStart command doesn't match what is in the wiki to start as a user.  Don't you need to specify the config file and pid file to use?

EDIT: oops, I didn't realize the above was not the OP's post.  I thought that was a service file that was not working not an additional example of a working one.

Last edited by Trilby (2016-11-20 18:04:43)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#5 2016-11-20 16:12:09

nambot
Member
Registered: 2016-11-05
Posts: 12

Re: Auto starting minidlna as user without login

I'm using the default location /etc/minidlna.conf and /var/run/minidlna/minidlna.pid
So I'm good with that.

But maybe the OP should post his file like V1del suggested. :-)

Last edited by nambot (2016-11-20 16:12:50)

Offline

#6 2016-11-24 16:39:28

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 768

Re: Auto starting minidlna as user without login

OP here - sorry for the delay, but things have been hectic here.

My service file currently looks like:

[Unit]
Description=minidlna server
After=network.target

[Service]
Type=simple
User=paul
Group=users
ExecStart=/usr/bin/minidlnad -f /home/$USER/.config/minidlna/minidlna.conf -P /home/$USER/.config/minidlna/minidlna.pid
ProtectSystem=full
ProtectHome=on
PrivateDevices=on
NoNewPrivileges=on

[Install]
WantedBy=multi-user.target

It's currently failing with:

fatal: Error reading configuration file /home/$USER/.config/minidlna/minidlna.conf

I changed the ExecStart to match what the wiki says.

Edit: I've since tweaked the ExecStart again to

ExecStart=/usr/bin/minidlnad -f /home/paul/.config/minidlna/minidlna.conf -P /home/paul/.config/minidlna/minidlna.pid

, but still ge tthe same error - although with "paul" instead of $USER.  I had assumed it would resove $USER to the value of the "User" line.  I even tried changing the exec to use $User. but to no avail.

The file in question does exist and is readable by my user.

Last edited by phunni (2016-11-24 16:42:22)

Offline

#7 2016-11-24 17:37:16

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,517
Website

Re: Auto starting minidlna as user without login

$USER is a shell variable, so that will not work in service files - more importantly, even if it did expand $USER the uid running the service file is 0 (so USER=root).  You will need to use the full path.

Do you have a separate home partition? I suspect the problem with the full path is that your home partition may not be mounted when this first runs.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#8 2016-11-24 18:48:50

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,627

Re: Auto starting minidlna as user without login

Set ProtectHome=on to off, since you actually want to access your home directory

Offline

#9 2016-11-24 23:02:20

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 768

Re: Auto starting minidlna as user without login

+V1del thanks - that seems to have worked.  At least, the server has started properly.  I haven't yet had the chance to actually test streaming from it.

Offline

#10 2016-11-27 20:25:41

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 768

Re: Auto starting minidlna as user without login

The server starts now, but it's not actually streaming content without error.  As this seems to be a different issue, I've started a new thread:
https://bbs.archlinux.org/viewtopic.php … 5#p1672495

please take a look and comment if you can help!  Thanks.

Offline

#11 2016-11-27 20:37:09

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 768

Re: Auto starting minidlna as user without login

Actually - looking at "systemctl status minidlna" I'm not certain it is starting properly:

● minidlna.service - minidlna server
   Loaded: loaded (/usr/lib/systemd/system/minidlna.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Sun 2016-11-27 20:31:05 GMT; 16s ago
  Process: 10836 ExecStart=/usr/bin/minidlnad -f /home/paul/.config/minidlna/minidlna.conf -P /home/paul/.config/minidlna/minidlna.pid (code=exited,
 Main PID: 10836 (code=exited, status=0/SUCCESS)

Offline

#12 2016-11-27 21:28:22

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Auto starting minidlna as user without login

You copied most of the default minidlna.service, but not the -S command-line switch. It is not very well documented, but it seems to stop minidlnad from forking so it works with Type=simple.

Offline

Board footer

Powered by FluxBB