changeset 392:5587d7fa0108 prerelease

Added a new init.d script for the shutdown button and updated the bela script to use the Makefile to stop.
author andrewm
date Tue, 14 Jun 2016 21:39:06 +0100
parents db1714fe2814
children ff60102d5f39
files resources/initd-bela resources/initd-bela_shutdown_switch
diffstat 2 files changed, 66 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/resources/initd-bela	Tue Jun 14 21:13:40 2016 +0100
+++ b/resources/initd-bela	Tue Jun 14 21:39:06 2016 +0100
@@ -17,7 +17,7 @@
     sh Bela_node.sh
     ;;
   stop)
-    pkill BeagleRT
+    cd /root/Bela && make stop
     ;;
   *)
     echo "Usage: /etc/init.d/bela {start|stop}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/resources/initd-bela_shutdown_switch	Tue Jun 14 21:39:06 2016 +0100
@@ -0,0 +1,65 @@
+#!/bin/sh
+# Script to start the GPIO shutdown button checker
+# Adapted from Stephen C Phillips:
+# http://blog.scphillips.com/posts/2013/07/getting-a-python-script-to-run-in-the-background-as-a-service-on-boot/
+
+### BEGIN INIT INFO
+# Provides:          bela_shutdown_swtich
+# Required-Start:    
+# Required-Stop:    
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Monitor the shutdown button on the Bela cape
+# Description:        Monitor the shutdown button on the Bela cape
+### END INIT INFO
+
+# Change the next 3 lines to suit where you install your script and what you want to call it
+DIR=/root
+DAEMON=$DIR/shutdown_switch.sh
+DAEMON_NAME=shutdown_switch
+
+# Add any command line options for your daemon here
+DAEMON_OPTS=""
+
+# This next line determines what user the script runs as.
+# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
+DAEMON_USER=root
+
+# The process ID of the script when it runs is stored here:
+PIDFILE=/var/run/$DAEMON_NAME.pid
+
+. /lib/lsb/init-functions
+
+do_start () {
+    log_daemon_msg "Starting system $DAEMON_NAME daemon"
+    start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile --user $DAEMON_USER --chuid $DAEMON_USER --startas $DAEMON -- $DAEMON_OPTS
+    log_end_msg $?
+}
+do_stop () {
+    log_daemon_msg "Stopping system $DAEMON_NAME daemon"
+    start-stop-daemon --stop --pidfile $PIDFILE --retry 10
+    log_end_msg $?
+}
+
+case "$1" in
+
+    start|stop)
+        do_${1}
+        ;;
+
+    restart|reload|force-reload)
+        do_stop
+        do_start
+        ;;
+
+    status)
+        status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
+        ;;
+
+    *)
+        echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
+        exit 1
+        ;;
+
+esac
+exit 0
\ No newline at end of file