[systemd-devel] User systemd unit files

Andrei Borzenkov arvidjaar at gmail.com
Sun Sep 14 08:11:41 PDT 2014


В Thu, 11 Sep 2014 07:07:16 -0400
Chris Morgan <chmorgan at gmail.com> пишет:

> On Thu, Sep 11, 2014 at 5:03 AM, Colin Guthrie <gmane at colin.guthr.ie> wrote:
> > Chris Morgan wrote on 11/09/14 02:32:
> >>
> >> On Sep 10, 2014 5:46 PM, "Zbigniew Jędrzejewski-Szmek"
> >> <zbyszek at in.waw.pl <mailto:zbyszek at in.waw.pl>> wrote:
> >>>
> >>> On Tue, Sep 09, 2014 at 07:39:17PM -0400, Chris Morgan wrote:
> >>> > >> >> Specifically, running `systemd --user` directly is not supported
> >>> > >> >> anymore. The user mode still works, but only for one "user"
> >> instance
> >>> > >> >> per UID, launched through user@<uid>.service (recent releases
> >> start
> >>> > >> >> this automatically upon logging in).
> >>> > > Try 'systemctl --user'. If this start you can put units
> >>> > > it ~/.config/systemd/user/ or a similar path (check
> >> systemd.unit(5) out).
> >>> > >
> >>> > > Zbyszek
> >>> >
> >>> > I tried --user but I get some errors that I pasted above. It looks
> >>> > like it is no longer supported but I'm not sure.
> >>>
> >>> If you're getting the same message as above, you are still typing
> >>> systemd instead of systemctl.
> >>>
> >>> Zbyszek
> >>
> >> Ahh. The man page seemed to indicate that one should run systemd with
> >> --user first.
> >>
> >> I was able to run unit files via systemctl --user but the
> >> SYSTEMD_USER_PATH environment variable doesn't seem to be working, even
> >> though it is mentioned in the man page.
> >
> > Where are you setting this path? If "systemd --user" is already running
> > (which happens automatically with newer systemd's) then you have to make
> > sure *it* knows about the env var, not just the client side calls in.
> >
> > This *might* work, but I don't know for sure as I've not fiddled with
> > this stuff.
> >
> > systemctl --user set-environment SYSTEMD_USER_PATH=$HOME/somegitrepo/units/
> > systemctl --user daemon-reload
> >
> >
> > Col
> >
> > --
> >
> > Colin Guthrie
> > gmane(at)colin.guthr.ie
> > http://colin.guthr.ie/
> >
> > Day Job:
> >   Tribalogic Limited http://www.tribalogic.net/
> > Open Source:
> >   Mageia Contributor http://www.mageia.org/
> >   PulseAudio Hacker http://www.pulseaudio.org/
> >   Trac Hacker http://trac.edgewall.org/
> 
> 
> Hmm. I figured that the environment was used when the systemd user
> instance was started.
> 
> I tried systemctl --user set-environment and it shows up if I use
> show-environment but even if I use SYSTEMD_UNIT_PATH (I was typing on
> mobile and mistakenly typed USER instead of UNIT), and reloaded the
> daemon it doesn't appear to be taking effect, the test unit file I
> created isn't located.
> 

No, SYSTEMD_UNIT_PATH must be in environment of systemd; systemctl
set-environment sets different variables (which are not used for unit
lookup).

What you could do is to create *system* drop in file like

/etc/systemd/systemd/user at .service.d/environment.conf

with content similar to

[Service]
Environment=%h/somegitrepo/units

This should do it.

> I'm thinking I can use the 'systemctl link' command to link the
> scripts into the user folder. Basically after a build something like
> startup_and_start.sh could link each unit file and then call 'start'
> on them to start them up, simulating what would happen during system
> startup on the embedded side.
> 
> Would need to build each unit file from a template as the full path
> would be needed but that shouldn't be tough.
> 
> I appreciate the help from everyone here. It does look like
> SYSTEMD_UNIT_PATH was removed from newer versions of systemd and only
> XDG_xxxXXX is available, but that variable isn't mentioned at all in
> the man pages of my version of systemd, 208. Some of the confusion is
> between what systemd provides (systemd --user) and what, due to distro
> integration I should be using (systemctl --user), and I'm new to
> systemd.
> 
> Chris
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel



More information about the systemd-devel mailing list