3 # alsasound This shell script takes care of starting and stopping \
6 # This script requires /usr/sbin/alsactl program from alsa-utils package.
8 # Copyright (c) by Jaroslav Kysela <perex@jcu.cz>
10 # This program is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 # For PLD Linux Distribution:
26 # chkconfig: 2345 87 14
27 # description: ALSA driver
30 # Source function library.
31 . /etc/rc.d/init.d/functions
36 # insert all sound modules
38 modprobe -c | awk '$1 == "alias" && $3 != "off" && ($2 ~ /^snd-card-[0-9]$/) {print $3}' | \
40 msg_starting "sound driver: $line"
45 modprobe -c | awk '$1 == "alias" && $3 != "off" && ($2 ~ /^sound-service-[0-9]-[0-9]+$/) {print $3}' | \
47 msg_starting "sound driver: $line"
53 # restore driver settings
55 if [ -x /usr/sbin/alsactl ]; then
56 if [ -f /etc/asound.state ]; then
57 if [ "$(kernelver)" -lt "002006012" ]; then
59 [ -a /dev/snd/controlC0 ] && break
63 /usr/sbin/alsactl restore
66 show "ERROR: alsactl not found"; fail
73 # remove all sound modules
75 /sbin/lsmod | awk '/^(snd|ac97_bus)/ { print $1 }' | while read module; do \
83 # store driver settings
85 if [ -x /usr/sbin/alsactl ]; then
86 /usr/sbin/alsactl store
88 show '!!!alsactl not found!!!'; fail
91 # remove all sound modules
99 # run only detect module
101 /sbin/modprobe snd-detect
106 if [ ! -d /proc/asound ]; then
108 if [ -d /proc/asound ]; then
109 touch /var/lock/subsys/alsasound
114 if [ -f /proc/asound/detect ]; then
115 show "Shutting down sound detect module"
119 if [ -d /proc/asound ]; then
120 touch /var/lock/subsys/alsasound
125 msg_already_running "ALSA driver"
132 if [ -d /proc/asound ]; then
133 show "Shutting down sound driver"
135 if [ -f /proc/asound/detect ]; then
140 (rmmod isapnp; rmmod soundcore) 2> /dev/null
141 if [ -d /var/lock/subsys ]; then
142 rm -f /var/lock/subsys/alsasound
146 msg_not_running "ALSA driver"
151 if [ -f /var/lock/subsys/alsasound ]; then
155 msg_not_running "ALSA driver"
161 # See how we were called.
183 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"