added listen-for-shutdown scripts

This commit is contained in:
Tyler Jones 2017-05-10 09:05:53 -07:00
parent 38392806b3
commit c7712aa9a2
2 changed files with 41 additions and 0 deletions

12
listen-for-shutdown.py Normal file
View File

@ -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)

29
listen-for-shutdown.sh Normal file
View File

@ -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