aboutsummaryrefslogtreecommitdiff
blob: e64cc9f9fb93c54ec302b122c9dd35d1aaad4da0 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# $Id$

include rc-functions

include svdrpcmd
svdrp_command

addon_main() {
	# we already know vdr failed
	[ "${vdr_start_failed}" = "1" ] && return 0

	if [ "${VDRVERSNUM}" -ge "10715" ]; then
		SVDRP_PORT="${SVDRP_PORT:-6419}"
		logger -t vdr "New default svdrp port 6419!"
	else
		SVDRP_PORT="${SVDRP_PORT:-2001}"
	fi

	SVDRP_HOSTNAME="${SVDRP_HOSTNAME:-localhost}"
	[ "${SVDRP_PORT}" = "0" ] && return 0

	if [ ! -e /etc/vdr/remote.conf ]; then
		einfo "First start of vdr: No check for running vdr possible"
		einfo "until control device (remote/keyboard) keys are learnt!"
		return 0
	fi

	ebegin "  Waiting for working vdr"

	# Warten auf offenen svdrp port
	START_SVDRP_WAIT_SECONDS=${START_SVDRP_WAIT_SECONDS:-40}

	waitfor ${START_SVDRP_WAIT_SECONDS} svdrp_ready

	case "$?" in
	0)	eend 0
		;;
	1)	eend 1 "timeout. Hoping that VDR is running good nevertheless."
		einfo
		einfo "Ignore this if you connected a new remote/keyboard which gets learned."
		einfo "If your computer is very slow it is possible that vdr"
		einfo "needs more than ${START_SVDRP_WAIT_SECONDS} seconds to be up and going."
		einfo "You can enlarge that value inside /etc/conf.d/vdr (START_SVDRP_WAIT_SECONDS)."
		einfo
		# continue with state "started"
		;;
	2)	eend 2 "VDR process died, please check logfile"
		# tell init-script that vdr died
		vdr_exitcode=1
		;;
	esac

	return 0
}

svdrp_ready() {
	if ${SVDRPCMD} -d ${SVDRP_HOSTNAME} -p ${SVDRP_PORT} quit 2>/dev/null|grep -q ^220; then
		# svdrp open and ready
		return 0
	fi
	if ! test_vdr_process; then
		# Not running
		return 2
	fi
	return 1
}