Skip to content

Instantly share code, notes, and snippets.

@thinkAmi
Last active February 20, 2018 07:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkAmi/3726e0cc9bd009419b65 to your computer and use it in GitHub Desktop.
Save thinkAmi/3726e0cc9bd009419b65 to your computer and use it in GitHub Desktop.
Raspberry Pi 2 + systemd + udevで、USBデバイス挿入時にサービスを起動する

Raspberry Pi 2 + systemd + udevで、USBデバイス挿入時にサービスを起動する

SUBSYSTEM=="usb", ACTION=="add", ATTRS{idProduct}=="01bb", ATTRS{idVendor}=="054c", RUN+="/bin/sh -c 'echo Hello at `date` > /home/pi/hello.log'"
SUBSYSTEM=="usb", ACTION=="add", ATTRS{idProduct}=="01bb", ATTRS{idVendor}=="054c", GROUP="usb", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rc-s320.service", NAME="pasori320"
[Unit]
Description=Pasori RC-S320 service
Requires=dev-pasori320.device
After=dev-pasori320.device
[Service]
Type=simple
ExecStart=/bin/sh -c "echo Hello by `date` >> /home/pi/hello2.log"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment