Commit Graph

3 Commits (011058aec3d3400b682ba90fcfea8457c58e36cd)

Author SHA1 Message Date
Dustin 2a84d810e0 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.
2024-02-15 10:08:52 -06:00
Dustin ec4b640170 reload-udev-rules: Ensure rules.d directory exists
The `/run/udev/rules.d` directory may not always exist, especially at
boot.  We need to ensure that it does before we try to copy rules
exported by containers into it, or the unit will fail.
2024-01-18 20:01:06 -06:00
Dustin 74508faf27 nut: Apply udev rules on the host
NUT needs some udev rules in order to set the proper permissions on USB
etc. devices so it can run as an otherwise unprivileged user.  Since
udev rules can only be processed on the host, these rules need to be
copied out of the container and evaluated before the NUT server starts.
To enable this, the *nut-server* container image copies the rules it
contains to `/etc/udev/rules.d` if that directory is a mount point.  By
bind mounting a directory on the host at that path, we can get a copy of
the rules files outside the container.  Then, using a systemd path unit,
we can tell the udev daemon to reload and reevaluate its rules.

SELinux prevents processes in containers from writing to
`/etc/udev/rules.d` directly, so we have to use an intermediate location
and then copy the rules files to their final destination.
2024-01-14 19:24:55 -06:00