]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | ||
3 | # monitor GPIO pin 17 for shutdown signal | |
4 | ||
5 | # export GPIO pin 17 and set to input with pull-up | |
6 | echo "17" > /sys/class/gpio/export | |
7 | echo "in" > /sys/class/gpio/gpio17/direction | |
8 | echo "high" > /sys/class/gpio/gpio17/direction | |
9 | ||
10 | # wait for pin to go low | |
11 | while [ true ] | |
12 | do | |
13 | if [ "$(cat /sys/class/gpio/gpio17/value)" == '0' ] | |
14 | then | |
15 | echo "Raspberry Pi Shutting Down!" | |
16 | #halt & | |
17 | shutdown -h now | |
18 | exit 0 | |
19 | fi | |
20 | sleep 1 | |
21 | done |