blob: 9ef7dc0ac15c0da255655037a57f882e0724a9e3 (
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
|
#!/sbin/runscript
# Distributed under the terms of the GNU General Public License v2
# $Id$
opts="${opts} watchdogrestart"
. /etc/conf.d/vdr.watchdogd
common_init() {
vdr_home=/var/vdr
cd ${vdr_home}
. /usr/share/vdr/inc/functions.sh
include rc-functions
include plugin-functions
VDR_LOG_FILE=/var/vdr/tmp/vdr-start-log
}
clear_logfile() {
rm -f "${VDR_LOG_FILE}"
printf "" > "${VDR_LOG_FILE}"
}
#
# 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_vdr() {
local exitcode
einfo "Preparing start of vdr:"
init_params
add_daemonctrl_param --start --chdir ~vdr --exec ${VDR_BIN}
init_plugin_loader start
clear_logfile
load_addons_prefixed pre-start || return 1
ebegin "Starting ${VDRNAME}"
unset MAIL
export LOGNAME=vdr USER=vdr HOME="${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."
# TODO: Anything todo if starting fails? cleanups?
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_vdr() {
init_plugin_loader stop
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
}
start_watchdog() {
[ "${ENABLE_EXTERNAL_WATCHDOG:-yes}" = "yes" ] || return 0
ebegin "Starting vdr watchdog"
start-stop-daemon \
--start \
--background \
--make-pidfile \
--pidfile /var/run/vdrwatchdog.pid \
--exec /usr/sbin/vdr-watchdogd \
--name vdr-watchdogd
eend $? "failed starting vdr watchdog"
return 0
}
stop_watchdog() {
if [ "${ENABLE_EXTERNAL_WATCHDOG:-yes}" = "yes" ]; then
ebegin "Stopping vdr watchdog"
start-stop-daemon --stop --pidfile /var/run/vdrwatchdog.pid --name vdr-watchdogd
eend $? "failed stopping watchdog"
else
# Also stop watchdog if conf was changed to disabled while it was running
start-stop-daemon --stop --pidfile /var/run/vdrwatchdog.pid --name vdr-watchdogd --quiet
fi
return 0
}
start() {
common_init
start_vdr || return 1
start_watchdog || return 2
}
stop() {
common_init
stop_watchdog || return 2
stop_vdr
}
# gets called by watchdog to restart vdr
# and possibly reload modules
watchdogrestart() {
common_init
( stop_vdr )
if test_vdr_process; then
sleep 2
test_vdr_process && killall -9 vdr
fi
load_addons_prefixed watchdog-restart
( start_vdr )
}
|