#! /bin/bash # -*- sh -*- declare -a QUERY=(${QUERY_STRING//&/ }) ACTION=${QUERY[0]} TARGET=${QUERY[-1]} [ "$TARGET" = "$ACTION" ] && TARGET="" cat < RPiRENA Data Acqusition

Live plots of $(hostname)

EOT exec 2>&1 if [ -z "$ACTION" ] then RUNNING="" for r in python rpirena-auto.py do if sudo -u stephan /usr/bin/killall -s 0 -r "$r" 2>/dev/null then RUNNING="$r" echo "

$r is running!

" fi done [ -z "$RUNNING" ] && echo "

rpirena is NOT running.

" cat <Please choose an action:
EOT
ps axfu | grep -v ' 0.0 *0 *0 .*]$'
cat <


EOT
    exit 0
fi

case "$ACTION" in
    restart|stop)
	if sudo -u stephan /usr/bin/killall -s 0 -r 'rpirena-auto.py'
	then
	    CONFIRM="Really ${ACTION} the acquisition"
	else
	    CONFIRM='rpirena-auto.py is not running.'
	fi
	;;
    start)
	if sudo -u stephan /usr/bin/killall -s 0 -r 'rpirena(-auto)?.py'
	then
	    CONFIRM='rpirena(-auto)?.py is running'
	else
	    if [ "$TARGET" = "force" ]
	    then
		echo "
"
		sudo /etc/rc.local start_rpirena
		sleep 1
		echo "
" CONFIRM="sudo /etc/rc.local was executed" else CONFIRM='Really start rpirena-auto.py?' fi fi ;; halt) if [ "$TARGET" = "force" ] then echo "

Shutdown in procgress, bye …

sudo /sbin/halt" sleep 1 sudo /sbin/halt exit 0 else CONFIRM='Really shutdown the Raspberry Pi?' fi ;; esac cat <Please confirm:
EOT
ps axfu | grep -v ' 0.0 *0 *0 .*]$'
cat <


EOT