#!/bin/sh # realprod-nanny --- keep checking a Real stream, and restart things # if it goes away. # # Copyright © 2000-2005 Jamie Zawinski . # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation. No representations are made about the suitability of this # software for any purpose. It is provided "as is" without express or # implied warranty. # # Created: 16-Jul-2000 if [ $# != 0 ]; then echo "usage: $0" echo " you probably meant /etc/rc.d/init.d/realprod-nanny $@" >&2 exit 1 fi PATH=/home/jwz/src/realproducer:$PATH export PATH progname=realprod-nanny delay=2 delay2=5 initd=/etc/rc.d/init.d/realprod #ping_host=www.groovefactory.com #ping_host=www.layer42.net #ping_host=166.88.255.37 #ping_host=209.237.228.51 #ping_host=63.251.54.43 #url=rtsp://bigstream.groovefactory.com:554/encoder/groovefactory/dnalounge/live.rm #url=rtsp://sfr1.streams.groovefactory.com:554/encoder/groovefactory/dnalounge/live.rm url=rtsp://svr1.streams.groovefactory.com:554/encoder/groovefactory/dnalounge/live.rm #url2=rtsp://bigstream.groovefactory.com:554/encoder/groovefactory/dnalounge/liveaudio.rm pingable() { if ( ping -q -n -c 1 $1 >/dev/null ); then return 0 else return 1 fi } check_once() { # if ! pingable $ping_host ; then # echo '' # echo "$ping_host unpingable! stopping realproducer and waiting..." >&2 # $initd stop # # while ! pingable $ping_host; do # sleep $delay2 # done # # echo "$ping_host pingable again. restarting realproducer..." >&2 # $initd start # # elif ! rtsp-ping $url ; then if ! rtsp-ping $url ; then echo "$url not found! restarting realproducer..." >&2 $initd restart # elif ! rtsp-ping $url2 ; then # # echo "$url2 not found! restarting realproducer..." >&2 # $initd restart # fi sleep $delay } check_loop() { while true; do check_once done } # log all stdout/stderr text to syslog log_lines() { while read line ; do logger -st "$progname" " $line" done } echo "started at `date`" | log_lines check_loop 2>&1 | log_lines exit 0