Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email 



SOUNDCHECK SCRIPT

( Revised version 01-23-2005 )



It is already a while back that Owyn wrote us a really nice script to troubleshoot sound issues on our forum. It is only today that I noticed it never actually was posted in the Tips . . . . so today we will make up for it !
The script does work on most distros, but there might be parts that will not return output because that particular distro does not recognize a line in the script.

Here is what to do to run the script:

1). The first command:

CODE
$ kwrite sound.sh

This will open a window with a blank file . . . .


2). Next copy and paste the following text in that empty file:
CODE


#!/bin/sh
# soundchk.sh
# Rev 1.00 2003-10-13 Initial Release - Mandrake 9.1 specific
# Rev 1.01 2003-10-13 Added Checking Devices
#                     Added grep steps to restrict output. Really needed for Knoppix.
#                     Add file exists tests to find correct tools
#                     Completed port to Knoppix 3.3. Should also be much better for UNKNOWN.
# Rev 1.02 2003-10-14 Added test -x for aumix
#                     Fix bug in lspci greps
# Rev 1.03 2003-11-24 Add additional tests from alsa aadebug script
# Rev 1.04 2003-11-25 Fix typo in 1.03 lspci grep
#                     Add check for artsd
#                     Add check for using cdrom


# Rev 1.05 2005-01-22 Adapted to udev and kernel 2.6 by Bruno
# Rev 1.06 2005-01-23 Adapted by Bruno to better suit SUSE and Slackware
# Rev 1.07 2005-01-23 Added a bit of interactivity at the end --Bruno
# Rev 1.08 2005-01-23 Adapted chkconfig to suit SUSE --Bruno

echo
echo "soundchk.sh v1.08 - Running Sound Configuration Checks"
echo
echo
# time and user
date=$(date)
echo "Today is $date"
me=$(whoami)
echo "Sound tested by $me"
echo
echo
echo "== Identifying System =="
uname -s -r -v -p -o
cat /proc/cpuinfo | grep -i "model name"
cat /proc/cpuinfo | grep -i "cpu mhz"
cat /proc/meminfo | grep -i memtotal
cat /proc/meminfo | grep -i swaptotal

echo
echo "== Checking dsp devices =="
ls -l /dev | egrep -i dsp\|sound

echo
echo "== Checking mixer devices =="
ls -l /dev | egrep -i dsp\|mixer

echo
echo "== Checking Knotify =="
cat ~/.kde/share/config/knotifyrc


# adapted to suit SUSE and Slack
echo
echo "== Checking Driver =="
 
if test -f /usr/bin/lspcidrake
then /usr/bin/lspcidrake -v | egrep -i "(audio|multimedia|host bridge)"

elif test -f /sbin/lspci
then /sbin/lspci -v | egrep -i "(audio|multimedia|host bridge)"

elif test -f /bin/lspci
then /sbin/lspci -v | egrep -i "(audio|multimedia|host bridge)"

elif test -f /usr/bin/lspci
then /usr/bin/lspci -v | egrep -i "(audio|multimedia|host bridge)"

else
echo "==> Test not available on this system !"

fi


echo
echo "== Checking Actual Driver in Use (/etc/modules.conf) kernel 2.4 =="
if test -f /etc/modules.conf; then
     cat /etc/modules.conf | egrep -i snd\|sound
else
     echo "==> Test not available on this system !"
fi

# added for kernel 2.6 by Bruno
echo
echo "== Checking Actual Driver in Use (/etc/modprobe.conf) kernel 2.6 =="
if test -f /etc/modprobe.conf; then
     cat /etc/modprobe.conf | egrep -i snd\|sound
else
     echo "==> Test not available on this system !"
fi

if test -d /dev/snd; then
     echo
     echo "== Checking alsa /dev/snd =="
     ls --color=none /dev/snd
fi

echo
echo "== Checking if Module Loaded =="
/sbin/lsmod | egrep -i snd\|sound\|audio\|game

echo
 if test -x /sbin/chkconfig; then
     echo "== Checking in what level Sound service is configured to run =="
     /sbin/chkconfig --list sound

     echo
     echo "== Checking in what level Alsa service is configured to run =="
     /sbin/chkconfig --list alsa

     echo
     echo "== Checking in what level AlsaSound is configured to run ( Only SUSE !! ) =="
     /sbin/chkconfig --list alsasound

else
     echo "==> Test for run levels not available on this system !"
fi

echo
echo "== Checking if Sound Volume muted =="
if test -x /usr/bin/aumix; then
     aumix -q
else
     echo "==> Test not available on this system !"
fi

echo
echo "== Checking artsd setup =="
ps -A -f | grep -i artsd | grep -v grep

echo
echo "== Checking which program uses the sound card or cdrom =="
echo "                (no output is okay)"
if test -x /sbin/fuser; then
     /sbin/fuser -v /dev/dsp
     /sbin/fuser -v /dev/cdrom
else
     /bin/fuser -v /dev/dsp
     /bin/fuser -v /dev/cdrom
fi

# Extra test added by Bruno
echo
echo "== Test wav file . . . . . please wait =="


# test on SUSE
if test -f /opt/kde3/share/sounds/KDE_Startup.wav
 then
 /usr/bin/play /opt/kde3/share/sounds/KDE_Startup.wav

# test on Slackware
elif test -f /opt/kde/share/sounds/KDE_Startup.wav
  then
  /usr/bin/play /opt/kde/share/sounds/KDE_Startup.wav

# test on Mandrake, Fedora and PClos
elif test -f /usr/share/sounds/KDE_Startup.wav
  then
  /usr/bin/play /usr/share/sounds/KDE_Startup.wav
 
else
  echo "==> Test not available on this system !"

fi


# Interactive part
echo -n "Did you hear the soundfile Yes/No ?:"
read answer

# the user did not enter anything:
while [ -z "$answer" ]; do
echo "You did not tell me Yes or No !!!"
echo -n "Did you hear the soundfile Yes/No ?:"
read answer
done

echo "You typed:  $answer   Thanks !"

sleep 2

echo
echo "== End of Checks  ;-)"
echo
 



3). Now save the file ( File --> Save ) and close the kwrite window.


4). Next another command:

CODE
$ chmod 755 sound.sh

. . . it will look like nothing happens, this is okay.


5). And the last command is:

CODE
$ ./sound.sh

. . . now the script is running and will print the output to screen. ( Don't forget the dot before the slash in the command ! )


6). You can use the output of the script to post on the forum where you go to solve your Linux related problems.



The script has proven to be very useful in the past, so in case of sound related problems: just run the script and post the results.



Bruno


-- Dec 21 2004 ( Revised Dec 15 2005 ) --


Tips Linux Explorers   All Things Linux Forum   Great Linux Links   LinuxClues.com   Hometown   Email