Raspberry PI Shutdown Solution: Difference between revisions

From Playful Exploration
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:r2a2]]
[[Category:r2a2]][[category:Rpi]][[category:System Admin]]
== Shutdown on Wifi Dongle Unplug ==
== Shutdown on Wifi Dongle Unplug ==
See: http://raspberrypi.stackexchange.com/questions/4719/how-to-shut-down-rpi-when-running-headless
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.
It uses the already installed udev service to run a shell command when the a usb device unplugs.


First find the WIFI dongles vendor and model id:
First find the WIFI dongle's vendor and model ID:
<source lang="bash">
<source lang="bash">
sudo su
sudo su

Latest revision as of 22:46, 14 February 2016

Shutdown on Wifi Dongle Unplug

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

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

First find the WIFI dongle's 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.