Skip to content

Instantly share code, notes, and snippets.

@takeru
Created January 20, 2022 03:32
Show Gist options
  • Save takeru/1a56a913903a8420cc78155f01f7b416 to your computer and use it in GitHub Desktop.
Save takeru/1a56a913903a8420cc78155f01f7b416 to your computer and use it in GitHub Desktop.
ラズパイの右下のUSBになにか刺したらシャットダウンします〜
# /etc/systemd/system/shutdown_by_usb.service
[Unit]
Description=shutdown_by_usb
[Service]
Type=simple
ExecStart=bash -c 'while : ; do if [ -e /sys/bus/usb/devices/1-1.2 ] ; then echo "shutdown_by_usb!"; sleep 5; sudo shutdown -h now; sleep 60; else true; fi; sleep 1; $
Restart=always
[Install]
WantedBy=multi-user.target
## (osusume)
## sudo nano /boot/config.txt
## dtparam=pwr_led_trigger=heartbeat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment