PATCH for alsa-info.sh - using mktemp for instead of hardcoded temp dir.
Email subject should explain well enough.
Signature · 2 lines
Happiness is like peeing your pants. Everyone can see it, but only you can feel its warmth
alsa-info.sh +32 -30
@@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION=0.4.41 +SCRIPT_VERSION=0.4.42 CHANGELOG="http://hg.alsa-project.org/alsa/log/tip/alsa-info.sh" #################################################################################
@@ -61,7 +61,7 @@ update() { } cleanup() { - rm -r $TEMPDIR 2>/dev/null + rm -r $ALSAINFODIR 2>/dev/null }
@@ -99,7 +99,7 @@ withamixer() { echo "!!-------------" >> $FILE echo "" >> $FILE for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ; do - CARD_NAME=`grep "^ *$i " /tmp/alsainfo/alsacards.tmp|awk {'print $2'}` + CARD_NAME=`grep "^ *$i " $TEMPDIR/alsacards.tmp|awk {'print $2'}` echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE echo "" >>$FILE amixer -c$i>> $FILE
@@ -122,9 +122,9 @@ withalsactl() { if [ -z "$exe" ]; then exe=`whereis alsactl | cut -d ' ' -f 2` fi - $exe -f /tmp/alsainfo/alsactl.tmp store + $exe -f $TEMPDIR/alsactl.tmp store echo "--startcollapse--" >> $FILE - cat /tmp/alsainfo/alsactl.tmp >> $FILE + cat $TEMPDIR/alsactl.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE
@@ -255,8 +255,9 @@ fi # question fi # question #Set the output file -TEMPDIR="/tmp/alsainfo/" -FILE="/tmp/alsa-info.txt" +ALSAINFODIR="/tmp/alsainfo/" +TEMPDIR=`mktemp -d --tmpdir=$ALSAINFODIR` +FILE="$ALSAINFODIR/alsa-info.txt" if [ "$PROCEED" = "yes" ]; then
@@ -267,6 +268,7 @@ fi fi #Create the temporary work dir. +mkdir $ALSAINFODIR 2>/dev/null mkdir $TEMPDIR 2>/dev/null #Fetch the info and store in temp files/variables
@@ -279,22 +281,22 @@ ALSA_DRIVER_VERSION=`cat /proc/asound/ve ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'` ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'` ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}` -VENDOR_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2);}' >/tmp/alsainfo/vendor_id.tmp` -DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >/tmp/alsainfo/device_id.tmp` +VENDOR_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2);}' >$TEMPDIR/vendor_id.tmp` +DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >$TEMPDIR/device_id.tmp` LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 )) -cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>/tmp/alsainfo/alsamodules.tmp -cat /proc/asound/cards >/tmp/alsainfo/alsacards.tmp -lspci |grep -i "multi\|audio">/tmp/alsainfo/lspci.tmp +cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>$TEMPDIR/alsamodules.tmp +cat /proc/asound/cards >$TEMPDIR/alsacards.tmp +lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp #Check for HDA-Intel cards codec#* -cat /proc/asound/card*/codec\#* > /tmp/alsainfo/alsa-hda-intel.tmp 2> /dev/null +cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2> /dev/null #Check for AC97 cards codec -cat /proc/asound/card*/codec97\#0/ac97\#0-0 > /tmp/alsainfo/alsa-ac97.tmp 2> /dev/null -cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > /tmp/alsainfo/alsa-ac97-regs.tmp 2> /dev/null +cat /proc/asound/card*/codec97\#0/ac97\#0-0 > $TEMPDIR/alsa-ac97.tmp 2> /dev/null +cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > $TEMPDIR/alsa-ac97-regs.tmp 2> /dev/null #Fetch the info, and put it in $FILE in a nice readable format. -echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE +echo "name=$USER&type=33&description=$ALSAINFODIR/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE echo "!!################################" >> $FILE echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE echo "!!################################" >> $FILE
@@ -329,19 +331,19 @@ echo "!!Loaded ALSA modules" >> $FILE echo "!!Loaded ALSA modules" >> $FILE echo "!!-------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/alsamodules.tmp >> $FILE +cat $TEMPDIR/alsamodules.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!Soundcards recognised by ALSA" >> $FILE echo "!!-----------------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/alsacards.tmp >> $FILE +cat $TEMPDIR/alsacards.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!PCI Soundcards installed in the system" >> $FILE echo "!!--------------------------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/lspci.tmp >> $FILE +cat $TEMPDIR/lspci.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!Advanced information - PCI Vendor/Device/Susbsystem ID's" >> $FILE
@@ -374,27 +376,27 @@ echo "" >> $FILE echo "" >> $FILE fi -if [ -s "/tmp/alsainfo/alsa-hda-intel.tmp" ] +if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ] then echo "!!HDA-Intel Codec information" >> $FILE echo "!!---------------------------" >> $FILE echo "--startcollapse--" >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-hda-intel.tmp >> $FILE + cat $TEMPDIR/alsa-hda-intel.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE fi -if [ -s "/tmp/alsainfo/alsa-ac97.tmp" ] +if [ -s "$TEMPDIR/alsa-ac97.tmp" ] then echo "!!AC97 Codec information" >> $FILE echo "!!---------------------------" >> $FILE echo "--startcollapse--" >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-ac97.tmp >> $FILE + cat $TEMPDIR/alsa-ac97.tmp >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-ac97-regs.tmp >> $FILE + cat $TEMPDIR/alsa-ac97-regs.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE
@@ -549,7 +551,7 @@ if [[ -n "$DIALOG" ]] if [[ -n "$DIALOG" ]] then if [[ -z $NOUPLOAD ]]; then - wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>/tmp/alsainfo/wget.tmp || echo "Upload failed; exit" + wget -O - --tries=5 --timeout=60 --post-file=$ALSAINFODIR/alsa-info.txt "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit" { for i in 10 20 30 40 50 60 70 80 90; do echo $i sleep 0.2
@@ -560,7 +562,7 @@ else if [[ -z $NOUPLOAD ]]; then echo -n "Uploading information to www.pastebin.ca ... " - wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>/tmp/alsainfo/wget.tmp & + wget -O - --tries=5 --timeout=60 --post-file=$ALSAINFODIR/alsa-info.txt http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>$TEMPDIR/wget.tmp & fi fi #Progess spinner for wget transfer.
@@ -579,9 +581,9 @@ if [[ -z $NOUPLOAD ]]; then if [[ -z $NOUPLOAD ]]; then if [[ -n "$TPUT" ]] then - FINAL_URL=`tput setaf 1; grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0` + FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0` else - FINAL_URL=`grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'` + FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'` fi fi #Output the URL of the uploaded file.
@@ -603,8 +605,8 @@ then dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 DIALOG_EXIT_CODE=$? if [ $DIALOG_EXIT_CODE = 0 ]; then - grep -v "alsa-info.txt" /tmp/alsa-info.txt >/tmp/alsainfo/uploaded.txt - dialog --backtitle "$BGTITLE" --textbox /tmp/alsainfo/uploaded.txt 0 0 + grep -v "alsa-info.txt" $ALSAINFODIR/alsa-info.txt >$TEMPDIR/uploaded.txt + dialog --backtitle "$BGTITLE" --textbox $TEMPDIR/uploaded.txt 0 0 fi fi fi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
At Thu, 28 Feb 2008 00:36:52 +1000,
Quoted 2 lines · Travis Place
Email subject should explain well enough.
I see some problems with this change:
- it doesn't work if /tmp/alsainfo doesn't exist
- temp directory isn't removed if --no-upload is given
I think you should avoid --tempdir=xxx with mktemp.
The output file name is another question.
IMO, it'd be better to pass the output file name via a command line option, and put it on the home directory (e.g. ~/alsa-info.out) as default rather than /tmp.
Thanks,
Takashi
Quoted 199 lines
Signature · 4 lines
Happiness is like peeing your pants. Everyone can see it, but only you can feel its warmth [2 alsa-info-mktemp.patch <text/x-diff; us-ascii (7bit)>] diff -r e167861901c7 alsa-info.shalsa-info.sh +32
-30@@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION=0.4.41 +SCRIPT_VERSION=0.4.42 CHANGELOG="http://hg.alsa-project.org/alsa/log/tip/alsa-info.sh" #################################################################################@@ -61,7 +61,7 @@ update() { } cleanup() { - rm -r $TEMPDIR 2>/dev/null + rm -r $ALSAINFODIR 2>/dev/null }@@ -99,7 +99,7 @@ withamixer() { echo "!!-------------" >> $FILE echo "" >> $FILE for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ; do - CARD_NAME=`grep "^ *$i " /tmp/alsainfo/alsacards.tmp|awk {'print $2'}` + CARD_NAME=`grep "^ *$i " $TEMPDIR/alsacards.tmp|awk {'print $2'}` echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE echo "" >>$FILE amixer -c$i>> $FILE@@ -122,9 +122,9 @@ withalsactl() { if [ -z "$exe" ]; then exe=`whereis alsactl | cut -d ' ' -f 2` fi - $exe -f /tmp/alsainfo/alsactl.tmp store + $exe -f $TEMPDIR/alsactl.tmp store echo "--startcollapse--" >> $FILE - cat /tmp/alsainfo/alsactl.tmp >> $FILE + cat $TEMPDIR/alsactl.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE@@ -255,8 +255,9 @@ fi # question fi # question #Set the output file -TEMPDIR="/tmp/alsainfo/" -FILE="/tmp/alsa-info.txt" +ALSAINFODIR="/tmp/alsainfo/" +TEMPDIR=`mktemp -d --tmpdir=$ALSAINFODIR` +FILE="$ALSAINFODIR/alsa-info.txt" if [ "$PROCEED" = "yes" ]; then@@ -267,6 +268,7 @@ fi fi #Create the temporary work dir. +mkdir $ALSAINFODIR 2>/dev/null mkdir $TEMPDIR 2>/dev/null #Fetch the info and store in temp files/variables@@ -279,22 +281,22 @@ ALSA_DRIVER_VERSION=`cat /proc/asound/ve ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'} |sed 's/\.$//'` ALSA_LIB_VERSION=`grep VERSION_STR /usr/include/alsa/version.h 2>/dev/null|awk {'print $3'}|sed 's/"//g'` ALSA_UTILS_VERSION=`amixer -v |awk {'print $3'}` -VENDOR_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2);}' >/tmp/alsainfo/vendor_id.tmp` -DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >/tmp/alsainfo/device_id.tmp` +VENDOR_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'print substr($0, 2);}' >$TEMPDIR/vendor_id.tmp` +DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >$TEMPDIR/device_id.tmp` LAST_CARD=$((`grep "]: " /proc/asound/cards | wc -l` - 1 )) -cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>/tmp/alsainfo/alsamodules.tmp -cat /proc/asound/cards >/tmp/alsainfo/alsacards.tmp -lspci |grep -i "multi\|audio">/tmp/alsainfo/lspci.tmp +cat /proc/asound/modules 2>/dev/null|awk {'print $2'}>$TEMPDIR/alsamodules.tmp +cat /proc/asound/cards >$TEMPDIR/alsacards.tmp +lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp #Check for HDA-Intel cards codec#* -cat /proc/asound/card*/codec\#* > /tmp/alsainfo/alsa-hda-intel.tmp 2> /dev/null +cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2> /dev/null #Check for AC97 cards codec -cat /proc/asound/card*/codec97\#0/ac97\#0-0 > /tmp/alsainfo/alsa-ac97.tmp 2> /dev/null -cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > /tmp/alsainfo/alsa-ac97-regs.tmp 2> /dev/null +cat /proc/asound/card*/codec97\#0/ac97\#0-0 > $TEMPDIR/alsa-ac97.tmp 2> /dev/null +cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > $TEMPDIR/alsa-ac97-regs.tmp 2> /dev/null #Fetch the info, and put it in $FILE in a nice readable format. -echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE +echo "name=$USER&type=33&description=$ALSAINFODIR/alsa-info.txt&expiry=&s=Submit+Post&content=" > $FILE echo "!!################################" >> $FILE echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE echo "!!################################" >> $FILE@@ -329,19 +331,19 @@ echo "!!Loaded ALSA modules" >> $FILE echo "!!Loaded ALSA modules" >> $FILE echo "!!-------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/alsamodules.tmp >> $FILE +cat $TEMPDIR/alsamodules.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!Soundcards recognised by ALSA" >> $FILE echo "!!-----------------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/alsacards.tmp >> $FILE +cat $TEMPDIR/alsacards.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!PCI Soundcards installed in the system" >> $FILE echo "!!--------------------------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/lspci.tmp >> $FILE +cat $TEMPDIR/lspci.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!Advanced information - PCI Vendor/Device/Susbsystem ID's" >> $FILE@@ -374,27 +376,27 @@ echo "" >> $FILE echo "" >> $FILE fi -if [ -s "/tmp/alsainfo/alsa-hda-intel.tmp" ] +if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ] then echo "!!HDA-Intel Codec information" >> $FILE echo "!!---------------------------" >> $FILE echo "--startcollapse--" >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-hda-intel.tmp >> $FILE + cat $TEMPDIR/alsa-hda-intel.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE fi -if [ -s "/tmp/alsainfo/alsa-ac97.tmp" ] +if [ -s "$TEMPDIR/alsa-ac97.tmp" ] then echo "!!AC97 Codec information" >> $FILE echo "!!---------------------------" >> $FILE echo "--startcollapse--" >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-ac97.tmp >> $FILE + cat $TEMPDIR/alsa-ac97.tmp >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-ac97-regs.tmp >> $FILE + cat $TEMPDIR/alsa-ac97-regs.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE@@ -549,7 +551,7 @@ if [[ -n "$DIALOG" ]] if [[ -n "$DIALOG" ]] then if [[ -z $NOUPLOAD ]]; then - wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>/tmp/alsainfo/wget.tmp || echo "Upload failed; exit" + wget -O - --tries=5 --timeout=60 --post-file=$ALSAINFODIR/alsa-info.txt "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit" { for i in 10 20 30 40 50 60 70 80 90; do echo $i sleep 0.2@@ -560,7 +562,7 @@ else if [[ -z $NOUPLOAD ]]; then echo -n "Uploading information to www.pastebin.ca ... " - wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>/tmp/alsainfo/wget.tmp & + wget -O - --tries=5 --timeout=60 --post-file=$ALSAINFODIR/alsa-info.txt http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>$TEMPDIR/wget.tmp & fi fi #Progess spinner for wget transfer.@@ -579,9 +581,9 @@ if [[ -z $NOUPLOAD ]]; then if [[ -z $NOUPLOAD ]]; then if [[ -n "$TPUT" ]] then - FINAL_URL=`tput setaf 1; grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0` + FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0` else - FINAL_URL=`grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'` + FINAL_URL=`grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'` fi fi #Output the URL of the uploaded file.@@ -603,8 +605,8 @@ then dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 DIALOG_EXIT_CODE=$? if [ $DIALOG_EXIT_CODE = 0 ]; then - grep -v "alsa-info.txt" /tmp/alsa-info.txt >/tmp/alsainfo/uploaded.txt - dialog --backtitle "$BGTITLE" --textbox /tmp/alsainfo/uploaded.txt 0 0 + grep -v "alsa-info.txt" $ALSAINFODIR/alsa-info.txt >$TEMPDIR/uploaded.txt + dialog --backtitle "$BGTITLE" --textbox $TEMPDIR/uploaded.txt 0 0 fi fi fi[3 <text/plain; us-ascii (7bit)>]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 245 lines · Takashi Iwai
At Thu, 28 Feb 2008 00:36:52 +1000,
Quoted 1 line · Travis Place
Email subject should explain well enough.
I see some problems with this change:
- it doesn't work if/tmp/alsainfodoesn't exist
- temp directory isn't removed if --no-upload is givenI think you should avoid --tempdir=xxx with mktemp.
The output file name is another question.
IMO, it'd be better to pass the output file name via a command line option, and put it on the home directory (e.g. ~/alsa-info.out) as default rather than /tmp.Thanks,
Takashi
Quoted 215 lines
--
Happiness is like peeing your pants. Everyone can see it, but only you can feel its warmth
[2 alsa-info-mktemp.patch <text/x-diff; us-ascii (7bit)>] diff -re167861901c7alsa-info.shalsa-info.sh +1
-1@@ -1,6 +1,6 @@ #!/bin/bash -SCRIPT_VERSION=0.4.41 +SCRIPT_VERSION=0.4.42 CHANGELOG="http://hg.alsa-project.org/alsa/log/tip/alsa-info.sh"#########################################################################
######## @@ -61,7 +61,7 @@update(){
}
cleanup(){alsa-info.sh +1
-1- rm -r $TEMPDIR 2>/dev/null + rm -r $ALSAINFODIR 2>/dev/null }@@ -99,7 +99,7 @@ withamixer() { echo "!!-------------" >> $FILE echo "" >> $FILE for i in `grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1} '` ;do - CARD_NAME=`grep "^ *$i " /tmp/alsainfo/alsacards.tmp|awk {'print
$2'}+ CARD_NAME=grep "^ *$i " $TEMPDIR/alsacards.tmp|awk {'print $2'}`
echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE echo ""Quoted 1 line
Quoted 1 line
$FILE
alsa-info.sh +6
-4amixer -c$i>> $FILE@@ -122,9 +122,9 @@ withalsactl() { if [ -z "$exe" ]; then exe=`whereis alsactl | cut -d ' ' -f 2` fi - $exe -f /tmp/alsainfo/alsactl.tmp store + $exe -f $TEMPDIR/alsactl.tmp store echo "--startcollapse--" >> $FILE - cat /tmp/alsainfo/alsactl.tmp >> $FILE + cat $TEMPDIR/alsactl.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE@@ -255,8 +255,9 @@ fi # question fi # question #Set the output file -TEMPDIR="/tmp/alsainfo/" -FILE="/tmp/alsa-info.txt" +ALSAINFODIR="/tmp/alsainfo/" +TEMPDIR=`mktemp -d --tmpdir=$ALSAINFODIR` +FILE="$ALSAINFODIR/alsa-info.txt" if [ "$PROCEED" = "yes" ]; then@@ -267,6 +268,7 @@ fi fi #Create the temporary work dir. +mkdir $ALSAINFODIR 2>/dev/null mkdir $TEMPDIR 2>/dev/null #Fetch the info and store in temp files/variables@@ -279,22 +281,22 @@ ALSA_DRIVER_VERSION=`cat /proc/asound/ve ALSA_DRIVER_VERSION=`cat /proc/asound/version |head -n1|awk {'print $7'}|sed 's/\.$//'
ALSA_LIB_VERSION=grepVERSION_STR/usr/include/alsa/version.h2>/dev/null|awk {'print $3'}|sed 's/"//g'ALSA_UTILS_VERSION=amixer -v |awk {'print $3'}-VENDOR_ID=lspci -vn |grep 040[1-3] | awk -F':' '{print $3}'|awk {'printsubstr($0, 2);}' >/tmp/alsainfo/vendor_id.tmp-DEVICE_ID=lspci -vn|grep 040[1-3] | awk -F':' '{print $4}'|awk {'print $1'} >/tmp/alsainfo/device_id.tmp` +VENDOR_ID=`lspci -vn |grep 040[1-3] | awkalsa-info.sh +1
-1-F':' '{print $3}'|awk {'print substr($0, 2);}' >$TEMPDIR/vendor_id.tmp` +DEVICE_ID=`lspci -vn |grep 040[1-3] | awk -F':' '{print $4}'|awk {'print$1'} >$TEMPDIR/device_id.tmp
LAST_CARD=$((grep "]: "/proc/asound/cards| wc -l` - 1 ))
-cat/proc/asound/modules2>/dev/null|awk {'print $2'}>/tmp/alsainfo/alsamodules.tmp -cat/proc/asound/cardsQuoted 1 line
/tmp/alsainfo/alsacards.tmpalsa-info.sh +1
-1-lspci |grep -i "multi\|audio">/tmp/alsainfo/lspci.tmp +cat /proc/asound/modules 2>/dev/null|awk {'print$2'}>$TEMPDIR/alsamodules.tmp +cat
/proc/asound/cardsQuoted 1 line
$TEMPDIR/alsacards.tmp
alsa-info.sh +1
-1+lspci |grep -i "multi\|audio">$TEMPDIR/lspci.tmp #Check for HDA-Intel cards codec#* -cat /proc/asound/card*/codec\#* > /tmp/alsainfo/alsa-hda-intel.tmp 2>
/dev/null+cat /proc/asound/card*/codec\#* > $TEMPDIR/alsa-hda-intel.tmp 2>/dev/null#Check for AC97 cards codec
-cat /proc/asound/card*/codec97\#0/ac97\#0-0 >/tmp/alsainfo/alsa-ac97.tmp2>/dev/null-cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs >/tmp/alsainfo/alsa-ac97-regs.tmp2>/dev/null+cat /proc/asound/card*/codec97\#0/ac97\#0-0 > $TEMPDIR/alsa-ac97.tmp 2>/dev/null+cat /proc/asound/card*/codec97\#0/ac97\#0-0+regs > $TEMPDIR/alsa-ac97-regs.tmp 2>/dev/null#Fetch the info, and put it in $FILE in a nice readable format.
-echo "name=$USER&type=33&description=/tmp/alsa-info.txt&expiry=&s=Submit+Post& content=" > $FILE +echo "name=$USER&type=33&description=$ALSAINFODIR/alsa-info.txt&expiry=&s=Subm it+Post&content=" > $FILE echo "!!################################" >> $FILE
echo "!!ALSA Information Script v $SCRIPT_VERSION" >> $FILE echo "!!################################" >> $FILEalsa-info.sh +3
-3@@ -329,19 +331,19 @@ echo "!!Loaded ALSA modules" >> $FILE echo "!!Loaded ALSA modules" >> $FILE echo "!!-------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/alsamodules.tmp >> $FILE +cat $TEMPDIR/alsamodules.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!Soundcards recognised by ALSA" >> $FILE echo "!!-----------------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/alsacards.tmp >> $FILE +cat $TEMPDIR/alsacards.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!PCI Soundcards installed in the system" >> $FILE echo "!!--------------------------------------" >> $FILE echo "" >> $FILE -cat /tmp/alsainfo/lspci.tmp >> $FILE +cat $TEMPDIR/lspci.tmp >> $FILE echo "" >> $FILE echo "" >> $FILE echo "!!Advanced information - PCI Vendor/Device/Susbsystem ID's" >>$FILE @@ -374,27 +376,27 @@ echo "" >> $FILE
echo "" >> $FILE
fialsa-info.sh +5
-6-if [ -s "/tmp/alsainfo/alsa-hda-intel.tmp" ] +if [ -s "$TEMPDIR/alsa-hda-intel.tmp" ] then echo "!!HDA-Intel Codec information" >> $FILE echo "!!---------------------------" >> $FILE echo "--startcollapse--" >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-hda-intel.tmp >> $FILE + cat $TEMPDIR/alsa-hda-intel.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE fi -if [ -s "/tmp/alsainfo/alsa-ac97.tmp" ] +if [ -s "$TEMPDIR/alsa-ac97.tmp" ] then echo "!!AC97 Codec information" >> $FILE echo "!!---------------------------" >> $FILE echo "--startcollapse--" >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-ac97.tmp >> $FILE + cat $TEMPDIR/alsa-ac97.tmp >> $FILE echo "" >> $FILE - cat /tmp/alsainfo/alsa-ac97-regs.tmp >> $FILE + cat $TEMPDIR/alsa-ac97-regs.tmp >> $FILE echo "--endcollapse--" >> $FILE echo "" >> $FILE echo "" >> $FILE@@ -549,7 +551,7 @@ if [[ -n "$DIALOG" ]] if [[ -n "$DIALOG" ]] then if [[ -z $NOUPLOAD ]]; then - wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txt"http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=
blahblah" &>/tmp/alsainfo/wget.tmp || echo "Upload failed; exit" + wget -O
- --tries=5 --timeout=60 --post-file=$ALSAINFODIR/alsa-info.txt "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw= blahblah" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit" { for i in 10 20 30 40 50 60 70 80 90; doalsa-info.sh +0
-1echo $i sleep 0.2@@ -560,7 +562,7 @@ else if [[ -z $NOUPLOAD ]]; then echo -n "Uploading information to www.pastebin.ca ... " - wget -O - --tries=5 --timeout=60 --post-file=/tmp/alsa-info.txthttp://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY
&>/tmp/alsainfo/wget.tmp & + wget -O - --tries=5 --timeout=60
--post-file=$ALSAINFODIR/alsa-info.txt
http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>$TEMPDIR/wget.tmp & fi
fi
#Progess spinner for wget transfer.alsa-info.sh +1
-2@@ -579,9 +581,9 @@ if [[ -z $NOUPLOAD ]]; then if [[ -z $NOUPLOAD ]]; then if [[ -n "$TPUT" ]] then - FINAL_URL=`tput setaf 1; grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0` + FINAL_URL=`tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp |sed -n's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p';tput sgr0` else
alsa-info.sh +0
-1- FINAL_URL=`grep "SUCCESS:" /tmp/alsainfo/wget.tmp |sed -n's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'
+ FINAL_URL=grep
"SUCCESS:" $TEMPDIR/wget.tmp |sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'` fi
fi
#Output the URL of the uploaded file.alsa-info.sh +0
-0@@ -603,8 +605,8 @@ then dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno"Would you like to see the uploaded information?" 5 100 DIALOG_EXIT_CODE=$?
alsa-info.sh +1
-2if [ $DIALOG_EXIT_CODE = 0 ]; then - grep -v "alsa-info.txt" /tmp/alsa-info.txt >/tmp/alsainfo/uploaded.txt - dialog --backtitle "$BGTITLE" --textbox /tmp/alsainfo/uploaded.txt 0 0 + grep -v "alsa-info.txt" $ALSAINFODIR/alsa-info.txtQuoted 1 line
$TEMPDIR/uploaded.txt+ dialog --backtitle "$BGTITLE" --textboxQuoted 8 lines
$TEMPDIR/uploaded.txt0 0 fi
fi
fi
[3 <text/plain; us-ascii (7bit)>]
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 4 lines
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Ahh, crap, errors galore.. im too tired for this.. ill take a proper go at it later.. sorry
Signature · 2 lines
Happiness is like peeing your pants. Everyone can see it, but only you can feel its warmth
A message that is not in the archive (sent off-list or not yet received): [email protected]
At Thu, 28 Feb 2008 02:42:20 +1000,
Quoted 13 lines · Travis Place
Quoted 11 lines · you
At Thu, 28 Feb 2008 00:36:52 +1000,
Quoted 1 line · Travis Place
Email subject should explain well enough.
I see some problems with this change:
- it doesn't work if/tmp/alsainfodoesn't exist
- temp directory isn't removed if --no-upload is givenI think you should avoid --tempdir=xxx with mktemp.
Quoted 7 lines
Quoted 4 lines
The output file name is another question.
IMO, it'd be better to pass the output file name via a command line option, and put it on the home directory (e.g. ~/alsa-info.out) as default rather than /tmp.well,
/tmp/alsainfo/will exist, as we create it in the script.. its $ALSAINFODIR .. the temp dir is then created inside that.
It's created too late. And, if we create /tmp/alsainfo, there is little merit of mktemp as /tmp/alsainfo could be a symlink. Simply TEMPDIR should be what mktemp creates, and clean it up after quitting.
Quoted 3 lines
As for not being cleaned up, if --no-upload is specified, ill check that now..
Also, is outputting the resulting file to ~/ wise ?
It's at least safer than the fixed filename on /tmp. I don't insist on this option, though.
Anyway, --output-file=xxx would be a nice addition.
Quoted 2 lines
should this occur even if the result is uploaded, or only on --no-upload ?
I don't think it's needed when uploaded (except for any debugging reason).
Just my $0.02.
thanks,
Takashi
Quoted 47 lines · Takashi Iwai
At Thu, 28 Feb 2008 02:42:20 +1000,
Quoted 12 lines · Travis Place
Quoted 11 lines · you
At Thu, 28 Feb 2008 00:36:52 +1000,
Quoted 1 line · Travis Place
Email subject should explain well enough.
I see some problems with this change:
- it doesn't work if/tmp/alsainfodoesn't exist
- temp directory isn't removed if --no-upload is givenI think you should avoid --tempdir=xxx with mktemp.
Quoted 7 lines
Quoted 4 lines
The output file name is another question.
IMO, it'd be better to pass the output file name via a command line option, and put it on the home directory (e.g. ~/alsa-info.out) as default rather than /tmp.well,
/tmp/alsainfo/will exist, as we create it in the script.. its $ALSAINFODIR .. the temp dir is then created inside that.It's created too late. And, if we create
/tmp/alsainfo, there is little merit of mktemp as/tmp/alsainfocould be a symlink. Simply TEMPDIR should be what mktemp creates, and clean it up after quitting.Quoted 4 lines
As for not being cleaned up, if --no-upload is specified, ill check that now..
Also, is outputting the resulting file to ~/ wise ?
It's at least safer than the fixed filename on /tmp. I don't insist on this option, though.
Anyway, --output-file=xxx would be a nice addition.
Quoted 2 lines
should this occur even if the result is uploaded, or only on --no-upload ?
I don't think it's needed when uploaded (except for any debugging reason).
Just my $0.02.
Quoted 7 lines
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
I will impement this all correctly tomorrow.. why do i always decide to tinker at about 3am ? heh
Nice to see other people adding to the script too..
Signature · 2 lines
Happiness is like peeing your pants. Everyone can see it, but only you can feel its warmth