#!/bin/sh ############################################################################## ## Darkice Watchdog ## ## This script checks a darkice live stream on a local or remote icecast ## server and restart darkice if the stream is down. ## ## Niels Dettenbach ## (c) 2009 GPL ## v0.3 ## ## ## ## prerequisites: ## -------------- ## ## - darkice (http://darkice.org/) ## ## - curl (http://curl.haxx.se/) ## ## ## installation: ## ------------- ## ## - adjust settings ## ## - make it executable with: ## chmod +x icecast.watchdog ## ## - install darkice init script if not there: ## cp rc.darkice /etc/initd./darkice ## ## - you may adjust #restart darkice command to your own if required ## ## - add it to /etc/crontab - i.e.: ## ## */5 * * * * root /full/path/to/icecast.watchdog > /dev/null ## ############################################################################### ### settings # icecast status URL URL='http://stream.server.tld:8000/status.xsl' # filename of stream TEXTTOSEARCH='yourstream.mp3' # timeout TIMEOUT=10 # sleep within restart SLEEP=5 # log file LOGFILE=/var/log/darkice_watchdog # curl binary CURL=`which curl` #CURL=/usr/bin/curl ## endof settings DATE=$(date) CUR=$($CURL --connect-timeout ${TIMEOUT} --max-time ${TIMEOUT} -3 --silent ${URL}) TEST=$(echo $CUR | grep ${TEXTTOSEARCH}) # If not zero, server is OK if [[ ! $TEST == "" ]]; then echo $DATE "- stream is OK" >> $LOGFILE; else echo $DATE "- stream down - restart" >> $LOGFILE; #restart darkice /etc/init.d/darkice stop sleep $SLEEP /etc/init.d/darkice start fi