Re: [systemd-devel] What is wrong with my .path setup?

2022-03-20 Thread Mantas Mikulėnas
On Sun, Mar 20, 2022, 23:27 John Ioannidis  wrote:

> Here are my .path and .service files:
>
> $ *cat /etc/systemd/system/trigg.path *
> [Path]
> DirectoryNotEmpty=/root/trigger
> MakeDirectory=true
>
> $ *cat /etc/systemd/system/trigg.service *
> [Unit]
> Description=Trigger Service
>
> [Service]
> ExecStart=/usr/bin/touch /root/wastriggered
> Type=oneshot
>
>
> Now, after robooting, I would have expected that /root/trigger would
> exist; it does not. And, of course, creating it manually and touching a
> file in there does not trigger the path.
>
> What am I missing? I have successfully used .path units in the past, and
> what I'm doing here looks right; unfortunately I do not have access to
> those old machines any more (previous employer).
>

Seems like there's nothing that would activate your .path unit itself –
path watches or timer schedules are only established while the .path or the
.timer is "started". So you will usually need:

[Install]
WantedBy=paths.target

and the corresponding 'systemctl enable'.


Re: [systemd-devel] What is wrong with my .path setup?

2022-03-20 Thread John Ioannidis
On Sun, Mar 20, 2022 at 5:26 PM John Ioannidis 
wrote:

> Here are my .path and .service files:
>
> $ *cat /etc/systemd/system/trigg.path *
> [Path]
> DirectoryNotEmpty=/root/trigger
> MakeDirectory=true
>
> $ *cat /etc/systemd/system/trigg.service *
> [Unit]
> Description=Trigger Service
>
> [Service]
> ExecStart=/usr/bin/touch /root/wastriggered
> Type=oneshot
>
>
I forgot to add:

$ *sudo systemctl status trigg.path *
● trigg.path
 Loaded: loaded (/etc/systemd/system/trigg.path; static; vendor preset:
enabled)
 Active: inactive (dead)
   Triggers: ● trigg.service
$ *sudo systemctl status trigg.service *
● trigg.service - Trigger Service
 Loaded: loaded (/etc/systemd/system/trigg.service; static; vendor
preset: enabled)
 Active: inactive (dead)


Thanks!

/ji

>
> Now, after robooting, I would have expected that /root/trigger would
> exist; it does not. And, of course, creating it manually and touching a
> file in there does not trigger the path.
>
> What am I missing? I have successfully used .path units in the past, and
> what I'm doing here looks right; unfortunately I do not have access to
> those old machines any more (previous employer).
>
> This is all on a fully-patched Ubuntu 20.04LTS machine:
> $ systemd --version
> systemd 245 (245.4-4ubuntu3.15)
> +PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP
> +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN
> +PCRE2 default-hierarchy=hybrid
>


[systemd-devel] What is wrong with my .path setup?

2022-03-20 Thread John Ioannidis
Here are my .path and .service files:

$ *cat /etc/systemd/system/trigg.path *
[Path]
DirectoryNotEmpty=/root/trigger
MakeDirectory=true

$ *cat /etc/systemd/system/trigg.service *
[Unit]
Description=Trigger Service

[Service]
ExecStart=/usr/bin/touch /root/wastriggered
Type=oneshot


Now, after robooting, I would have expected that /root/trigger would exist;
it does not. And, of course, creating it manually and touching a file in
there does not trigger the path.

What am I missing? I have successfully used .path units in the past, and
what I'm doing here looks right; unfortunately I do not have access to
those old machines any more (previous employer).

This is all on a fully-patched Ubuntu 20.04LTS machine:
$ systemd --version
systemd 245 (245.4-4ubuntu3.15)
+PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP
+GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN
+PCRE2 default-hierarchy=hybrid