summarylogtreecommitdiffstats
path: root/plusberrypi-shutdown.sh
diff options
context:
space:
mode:
authorStefan Richter2015-10-25 15:47:35 +0100
committerStefan Richter2015-10-25 15:47:35 +0100
commita98400d9aeb6117917ac965361d990a38cf6974b (patch)
tree4fe031976bf417ac282bd11ce59cdbdcd8fd379c /plusberrypi-shutdown.sh
downloadaur-a98400d9aeb6117917ac965361d990a38cf6974b.tar.gz
initial files for systemd service (Plusberry Pi Power Button Support)
Diffstat (limited to 'plusberrypi-shutdown.sh')
-rw-r--r--plusberrypi-shutdown.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/plusberrypi-shutdown.sh b/plusberrypi-shutdown.sh
new file mode 100644
index 000000000000..0389bff11997
--- /dev/null
+++ b/plusberrypi-shutdown.sh
@@ -0,0 +1,17 @@
+#!/bin/bash -e
+
+echo 24 > /sys/class/gpio/export
+echo in > /sys/class/gpio/gpio24/direction
+
+trap "{ echo 24 > /sys/class/gpio/unexport; exit 0; }" TERM
+
+while [ true ]
+do
+ if [ $(cat /sys/class/gpio/gpio24/value) == 0 ]
+ then
+ poweroff
+ exit 0
+ else
+ sleep 1
+ fi
+done