Script - CCcam respons check [webinfo]
Verfasst: Mi 12. Okt 2011, 17:14
Script zum überprüfen ob CCcam noch reagiert - benutzt den WEBINFO Port anstatt wie das andere Script des TELNETINFO Ports ...
Code: Alles auswählen
#!/bin/bash
#
### CONFIG - START
# /path/to/CCcam.cfg ... if your using USER/PASS ("" to disable and use below settings)
# CCcam-default: /var/etc/CCcam.cfg
CCcamCFG="/var/etc/CCcam.cfg"
# ONLY if you dont run CCcam-Server on same Box (else set above CCcamCFG)
USERNAME=""
PASSWORD=""
WEBINFOPORT=""
# IP/Host of your CCcam-Server to connect to...
CCCAMIP="localhost"
# which command restarts cccam?
RestartCAMcmd="/var/emu/script/cccam restart"
### CONFIG - END
# -------------------------------------------------------------- #
# >>> >> > DO NOT MESS WiTH ANYTHiNG BELOW THiS LiNE! < << <<< #
# -------------------------------------------------------------- #
_tmpdirs="/tmp /var/tmp /var/emu/tmp /usr/tmp /usr/local/tmp"
[ ! -z "$HOME" ] && _tmpdirs="${_tmpdirs} $HOME"
for _td in $_tmpdirs; do
[ -d "$_td" -a -w "$_td" ] && TMPd=$_td && break
done
[ -z "$TMPd" ] && TMPd="" || TMPd=$TMPd/
# read CCcam.cfg and extract user/pass/port
proc_read_CCcamcfg() {
[ ! -z "$CCcamCFG" -a ! -f "$CCcamCFG" ] && echo "ERROR cant find $CCcamCFG" && exit 1
USERNAME=`grep -i "WEBINFO USERNAME" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g'`
PASSWORD=`grep -i "WEBINFO PASSWORD" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g'`
WEBINFOPORT=`grep -i "WEBINFO LISTEN PORT" $CCcamCFG | cut -d ":" -f2 | sed -e 's/ //g' | sed -e 's/\r//g'`
}
proc_get_infos() {
[ ! -z "$CCcamCFG" ] && proc_read_CCcamcfg
[ -z "$WEBINFOPORT" ] && WEBINFOPORT="16001"
[ -z "$CCCAMIP" ] && CCCAMIP="127.0.0.1"
if [ -z "$USERNAME" ]; then
URL="http://${CCCAMIP}:${WEBINFOPORT}"
else
URL="http://"${USERNAME}":"${PASSWORD}"@${CCCAMIP}:${WEBINFOPORT}"
fi
}
proc_get_infos
rm -f ${TMPd}CCcamCheck.html
wget -q -O - "${URL}/" > ${TMPd}CCcamCheck.html
if [ $? -ne "0" ]; then
echo "Fehler beim anmelden/verbinden aufs CCcam WebIf!"
exit 1
fi
if [ ! -f "${TMPd}CCcamCheck.html" ]; then
echo " BAD - CCcam seems frozen, restarting CCcam!"
$RestartCAMcmd
if [ $? -ne "0" ]; then
echo "Fehler beim ausfuehren des CCcam-restart commands!"
exit 1
fi
else
echo "Ok!"
fi
exit 0