while [ 1 ]
do
#!/bin/sh
# Variablen deklarieren
vCCcam="CCcam2_3_0" # CCcam Version - Script
bCCcam="CCcam2_3_0" # CCcam Version - binary
pCCcam=mein-port # CCcam-WebIf Port
cUser="mein-user" # Username Webinfo
cPass="mein-passwort" # Passwort Webinfo
time=$(date +%A", "%d-%m-%Y" @ "%H:%M:%I)
#echo $time" Script started ..." > /tmp/CCcam_restarts.log
#pruefen ob cccam bin laeuft
if [ "$(ps aux |grep -v grep |grep -c $bCCcam)" == "0" ]
then
BIN=FALSE
echo $time" $vCCcam not running ..." >> /tmp/CCcam_restarts.log
else
BIN=TRUE
echo $time" $vCCcam running ..." >> /tmp/CCcam_restarts.log
fi
#pruefen ob WEB-IF erreichbar
#if wget -q -t2 -O- http://$cUser:$cPass@127.0.0.1:$pCCcam > /dev/null
if wget -q -t2 -O- --user $cUser --password $cPass http://127.0.0.1:$pCCcam > /dev/null
then
WEBIF=TRUE
echo $time" $vCCcam webif running ..." >> /tmp/CCcam_restarts.log
else
WEBIF=FALSE
echo $time" $vCCcam webif not running ..." >> /tmp/CCcam_restarts.log
fi
#wenn WEBIF=FALSE O D E R BIN=FALSE cam neu starten
if [ $BIN = "FALSE" ]
then
/usr/script/"$vCCcam"_cam.sh start
echo $time" $vCCcam restarted ..." >> /tmp/CCcam_restarts.log
elif [ $WEBIF = "FALSE" ]
then
/usr/script/"$vCCcam"_cam.sh stop
/usr/script/"$vCCcam"_cam.sh start
echo $time" $vCCcam stopped - restarted ..." >> /tmp/CCcam_restarts.log
else
WEBIF=FALSE
echo $time" $vCCcam is already running ..." >> /tmp/CCcam_restarts.log
fi
exit 0
sleep 5
done