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

Colin Law clanlaw at gmail.com
Sat Feb 11 12:07:13 UTC 2017


On 10 February 2017 at 14:04, Peter Silva <peter at bsqt.homeip.net> 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.)
>
> 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.
>
> in systemd, I use the documented stuff in dh_ and it puts the service file
> in the right place.
>
> 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 believe the default should be disabled, it should only be enabled if
you have done something that causes symlinks to be inserted in the
.wants directories for other services. If you run
sudo system enable|disable sarra
then you should see it adding or removing the links.

>
>     -- 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?

If it won't be used as service then just leave it disabled.  Since it
will not be run then it does not matter if the user does not exist.

Colin



More information about the ubuntu-users mailing list