Raspberry PI Shutdown Solution: Difference between revisions

From Playful Exploration
Jump to navigation Jump to search
(Created page with "Category:r2a2 == Shutdown on Wifi Dongle Unplug == See: http://raspberrypi.stackexchange.com/questions/4719/how-to-shut-down-rpi-when-running-headless It uses already ins...")
 
Line 16: Line 16:
  Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
  Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter


Note the ID mine was 148f:5370 and plug the numbers into the udev rule:
Note the ID of the wifi dongle.  Mine was 148f:5370.  Plug the numbers into the udev rule:
<source lang="bash">
<source lang="bash">
echo 'ACTION=="remove", ENV{ID_VENDOR_ID}=="148f", ENV{ID_MODEL_ID}=="5370", RUN+="/sbin/shutdown -h now"' >/etc/udev/rules.d/00-my_pi_shutdown.rules
echo 'ACTION=="remove", ENV{ID_VENDOR_ID}=="148f", ENV{ID_MODEL_ID}=="5370", RUN+="/sbin/shutdown -h now"' >/etc/udev/rules.d/00-my_pi_shutdown.rules

Revision as of 07:12, 8 February 2016

Shutdown on Wifi Dongle Unplug

See: http://raspberrypi.stackexchange.com/questions/4719/how-to-shut-down-rpi-when-running-headless

It uses already installed udev service to run a shell command when the a usb device unplugs.

First find the WIFI dongles vendor and model id:

sudo su
lsusb

Output:

Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter

Note the ID of the wifi dongle. Mine was 148f:5370. Plug the numbers into the udev rule:

echo 'ACTION=="remove", ENV{ID_VENDOR_ID}=="148f", ENV{ID_MODEL_ID}=="5370", RUN+="/sbin/shutdown -h now"' >/etc/udev/rules.d/00-my_pi_shutdown.rules
udevadm control --reload-rules

That's it. Now when unplugging the wifi dongle the RPI should shutdown.