[systemd-devel] Serial getty on USB dongle insertion

Andrei Borzenkov arvidjaar at gmail.com
Thu Jul 13 03:37:50 UTC 2017


13.07.2017 03:38, Paul D. DeRocco пишет:
> I've created a serial-getty at ttyUSB2.service file, which is basically a
> copy of serial-getty at .service with a specific device name and a fixed baud
> rate. It works fine when I plug in a serial dongle that gets assigned that
> name. (I have permanent ttyUSB0 and ttyUSB1 devices which don't use
> getty.)
> 
> If I logout, it just offers me a new login prompt. If I unplug the dongle,
> the automatic retrying fails, and plugging it in again doesn't bring it
> back to life.
> 
> If I use Restart=no, then I can terminate it either by logging out or
> yanking the dongle, but it naturally won't restart if I plug the dongle in
> again. Is there a way of configuring the service to start every time the
> dongle is inserted, whether I logged out before yanking the dongle or not?
> Or does this require some special udev rule?
> 

Yes, set ENV{SYSTEMD_WANTS}="serial-getty at ttyUSB2.service" property on
your device in udev rule; this will trigger starting of this service
when device appears. You probably also want to add
"BindsTo=dev-ttyUSB2.device" (or whatever name of your device unit is)
so systemd stops it when dongle is unplugged and does not attempt to
restart.


More information about the systemd-devel mailing list