#!/bin/bash
if ! (set -o noclobber ; echo > /tmp/camera.lock) ; then
    echo "camera lock exists already..."
    exit 1  # the global.lock already exists
fi

DATE=$(date +"%Y-%m-%d_%H%M")

raspistill -w 320 -h 256 -e png -o /home/pi/camera/images/latest.png
/home/pi/pisstv/pisstv /home/pi/camera/images/latest.png 22050 
cp /home/pi/camera/images/latest.png /home/pi/camera/images/$DATE.png

rm -rf /tmp/camera.lock

cp /home/pi/camera/images/latest.png.wav /home/pi/camera/images/$DATE.png.wav
rm /home/pi/pibox_V2/sounds/*.wav
cp /home/pi/camera/images/$DATE.png.wav /home/pi/pibox_V2/sounds


