Logoj0ke.net Open Build Service > Projects > multimedia > dvb > rcdvb
Sign Up | Log In

File rcdvb of Package dvb

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