Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #232411 > unrolled thread

user unit file

Started byJim Popovitch <jim@k4vqc.com>
First post2021-03-05 18:20 +0100
Last post2021-03-06 00:50 +0100
Articles 14 — 4 participants

Back to article view | Back to linux.debian.user


Contents

  user unit file Jim Popovitch <jim@k4vqc.com> - 2021-03-05 18:20 +0100
    Re: user unit file Sven Hartge <sven@svenhartge.de> - 2021-03-05 18:40 +0100
      Re: user unit file Jim Popovitch <jim@k4vqc.com> - 2021-03-05 19:00 +0100
        Re: user unit file Greg Wooledge <greg@wooledge.org> - 2021-03-05 19:20 +0100
          Re: user unit file Jim Popovitch <jim@k4vqc.com> - 2021-03-05 19:20 +0100
            Re: user unit file Greg Wooledge <greg@wooledge.org> - 2021-03-05 19:40 +0100
              Re: user unit file Jim Popovitch <jim@k4vqc.com> - 2021-03-05 20:20 +0100
                Re: user unit file Greg Wooledge <greg@wooledge.org> - 2021-03-05 20:30 +0100
                  Re: user unit file Jim Popovitch <jim@k4vqc.com> - 2021-03-05 20:40 +0100
                Re: user unit file Jim Popovitch <jim@k4vqc.com> - 2021-03-05 20:30 +0100
                Re: user unit file Greg Wooledge <greg@wooledge.org> - 2021-03-05 20:30 +0100
                Re: user unit file Jim Popovitch <jim@k4vqc.com> - 2021-03-05 20:40 +0100
        Re: user unit file Andrei POPESCU <andreimpopescu@gmail.com> - 2021-03-05 21:50 +0100
          Re: user unit file Jim Popovitch <jim@k4vqc.com> - 2021-03-06 00:50 +0100

#232411 — user unit file

FromJim Popovitch <jim@k4vqc.com>
Date2021-03-05 18:20 +0100
Subjectuser unit file
Message-ID<BPmhj-6rt-3@gated-at.bofh.it>
Please be gentle.  Searching for this is proving futile.

How do I enable systemd user (--user) unit files that are maintained in
a user's home directory at /home/bob/.config/systemd/user/*.service ?

tia,

-Jim P.

[toc] | [next] | [standalone]


#232412

FromSven Hartge <sven@svenhartge.de>
Date2021-03-05 18:40 +0100
Message-ID<BPmAF-6xU-5@gated-at.bofh.it>
In reply to#232411
Jim Popovitch <jim@k4vqc.com> wrote:
> Please be gentle.  Searching for this is proving futile.

> How do I enable systemd user (--user) unit files that are maintained in
> a user's home directory at /home/bob/.config/systemd/user/*.service ?

What do you mean with "enable"?

"Enable" as in "enable support"? Then everything is enabled.

Or "enable" as in "enable the unit"? Then "systemctl --user enable
unitname.service" does what you want.

Or "enable" as in "start at boot"? Then you to enable lingering for the
user via loginctl as root.

S°

-- 
Sigmentation fault. Core dumped.

[toc] | [prev] | [next] | [standalone]


#232413

FromJim Popovitch <jim@k4vqc.com>
Date2021-03-05 19:00 +0100
Message-ID<BPmU2-6ET-15@gated-at.bofh.it>
In reply to#232412
On Fri, 2021-03-05 at 18:36 +0100, Sven Hartge wrote:
> Jim Popovitch <jim@k4vqc.com> wrote:
> > Please be gentle.  Searching for this is proving futile.
> > How do I enable systemd user (--user) unit files that are maintained in
> > a user's home directory at /home/bob/.config/systemd/user/*.service ?
> 
> What do you mean with "enable"?
> 
> "Enable" as in "enable support"? Then everything is enabled.
> 
> Or "enable" as in "enable the unit"? Then "systemctl --user enable
> unitname.service" does what you want.
> 
> Or "enable" as in "start at boot"? Then you to enable lingering for the
> user via loginctl as root.
> 

Why not, All of the above! :)  

Right now I can't get this to work:

~$ systemctl --user enable Test.service
Failed to connect to bus: No such file or directory
~$ cat ~/.config/systemd/user/Test.service
[Unit]
Description = Test Service
After = network.target

[Service]
WorkingDirectory=/home/bob/Test/
ExecStart = bash Test.sh
TimeoutSec=15

[Install]
WantedBy=multi-user.target




tia,

-Jim P.

[toc] | [prev] | [next] | [standalone]


#232414

FromGreg Wooledge <greg@wooledge.org>
Date2021-03-05 19:20 +0100
Message-ID<BPndn-71q-3@gated-at.bofh.it>
In reply to#232413
Jim Popovitch (jim@k4vqc.com) wrote:
> Right now I can't get this to work:
> 
> ~$ systemctl --user enable Test.service
> Failed to connect to bus: No such file or directory

After Googling this error, I suspect that you're either operating in
an environment where the XDG variables are not being set properly,
or else dbus is actually not running.

How did you get to THAT specific shell, the one where you typed that
command and got that error?  Give details.

In that same shell, what does   env | grep XDG   give you?

How about   systemctl --user status   ?

[toc] | [prev] | [next] | [standalone]


#232415

FromJim Popovitch <jim@k4vqc.com>
Date2021-03-05 19:20 +0100
Message-ID<BPndn-71q-5@gated-at.bofh.it>
In reply to#232414
On Fri, 2021-03-05 at 13:11 -0500, Greg Wooledge wrote:
> Jim Popovitch (jim@k4vqc.com) wrote:
> > Right now I can't get this to work:
> > 
> > ~$ systemctl --user enable Test.service
> > Failed to connect to bus: No such file or directory
> 
> After Googling this error, I suspect that you're either operating in
> an environment where the XDG variables are not being set properly,
> or else dbus is actually not running.
> 
> How did you get to THAT specific shell, the one where you typed that
> command and got that error?  Give details.
> 
> In that same shell, what does   env | grep XDG   give you?
> 
> How about   systemctl --user status   ?
> 

It's a VPS server, I ssh'ed in.  No GUI, minimal install to test systemd
user unit files.

bob@sbc:~$ ps -ef|grep dbus
message+     520       1  0 13:08 ?        00:00:00 /usr/bin/dbus-daemon 
--system --address=systemd: --nofork --nopidfile --systemd-activation --
syslog-only
bob     2422    2413  0 18:14 pts/0    00:00:00 grep --color=auto dbus
bob@sbc:~$ env|grep XDG
bob@sbc:~$ systemctl --user status
Failed to connect to bus: No such file or directory
bob@sbc:~$


Thanks! Any advice/help is much appreciated.

-Jim P.

[toc] | [prev] | [next] | [standalone]


#232416

FromGreg Wooledge <greg@wooledge.org>
Date2021-03-05 19:40 +0100
Message-ID<BPnwL-79l-35@gated-at.bofh.it>
In reply to#232415
Jim Popovitch (jim@k4vqc.com) wrote:
> It's a VPS server, I ssh'ed in.  No GUI, minimal install to test systemd
> user unit files.

Apparently you need to configure sshd to use PAM.

> bob@sbc:~$ ps -ef|grep dbus
> message+     520       1  0 13:08 ?        00:00:00 /usr/bin/dbus-daemon 
> --system --address=systemd: --nofork --nopidfile --systemd-activation --
> syslog-only
> bob     2422    2413  0 18:14 pts/0    00:00:00 grep --color=auto dbus
> bob@sbc:~$ env|grep XDG
> bob@sbc:~$ systemctl --user status
> Failed to connect to bus: No such file or directory
> bob@sbc:~$

https://bbs.archlinux.org/viewtopic.php?id=234813

It was my first Google result.

[toc] | [prev] | [next] | [standalone]


#232417

FromJim Popovitch <jim@k4vqc.com>
Date2021-03-05 20:20 +0100
Message-ID<BPo9r-7CI-5@gated-at.bofh.it>
In reply to#232416
On Fri, 2021-03-05 at 13:35 -0500, Greg Wooledge wrote:
> Jim Popovitch (jim@k4vqc.com) wrote:
> > It's a VPS server, I ssh'ed in.  No GUI, minimal install to test systemd
> > user unit files.
> 
> Apparently you need to configure sshd to use PAM.
> 
> > bob@sbc:~$ ps -ef|grep dbus
> > message+     520       1  0 13:08 ?        00:00:00 /usr/bin/dbus-daemon 
> > --system --address=systemd: --nofork --nopidfile --systemd-activation --
> > syslog-only
> > bob     2422    2413  0 18:14 pts/0    00:00:00 grep --color=auto dbus
> > bob@sbc:~$ env|grep XDG
> > bob@sbc:~$ systemctl --user status
> > Failed to connect to bus: No such file or directory
> > bob@sbc:~$
> 
> https://bbs.archlinux.org/viewtopic.php?id=234813
> 
> It was my first Google result.

Ugh. So the solution seems to be to add UsePAM to sshd just to make
systemd work.  Not sure that I can get that approved, but I will see.

Thx Greg.

-Jim P.

[toc] | [prev] | [next] | [standalone]


#232419

FromGreg Wooledge <greg@wooledge.org>
Date2021-03-05 20:30 +0100
Message-ID<BPoj8-7FZ-1@gated-at.bofh.it>
In reply to#232417
Jim Popovitch (jim@k4vqc.com) wrote:
> On Fri, 2021-03-05 at 14:21 -0500, Greg Wooledge wrote:
> > Jim Popovitch (jim@k4vqc.com) wrote:
> > > Ugh. So the solution seems to be to add UsePAM to sshd just to make
> > > systemd work.  Not sure that I can get that approved, but I will see.
> > 
> > This sounds like an X-Y problem.  What are you actually trying to do?
> 
> That sounds like an X-Y question. :)
> 
> Obviously I'm trying to run a systemd unit file from within a non-root
> env.  I apologize if that wasn't obvious. 

Why?  What does it do?  Why do you need to invoke it this way?  What
results are you expecting to achieve?

[toc] | [prev] | [next] | [standalone]


#232426

FromJim Popovitch <jim@k4vqc.com>
Date2021-03-05 20:40 +0100
Message-ID<BPosN-7Jb-13@gated-at.bofh.it>
In reply to#232419
On Fri, 2021-03-05 at 14:29 -0500, Greg Wooledge wrote:
> Jim Popovitch (jim@k4vqc.com) wrote:
> > On Fri, 2021-03-05 at 14:21 -0500, Greg Wooledge wrote:
> > > Jim Popovitch (jim@k4vqc.com) wrote:
> > > > Ugh. So the solution seems to be to add UsePAM to sshd just to make
> > > > systemd work.  Not sure that I can get that approved, but I will see.
> > > 
> > > This sounds like an X-Y problem.  What are you actually trying to do?
> > 
> > That sounds like an X-Y question. :)
> > 
> > Obviously I'm trying to run a systemd unit file from within a non-root
> > env.  I apologize if that wasn't obvious. 
> 
> Why?  What does it do?  Why do you need to invoke it this way?  What
> results are you expecting to achieve?

Thanks Greg.

-Jim P.

[toc] | [prev] | [next] | [standalone]


#232420

FromJim Popovitch <jim@k4vqc.com>
Date2021-03-05 20:30 +0100
Message-ID<BPoj8-7FZ-5@gated-at.bofh.it>
In reply to#232417
On Fri, 2021-03-05 at 14:21 -0500, Greg Wooledge wrote:
> Jim Popovitch (jim@k4vqc.com) wrote:
> > Ugh. So the solution seems to be to add UsePAM to sshd just to make
> > systemd work.  Not sure that I can get that approved, but I will see.
> 
> This sounds like an X-Y problem.  What are you actually trying to do?

That sounds like an X-Y question. :)

Obviously I'm trying to run a systemd unit file from within a non-root
env.  I apologize if that wasn't obvious. 

-Jim P.

[toc] | [prev] | [next] | [standalone]


#232421

FromGreg Wooledge <greg@wooledge.org>
Date2021-03-05 20:30 +0100
Message-ID<BPoj8-7FZ-3@gated-at.bofh.it>
In reply to#232417
Jim Popovitch (jim@k4vqc.com) wrote:
> Ugh. So the solution seems to be to add UsePAM to sshd just to make
> systemd work.  Not sure that I can get that approved, but I will see.

This sounds like an X-Y problem.  What are you actually trying to do?

[toc] | [prev] | [next] | [standalone]


#232422

FromJim Popovitch <jim@k4vqc.com>
Date2021-03-05 20:40 +0100
Message-ID<BPosN-7Jb-1@gated-at.bofh.it>
In reply to#232417
On Fri, 2021-03-05 at 14:16 -0500, Jim Popovitch wrote:
> On Fri, 2021-03-05 at 13:35 -0500, Greg Wooledge wrote:
> > Jim Popovitch (jim@k4vqc.com) wrote:
> > > It's a VPS server, I ssh'ed in.  No GUI, minimal install to test systemd
> > > user unit files.
> > 
> > Apparently you need to configure sshd to use PAM.
> > 
> > > bob@sbc:~$ ps -ef|grep dbus
> > > message+     520       1  0 13:08 ?        00:00:00 /usr/bin/dbus-daemon 
> > > --system --address=systemd: --nofork --nopidfile --systemd-activation --
> > > syslog-only
> > > bob     2422    2413  0 18:14 pts/0    00:00:00 grep --color=auto dbus
> > > bob@sbc:~$ env|grep XDG
> > > bob@sbc:~$ systemctl --user status
> > > Failed to connect to bus: No such file or directory
> > > bob@sbc:~$
> > 
> > https://bbs.archlinux.org/viewtopic.php?id=234813
> > 
> > It was my first Google result.
> 
> Ugh. So the solution seems to be to add UsePAM to sshd just to make
> systemd work.  Not sure that I can get that approved, but I will see.

Further data: One also needs dbus-user-session which pulls in libpam-
systemd

-Jim P.

[toc] | [prev] | [next] | [standalone]


#232432

FromAndrei POPESCU <andreimpopescu@gmail.com>
Date2021-03-05 21:50 +0100
Message-ID<BPpyx-8lW-3@gated-at.bofh.it>
In reply to#232413

[Multipart message — attachments visible in raw view] — view raw

On Vi, 05 mar 21, 12:53:24, Jim Popovitch wrote:
> 
> Right now I can't get this to work:
> 
> ~$ systemctl --user enable Test.service
> Failed to connect to bus: No such file or directory

To save you some head banging after you fix this...

> ~$ cat ~/.config/systemd/user/Test.service
> [Unit]
> Description = Test Service
> After = network.target
> 
> [Service]
> WorkingDirectory=/home/bob/Test/
> ExecStart = bash Test.sh
> TimeoutSec=15
> 
> [Install]
> WantedBy=multi-user.target

... user units and system units are completely isolated from each other, 
so your After= and WantedBy= won't have the expected effect.


For WantedBy= you probably want (no pun intended) default.target 
instead.


This is a hack I'm using to order a user unite after a system unit is 
started:

	ExecStartPre=/usr/bin/sh -c 'until systemctl --quiet is-active network-online.target ; do sleep 1 ; done'


Note: you should read on network-online.target in systemd.special(7) if 
you intend to follow my example.

Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser

[toc] | [prev] | [next] | [standalone]


#232439

FromJim Popovitch <jim@k4vqc.com>
Date2021-03-06 00:50 +0100
Message-ID<BPsmJ-1HM-1@gated-at.bofh.it>
In reply to#232432
On Fri, 2021-03-05 at 22:45 +0200, Andrei POPESCU wrote:
> On Vi, 05 mar 21, 12:53:24, Jim Popovitch wrote:
> > Right now I can't get this to work:
> > 
> > ~$ systemctl --user enable Test.service
> > Failed to connect to bus: No such file or directory
> 
> To save you some head banging after you fix this...
> 
> > ~$ cat ~/.config/systemd/user/Test.service
> > [Unit]
> > Description = Test Service
> > After = network.target
> > 
> > [Service]
> > WorkingDirectory=/home/bob/Test/
> > ExecStart = bash Test.sh
> > TimeoutSec=15
> > 
> > [Install]
> > WantedBy=multi-user.target
> 
> ... user units and system units are completely isolated from each other, 
> so your After= and WantedBy= won't have the expected effect.
> 
> 
> For WantedBy= you probably want (no pun intended) default.target 
> instead.
> 
> 
> This is a hack I'm using to order a user unite after a system unit is 
> started:
> 
> 	ExecStartPre=/usr/bin/sh -c 'until systemctl --quiet is-active network-online.target ; do sleep 1 ; done'
> 
> 
> Note: you should read on network-online.target in systemd.special(7) if 
> you intend to follow my example.
> 
> Kind regards,
> Andrei

Thanks Andrei!

-Jim P.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web