blob: b3ada2664ce6a21b4954cfbf4c3794c29f593af8 (
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#!/sbin/runscript
# Distributed under the terms of the GNU General Public License v2
# $Id$
opts="${opts} watchdogrestart"
load_functions() {
cd /
. /usr/share/vdr/inc/functions.sh
include rc-functions
}
#
# Used to log error-messages in startscript to show them on
# OSD later when choosing apropriate point in commands.
#
vdr_log()
{
echo "$@" >> ${VDR_LOG_FILE}
}
depend() {
need net
[ "${IR_CTRL}" = "lirc" ] && need lircd
use lircd coldplug
after checkroot
}
start() {
INIT_PHASE="start"
load_functions
local exitcode
VDR_LOG_FILE=/var/vdr/tmp/vdr-start-log
rm -f "${VDR_LOG_FILE}"
> "${VDR_LOG_FILE}"
einfo "Preparing start of vdr:"
init_params
add_daemonctrl_param --start --chdir ~vdr --exec ${VDR_BIN}
load_addons_prefixed pre-start || return 1
ebegin "Starting ${VDRNAME}"
#
# finally start vdr
#
unset MAIL
vdr_home=/var/vdr
export LOGNAME=vdr
export USER=vdr
export HOME=${vdr_home}
cd ${vdr_home}
debug_msg " CMDLINE:" start-stop-daemon "${daemonctrl_opts}" "--" "${vdr_opts}"
if [ -z "${TERMINAL}" ]; then
eval start-stop-daemon ${daemonctrl_opts} \
-- --daemon ${vdr_opts}
exitcode=$?
else
TERMINAL=${TERMINAL##/dev/tty}
TERMINAL_DEVICE=/dev/tty${TERMINAL}
{
clear
einfo "Starting vdr"
} >${TERMINAL_DEVICE}
# strange commandline, to be fixed in next versions
openvt_opts=""
if [ "${SWITCH_TO_TERMINAL}" = "yes" ]; then
openvt_opts="${openvt_opts} -s"
fi
eval openvt -c ${TERMINAL} ${openvt_opts} -- \
start-stop-daemon ${daemonctrl_opts} \
-- ${vdr_opts}
exitcode=$?
fi
eend $exitcode "Failed to start vdr."
if [ "${exitcode}" = "0" ]; then
load_addons_prefixed post-start
if [ "$?" != "0" ]; then
exitcode=1
fi
fi
# wenn nachrichten vorhanden sind
if [ -s "${VDR_LOG_FILE}" ]; then
/usr/share/vdr/bin/vdr-bg.sh svdrpsend.pl mesg "Errors: Go to Commands/View VDR Start Log"
fi
return $exitcode
}
stop() {
INIT_PHASE="stop"
load_functions
load_addons_prefixed pre-stop
ebegin "Stopping ${VDRNAME}"
# Use --name here to allow us to kill vdr even after a new emerge
start-stop-daemon --stop --quiet --retry 15 --exec ${VDR_BIN}
exitcode=$?
eend $exitcode "Failed to stop vdr."
load_addons_prefixed post-stop
return $exitcode
}
# gets called by watchdog to restart vdr
# and possibly reload modules
watchdogrestart() {
load_functions
export WATCHDOG_RESTART="1"
/etc/init.d/vdr --nodeps stop
if test_vdr_process; then
sleep 2
test_vdr_process && killall -9 vdr
fi
/etc/init.d/vdr zap
load_addons_prefixed watchdog-restart
/etc/init.d/vdr start
unset WATCHDOG_RESTART
}
|