#!/bin/sh
if [ $# -ne 6 ] ; then
	echo "Usage $0 email group/device notice(yes/no) ring(yes/no) light(yes/no) message"
	exit 1
fi

email=$1
device=$2
notice=$3
ring=$4
light=$5
msg=$6
base_filename=`basename $0`
tmpfile=`mktemp /tmp/$base_filename.XXX`
#echo $tmpfile
base_url=http://zafora.icte.uowm.gr/~ictest00123/send_message.php

echo "Sending Message..."
fetch -o $tmpfile "$base_url?email=${email}&device=${device}&notify=${notice}&ring=${ring}&light=${light}&message=${msg}" > /dev/null 2>&1 
cmd=`cat $tmpfile | grep -i OK`

if [ $? -eq 0 ] ; then
	echo "Message Send succesfully..."
	rm $tmpfile
	exit 0
else
	echo "Message send failed..."
	cat $tmpfile
	rm $tmpfile
	exit 0
fi
