CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Posted by xaos52 on Wed 26th Sep 08:07 (modification of post by view diff)
download | new post

  1. #!/bin/bash
  2.  
  3. SCRIPT_VERSION=0.4.61
  4. CHANGELOG="http://www.alsa-project.org/alsa-info.sh.changelog"
  5.  
  6. #################################################################################
  7. #Copyright (C) 2007 Free Software Foundation.
  8.  
  9. #This program is free software; you can redistribute it and/or modify
  10. #it under the terms of the GNU General Public License as published by
  11. #the Free Software Foundation; either version 2 of the License, or
  12. #(at your option) any later version.
  13.  
  14. #This program is distributed in the hope that it will be useful,
  15. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. #GNU General Public License for more details.
  18.  
  19. #You should have received a copy of the GNU General Public License
  20. #along with this program; if not, write to the Free Software
  21. #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  22.  
  23. ##################################################################################
  24.  
  25. #The script was written for 2 main reasons:
  26. # 1. Remove the need for the devs/helpers to ask several questions before we can easily help the user.
  27. # 2. Allow newer/inexperienced ALSA users to give us all the info we need to help them.
  28.  
  29. #Set the locale (this may or may not be a good idea.. let me know)
  30. export LC_ALL=C
  31.  
  32. #Change the PATH variable, so we can run lspci (needed for some distros)
  33. PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin
  34. BGTITLE="ALSA-Info v $SCRIPT_VERSION"
  35. PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
  36. #Define some simple functions
  37.  
  38. pbcheck(){
  39.         [[ $UPLOAD = "no" ]] && return
  40.  
  41.         if [[ -z $PASTEBIN ]]; then
  42.                 [[ $(ping -c1 www.alsa-project.org) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes"
  43.         else
  44.                 [[ $(ping -c1 www.pastebin.ca) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes"
  45.         fi
  46. }
  47.  
  48. update() {
  49.         SHFILE=`mktemp -t alsa-info.XXXXXXXXXX` || exit 1
  50.         wget -O $SHFILE "http://www.alsa-project.org/alsa-info.sh" >/dev/null 2>&1
  51.         REMOTE_VERSION=`grep SCRIPT_VERSION $SHFILE |head -n1 |sed 's/.*=//'`
  52.         if [ "$REMOTE_VERSION" != "$SCRIPT_VERSION" ]; then
  53.                 if [[ -n $DIALOG ]]
  54.                 then
  55.                         OVERWRITE=
  56.                         if [ -w $0 ]; then
  57.                                 dialog --yesno "Newer version of ALSA-Info has been found\n\nDo you wish to install it?\nNOTICE: The original file $0 will be overwritten!" 0 0
  58.                                 DIALOG_EXIT_CODE=$?
  59.                                 if [[ $DIALOG_EXIT_CODE = 0 ]]; then
  60.                                   OVERWRITE=yes
  61.                                 fi
  62.                         fi
  63.                         if [ -z "$OVERWRITE" ]; then
  64.                                 dialog --yesno "Newer version of ALSA-Info has been found\n\nDo you wish to download it?" 0 0
  65.                                 DIALOG_EXIT_CODE=$?
  66.                         fi
  67.                         if [[ $DIALOG_EXIT_CODE = 0 ]]
  68.                         then
  69.                                 echo "Newer version detected: $REMOTE_VERSION"
  70.                                 echo "To view the ChangeLog, please visit $CHANGELOG"
  71.                                 if [ "$OVERWRITE" = "yes" ]; then
  72.                                         cp $SHFILE $0
  73.                                         echo "ALSA-Info script has been updated to v $REMOTE_VERSION"
  74.                                         echo "Please re-run the script"
  75.                                         rm $SHFILE 2>/dev/null
  76.                                 else
  77.                                         echo "ALSA-Info script has been downloaded as $SHFILE."
  78.                                         echo "Please re-run the script from new location."
  79.                                 fi
  80.                                 exit
  81.                         else
  82.                                 rm $SHFILE 2>/dev/null
  83.                         fi
  84.                 else
  85.                         echo "Newer version detected: $REMOTE_VERSION"
  86.                         echo "To view the ChangeLog, please visit $CHANGELOG"
  87.                         if [ -w $0 ]; then
  88.                                 echo "The original file $0 will be overwritten!"
  89.                                 echo -n "If you do not like to proceed, press Ctrl-C now.." ; read inp
  90.                                 cp $SHFILE $0
  91.                                 echo "ALSA-Info script has been updated. Please re-run it."
  92.                                 rm $SHFILE 2>/dev/null
  93.                         else
  94.                                 echo "ALSA-Info script has been downloaded $SHFILE."
  95.                                 echo "Please, re-run it from new location."
  96.                         fi
  97.                         exit
  98.                 fi
  99.         else
  100.                 rm $SHFILE 2>/dev/null
  101.         fi
  102. }
  103.  
  104. cleanup() {
  105.         if [ -n "$TEMPDIR" -a "$KEEP_FILES" != "yes" ]; then
  106.                 rm -rf "$TEMPDIR" 2>/dev/null
  107.         fi
  108.         test -n "$KEEP_OUTPUT" || rm -f "$NFILE"
  109. }
  110.  
  111.  
  112. withaplay() {
  113.         echo "!!Aplay/Arecord output" >> $FILE
  114.         echo "!!--------------------" >> $FILE
  115.         echo "" >> $FILE
  116.         echo "APLAY" >> $FILE
  117.         echo "" >> $FILE
  118.         aplay -l >> $FILE 2>&1
  119.         echo "" >> $FILE
  120.         echo "ARECORD" >> $FILE
  121.         echo "" >> $FILE
  122.         arecord -l >> $FILE 2>&1
  123.         echo "" >> $FILE
  124. }
  125.  
  126. withlsmod() {
  127.         echo "!!All Loaded Modules" >> $FILE
  128.         echo "!!------------------" >> $FILE
  129.         echo "" >> $FILE
  130.         lsmod |awk {'print $1'} >> $FILE
  131.         echo "" >> $FILE
  132.         echo "" >> $FILE
  133. }
  134.  
  135. withamixer() {
  136.         echo "!!Amixer output" >> $FILE
  137.         echo "!!-------------" >> $FILE
  138.         echo "" >> $FILE
  139.         for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ; do
  140.         CARD_NAME=`grep "^ *$i " $TEMPDIR/alsacards.tmp|awk {'print $2'}`
  141.         echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE
  142.         echo "" >>$FILE
  143.         amixer -c$i info>> $FILE 2>&1
  144.         amixer -c$i>> $FILE 2>&1
  145.         echo "" >> $FILE
  146.         done
  147.         echo "" >> $FILE
  148. }
  149.  
  150. withalsactl() {
  151.         echo "!!Alsactl output" >> $FILE
  152.         echo "!!--------------" >> $FILE
  153.         echo "" >> $FILE
  154.         exe=""
  155.         if [ -x /usr/sbin/alsactl ]; then
  156.                 exe="/usr/sbin/alsactl"
  157.         fi
  158.         if [ -x /usr/local/sbin/alsactl ]; then
  159.                 exe="/usr/local/sbin/alsactl"
  160.         fi
  161.         if [ -z "$exe" ]; then
  162.                 exe=`whereis alsactl | cut -d ' ' -f 2`
  163.         fi
  164.         $exe -f $TEMPDIR/alsactl.tmp store
  165.         echo "--startcollapse--" >> $FILE
  166.         cat $TEMPDIR/alsactl.tmp >> $FILE
  167.         echo "--endcollapse--" >> $FILE
  168.         echo "" >> $FILE
  169.         echo "" >> $FILE
  170. }
  171.  
  172. withdevices() {
  173.         echo "!!ALSA Device nodes" >> $FILE
  174.         echo "!!-----------------" >> $FILE
  175.         echo "" >> $FILE
  176.         ls -la /dev/snd/* >> $FILE
  177.         echo "" >> $FILE
  178.         echo "" >> $FILE
  179. }
  180.  
  181. withconfigs() {
  182. if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]] || [[ -e $HOME/.asoundrc.asoundconf ]]
  183. then
  184.         echo "!!ALSA configuration files" >> $FILE
  185.         echo "!!------------------------" >> $FILE
  186.         echo "" >> $FILE
  187.  
  188.         #Check for ~/.asoundrc
  189.         if [[ -e $HOME/.asoundrc ]]
  190.         then
  191.                 echo "!!User specific config file (~/.asoundrc)" >> $FILE
  192.                 echo "" >> $FILE
  193.                 cat $HOME/.asoundrc >> $FILE
  194.                 echo "" >> $FILE
  195.                 echo "" >> $FILE
  196.         fi
  197.         #Check for .asoundrc.asoundconf (seems to be Ubuntu specific)
  198.         if [[ -e $HOME/.asoundrc.asoundconf ]]
  199.         then
  200.                 echo "!!asoundconf-generated config file" >> $FILE
  201.                 echo "" >> $FILE
  202.                 cat $HOME/.asoundrc.asoundconf >> $FILE
  203.                 echo "" >> $FILE
  204.                 echo "" >> $FILE
  205.         fi
  206.         #Check for /etc/asound.conf
  207.         if [[ -e /etc/asound.conf ]]
  208.         then
  209.                 echo "!!System wide config file (/etc/asound.conf)" >> $FILE
  210.                 echo "" >> $FILE
  211.                 cat /etc/asound.conf >> $FILE
  212.                 echo "" >> $FILE
  213.                 echo "" >> $FILE
  214.         fi
  215. fi
  216. }
  217.  
  218. withsysfs() {
  219.     local i f
  220.     local printed=""
  221.     for i in /sys/class/sound/*; do
  222.         case "$i" in
  223.             */hwC?D?)
  224.                 if [ -f $i/init_pin_configs ]; then
  225.                     if [ -z "$printed" ]; then
  226.                         echo "!!Sysfs Files" >> $FILE
  227.                         echo "!!-----------" >> $FILE
  228.                         echo "" >> $FILE
  229.                     fi
  230.                     for f in init_pin_configs driver_pin_configs user_pin_configs init_verbs; do
  231.                         echo "$i/$f:" >> $FILE
  232.                         cat $i/$f >> $FILE
  233.                         echo >> $FILE
  234.                     done
  235.                     printed=yes
  236.                 fi
  237.                 ;;
  238.             esac
  239.     done
  240.     if [ -n "$printed" ]; then
  241.         echo "" >> $FILE
  242.     fi
  243. }
  244.  
  245. withdmesg() {
  246.         echo "!!ALSA/HDA dmesg" >> $FILE
  247.         echo "!!--------------" >> $FILE
  248.         echo "" >> $FILE
  249.         dmesg | grep -C1 -E 'ALSA|HDA|HDMI|sound|hda.codec|hda.intel' >> $FILE
  250.         echo "" >> $FILE
  251.         echo "" >> $FILE
  252. }
  253.  
  254. withall() {
  255.         withdevices
  256.         withconfigs
  257.         withaplay
  258.         withamixer
  259.         withalsactl
  260.         withlsmod
  261.         withsysfs
  262.         withdmesg
  263. }
  264.  
  265. get_alsa_library_version() {
  266.         ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'`
  267.  
  268.         if [ -z "$ALSA_LIB_VERSION" ]; then
  269.                 if [ -f /etc/lsb-release ]; then
  270.                         . /etc/lsb-release
  271.                         case "$DISTRIB_ID" in
  272.                                 Ubuntu)
  273.                                         if which dpkg > /dev/null ; then
  274.                                                 ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -`
  275.                                         fi
  276.  
  277.                                         if [ "$ALSA_LIB_VERSION" = "<none>" ]; then
  278.                                                 ALSA_LIB_VERSION=""
  279.                                         fi
  280.                                         return
  281.                                         ;;
  282.                                 *)
  283.                                         return
  284.                                         ;;
  285.                         esac
  286.                 elif [ -f /etc/debian_version ]; then
  287.                         if which dpkg > /dev/null ; then
  288.                                 ALSA_LIB_VERSION=`dpkg -l libasound2 | tail -1 | awk '{print $3}' | cut -f 1 -d -`
  289.                         fi
  290.  
  291.                         if [ "$ALSA_LIB_VERSION" = "<none>" ]; then
  292.                                 ALSA_LIB_VERSION=""
  293.                         fi
  294.                         return
  295.                 fi
  296.         fi
  297. }
  298.  
  299.  
  300. #Run checks to make sure the programs we need are installed.
  301. LSPCI=$(which lspci 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null);
  302. TPUT=$(which tput 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null);
  303. DIALOG=$(which dialog 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null);
  304.  
  305. #Check to see if sysfs is enabled in the kernel. We'll need this later on
  306. SYSFS=$(mount |grep sysfs|awk {'print $3'});
  307.  
  308. #Check modprobe config files for sound related options
  309. SNDOPTIONS=$(modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p')
  310.  
  311. KEEP_OUTPUT=
  312. NFILE=""
  313.  
  314. PASTEBIN=""
  315. WWWSERVICE="www.alsa-project.org"
  316. WELCOME="yes"
  317. PROCEED="yes"
  318. UPLOAD="ask"
  319. REPEAT=""
  320. while [ -z "$REPEAT" ]; do
  321. REPEAT="no"
  322. case "$1" in
  323.         --update|--help|--about)
  324.                 WELCOME="no"
  325.                 PROCEED="no"
  326.                 ;;
  327.         --upload)
  328.                 UPLOAD="yes"
  329.                 WELCOME="no"
  330.                 ;;
  331.         --no-upload)
  332.                 UPLOAD="no"
  333.                 WELCOME="no"
  334.                 ;;
  335.         --pastebin)
  336.                 PASTEBIN="yes"
  337.                 WWWSERVICE="pastebin"
  338.                 ;;
  339.         --no-dialog)
  340.                 DIALOG=""
  341.                 REPEAT=""
  342.                 shift
  343.                 ;;
  344.         --stdout)
  345.                 DIALOG=""
  346.                 UPLOAD="no"
  347.                 WELCOME="no"
  348.                 TOSTDOUT="yes"
  349.                 ;;
  350. esac
  351. done
  352.  
  353.  
  354. #Script header output.
  355. if [ "$WELCOME" = "yes" ]; then
  356. greeting_message="\
  357.  
  358. This script visits the following commands/files to collect diagnostic
  359. information about your ALSA installation and sound related hardware.
  360.  
  361.   dmesg
  362.   lspci
  363.   lsmod
  364.   aplay
  365.   amixer
  366.   alsactl
  367.   /proc/asound/
  368.   /sys/class/sound/
  369.   ~/.asoundrc (etc.)
  370.  
  371. See '$0 --help' for command line options.
  372. "
  373. if [[ -n "$DIALOG" ]]; then
  374.         dialog  --backtitle "$BGTITLE" \
  375.                 --title "ALSA-Info script v $SCRIPT_VERSION" \
  376.                 --msgbox "$greeting_message" 20 80
  377. else
  378.         echo "ALSA Information Script v $SCRIPT_VERSION"
  379.         echo "--------------------------------"
  380.         echo "$greeting_message"
  381. fi # dialog
  382. fi # WELCOME
  383.  
  384. #Set the output file
  385. TEMPDIR=`mktemp -t -d alsa-info.XXXXXXXXXX` || exit 1
  386. FILE="$TEMPDIR/alsa-info.txt"
  387. if [ -z "$NFILE" ]; then
  388.         NFILE=`mktemp -t alsa-info.txt.XXXXXXXXXX` || exit 1
  389. fi
  390.  
  391. trap cleanup 0
  392.  
  393. if [ "$PROCEED" = "yes" ]; then
  394.  
  395. if [[ -z "$LSPCI" ]]
  396. then
  397.         echo "This script requires lspci. Please install it, and re-run this script."
  398.         exit 0
  399. fi
  400.  
  401. #Fetch the info and store in temp files/variables
  402. DISTRO=`grep -ihs "buntu\|SUSE\|Fedora\|PCLinuxOS\|MEPIS\|Mandriva\|Debian\|Damn\|Sabayon\|Slackware\|KNOPPIX\|Gentoo\|Zenwalk\|Mint\|Kubuntu\|FreeBSD\|Puppy\|Freespire\|Vector\|Dreamlinux\|CentOS\|Arch\|Xandros\|Elive\|SLAX\|Red\|BSD\|KANOTIX\|Nexenta\|Foresight\|GeeXboX\|Frugalware\|64\|SystemRescue\|Novell\|Solaris\|BackTrack\|KateOS\|Pardus" /etc/{issue,*release,*version}`
  403. KERNEL_VERSION=`uname -r`
  404. KERNEL_PROCESSOR=`uname -p`
  405. KERNEL_MACHINE=`uname -m`
  406. KERNEL_OS=`uname -o`
  407. [[ `uname -v |grep SMP`  ]] && KERNEL_SMP="Yes" || KERNEL_SMP="No"
  408. ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'`
  409. get_alsa_library_version
  410. ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}`
  411. VENDOR_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2);}' >$TEMPDIR/vendor_id.tmp`
  412. DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >$TEMPDIR/device_id.tmp`
  413. LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 ))
  414.  
  415. ESDINST=$(which esd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
  416. PAINST=$(which pulseaudio 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
  417. ARTSINST=$(which artsd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
  418. JACKINST=$(which jackd 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
  419. ROARINST=$(which roard 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
  420. DMIDECODE=$(which dmidecode 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null)
  421.  
  422. #Check for DMI data
  423. if [ -d /sys/class/dmi/id ]; then
  424.     # No root privileges are required when using sysfs method
  425.     DMI_SYSTEM_MANUFACTURER=$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null)
  426.     DMI_SYSTEM_PRODUCT_NAME=$(cat /sys/class/dmi/id/product_name 2>/dev/null)
  427.     DMI_SYSTEM_PRODUCT_VERSION=$(cat /sys/class/dmi/id/product_version 2>/dev/null)
  428.     DMI_SYSTEM_FIRMWARE_VERSION=$(cat /sys/class/dmi/id/bios_version 2>/dev/null)
  429. elif [ -x $DMIDECODE ]; then
  430.     DMI_SYSTEM_MANUFACTURER=$($DMIDECODE -s system-manufacturer 2>/dev/null)
  431.     DMI_SYSTEM_PRODUCT_NAME=$($DMIDECODE -s system-product-name 2>/dev/null)
  432.     DMI_SYSTEM_PRODUCT_VERSION=$($DMIDECODE -s system-version 2>/dev/null)
  433.     DMI_SYSTEM_FIRMWARE_VERSION=$($DMIDECODE -s bios-version 2>/dev/null)
  434. fi
  435.  
  436. cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>$TEMPDIR/alsamodules.tmp
  437. cat /proc/asound/cards >$TEMPDIR/alsacards.tmp
  438. lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp
  439.  
  440. #Check for HDA-Intel cards codec#*
  441. cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2> /dev/null
  442.  
  443. #Check for AC97 cards codec
  444. cat /proc/asound/card*/codec97\#0/ac97\#0-0 > $TEMPDIR/alsa-ac97.tmp 2> /dev/null
  445. cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > $TEMPDIR/alsa-ac97-regs.tmp 2> /dev/null
  446.  
  447. #Check for USB mixer setup
  448. cat /proc/asound/card*/usbmixer > $TEMPDIR/alsa-usbmixer.tmp 2> /dev/null
  449.  
  450. #Fetch the info, and put it in $FILE in a nice readable format.
  451. if [[ -z $PASTEBIN ]]; then
  452. echo "upload=true&script=true&cardinfo=" > $FILE
  453. else
  454. echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE
  455. fi
  456. echo "!!################################" >> $FILE
  457. echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE
  458. echo "!!################################" >> $FILE
  459. echo "" >> $FILE
  460. echo "!!Script ran on: `LANG=C TZ=UTC date`" >> $FILE
  461. echo "" >> $FILE
  462. echo "" >> $FILE
  463. echo "!!Linux Distribution" >> $FILE
  464. echo "!!------------------" >> $FILE
  465. echo "" >> $FILE
  466. echo $DISTRO >> $FILE
  467. echo "" >> $FILE
  468. echo "" >> $FILE
  469. echo "!!DMI Information" >> $FILE
  470. echo "!!---------------" >> $FILE
  471. echo "" >> $FILE
  472. echo "Manufacturer:      $DMI_SYSTEM_MANUFACTURER" >> $FILE
  473. echo "Product Name:      $DMI_SYSTEM_PRODUCT_NAME" >> $FILE
  474. echo "Product Version:   $DMI_SYSTEM_PRODUCT_VERSION" >> $FILE
  475. echo "Firmware Version:  $DMI_SYSTEM_FIRMWARE_VERSION" >> $FILE
  476. echo "" >> $FILE
  477. echo "" >> $FILE
  478. echo "!!Kernel Information" >> $FILE
  479. echo "!!------------------" >> $FILE
  480. echo "" >> $FILE
  481. echo "Kernel release:    $KERNEL_VERSION" >> $FILE
  482. echo "Operating System:  $KERNEL_OS" >> $FILE
  483. echo "Architecture:      $KERNEL_MACHINE" >> $FILE
  484. echo "Processor:         $KERNEL_PROCESSOR" >> $FILE
  485. echo "SMP Enabled:       $KERNEL_SMP" >> $FILE
  486. echo "" >> $FILE
  487. echo "" >> $FILE
  488. echo "!!ALSA Version" >> $FILE
  489. echo "!!------------" >> $FILE
  490. echo "" >> $FILE
  491. echo "Driver version:     $ALSA_DRIVER_VERSION" >> $FILE
  492. echo "Library version:    $ALSA_LIB_VERSION" >> $FILE
  493. echo "Utilities version:  $ALSA_UTILS_VERSION" >> $FILE
  494. echo "" >> $FILE
  495. echo "" >> $FILE
  496. echo "!!Loaded ALSA modules" >> $FILE
  497. echo "!!-------------------" >> $FILE
  498. echo "" >> $FILE
  499. cat $TEMPDIR/alsamodules.tmp >> $FILE
  500. echo "" >> $FILE
  501. echo "" >> $FILE
  502. echo "!!Sound Servers on this system" >> $FILE
  503. echo "!!----------------------------" >> $FILE
  504. echo "" >> $FILE
  505. if [[ -n $PAINST ]];then
  506. [[ `pgrep '^(.*/)?pulseaudio$'` ]] && PARUNNING="Yes" || PARUNNING="No"
  507. echo "Pulseaudio:" >> $FILE
  508. echo "      Installed - Yes ($PAINST)" >> $FILE
  509. echo "      Running - $PARUNNING" >> $FILE
  510. echo "" >> $FILE
  511. fi
  512. if [[ -n $ESDINST ]];then
  513. [[ `pgrep '^(.*/)?esd$'` ]] && ESDRUNNING="Yes" || ESDRUNNING="No"
  514. echo "ESound Daemon:" >> $FILE
  515. echo "      Installed - Yes ($ESDINST)" >> $FILE
  516. echo "      Running - $ESDRUNNING" >> $FILE
  517. echo "" >> $FILE
  518. fi
  519. if [[ -n $ARTSINST ]];then
  520. [[ `pgrep '^(.*/)?artsd$'` ]] && ARTSRUNNING="Yes" || ARTSRUNNING="No"
  521. echo "aRts:" >> $FILE
  522. echo "      Installed - Yes ($ARTSINST)" >> $FILE
  523. echo "      Running - $ARTSRUNNING" >> $FILE
  524. echo "" >> $FILE
  525. fi
  526. if [[ -n $JACKINST ]];then
  527. [[ `pgrep '^(.*/)?jackd$'` ]] && JACKRUNNING="Yes" || JACKRUNNING="No"
  528. echo "Jack:" >> $FILE
  529. echo "      Installed - Yes ($JACKINST)" >> $FILE
  530. echo "      Running - $JACKRUNNING" >> $FILE
  531. echo "" >> $FILE
  532. fi
  533. if [[ -n $ROARINST ]];then
  534. [[ `pgrep '^(.*/)?roard$'` ]] && ROARRUNNING="Yes" || ROARRUNNING="No"
  535. echo "RoarAudio:" >> $FILE
  536. echo "      Installed - Yes ($ROARINST)" >> $FILE
  537. echo "      Running - $ROARRUNNING" >> $FILE
  538. echo "" >> $FILE
  539. fi
  540. if [[ -z "$PAINST" && -z "$ESDINST" && -z "$ARTSINST" && -z "$JACKINST" && -z "$ROARINST" ]];then
  541. echo "No sound servers found." >> $FILE
  542. echo "" >> $FILE
  543. fi
  544. echo "" >> $FILE
  545. echo "!!Soundcards recognised by ALSA" >> $FILE
  546. echo "!!-----------------------------" >> $FILE
  547. echo "" >> $FILE
  548. cat $TEMPDIR/alsacards.tmp >> $FILE
  549. echo "" >> $FILE
  550. echo "" >> $FILE
  551. echo "!!PCI Soundcards installed in the system" >> $FILE
  552. echo "!!--------------------------------------" >> $FILE
  553. echo "" >> $FILE
  554. cat $TEMPDIR/lspci.tmp >> $FILE
  555. echo "" >> $FILE
  556. echo "" >> $FILE
  557. echo "!!Advanced information - PCI Vendor/Device/Subsystem ID's" >> $FILE
  558. echo "!!-------------------------------------------------------" >> $FILE
  559. echo "" >> $FILE
  560. lspci -vvn |grep -A1 040[1-3] >> $FILE
  561. echo "" >> $FILE
  562. echo "" >> $FILE
  563.  
  564. if [ "$SNDOPTIONS" ]
  565. then
  566. echo "!!Modprobe options (Sound related)" >> $FILE
  567. echo "!!--------------------------------" >> $FILE
  568. echo "" >> $FILE
  569. modprobe -c|sed -n 's/^options \(snd[-_][^ ]*\)/\1:/p' >> $FILE
  570. echo "" >> $FILE
  571. echo "" >> $FILE
  572. fi
  573.  
  574. if [ -d "$SYSFS" ]
  575. then
  576. echo "!!Loaded sound module options" >> $FILE
  577. echo "!!---------------------------" >> $FILE
  578. echo "" >> $FILE
  579. for mod in `cat /proc/asound/modules|awk {'print $2'}`;do
  580. echo "!!Module: $mod" >> $FILE
  581. for params in `echo $SYSFS/module/$mod/parameters/*`; do
  582.         echo -ne "\t";
  583.         echo "$params : `cat $params`" | sed 's:.*/::';
  584. done >> $FILE
  585. echo "" >> $FILE
  586. done
  587. echo "" >> $FILE
  588. fi
  589.  
  590. if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ]
  591. then
  592.         echo "!!HDA-Intel Codec information" >> $FILE
  593.         echo "!!---------------------------" >> $FILE
  594.         echo "--startcollapse--" >> $FILE
  595.         echo "" >> $FILE
  596.         cat $TEMPDIR/alsa-hda-intel.tmp >> $FILE
  597.         echo "--endcollapse--" >> $FILE
  598.         echo "" >> $FILE
  599.         echo "" >> $FILE
  600. fi
  601.  
  602. if [ -s "$TEMPDIR/alsa-ac97.tmp" ]
  603. then
  604.         echo "!!AC97 Codec information" >> $FILE
  605.         echo "!!----------------------" >> $FILE
  606.         echo "--startcollapse--" >> $FILE
  607.         echo "" >> $FILE
  608.         cat $TEMPDIR/alsa-ac97.tmp >> $FILE
  609.         echo "" >> $FILE
  610.         cat $TEMPDIR/alsa-ac97-regs.tmp >> $FILE
  611.         echo "--endcollapse--" >> $FILE
  612.         echo "" >> $FILE
  613.         echo "" >> $FILE
  614. fi
  615.  
  616. if [ -s "$TEMPDIR/alsa-usbmixer.tmp" ]
  617. then
  618.         echo "!!USB Mixer information" >> $FILE
  619.         echo "!!---------------------" >> $FILE
  620.         echo "--startcollapse--" >> $FILE
  621.         echo "" >> $FILE
  622.         cat $TEMPDIR/alsa-usbmixer.tmp >> $FILE
  623.         echo "--endcollapse--" >> $FILE
  624.         echo "" >> $FILE
  625.         echo "" >> $FILE
  626. fi
  627.  
  628. #If no command line options are specified, then run as though --with-all was specified
  629. if [[ -z "$1" ]]
  630. then
  631.         update
  632.         withall
  633.         pbcheck 
  634. fi
  635.  
  636. fi # proceed
  637.  
  638. #loop through command line arguments, until none are left.
  639. if [[ -n "$1" ]]
  640. then
  641.         until [ -z "$1" ]
  642.         do
  643.         case "$1" in
  644.                 --pastebin)
  645.                         update
  646.                         withall
  647.                         pbcheck
  648.                         ;;
  649.                 --update)
  650.                         update
  651.                         exit
  652.                         ;;
  653.                 --upload)
  654.                         UPLOAD="yes"
  655.                         withall
  656.                         ;;
  657.                 --no-upload)
  658.                         UPLOAD="no"
  659.                         withall
  660.                         ;;
  661.                 --output)
  662.                         shift
  663.                         NFILE="$1"
  664.                         KEEP_OUTPUT="yes"
  665.                         ;;
  666.                 --debug)
  667.                         echo "Debugging enabled. $FILE and $TEMPDIR will not be deleted"
  668.                         KEEP_FILES="yes"
  669.                         echo ""
  670.                         withall
  671.                         ;;
  672.                 --with-all)
  673.                         withall
  674.                         ;;
  675.                 --with-aplay)
  676.                         withaplay
  677.                         ;;
  678.                 --with-amixer)
  679.                         withamixer
  680.                         ;;
  681.                 --with-alsactl)
  682.                         withalsactl
  683.                         ;;
  684.                 --with-devices)
  685.                         withdevices
  686.                         ;;
  687.                 --with-dmesg)
  688.                         withdmesg
  689.                         ;;
  690.                 --with-configs)
  691.                         if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]]
  692.                         then
  693.                                 echo "!!ALSA configuration files" >> $FILE
  694.                                 echo "!!------------------------" >> $FILE
  695.                                 echo "" >> $FILE
  696.  
  697.                                 #Check for ~/.asoundrc
  698.                                 if [[ -e $HOME/.asoundrc ]]
  699.                                 then
  700.                                         echo "!!User specific config file ($HOME/.asoundrc)" >> $FILE
  701.                                         echo "" >> $FILE
  702.                                         cat $HOME/.asoundrc >> $FILE
  703.                                         echo "" >> $FILE
  704.                                         echo "" >> $FILE
  705.                                 fi
  706.  
  707.                                 #Check for /etc/asound.conf
  708.                                 if [[ -e /etc/asound.conf ]]
  709.                                 then
  710.                                         echo "!!System wide config file (/etc/asound.conf)" >> $FILE
  711.                                         echo "" >> $FILE
  712.                                         cat /etc/asound.conf >> $FILE
  713.                                         echo "" >> $FILE
  714.                                         echo "" >> $FILE
  715.                                 fi
  716.                         fi
  717.                         ;;
  718.                 --stdout)
  719.                         UPLOAD="no"
  720.                         withall
  721.                         cat $FILE
  722.                         rm $FILE
  723.                         ;;
  724.                 --about)
  725.                         echo "Written/Tested by the following users of #alsa on irc.freenode.net:"
  726.                         echo ""
  727.                         echo "  wishie - Script author and developer / Testing"
  728.                         echo "  crimsun - Various script ideas / Testing"
  729.                         echo "  gnubien - Various script ideas / Testing"
  730.                         echo "  GrueMaster - HDA Intel specific items / Testing"
  731.                         echo "  olegfink - Script update function"
  732.                         echo "  TheMuso - display to stdout functionality"
  733.                         exit 0
  734.                         ;;
  735.                 *)
  736.                         echo "alsa-info.sh version $SCRIPT_VERSION"
  737.                         echo ""
  738.                         echo "Available options:"
  739.                         echo "  --with-aplay (includes the output of aplay -l)"
  740.                         echo "  --with-amixer (includes the output of amixer)"
  741.                         echo "  --with-alsactl (includes the output of alsactl)"
  742.                         echo "  --with-configs (includes the output of ~/.asoundrc and"
  743.                         echo "      /etc/asound.conf if they exist)"
  744.                         echo "  --with-devices (shows the device nodes in /dev/snd/)"
  745.                         echo "  --with-dmesg (shows the ALSA/HDA kernel messages)"
  746.                         echo ""
  747.                         echo "  --output FILE (specify the file to output for no-upload mode)"
  748.                         echo "  --update (check server for script updates)"
  749.                         echo "  --upload (upload contents to remote server)"
  750.                         echo "  --no-upload (do not upload contents to remote server)"
  751.                         echo "  --pastebin (use http://pastebin.ca) as remote server"
  752.                         echo "      instead www.alsa-project.org"
  753.                         echo "  --stdout (print alsa information to standard output"
  754.                         echo "      instead of a file)"
  755.                         echo "  --about (show some information about the script)"
  756.                         echo "  --debug (will run the script as normal, but will not"
  757.                         echo "       delete $FILE)"
  758.                         exit 0
  759.                         ;;
  760.         esac
  761.         shift 1
  762.         done
  763. fi
  764.  
  765. if [ "$PROCEED" = "no" ]; then
  766.         exit 1
  767. fi
  768.  
  769. if [ "$UPLOAD" = "ask" ]; then
  770.         if [[ -n "$DIALOG" ]]; then
  771.                 dialog --backtitle "$BGTITLE" --title "Information collected" --yes-label " UPLOAD / SHARE " --no-label " SAVE LOCALLY " --defaultno --yesno "\n\nAutomatically upload ALSA information to $WWWSERVICE?" 10 80
  772.                 DIALOG_EXIT_CODE=$?
  773.                 if [ $DIALOG_EXIT_CODE != 0 ]; then
  774.                         UPLOAD="no"
  775.                 else
  776.                         UPLOAD="yes"
  777.                 fi
  778.         else
  779.                 echo -n "Automatically upload ALSA information to $WWWSERVICE? [y/N] : "
  780.                 read -e CONFIRM
  781.                 if [ "$CONFIRM" != "y" ]; then
  782.                         UPLOAD="no"
  783.                 else
  784.                         UPLOAD="yes"
  785.                 fi
  786.         fi
  787.  
  788. fi
  789.  
  790. if [ "$UPLOAD" = "no" ]; then
  791.  
  792.         if [ -z "$TOSTDOUT" ]; then
  793.                 mv -f $FILE $NFILE || exit 1
  794.                 KEEP_OUTPUT="yes"
  795.         fi
  796.  
  797.         if [[ -n $DIALOG ]]
  798.         then
  799.                 if [[ -n $PBERROR ]]; then
  800.                         dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "An error occurred while contacting the $WWWSERVICE.\n Your information was NOT automatically uploaded.\n\nYour ALSA information is in $NFILE" 10 100
  801.                 else
  802.                         dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "\n\nYour ALSA information is in $NFILE" 10 60
  803.                 fi
  804.         else
  805.                 echo
  806.  
  807.                 if [[ -n $PBERROR ]]; then
  808.                         echo "An error occurred while contacting the $WWWSERVICE."
  809.                         echo "Your information was NOT automatically uploaded."
  810.                         echo ""
  811.                         echo "Your ALSA information is in $NFILE"
  812.                         echo ""
  813.                 else
  814.                         if [ -z "$TOSTDOUT" ]; then
  815.                                 echo ""
  816.                                 echo "Your ALSA information is in $NFILE"
  817.                                 echo ""
  818.                         fi
  819.                 fi
  820.         fi
  821.  
  822.         exit
  823.  
  824. fi # UPLOAD
  825.  
  826. #Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it doesnt.
  827. if
  828. WGET=$(which wget 2>/dev/null| sed 's|^[^/]*||' 2>/dev/null); [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ `wget --help |grep post-file` ]]
  829. then
  830.  
  831. if [[ -n $DIALOG ]]
  832. then
  833.  
  834. if [[ -z $PASTEBIN ]]; then
  835.         wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://www.alsa-project.org/cardinfo-db/" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit"
  836.         { for i in 10 20 30 40 50 60 70 80 90; do
  837.                 echo $i
  838.                 sleep 0.2
  839.         done
  840.         echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.alsa-project.org ..." 6 70 0
  841. else
  842.         wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit"
  843.         { for i in 10 20 30 40 50 60 70 80 90; do
  844.                 echo $i
  845.                 sleep 0.2
  846.         done
  847.         echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.pastebin.ca ..." 6 70 0
  848. fi
  849.  
  850. dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100
  851. DIALOG_EXIT_CODE=$?
  852. if [ $DIALOG_EXIT_CODE = 0 ]; then
  853.         grep -v "alsa-info.txt" $FILE >$TEMPDIR/uploaded.txt
  854.         dialog --backtitle "$BGTITLE" --textbox $TEMPDIR/uploaded.txt 0 0
  855. fi
  856.  
  857. clear
  858.  
  859. # no dialog
  860. else
  861.  
  862. if [[ -z $PASTEBIN ]]; then
  863.         echo -n "Uploading information to www.alsa-project.org ... "
  864.         wget -O - --tries=5 --timeout=60 --post-file=$FILE http://www.alsa-project.org/cardinfo-db/ &>$TEMPDIR/wget.tmp &
  865. else
  866.         echo -n "Uploading information to www.pastebin.ca ... "
  867.         wget -O - --tries=5 --timeout=60 --post-file=$FILE http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>$TEMPDIR/wget.tmp &
  868. fi
  869.  
  870. #Progess spinner for wget transfer.
  871. i=1
  872. sp="/-\|"
  873. echo -n ' '
  874. while pgrep wget &>/dev/null
  875. do
  876.         echo -en "\b${sp:i++%${#sp}:1}"
  877. done
  878.  
  879. echo -e "\b Done!"
  880. echo ""
  881.  
  882. fi #dialog
  883.  
  884. #See if tput is available, and use it if it is. 
  885. if [[ -n "$TPUT" ]]
  886. then
  887.         if [[ -z $PASTEBIN ]]; then
  888.                 FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2 ; tput sgr0`
  889.         else
  890.                 FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0`
  891.         fi
  892. else
  893.         if [[ -z $PASTEBIN ]]; then
  894.                 FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2`
  895.         else
  896.                 FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'`
  897.         fi
  898. fi
  899.  
  900. #Output the URL of the uploaded file.   
  901. echo "Your ALSA information is located at $FINAL_URL"
  902. echo "Please inform the person helping you."
  903. echo ""
  904.  
  905. #We couldnt find a suitable wget, so tell the user to upload manually.
  906. else
  907.         mv -f $FILE $NFILE || exit 1
  908.         KEEP_OUTPUT="yes"
  909.         if [[ -z $DIALOG ]]
  910.         then
  911.                 if [[ -z $PASTEBIN ]]; then
  912.                 echo ""
  913.                 echo "Could not automatically upload output to http://www.alsa-project.org"
  914.                 echo "Possible reasons are:"
  915.                 echo "    1. Couldnt find 'wget' in your PATH"
  916.                 echo "    2. Your version of wget is less than 1.8.2"
  917.                 echo ""
  918.                 echo "Please manually upload $NFILE to http://www.alsa-project.org/cardinfo-db/ and submit your post."
  919.                 echo ""
  920.                 else
  921.                 echo ""
  922.                 echo "Could not automatically upload output to http://www.pastebin.ca"
  923.                 echo "Possible reasons are:"
  924.                 echo "    1. Couldnt find 'wget' in your PATH"
  925.                 echo "    2. Your version of wget is less than 1.8.2"
  926.                 echo ""
  927.                 echo "Please manually upload $NFILE to http://www.pastebin.ca/upload.php and submit your post."
  928.                 echo ""
  929.                 fi
  930.         else
  931.                 if [[ -z $PASTEBIN ]]; then
  932.                         dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to http://www.alsa-project.org.\nPossible reasons are:\n\n    1. Couldn't find 'wget' in your PATH\n    2. Your version of wget is less than 1.8.2\n\nPlease manually upload $NFILE to http://www.alsa-project,org/cardinfo-db/ and submit your post." 25 100
  933.                 else
  934.                         dialog --backtitle "$BGTITLE" --msgbox "Could not automatically upload output to http://www.pastebin.ca.\nPossible reasons are:\n\n    1. Couldn't find 'wget' in your PATH\n    2. Your version of wget is less than 1.8.2\n\nPlease manually upload $NFILE to http://www.pastebin.ca/upload.php and submit your post." 25 100
  935.                 fi
  936.         fi
  937. fi

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me