[systemd-devel] udev rule, continue to next rule only if preb failed
Lennart Poettering
lennart at poettering.net
Fri May 26 08:23:21 UTC 2023
On Do, 25.05.23 20:25, daggs (daggs at gmx.com) wrote:
> Greetings,
>
> I'm trying to implement the following behavior:
> if a usb is added ot removed, run a script before all other existing rules but continue to existing iff the script failed
> I've added the following rule to /etc/udev/rules.d/5-usb_vm.rules:
> ACTION=="add", SUBSYSTEM=="usb", RUN="/usr/local/bin/handle_udev_action"
> ACTION=="remove", SUBSYSTEM=="usb", RUN="/usr/local/bin/handle_udev_action"
>
> /usr/local/bin/handle_udev_action runs exit 1 iff the device is a specific one (for testing)
> but the code continues to the next rule.
> is there any way to stop it if the script returned 9?
Please see documentation. RUN= is invoked *after* the rules have
finished execution.
There's IMPORT{program}=, which is run as part of rule processing, but it can only be used for very quickly
running programs, and you have to communicate results of your script
via properties you write to stdout rather than exit status.
Lennart
--
Lennart Poettering, Berlin
More information about the systemd-devel
mailing list