mixer revision 240336
1127043Sjhb#!/bin/sh - 2127043Sjhb# 3127043Sjhb# Copyright (c) 2004 The FreeBSD Project 4127043Sjhb# All rights reserved. 5127043Sjhb# 6127043Sjhb# Redistribution and use in source and binary forms, with or without 7127043Sjhb# modification, are permitted provided that the following conditions 8127043Sjhb# are met: 9127043Sjhb# 1. Redistributions of source code must retain the above copyright 10127043Sjhb# notice, this list of conditions and the following disclaimer. 11127043Sjhb# 2. Redistributions in binary form must reproduce the above copyright 12127043Sjhb# notice, this list of conditions and the following disclaimer in the 13127043Sjhb# documentation and/or other materials provided with the distribution. 14127043Sjhb# 15127043Sjhb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16127043Sjhb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17127043Sjhb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18127043Sjhb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19127043Sjhb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20127043Sjhb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21127043Sjhb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22127043Sjhb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23127043Sjhb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24127043Sjhb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25127043Sjhb# SUCH DAMAGE. 26127043Sjhb# 27127043Sjhb# $FreeBSD: head/etc/rc.d/mixer 240336 2012-09-11 05:04:59Z obrien $ 28127043Sjhb# 29127043Sjhb 30127043Sjhb# PROVIDE: mixer 31240336Sobrien# REQUIRE: FILESYSTEMS 32136224Smtm# KEYWORD: nojail shutdown 33127043Sjhb 34127043Sjhb. /etc/rc.subr 35127043Sjhb 36127043Sjhbname="mixer" 37163063Sflzrcvar="mixer_enable" 38127043Sjhbstop_cmd="mixer_stop" 39127043Sjhbstart_cmd="mixer_start" 40127043Sjhbreload_cmd="mixer_start" 41127043Sjhbextra_commands="reload" 42127043Sjhb 43127043Sjhb# 44127043Sjhb# List current mixer devices to stdout. 45127043Sjhb# 46127043Sjhblist_mixers() 47127043Sjhb{ 48127043Sjhb ( cd /dev ; ls mixer* 2>/dev/null ) 49127043Sjhb} 50127043Sjhb 51127043Sjhb# 52127043Sjhb# Save state of an individual mixer specified as $1 53127043Sjhb# 54127043Sjhbmixer_save() 55127043Sjhb{ 56127478Sdougb local dev 57127043Sjhb 58127043Sjhb dev="/dev/${1}" 59127043Sjhb if [ -r ${dev} ]; then 60127478Sdougb /usr/sbin/mixer -f ${dev} -s > /var/db/${1}-state 2>/dev/null 61127043Sjhb fi 62127043Sjhb} 63127043Sjhb 64127043Sjhb# 65127043Sjhb# Restore the state of an individual mixer specified as $1 66127043Sjhb# 67127043Sjhbmixer_restore() 68127043Sjhb{ 69127043Sjhb local file dev 70127043Sjhb 71127043Sjhb dev="/dev/${1}" 72127478Sdougb file="/var/db/${1}-state" 73127043Sjhb if [ -r ${dev} -a -r ${file} ]; then 74127043Sjhb /usr/sbin/mixer -f ${dev} `cat ${file}` > /dev/null 75127043Sjhb fi 76127043Sjhb} 77127043Sjhb 78127043Sjhb# 79127043Sjhb# Restore state of all mixers 80127043Sjhb# 81127043Sjhbmixer_start() 82127043Sjhb{ 83127043Sjhb local mixer 84127043Sjhb 85127043Sjhb for mixer in `list_mixers`; do 86127043Sjhb mixer_restore ${mixer} 87127043Sjhb done 88127043Sjhb} 89127043Sjhb 90127043Sjhb# 91127043Sjhb# Save the state of all mixers 92127043Sjhb# 93127043Sjhbmixer_stop() 94127043Sjhb{ 95127043Sjhb local mixer 96127043Sjhb 97127043Sjhb for mixer in `list_mixers`; do 98127043Sjhb mixer_save ${mixer} 99127043Sjhb done 100127043Sjhb} 101127043Sjhb 102127043Sjhbload_rc_config $name 103127043Sjhbrun_rc_command "$1" 104