#!/bin/sh # (c) MandrakeSoft, Chmouel Boudjnah <chmouel@mandrakesoft.com> # $Id: sound.init,v 1.10 2002/11/18 22:05:31 flepied Exp $ # # sound: This shell script launch the sound on your system. # # chkconfig: 2345 18 69 # description: This shell script launch the sound on your system. . /etc/rc.d/init.d/functions PKLVL=$(cut -f1 /proc/sys/kernel/printk) sysctl -n -w kernel.printk=0 conf_file=/etc/modules.conf function start_mixer () { if [ -d /proc/asound ] && [ -x /usr/sbin/alsactl ];then return 0; fi if egrep -q '(sparcaudio|sound)' /proc/devices 2>/dev/null && \ [ "$retval" -eq 0 ] && [ -x /usr/bin/aumix ];then if [ ! -r /etc/.aumixrc ];then action "Setting mixer settings" /usr/bin/aumix -v80 -w80 -c80 else action "Loading mixer settings" /usr/bin/aumix -f /etc/.aumixrc -L fi fi } function stop_mixer () { if [ -d /proc/asound ] && [ -x /usr/sbin/alsactl ];then return 0; fi if egrep -q '(sparcaudio|sound)' /proc/devices 2>/dev/null && [ -x /usr/bin/aumix ];then action "Saving mixer settings" /usr/bin/aumix -f /etc/.aumixrc -S fi } function module () { opt="" phrase=$1 alias=$2 [ -n "$3" ] && opt="-r" module=`egrep -s "^alias( |\t)+"$alias"( |\t)+" $conf_file | awk '{ print $3 }'` if [ -n "$module" ] && [ "$module" != "off" ];then action "$phrase ($module)" modprobe "$opt" $module return $? fi } case $1 in start) retval=0 if [ ! -d /proc/asound ];then module "Loading sound module" sound || retval=1 awk '/^((alias)|(probe)) +sound-slot-[0-9]/ {print $2}' $conf_file | ( \ while read line; do [[ $line = snd-card-* ]] && continue #we do it via alsa script module "Loading sound module" $line || retval=1 done ) module "Loading midi module" midi fi start_mixer; touch /var/lock/subsys/sound ;; stop) # i should have the same semantic of alsa script than oss script, # but i do not :-(, patches welcome. stop_mixer; rm -f /var/lock/subsys/sound ;; status) if egrep -q '(sparcaudio|sound)' /proc/devices;then gprintf "Sound loaded" echo fi ;; reload) ;; restart) $0 stop $0 start ;; *) echo "Usage: %s\n" "$(basename $0) {start|stop|restart|status}" exit 0 esac sysctl -n -w kernel.printk=$PKLVL exit 0