]> git.pld-linux.org Git - packages/alsa-utils.git/blame - alsasound.init
- BR: xmlto
[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 5#
f3ec2d8f 6# Copyright (c) by Jaroslav Kysela <perex@jcu.cz>
634db781
AM
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21#
22#
2efb5f03 23# For PLD Linux Distribution:
8e5b4036 24# chkconfig: 2345 87 14
25# description: ALSA driver
634db781
AM
26#
27
28# Source function library.
29. /etc/rc.d/init.d/functions
30
678c4fff
AM
31driver_start()
32{
634db781
AM
33 #
34 # insert all sound modules
35 #
b0646167 36 modprobe -c | awk '$1 == "alias" && $3 != "off" && ($2 ~ /^snd-card-[0-9]$/) {print $3}' | \
e0831d0a 37 while read line; do \
38 msg_starting "sound driver: $line"
39 busy
40 /sbin/modprobe $line
41 ok
42 done
b0646167 43 modprobe -c | awk '$1 == "alias" && $3 != "off" && ($2 ~ /^sound-service-[0-9]-[0-9]+$/) {print $3}' | \
634db781 44 while read line; do \
d08febb7 45 msg_starting "sound driver: $line"
150b8378 46 busy
47 /sbin/modprobe $line
48 ok
634db781 49 done
634db781
AM
50}
51
678c4fff
AM
52detect_stop()
53{
634db781
AM
54 #
55 # remove all sound modules
56 #
4d1ff5eb
ER
57 /sbin/lsmod | awk '/^(snd|ac97_bus)/ { print $1 }' | while read module; do \
58 /sbin/rmmod $module
634db781
AM
59 done
60}
61
678c4fff
AM
62driver_stop()
63{
634db781
AM
64 #
65 # remove all sound modules
66 #
67 detect_stop
68}
69
678c4fff
AM
70detect_start()
71{
634db781
AM
72 #
73 # run only detect module
74 #
75 /sbin/modprobe snd-detect
76}
77
02813c63
ER
78# Start driver.
79start() {
634db781 80 if [ ! -d /proc/asound ]; then
d08febb7 81 driver_start
82 if [ -d /proc/asound ]; then
83 touch /var/lock/subsys/alsasound
84 else
85 exit 1
86 fi
634db781 87 else
d08febb7 88 if [ -f /proc/asound/detect ]; then
b52c7707 89 show "Shutting down sound detect module"
d08febb7 90 detect_stop
91 ok
92 driver_start
93 if [ -d /proc/asound ]; then
94 touch /var/lock/subsys/alsasound
95 else
96 exit 1
97 fi
98 else
e0831d0a 99 msg_already_running "ALSA driver"
d08febb7 100 fi
634db781 101 fi
02813c63
ER
102}
103
104# Stop daemons.
105stop() {
634db781 106 if [ -d /proc/asound ]; then
b52c7707 107 show "Shutting down sound driver"
d08febb7 108 busy
109 if [ -f /proc/asound/detect ]; then
110 detect_stop
111 else
112 driver_stop
113 fi
e0831d0a 114 (rmmod isapnp; rmmod soundcore) 2> /dev/null
d08febb7 115 if [ -d /var/lock/subsys ]; then
116 rm -f /var/lock/subsys/alsasound
117 fi
118 ok
634db781 119 else
d08febb7 120 msg_not_running "ALSA driver"
634db781 121 fi
5ef1ff04
ER
122}
123
031987f5
JB
124condrestart() {
125 if [ -f /var/lock/subsys/alsasound ]; then
126 stop
127 start
128 else
129 msg_not_running "ALSA driver"
130 RETVAL=$1
131 fi
132}
133
02813c63
ER
134
135# See how we were called.
136case "$1" in
137 start)
138 start
139 ;;
140 stop)
141 stop
d08febb7 142 ;;
031987f5 143 restart)
02813c63
ER
144 stop
145 start
d08febb7 146 ;;
031987f5
JB
147 try-restart)
148 condrestart 0
149 ;;
150 force-reload)
151 condrestart 7
152 ;;
d08febb7 153 status)
154 # TODO
634db781 155 ;;
634db781 156 *)
031987f5 157 msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
d08febb7 158 exit 3
634db781
AM
159esac
160
161exit 0
This page took 0.115264 seconds and 4 git commands to generate.