alsa-utils/alsa-initscript

63 lines
1.6 KiB
Plaintext
Raw Normal View History

#! /bin/bash
#
# alsa
#
# This script takes care of starting alsa oss compatibility modules for
# pcm and saving/restoring mixer volume settings.
# If an alsa driver is not loaded this script does nothing.
#
# Copyright (c) 2004-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
#
# chkconfig: 2345 87 14
# description: ALSA volumes set and oss compatibiliy layer
#
### END INIT INFO
[ -r /etc/init.d/functions ] && . /etc/init.d/functions
[ -r /etc/sysconfig/sound ] && . /etc/sysconfig/sound
# see how we were called.
case "$1" in
start)
if [ -d /proc/asound ]; then
[ "$ENABLE_LEGACY_OSS" = "true" -o "$ENABLE_LEGACY_OSS" = "1" ] && {
echo -n "Loading ALSA-OSS legacy sound modules: "
modprobe snd-seq-oss
modprobe snd-mixer-oss
modprobe snd-pcm-oss
evaluate_retval
echo
}
# Restore is now called by udev
echo -n "Restoring sound card volumes"
/usr/sbin/alsactl restore >/dev/null 2>&1 || /usr/sbin/alsactl init >/dev/null 2>&1
evaluate_retval
echo
else
echo "ALSA driver is not running."
fi
;;
stop)
# stop oss emulation modules
if [ -d /proc/asound ]; then
echo -n "Saving sound card volumes"
/usr/sbin/alsactl store >/dev/null 2>&1
evaluate_retval
fi
;;
restart|reload)
$0 stop
$0 start
;;
status)
[ -n "`lsmod | grep snd[-_]mixer[-_]oss`" ] \
&& echo "ALSA-OSS legacy modules loaded." \
|| echo "ALSA-OSS legacy modules not loaded."
;;
*)
echo "Usage: alsa {start|stop|restart|status}"
exit 1
esac
exit 0