added listen-for-shutdown scripts
This commit is contained in:
parent
38392806b3
commit
c7712aa9a2
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
|
||||||
|
import RPi.GPIO as GPIO
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
GPIO.setmode(GPIO.BCM)
|
||||||
|
GPIO.setup(3, GPIO.IN)
|
||||||
|
GPIO.wait_for_edge(3, GPIO.FALLING)
|
||||||
|
|
||||||
|
subprocess.call(['shutdown', '-h', 'now'], shell=False)
|
|
@ -0,0 +1,29 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: listen-for-shutdown.py
|
||||||
|
# Required-Start: $remote_fs $syslog
|
||||||
|
# Required-Stop: $remote_fs $syslog
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# If you want a command to always run, put it here
|
||||||
|
|
||||||
|
# Carry out specific functions when asked to by the system
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo "Starting listen-for-shutdown.py"
|
||||||
|
/usr/local/bin/listen-for-shutdown.py &
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
echo "Stopping listen-for-shutdown.py"
|
||||||
|
killall listen-for-shutdown.py
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: /etc/init.d/listen-for-shutdown.sh {start|stop}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue