summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Richter2015-10-25 15:47:35 +0100
committerStefan Richter2015-10-25 15:47:35 +0100
commita98400d9aeb6117917ac965361d990a38cf6974b (patch)
tree4fe031976bf417ac282bd11ce59cdbdcd8fd379c
downloadaur-a98400d9aeb6117917ac965361d990a38cf6974b.tar.gz
initial files for systemd service (Plusberry Pi Power Button Support)
-rw-r--r--.SRCINFO19
-rw-r--r--.gitignore3
-rw-r--r--PKGBUILD17
-rw-r--r--plusberrypi-shutdown.service8
-rw-r--r--plusberrypi-shutdown.sh17
5 files changed, 64 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..8373a59f1ecc
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,19 @@
+# Generated by mksrcinfo v8
+# Sun Oct 25 14:46:23 UTC 2015
+pkgbase = plusberrypi-shutdown
+ pkgdesc = A systemd service for shutting down your PlusberryPi with the power button.
+ pkgver = 1.0.0
+ pkgrel = 1
+ url = http://plusberrypi.com
+ arch = armv6h
+ arch = armv7h
+ license = GPL
+ depends = systemd
+ depends = bash
+ source = plusberrypi-shutdown.service
+ source = plusberrypi-shutdown.sh
+ md5sums = 3b61dc69b028543e40ca60ff4b0833e9
+ md5sums = b531ced76846544496701af6983062ad
+
+pkgname = plusberrypi-shutdown
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000000..31e1e864ebb8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+pkg/
+src/
+plusberrypi-shutdown-*.pkg*
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..27f30b083a1b
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,17 @@
+# Maintainer: Stefan Richter (sealor) <jdevsr3 googlemail com>
+pkgname=plusberrypi-shutdown
+pkgver=1.0.0
+pkgrel=1
+pkgdesc="A systemd service for shutting down your PlusberryPi with the power button."
+arch=('armv6h' 'armv7h')
+url="http://plusberrypi.com"
+license=('GPL')
+depends=('systemd' 'bash')
+source=('plusberrypi-shutdown.service' 'plusberrypi-shutdown.sh')
+md5sums=('3b61dc69b028543e40ca60ff4b0833e9'
+ 'b531ced76846544496701af6983062ad')
+
+package() {
+ install -m 644 -D -t $pkgdir/etc/systemd/system/ $srcdir/plusberrypi-shutdown.service
+ install -m 744 -D -t $pkgdir/usr/bin/ $srcdir/plusberrypi-shutdown.sh
+}
diff --git a/plusberrypi-shutdown.service b/plusberrypi-shutdown.service
new file mode 100644
index 000000000000..61ca65d3d3d3
--- /dev/null
+++ b/plusberrypi-shutdown.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=This service watches GPIO 24 for Plusberry shutdown.
+
+[Service]
+ExecStart=/usr/bin/plusberrypi-shutdown.sh
+
+[Install]
+WantedBy=multi-user.target
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