want to write a systemd service file where a user may not exist.

Oliver Grawert ogra at ubuntu.com
Sat Feb 11 12:41:47 UTC 2017


hi,
On Fr, 2017-02-10 at 09:04 -0500, Peter Silva wrote:
> 
> Hi folks, wondering if people could direct me to a good place to ask
> this question.  It isn't really a user question, but ... anyways.   I
> work on a package that can run either under a dedicated user, as a
> sort of daemon or server mode, or it can be used by ordinary users
> directly in client mode (connecting to daemons elsewhere.)
> 
there are plenty of ways to achieve that :)

> When I install the package, on older releases, there is /etc/default
> and I put a file there to ensure it is disabled by default.   That's
> fine.
you could use a wrapper script for starting your daemon that first
checks /etc/default ...
> 
> in systemd, I use the documented stuff in dh_ and it puts the service
> file in the right place.

you could not use debhelper (which is responsible for enabling the
service by default) but just install the service file to 
/lib/systemd/system/ from the debian/install file, not using the
debhelper functions ...

then it should not be started by default and you have to manually do
"systemctl enable <service>"

> 
> Two issues:
>     -- when I do systemctl status sarra ... it says: 'vendor preset:
> enabled')  I want it to be disabled by default.  Couldn't find that.
> 
>     -- I don't want to create the daemon user on systems where
>  it will only be used as a client, so in many cases the 'user'
> specified in the service file will not exist.   How to cleanly handle
> that?
> 
you would use a debconf question asking the admin if he wants the user
created ...

ciao
	oli
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20170211/46b272ea/attachment.sig>


More information about the ubuntu-users mailing list