#!/bin/sh # realprod-nanny --- keep checking a Real stream, and restart things # if it goes away. # # Copyright © 2000-2008 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 initd=/etc/rc.d/init.d/realprod url=rtsp://svr1.streams.groovefactory.com:7070/broadcast/groovefactory/dnalounge/live.rm pingable() { if ( ping -q -n -c 1 $1 >/dev/null ); then return 0 else return 1 fi } check_once() { if ! rtsp-ping $url ; then echo "$url not found! restarting realproducer..." >&2 $initd restart fi } check_loop() { while true; do check_once sleep 30 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