The script (with log in information obscured):
Code: Select all
#!/bin/bash
## outer loop runs forever
while true;
do
## inner loop restricts operation to after 07:00 and before 21:00
while [ $(date +"%k") -gt 7 -a $(date +"%k") -lt 21 ];
do
echo taking picture
raspistill -q 20 -t 500 -n -o /home/pi/webcam/raw_camera.jpg -w 320 -h 240
nowday=$(date +"%A,")
nowdate=$(date +"%d-%b-%Y")
nowtime=$(date +"%H:%M")
echo annotating footer image
convert /home/pi/webcam/banner_320x30.jpg \
-fill '#0008' -draw 'roundrectangle 5,5,315,25,20,20' \
-fill white -annotate +20+20 '© dyfi.com' \
-annotate +95+20 "$nowday" \
-annotate +165+20 "$nowdate" \
-annotate +270+20 "$nowtime" \
/home/pi/webcam/footer_320x30.jpg
echo combining camera and footer images
convert -append /home/pi/webcam/raw_camera.jpg /home/pi/webcam/footer_320x30.jpg /home/pi/webcam/webcam_image.jpg
echo uploading image
ncftpput -u xxxxxxxxx -p xxxxxxxxxxxxxxxx xxxxxxxxxx.com /xxxxxxxxx/xxxxxxxxx /home/pi/webcam/webcam_image.jpg
echo waiting 30 seconds
sleep 30
done
done
exit 0