#!/bin/sh
if ps | grep fetch2300 | grep -v grep >/dev/null; then
    if [ -f /tmp/upload.dat ]; then
	rm /tmp/upload_response;
	killall -9 wget;
  wget -q "http://pro.idokep.hu/sendws.php?user="`cat /etc/user`"&pass="`cat /etc/pass`"&tipus=ip_illeszto_v2"`cat /tmp/upload.dat` -O /tmp/upload_response;
	rm /tmp/upload.*;
    fi;
else
    cd /tmp/
    fetch2300 &
fi;    

if ! pgrep mjpg_streamer; then 
	mjpg_streamer -i 'input_uvc.so -r 1600x1200 -f 5' & 
fi;
killall -9 wget;
wget -q http://127.0.0.1:8080/?action=snapshot -O /tmp/cam.jpg;
if [ -f /tmp/cam.jpg ]; then 
	killall -9 wput;
	wput -q /tmp/cam.jpg "ftp://"`cat /etc/user`":"`cat /etc/pass`"@ftp.viharvadasz.hu/";
	rm /tmp/cam.jpg;
fi;
	
