#!/bin/bash

echo "Fin event" >>/home/souti/motion/detection.log


json="http://localhost:81/json.htm?type=command&param=udevice&idx=240&nvalue=0"
curl -s -i -H "Accept: application/json" $json >/dev/null

#presence=`curl "http://localhost:81/json.htm?type=devices&rid=183" 2>/dev/null|grep Status|grep "On"`

echo "Fin event envoi de mail $presence" >>/home/souti/motion/detection.log
echo "Detection de mouvement en absence " |mail -a `ls -rt /home/souti/motion/*avi | tail -1` -r souti@free.fr -s "Detection de mouvement" -- jerome.delacotte@gmail.com


#if [ "$presence" = "" ]; then
#   echo "Fin event envoi de mail $presence" >>/home/souti/motion/detection.log
#   echo "Detection de mouvement en absence " |mail -a `ls -rt /home/souti/motion/*avi | tail -1` -r souti@free.fr -s "Detection de mouvement" -- jerome.delacotte@gmail.com
#else
#	echo "Fin event Pas d'envoi de mail $presence" >>/home/souti/motion/detection.log
#fi
