reload-udev-rules: Add delay before copying files

Since *systemd* starts the *reload-udev-rules.service* unit as soon as
any file in the `/run/containers/udev-rules` directory changes, the `cp`
command may start before all of the files have been copied out of the
container.  If this happens, some of the rules will not get copied to
the final path, and thus will not be processed by *udev*.

Togive the container a chance to finish copying all of the files before
we process them, we need a bit of a delay.  Obviously, this is not a
perfect solution, as it could potentially take longer than 250ms to copy
the files in some cases, but hopefully those cases are rare enough to
not worry about.
master
Dustin 2024-02-15 10:05:07 -06:00
parent 1738e4a1f1
commit 2a84d810e0
1 changed files with 1 additions and 0 deletions

View File

@ -4,6 +4,7 @@ ConditionDirectoryNotEmpty=/run/containers/udev-rules
[Service]
Type=oneshot
ExecStartPre=/bin/mkdir -p /run/udev/rules.d
ExecStart=/bin/sleep 0.25
ExecStart=/bin/sh -c 'cp /run/containers/udev-rules/*.rules /run/udev/rules.d/'
ExecStart=/usr/bin/udevadm control --reload
ExecStart=/usr/bin/udevadm trigger