aboutsummaryrefslogtreecommitdiff
blob: 3d18845357468e942fff70d4d2e870004e359dd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/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

log() {
	logger -i -t vdrwatchdog -p local0.info	"$@"
}

do_restart() {
	log "restarting VDR"
	/etc/init.d/vdr watchdogrestart
	/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"