]>
Commit | Line | Data |
---|---|---|
eff594b8 PZ |
1 | #!/bin/sh |
2 | # | |
3 | # alsasave This shell script takes care of stopping ALSA sound driver. | |
4 | # | |
5 | # This script requires /usr/sbin/alsactl program from alsa-utils package. | |
6 | # | |
7 | # Copyright (c) by Jaroslav Kysela <perex@jcu.cz> | |
8 | # | |
9 | # This program is free software; you can redistribute it and/or modify | |
10 | # it under the terms of the GNU General Public License as published by | |
11 | # the Free Software Foundation; either version 2 of the License, or | |
12 | # (at your option) any later version. | |
13 | # | |
14 | # This program is distributed in the hope that it will be useful, | |
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | # GNU General Public License for more details. | |
18 | # | |
19 | # You should have received a copy of the GNU General Public License | |
20 | # along with this program; if not, write to the Free Software | |
21 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
22 | # | |
23 | # | |
24 | # For PLD Linux Distribution: | |
25 | # chkconfig: 2345 80 14 | |
26 | # description: ALSA driver | |
27 | # | |
28 | ||
29 | # Source function library. | |
30 | . /etc/rc.d/init.d/functions | |
31 | ||
32 | alsactl=/usr/sbin/alsactl | |
dc764c52 | 33 | subsyslock=var/lock/subsys/alsa-udev |
eff594b8 PZ |
34 | detect_stop() |
35 | { | |
36 | # | |
37 | # remove all sound modules | |
38 | # | |
39 | /sbin/lsmod | awk '/^snd/ { print $0 }' | while read line; do \ | |
40 | /sbin/rmmod `echo $line | cut -d ' ' -f 1`; \ | |
41 | done | |
42 | } | |
43 | ||
44 | ||
45 | driver_stop() | |
46 | { | |
47 | # | |
48 | # store driver settings | |
49 | # | |
50 | if [ -x $alsactl ]; then | |
51 | $alsactl store | |
52 | else | |
53 | show '!!!alsactl not found!!!'; fail | |
54 | fi | |
55 | } | |
56 | ||
57 | # See how we were called. | |
58 | case "$1" in | |
59 | start) | |
dc764c52 | 60 | touch $subsyslock |
eff594b8 PZ |
61 | ;; |
62 | stop) | |
63 | # Stop daemons. | |
64 | if [ -d /proc/asound ]; then | |
dc764c52 | 65 | show "Shutting down sound driver" |
eff594b8 PZ |
66 | busy |
67 | if [ -f /proc/asound/detect ]; then | |
68 | detect_stop | |
69 | else | |
70 | driver_stop | |
71 | fi | |
72 | (rmmod isapnp; rmmod soundcore) 2> /dev/null | |
dc764c52 | 73 | [ -f $subsyslock ] && rm $subsyslock |
eff594b8 PZ |
74 | ok |
75 | else | |
76 | msg_not_running "ALSA driver" | |
77 | fi | |
78 | ;; | |
79 | save) | |
80 | driver_stop | |
81 | ;; | |
82 | status) | |
83 | #TODO | |
84 | ;; | |
85 | *) | |
86 | msg_usage "$0 {start|stop|save|status}" | |
87 | exit 3 | |
88 | esac | |
89 | ||
90 | exit 0 |