GDH-gentoo wrote:DaggyStyle wrote:ideally, I'd like to remove the service and relay only on udev events.
the main issue is that the add event needs to run several commands a few seconds after udev finished handling the add event.
I don't understand. An udev rule that matches the event you are interested in and contains
RUN="your-script" does not work?
it runs well but as explained above, the device takes a few minutes to function after the add rule was matched.
the script waits for 5'6 minutes for a specific "signal", if within that timeframe the specific "signal" is received, I continue with the next cmds, if not, it bails out.
Hu wrote:That worked fine, once. Modern udev is very specific about how they don't want you running "long running" jobs. At least for systemd-udevd, I think they actually take steps that make this not work. I don't know if udev under openrc, or eudev under openrc, have the same problem. The canonical answer from the systemd people is to use a udev rule that triggers a systemd service to do the real work. That won't work under openrc, where there is no systemd service to trigger.
DaggyStyle: how exactly did you make the script fork?
tried &, nohup and even openrc pre_up, all of them worked.
javeree wrote:I believe the best way to start a long running script under udev is RUN="echo myscript | at now"
(required atd daemon)
thanks for the sugggestion, will look at it.
GDH-gentoo wrote:Hu wrote:That worked fine, once. Modern udev is very specific about how they don't want you running "long running" jobs. At least for systemd-udevd, I think they actually take steps that make this not work.
Yeah, as far as I can tell, both
systemd-udevd and eudev's
udevd kill the spawned process if it runs for too long, but "too long" is a time interval of configurable duration that defaults to 3 minutes.
javeree wrote:I believe the best way to start a long running script under udev is RUN="echo myscript | at now"
(required atd daemon)
I don't think that will work; as far as I can tell the value assigned to
RUN is not parsed by a shell, so the pipe character might not work as expected.
RUN="/bin/sh -c 'echo myscript | at now'" on the other hand might, but I don't see at the moment why simply calling the script won't work.
EDIT to clarify: What I'm expecting the script spawned by the udev rule to do is running the per-event "several commands" referred to in the OP, not a long-lived process. I understand that the long-lived process spawned by an OpenRC service script is what the OP wants to get rid of.
the main issue is that udev waits for the child, that is want I need to fix, e.g. udev runs the script and continues while the script continues in the background.
Only two things are infinite, the universe and human stupidity and I'm not sure about the former - Albert Einstein