[systemd-devel] Passing variables from udev to unit

Peter Hutterer peter.hutterer at who-t.net
Fri Mar 14 00:13:15 PDT 2014


On Fri, Mar 14, 2014 at 06:27:26AM +0400, Andrey Borzenkov wrote:
> В Fri, 14 Mar 2014 08:53:45 +1000
> Peter Hutterer <peter.hutterer at who-t.net> пишет:
> 
> > Hey,
> > 
> > I have a service file wacom-inputattach at .service that is started from a udev
> > rule:
> > 
> >   SUBSYSTEM=="tty|pnp", KERNEL=="ttyS[0-9]*", ATTRS{id}=="WACf*",
> >   TAG+="systemd", ENV{SYSTEMD_WANTS}+="wacom-inputattach@%k.service"
> > 
> > and the service file then runs:
> > 
> >   ExecStart=/usr/bin/inputattach -w8001 /dev/%I
> > 
> > That works fine, but now I need to pass a second parameter into the service
> > file. Ideally I want to run something like:
> > 
> >   ExecStart=/usr/bin/inputattach --baud $BAUD -w8001 /dev/%I
> > 
> > I can set the baud rate based on ATTRS{id} in the udev rule, I just don't
> > know if there is a way to pass this to the service file. Is there a way to
> > do this or do I need to write a wrapper?
> 
> 
> One possibility would be to generate 
> /run/systemd/system/wacom-inputattach@%k.service.d/baud.conf that
> contains
> 
> [Service]
> BAUD=9600
> 
> But this requires systemd reload and may generate burst of reload
> requests if there are multiple devices. May be wrapper is simpler.

thanks, I'll look into that. there should only ever be one of these devices
and they're built-in, so that shouldn't matter too much (in fact it'd
probably be possible to generate this file only once, but that's too much
effort to figure out).

Cheers,
  Peter


More information about the systemd-devel mailing list