]> git.pld-linux.org Git - packages/alsa-utils.git/blame - alsasound.init
- typo
[packages/alsa-utils.git] / alsasound.init
CommitLineData
678c4fff 1#!/bin/sh
634db781 2#
8e5b4036 3# alsasound This shell script takes care of starting and stopping \
4# ALSA sound driver.
634db781
AM
5#
6# This script requires /usr/sbin/alsactl program from alsa-utils package.
7#
8# Copyright (c) by Jaroslav Kysela <perex@jcu.cz>
9#
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.
14#
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.
19#
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.
23#
24#
2efb5f03 25# For PLD Linux Distribution:
8e5b4036 26# chkconfig: 2345 87 14
27# description: ALSA driver
634db781
AM
28#
29
30# Source function library.
31. /etc/rc.d/init.d/functions
32
33alsactl=/usr/sbin/alsactl
34
e0831d0a 35if [ $(kernelverser) = "002006" ]; then
36 MODULES_CONF=/etc/modprobe.conf
37elif [ -r /etc/modules.conf ]; then
38 MODULES_CONF=/etc/modules.conf
634db781 39else
e0831d0a 40 MODULES_CONF=/etc/conf.modules
634db781
AM
41fi
42
678c4fff
AM
43driver_start()
44{
634db781
AM
45 #
46 # insert all sound modules
47 #
150b8378 48 if OLDLOGLEV=$(awk '{print $1}' < /proc/sys/kernel/printk 2> /dev/null); then
678c4fff
AM
49 /sbin/loglevel 1
50 fi
e0831d0a 51 awk '$1 == "alias" && $3 != "off" && ($2 ~ /^snd-card-[0-9]$/) {print $2}' < $MODULES_CONF | \
52 while read line; do \
53 msg_starting "sound driver: $line"
54 busy
55 /sbin/modprobe $line
56 ok
57 done
58 awk '$1 == "alias" && $3 != "off" && ($2 ~ /^sound-service-[0-9]-[0-9]+$/) {print $2}' < $MODULES_CONF | \
634db781 59 while read line; do \
d08febb7 60 msg_starting "sound driver: $line"
150b8378 61 busy
62 /sbin/modprobe $line
63 ok
634db781 64 done
678c4fff
AM
65 if [ -n "$OLDLOGLEV" ]; then
66 /sbin/loglevel "$OLDLOGLEV"
67 fi
634db781
AM
68 #
69 # restore driver settings
70 #
71 if [ -x $alsactl ]; then
b8fb64c0 72 if [ -f /etc/asound.state ]; then
73 $alsactl restore
74 fi
634db781
AM
75 else
76 show "ERROR: alsactl not found"; fail
77 fi
78}
79
678c4fff
AM
80detect_stop()
81{
634db781
AM
82 #
83 # remove all sound modules
84 #
e0831d0a 85 /sbin/lsmod | awk '/^snd/ { print $0 }' | while read line; do \
86 /sbin/rmmod `echo $line | cut -d ' ' -f 1`; \
634db781
AM
87 done
88}
89
678c4fff
AM
90driver_stop()
91{
634db781
AM
92 #
93 # store driver settings
94 #
95 if [ -x $alsactl ]; then
96 $alsactl store
97 else
678c4fff 98 show '!!!alsactl not found!!!'; fail
634db781
AM
99 fi
100 #
101 # remove all sound modules
102 #
103 detect_stop
104}
105
678c4fff
AM
106detect_start()
107{
634db781
AM
108 #
109 # run only detect module
110 #
111 /sbin/modprobe snd-detect
112}
113
114# See how we were called.
115case "$1" in
116 start)
d08febb7 117 # Start driver.
634db781 118 if [ ! -d /proc/asound ]; then
d08febb7 119 driver_start
120 if [ -d /proc/asound ]; then
121 touch /var/lock/subsys/alsasound
122 else
123 exit 1
124 fi
634db781 125 else
d08febb7 126 if [ -f /proc/asound/detect ]; then
127 show "Shutting down sound detect module:"
128 detect_stop
129 ok
130 driver_start
131 if [ -d /proc/asound ]; then
132 touch /var/lock/subsys/alsasound
133 else
134 exit 1
135 fi
136 else
e0831d0a 137 msg_already_running "ALSA driver"
d08febb7 138 fi
634db781 139 fi
d08febb7 140 ;;
634db781 141 stop)
d08febb7 142 # Stop daemons.
634db781 143 if [ -d /proc/asound ]; then
d08febb7 144 show "Shutting down sound driver:"
145 busy
146 if [ -f /proc/asound/detect ]; then
147 detect_stop
148 else
149 driver_stop
150 fi
e0831d0a 151 (rmmod isapnp; rmmod soundcore) 2> /dev/null
d08febb7 152 if [ -d /var/lock/subsys ]; then
153 rm -f /var/lock/subsys/alsasound
154 fi
155 ok
634db781 156 else
d08febb7 157 msg_not_running "ALSA driver"
634db781 158 fi
d08febb7 159 ;;
160 restart|force-reload)
634db781
AM
161 $0 stop
162 $0 start
d08febb7 163 exit $?
164 ;;
165 status)
166 # TODO
634db781 167 ;;
634db781 168 *)
d08febb7 169 msg_usage "$0 {start|stop|restart|force-reload|status}"
170 exit 3
634db781
AM
171esac
172
173exit 0
This page took 0.068763 seconds and 4 git commands to generate.