Files
django-ram/connector/99-dcc-usb-connector.rules

23 lines
997 B
Plaintext

# Udev rule to auto-start/stop dcc-usb-connector.service when USB device is connected/removed
#
# This rule detects when a CH340 USB-to-serial adapter (ID 1a86:7523)
# is connected/removed on /dev/ttyUSB0, then automatically starts/stops
# the dcc-usb-connector.service (user systemd service).
#
# Installation:
# sudo cp 99-dcc-usb-connector.rules /etc/udev/rules.d/
# sudo udevadm control --reload-rules
# sudo udevadm trigger --subsystem-match=tty
#
# Testing:
# udevadm test /sys/class/tty/ttyUSB0
# udevadm monitor --property --subsystem-match=tty
#
# The service will be started when the device is plugged in and stopped
# when the device is unplugged.
# Match USB device 1a86:7523 on ttyUSB0
# TAG+="systemd" tells systemd to track this device
# ENV{SYSTEMD_USER_WANTS} starts the service on "add" and stops it on "remove"
SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", KERNEL=="ttyUSB0", TAG+="systemd", ENV{SYSTEMD_USER_WANTS}="dcc-usb-connector.service"