5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
22 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
25 # This is the audio_clean program.
27 # Following is the syntax for calling the script:
28 # scriptname [-s|-f|-i|-I] devicename [-A|-D] [username] [zonename]
31 # $1: -s for standard cleanup by a user
32 # -f for forced cleanup by an administrator
33 # -i for boot-time initialization (when the system is booted with -r)
34 # -I to suppress error/warning messages; the script is run in the '-i'
37 # $2: devicename - device to be allocated/deallocated, e.g., sr0
39 # $3: -A if cleanup is for allocation, or -D if cleanup is for deallocation.
41 # $4: username - run the script as this user, rather than as the caller.
43 # $5: zonename - zone in which device to be allocated/deallocated
45 # $6: zonepath - root path of zonename
47 # Unless the clean script is being called for boot-time
48 # initialization, it may communicate with the user via stdin and
49 # stdout. To communicate with the user via CDE dialogs, create a
50 # script or link with the same name, but with ".windowing" appended.
51 # For example, if the clean script specified in device_allocate is
52 # /etc/security/xyz_clean, that script must use stdin/stdout. If a
53 # script named /etc/security/xyz_clean.windowing exists, it must use
54 # dialogs. To present dialogs to the user, the dtksh script
55 # /etc/security/lib/wdwmsg may be used.
57 # This particular script, audio_clean, will work using stdin/stdout, or
58 # using dialogs. A symbolic link audio_clean.windowing points to
62 trap "" INT TERM QUIT TSTP ABRT
64 USAGE
="usage: $0 [-s|-f|-i|-I] devicename [-A|-D][username][zonename][zonepath]"
65 PATH
="/usr/bin:/usr/sbin"
66 WDWMSG
="/etc/security/lib/wdwmsg"
69 if [ `basename $0` != `basename $0 .windowing` ]; then
76 # *** Shell Function Declarations ***
80 if [ "$WINDOWING" = "yes" ]; then
81 if [ $MODE = "allocate" ]; then
82 TITLE
="Audio Device Allocation"
84 TITLE
="Audio Device Dellocation"
86 $WDWMSG "$*" "$TITLE" OK
93 if [ "$MODE" = "allocate" ]; then
94 msg
"$0: Allocate of $DEVICE failed."
96 msg
"$0: Deallocate of $DEVICE failed."
105 # Check syntax, parse arguments.
124 shift `expr $OPTIND - 1`
127 if [ "$2" = "-A" ]; then
129 elif [ "$2" = "-D" ]; then
132 if [ "$MODE" != "allocate" -a "$MODE" != "deallocate" ]; then
138 SAVEDIR
=/etc
/security
/audio
139 MAP
=`dminfo -v -n $DEVICE`
140 DEVICE
=`echo $MAP | cut -f1 -d:`
141 TYPE
=`echo $MAP | cut -f2 -d:`
142 FILES
=`echo $MAP | cut -f3 -d:`
144 if [ ! -d ${SAVEDIR} ]
146 /usr
/bin
/mkdir
-m 0755 -p ${SAVEDIR} || fail_msg
147 /usr
/bin
/chown root
:sys
${SAVEDIR} || fail_msg
152 x
="`expr $d : '/dev/mixer[0-9][0-9]*'`"
153 if [ "$x" -ne 0 ] ; then
158 SAVEFILE
="${SAVEDIR}/`basename ${DEVNM}`"
160 if [ "${FLAG}" = "i" -a ! -r "${SAVEFILE}" ]
162 /usr
/bin
/audioctl save-controls
-d ${DEVNM} -f ${SAVEFILE} || fail_msg
164 /usr
/bin
/audioctl load-controls
-d ${DEVNM} ${SAVEFILE} || fail_msg