diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..7055322 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,41 @@ +#ofxPiMapper Scripts + +This directory contains useful scripts to be used to autorun and keep alive your projection mapping application. + + +## keepalive-example.sh + +This script launches and keeps alive the example application. + +1. Copy it to your home directory. + ``` + cp keepalive-example.sh ~/keepalive-example.sh + ``` +2. Set exec permissions. + ``` + chmod a+x keepalive-example.sh + ``` +3. Run `crontab -e` and add the following lines to make use of it. + ``` + @reboot /home/pi/keepalive-example.sh + * * * * * /home/pi/keepalive-example.sh + ``` + + +## keepalive-example-camera.sh + +This script launches and keeps alive the example-camera application. + +1. Copy it to your home directory. + ``` + cp keepalive-example-camera.sh ~/keepalive-example-camera.sh + ``` +2. Set exec permissions. + ``` + chmod a+x keepalive-example-camera.sh + ``` +3. Run `crontab -e` and add the following lines to make use of it. + ``` + @reboot /home/pi/keepalive-example-camera.sh + * * * * * /home/pi/keepalive-example-camera.sh + ``` diff --git a/scripts/keepalive-example-camera.sh b/scripts/keepalive-example-camera.sh new file mode 100644 index 0000000..39a788a --- /dev/null +++ b/scripts/keepalive-example-camera.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +PROCESS_DIR="/home/pi/openFrameworks/addons/ofxPiMapper/example/bin" +PROCESS_NAME="example-camera" + +case "$(pidof $PROCESS_NAME | wc -w)" in + +0) echo "Restarting $PROCESS_NAME: $(date)" >> "/var/log/$PROCESS_NAME.txt" + "$PROCESS_DIR/$PROCESS_NAME" & + ;; +1) # all ok + ;; +*) echo "Removed double $PROCESS_NAME: $(date)" >> "/var/log/$PROCESS_NAME.txt" + kill $(pidof $PROCESS_NAME | awk '{print $1}') + ;; +esac diff --git a/scripts/keepalive-example.sh b/scripts/keepalive-example.sh new file mode 100644 index 0000000..9abf705 --- /dev/null +++ b/scripts/keepalive-example.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +PROCESS_DIR="/home/pi/openFrameworks/addons/ofxPiMapper/example/bin" +PROCESS_NAME="example" + +case "$(pidof $PROCESS_NAME | wc -w)" in + +0) echo "Restarting $PROCESS_NAME: $(date)" >> "/var/log/$PROCESS_NAME.txt" + "$PROCESS_DIR/$PROCESS_NAME" & + ;; +1) # all ok + ;; +*) echo "Removed double $PROCESS_NAME: $(date)" >> "/var/log/$PROCESS_NAME.txt" + kill $(pidof $PROCESS_NAME | awk '{print $1}') + ;; +esac