Mercurial > hg > beaglert
annotate resources/initd-bela_shutdown_switch @ 478:cb875406a594 prerelease
Makefile does syntax check of the project files only (ignores core)
| author | Giulio Moro <giuliomoro@yahoo.it> | 
|---|---|
| date | Mon, 20 Jun 2016 21:38:57 +0100 | 
| parents | 5587d7fa0108 | 
| children | 
| rev | line source | 
|---|---|
| andrewm@392 | 1 #!/bin/sh | 
| andrewm@392 | 2 # Script to start the GPIO shutdown button checker | 
| andrewm@392 | 3 # Adapted from Stephen C Phillips: | 
| andrewm@392 | 4 # http://blog.scphillips.com/posts/2013/07/getting-a-python-script-to-run-in-the-background-as-a-service-on-boot/ | 
| andrewm@392 | 5 | 
| andrewm@392 | 6 ### BEGIN INIT INFO | 
| andrewm@392 | 7 # Provides: bela_shutdown_swtich | 
| andrewm@392 | 8 # Required-Start: | 
| andrewm@392 | 9 # Required-Stop: | 
| andrewm@392 | 10 # Default-Start: 2 3 4 5 | 
| andrewm@392 | 11 # Default-Stop: 0 1 6 | 
| andrewm@392 | 12 # Short-Description: Monitor the shutdown button on the Bela cape | 
| andrewm@392 | 13 # Description: Monitor the shutdown button on the Bela cape | 
| andrewm@392 | 14 ### END INIT INFO | 
| andrewm@392 | 15 | 
| andrewm@392 | 16 # Change the next 3 lines to suit where you install your script and what you want to call it | 
| andrewm@392 | 17 DIR=/root | 
| andrewm@392 | 18 DAEMON=$DIR/shutdown_switch.sh | 
| andrewm@392 | 19 DAEMON_NAME=shutdown_switch | 
| andrewm@392 | 20 | 
| andrewm@392 | 21 # Add any command line options for your daemon here | 
| andrewm@392 | 22 DAEMON_OPTS="" | 
| andrewm@392 | 23 | 
| andrewm@392 | 24 # This next line determines what user the script runs as. | 
| andrewm@392 | 25 # Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python. | 
| andrewm@392 | 26 DAEMON_USER=root | 
| andrewm@392 | 27 | 
| andrewm@392 | 28 # The process ID of the script when it runs is stored here: | 
| andrewm@392 | 29 PIDFILE=/var/run/$DAEMON_NAME.pid | 
| andrewm@392 | 30 | 
| andrewm@392 | 31 . /lib/lsb/init-functions | 
| andrewm@392 | 32 | 
| andrewm@392 | 33 do_start () { | 
| andrewm@392 | 34 log_daemon_msg "Starting system $DAEMON_NAME daemon" | 
| andrewm@392 | 35 start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS | 
| andrewm@392 | 36 log_end_msg $? | 
| andrewm@392 | 37 } | 
| andrewm@392 | 38 do_stop () { | 
| andrewm@392 | 39 log_daemon_msg "Stopping system $DAEMON_NAME daemon" | 
| andrewm@392 | 40 start-stop-daemon --stop --pidfile $PIDFILE --retry 10 | 
| andrewm@392 | 41 log_end_msg $? | 
| andrewm@392 | 42 } | 
| andrewm@392 | 43 | 
| andrewm@392 | 44 case "$1" in | 
| andrewm@392 | 45 | 
| andrewm@392 | 46 start|stop) | 
| andrewm@392 | 47 do_${1} | 
| andrewm@392 | 48 ;; | 
| andrewm@392 | 49 | 
| andrewm@392 | 50 restart|reload|force-reload) | 
| andrewm@392 | 51 do_stop | 
| andrewm@392 | 52 do_start | 
| andrewm@392 | 53 ;; | 
| andrewm@392 | 54 | 
| andrewm@392 | 55 status) | 
| andrewm@392 | 56 status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $? | 
| andrewm@392 | 57 ;; | 
| andrewm@392 | 58 | 
| andrewm@392 | 59 *) | 
| andrewm@392 | 60 echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}" | 
| andrewm@392 | 61 exit 1 | 
| andrewm@392 | 62 ;; | 
| andrewm@392 | 63 | 
| andrewm@392 | 64 esac | 
| andrewm@392 | 65 exit 0 | 
