File rcdvb of Package dvb (Revision 84655acfd949706e64fb01bb769feee4)
Currently displaying revision 84655acfd949706e64fb01bb769feee4, show latest
x
1
2
# Copyright (c) 1996, 1997, 1998 S.u.S.E. GmbH
3
# Copyright (c) 1998, 1999, 2000, 2001 SuSE GmbH
4
# Copyright (c) 2002, 2003, 2004 SuSE Linux AG
5
# Copyright (c) 2005 SUSE LINUX Products GmbH
6
#
7
# Author: Kurt Garloff, Ludwig Nussel
8
#
9
# init.d/dvb
10
#
11
# and symbolic its link
12
#
13
# /sbin/rcdvb
14
#
15
# System startup script for the dvb card driver
16
#
17
### BEGIN INIT INFO
18
# Provides: dvb
19
# Required-Start:
20
# Required-Stop:
21
# Default-Start: 3 5
22
# Default-Stop: 0 1 2 6
23
# X-UnitedLinux-Should-Start: hotplug
24
# Short-Description: (re)loads drivers for DVB cards.
25
# Description: This script is mostly useless nowadays as drivers
26
# are loaded automatically. You may configure vdr to use it
27
# to reload drivers in case vdr crashes though. See
28
# /etc/sysconfig/vdr
29
### END INIT INFO
30
31
# Source SuSE config
32
. /etc/sysconfig/dvb
33
34
kernelversion=`IFS=. read a b c < <(uname -r); echo $a.$b`
35
36
av7110_loadkeys_path="/usr/share/dvb/av7110_loadkeys"
37
if [ "$kernelversion" = 2.4 ]; then
38
moddir=/lib/modules/`uname -r`/dvb
39
else
40
moddir=/lib/modules/`uname -r`/kernel/drivers/media/dvb
41
fi
42
43
frontend_modules()
44
{
45
if [ "$kernelversion" = 2.4 ]; then
46
for vendor in ves alps_ st grundig_ tda mt; do
47
for m in $moddir/$vendor*; do
48
test -e $m && basename $m .o
49
done
50
done
51
else
52
for m in $moddir/frontends/*; do
53
test -e $m && basename $m .ko
54
done
55
fi
56
}
57
58
load_modules()
59
{
60
if [ -z "$DVB_LOAD_MODULES" ]; then
61
modprobe -q dvb-core
62
63
# XXX this one could be PCI probed !!!
64
modprobe -q dvb-ttpci
65
66
# this one too (#36969)
67
grep -q bttv /proc/modules && modprobe -q dvb-bt8xx
68
69
# Frontends are behind an I2C bus, hard to probe.
70
# insert all drivers and see which one finds a device.
71
for m in `frontend_modules`; do
72
modprobe -q $m
73
done
74
elif [ "$DVB_LOAD_MODULES" = "no" ]; then
75
:
76
else
77
echo -n " ["
78
for module in $DVB_LOAD_MODULES; do
79
echo -n " $module"
80
modprobe -q "$module"
81
done
82
echo -n " ]"
83
fi
84
}
85
86
unload_modules()
87
{
88
if [ -z "$DVB_LOAD_MODULES" ]; then
89
rmmod dvb-bt8xx 2>/dev/null
90
rmmod dvb-ttpci
91
for m in `frontend_modules`; do
92
rmmod $m
93
done
94
rmmod dvb-core
95
elif [ "$DVB_LOAD_MODULES" = "no" ]; then
96
:
97
else
98
echo -n " ["
99
for module in $DVB_LOAD_MODULES; do
100
echo -n " $module"
101
rmmod "$module"
102
done
103
echo -n " ]"
104
fi
105
}
106
107
# Determine the base and follow a runlevel link name.
108
base=${0##*/}
109
link=${base#*[SK][0-9][0-9]}
110
111
# Shell functions sourced from /etc/rc.status:
112
# rc_check check and set local and overall rc status
113
# rc_status check and set local and overall rc status
114
# rc_status -v ditto but be verbose in local rc status
115
# rc_status -v -r ditto and clear the local rc status
116
# rc_failed set local and overall rc status to failed
117
# rc_failed <num> set local and overall rc status to <num><num>
118
# rc_reset clear local rc status (overall remains)
119
# rc_exit exit appropriate to overall rc status
120
. /etc/rc.status
121
122
# First reset status of this service
123
rc_reset
124
125
# Return values acc. to LSB for all commands but status:
126
# 0 - success
127
# 1 - generic or unspecified error
128
# 2 - invalid or excess argument(s)
129
# 3 - unimplemented feature (e.g. "reload")
130
# 4 - insufficient privilege
131
# 5 - program is not installed
132
# 6 - program is not configured
133
# 7 - program is not running
134
#
135
# Note that starting an already running service, stopping
136
# or restarting a not-running service as well as the restart
137
# with force-reload (in case signalling is not supported) are
138
# considered a success.
139
140
case "$1" in
141
start)
142
echo -n "Starting DVB"
143
144
load_modules
145
rc_status -v
146
147
if [ -n "$DVB_AV7110_LOADKEYS_FILE" -a \
148
-e "$av7110_loadkeys_path/$DVB_AV7110_LOADKEYS_FILE" -a \
149
-w /proc/av7110_ir ]; then
150
151
echo -n "Loading $DVB_AV7110_LOADKEYS_FILE"
152
/usr/bin/av7110_loadkeys \
153
"$av7110_loadkeys_path/$DVB_AV7110_LOADKEYS_FILE" \
154
> /proc/av7110_ir
155
rc_status -v
156
fi
157
;;
158
stop)
159
echo -n "Shutting down DVB"
160
161
if [ -n "$RUNLEVEL" -a \( "$RUNLEVEL" = 0 -o "$RUNLEVEL" = 6 \) ]; then
162
# don't waste time unloading drivers at
163
# shutdown/reboot
164
:
165
else
166
unload_modules
167
fi
168
169
rc_failed 0 # don't say failed if modules were not loaded
170
171
# Remember status and be verbose
172
rc_status -v
173
;;
174
try-restart)
175
176
$0 status >/dev/null && $0 restart
177
178
# Remember status and be quiet
179
rc_status
180
;;
181
restart)
182
## Stop the service and regardless of whether it was
183
## running or not, start it again.
184
$0 stop
185
$0 start
186
187
# Remember status and be quiet
188
rc_status
189
;;
190
force-reload)
191
echo -n "Reload service DVB"
192
193
$0 stop && $0 start
194
rc_status
195
;;
196
reload)
197
# not supported
198
rc_failed 3
199
rc_status -v
200
;;
201
status)
202
echo -n "Checking for DVB: "
203
204
# Status has a slightly different for the status command:
205
# 0 - service running
206
# 1 - service dead, but /var/run/ pid file exists
207
# 2 - service dead, but /var/lock/ lock file exists
208
# 3 - service not running
209
210
# NOTE: checkproc returns LSB compliant status values.
211
/sbin/lsmod|grep -q ^dvb || rc_failed 3
212
rc_status -v
213
;;
214
*)
215
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}"
216
exit 1
217
;;
218
esac
219
rc_exit
220