From 2a84d810e067d0f3ca1307592adc5366b1425051 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 15 Feb 2024 10:05:07 -0600 Subject: [PATCH] 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. --- templates/common/reload-udev-rules.service | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/common/reload-udev-rules.service b/templates/common/reload-udev-rules.service index 6bc83b7..4b94296 100644 --- a/templates/common/reload-udev-rules.service +++ b/templates/common/reload-udev-rules.service @@ -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