[systemd-devel] User systemd unit files

Chris Morgan chmorgan at gmail.com
Thu Sep 11 04:07:16 PDT 2014


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.

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


More information about the systemd-devel mailing list