#!/bin/sh # $Id$ # # Distributed under the GPL # # watchdog script to restart vdr after failure # to stop watchdog temporarily touch /tmp/vdr-nowatchdog # # #detach from terminal exec < /dev/null exec >/dev/null 2>&1 . /etc/conf.d/vdr.watchdogd if [ "${DEBUG}" == 1 ]; then exec >/tmp/vdrwatchdogd-log 2>&1 date set -x fi log() { logger -i -t vdrwatchdog -p local0.info "$@" } do_restart() { log "restarting VDR" /etc/init.d/vdr watchdogrestart log "VDR has been restarted" /usr/bin/svdrpsend.pl mesg "Warning: vdr was restarted by watchdog." & } is_paused() { [ -f /tmp/vdr-nowatchdog ] } VDR=/usr/bin/vdr log "Starting vdrwatchdog" while true; do pid=$(pidof -s ${VDR}) if [ -n "${pid}" ]; then /usr/bin/wait_on_pid "${pid}" fi while is_paused; do sleep 10 done if ! pidof ${VDR} >/dev/null; then do_restart fi done log "Exiting vdrwatchdog"