#!/bin/bash
echo "Content-type: text/html"
echo ""
echo 'Bell Rang!!!'
echo ""
echo ""
img="$(date +%s)"; #get time/date stamp for images
let h="$(date +%H)"; #get current hour
#Create log file
echo "====================" >> /tmp/doorbell.log
date >> /tmp/doorbell.log
echo "Hour: $h" >> /tmp/doorbell.log
#if it's between 8AM and 8PM ring bell
if [[ "$h" -ge 8 ]] && [[ "$h" -lt 22 ]]
then
echo "Rang..." >> /tmp/doorbell.log
wget -q "<url to mail server>" -O /dev/null &
mplayer bell.mp3 > /dev/null &
wget -q "<url to second computer>" -O /dev/null &
#set ip video 9100a to correct camera
wget --user=<user> --password=<password> "http://<ip address to camera server>/SetChannel.cgi?Channel=2" -O /dev/null
fi
#take 4 photos and upload them
for i in `seq 1 4`
do
wget --user=<user> --password=<password> "http://<ip address to camera server>/Jpeg/CamImg.jpg" -O "../imgs/${img}_${i}.jpg" &&
curl -X POST -F "file=@../imgs/${img}_${i}.jpg" "https://<url for server>/upload.php" -o /dev/null
sleep 1
done