IPTV KHnet dvbtwatchdog

Z KHnetWiki

Přejít na: navigace, hledání

DVBT watchdog

ukázka, funkční, ale zde pravděpodobně neudržovaná.

#!/bin/bash

CARD=$1
PORT=$2
FILE=$3

/usr/bin/wget -q -O /dev/null http://127.0.0.1:${PORT} &
PID=$!
echo $PID
sleep 1
kill -9 $PID >/dev/null 2>&1

if [ $? = 0 ]; then
   echo "OK"

   echo -n `date +'%Y-%m-%d %R'` >/home/httpd/html/card.${CARD}.status.temp
   echo -n " |$(($PORT%100/10))" >>/home/httpd/html/card.${CARD}.status.temp
   echo " |OK" >>/home/httpd/html/card.${CARD}.status.temp

   mv -f /home/httpd/html/card.${CARD}.status.temp /home/httpd/html/card.${CARD}.status

else
   echo "KO"

   PID=`cat /var/run/vlc.${CARD}.pid`
   rm -f /var/run/vlc.${CARD}.pid

   if [ `cat /proc/${PID}/status | grep "Name:" | awk '{print $2}'` == "vlc" ]; then
       kill $PID
   fi

   sleep 5
   /usr/local/mediaserver/${FILE}

   logger -t vlc "Restarted on card ${CARD} (port ${PORT} not responding)"

fi
Osobní nástroje