Skip to contentSkip to conversation

alsa-info.sh: Improve output and fix file upload issues

PATCH Applied David Ward 2 participants 13 messages Dec 21, 2019 – Jan 7, 2020

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore

David Ward

author
#0 lore raw

cover alsa-info.sh: Improve output and fix file upload issues

David Ward (11):
alsa-info.sh: Consolidate PCI device output
alsa-info.sh: Read from /proc/modules and sort the result alsa-info.sh: Simplify iteration over cards when calling amixer alsa-info.sh: Use existing function to print ALSA configuration files alsa-info.sh: Exit script after writing information to stdout alsa-info.sh: Replace gauge with infobox for upload dialog alsa-info.sh: Remove progress spinner during upload without dialog alsa-info.sh: Condense nested commands for file upload alsa-info.sh: Condense nested commands for formatting upload result alsa-info.sh: Perform test for wget earlier
alsa-info.sh: Warn after actual upload failure; do not ping server

 alsa-info/alsa-info.sh | 251 ++++++++++++++++++-------------------------------
 1 file changed, 90 insertions(+), 161 deletions(-)
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#1 lore raw

PATCH 1/11 alsa-info.sh: Consolidate PCI device output

Include numeric IDs and subsystem info in the PCI device output, without placing them in a separate section.

---
 alsa-info/alsa-info.sh | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
alsa-info/alsa-info.sh +3 -7
index cf7ad89..8fc6997 100755
@@ -455,7 +455,9 @@ fi
 cat /proc/asound/modules 2>/dev/null | awk '{ print $2 }' > $TEMPDIR/alsamodules.tmp
 cat /proc/asound/cards > $TEMPDIR/alsacards.tmp
 if [[ ! -z "$LSPCI" ]]; then
-  lspci | grep -i "multi\|audio">$TEMPDIR/lspci.tmp
+	for class in 0401 0402 0403; do
+		lspci -vvnn -d "::$class" | sed -n '/^[^\t]/,+1p'
+	done > $TEMPDIR/lspci.tmp
 fi
 
 #Check for HDA-Intel cards codec#*
@@ -585,12 +587,6 @@ echo "" >> $FILE
 cat $TEMPDIR/lspci.tmp >> $FILE
 echo "" >> $FILE
 echo "" >> $FILE
-echo "!!Advanced information - PCI Vendor/Device/Subsystem ID's" >> $FILE
-echo "!!-------------------------------------------------------" >> $FILE
-echo "" >> $FILE
-lspci -vvn |grep -A1 040[1-3] >> $FILE
-echo "" >> $FILE
-echo "" >> $FILE
 fi
 
 if [ "$SNDOPTIONS" ]
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#2 lore raw

PATCH 2/11 alsa-info.sh: Read from /proc/modules and sort the result

In reply to David Ward

Sorting the list of loaded modules makes it much easier to compare two alsa-info.txt files, even if they are both from the same system (since the order actually changes after each reboot).

lsmod just formats the contents of /proc/modules. After this script calls lsmod, it strips everything but module names from the output. This same result can be obtained just as easily by reading directly from /proc/modules; then there is no need to remove the header line printed by lsmod before sorting the output.

---
 alsa-info/alsa-info.sh | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
alsa-info/alsa-info.sh +4 -5
index 8fc6997..ed1d9e2 100755
@@ -35,7 +35,7 @@ BGTITLE="ALSA-Info v $SCRIPT_VERSION"
 PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
 
 WGET=$(which wget 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null)
-REQUIRES="mktemp grep pgrep whereis ping awk date uname cat dmesg amixer alsactl"
+REQUIRES="mktemp grep pgrep whereis ping awk date uname cat sort dmesg amixer alsactl"
 
 #
 # Define some simple functions
@@ -131,11 +131,11 @@ withaplay() {
 	echo "" >> $FILE
 }
 
-withlsmod() {
+withmodules() {
 	echo "!!All Loaded Modules" >> $FILE
 	echo "!!------------------" >> $FILE
 	echo "" >> $FILE
-	lsmod | awk '{print $1}' >> $FILE
+	awk '{print $1}' < /proc/modules | sort >> $FILE
 	echo "" >> $FILE
 	echo "" >> $FILE
 }
@@ -254,7 +254,7 @@ withall() {
 	withaplay
 	withamixer
 	withalsactl
-	withlsmod
+	withmodules
 	withsysfs
 	withdmesg
 	WITHALL="no"
@@ -366,7 +366,6 @@ information about your ALSA installation and sound related hardware.
 
   dmesg
   lspci
-  lsmod
   aplay
   amixer
   alsactl
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#3 lore raw

PATCH 3/11 alsa-info.sh: Simplify iteration over cards when calling amixer

In reply to David Ward

Read card names directly from individual procfs files, and pass them to amixer using the '-c' option.

---
 alsa-info/alsa-info.sh | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
alsa-info/alsa-info.sh +5 -5
index ed1d9e2..e1067d4 100755
@@ -144,12 +144,12 @@ withamixer() {
         echo "!!Amixer output" >> $FILE
         echo "!!-------------" >> $FILE
         echo "" >> $FILE
-	for i in $(grep "]: " /proc/asound/cards | awk -F ' ' '{ print $1 }') ; do
-		CARD_NAME=$(grep "^ *$i " $TEMPDIR/alsacards.tmp | awk '{ print $2 }')
-		echo "!!-------Mixer controls for card $i $CARD_NAME]" >> $FILE
+	for f in /proc/asound/card*/id; do
+		[ -f "$f" ] && read -r CARD_NAME < "$f" || continue
+		echo "!!-------Mixer controls for card $CARD_NAME" >> $FILE
 		echo "" >>$FILE
-		amixer -c$i info >> $FILE 2>&1
-		amixer -c$i >> $FILE 2>&1
+		amixer -c "$CARD_NAME" info >> $FILE 2>&1
+		amixer -c "$CARD_NAME" >> $FILE 2>&1
 		echo "" >> $FILE
 	done
 	echo "" >> $FILE
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#4 lore raw

PATCH 4/11 alsa-info.sh: Use existing function to print ALSA configuration files

In reply to David Ward
---
 alsa-info/alsa-info.sh | 27 +--------------------------
 1 file changed, 1 insertion(+), 26 deletions(-)
alsa-info/alsa-info.sh +1 -26
index e1067d4..bf353de 100755
@@ -710,33 +710,8 @@ if [ -n "$1" ]; then
 			WITHALL="no"
 			;;
 		--with-configs)
+			withconfigs
 			WITHALL="no"
-			if [[ -e $HOME/.asoundrc ]] || [[ -e /etc/asound.conf ]]
-			then
-				echo "!!ALSA configuration files" >> $FILE
-				echo "!!------------------------" >> $FILE
-				echo "" >> $FILE
-
-				#Check for ~/.asoundrc
-				if [[ -e $HOME/.asoundrc ]]
-				then
-					echo "!!User specific config file ($HOME/.asoundrc)" >> $FILE
-					echo "" >> $FILE
-					cat $HOME/.asoundrc >> $FILE
-					echo "" >> $FILE
-					echo "" >> $FILE
-				fi
-
-				#Check for /etc/asound.conf
-				if [[ -e /etc/asound.conf ]]
-				then
-					echo "!!System wide config file (/etc/asound.conf)" >> $FILE
-					echo "" >> $FILE
-					cat /etc/asound.conf >> $FILE
-					echo "" >> $FILE
-					echo "" >> $FILE
-				fi
-			fi
 			;;
 		--stdout)
 			UPLOAD="no"
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#5 lore raw

PATCH 5/11 alsa-info.sh: Exit script after writing information to stdout

In reply to David Ward

The '--stdout' option is mutually exclusive with uploading the file.

---
 alsa-info/alsa-info.sh | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
alsa-info/alsa-info.sh +6 -11
index bf353de..372d7ae 100755
@@ -349,9 +349,7 @@ case "$1" in
 		;;
 	--stdout)
 		DIALOG=""
-		UPLOAD="no"
 		WELCOME="no"
-		TOSTDOUT="yes"
 		;;
 esac
 done
@@ -720,6 +718,7 @@ if [ -n "$1" ]; then
 			fi
 			cat $FILE
 			rm $FILE
+			exit
 			;;
 		--about)
 			echo "Written/Tested by the following users of #alsa on irc.freenode.net:"
@@ -793,10 +792,8 @@ fi
 
 if [ "$UPLOAD" = "no" ]; then
 
-	if [ -z "$TOSTDOUT" ]; then
-		mv -f $FILE $NFILE || exit 1
-		KEEP_OUTPUT="yes"
-	fi
+	mv -f $FILE $NFILE || exit 1
+	KEEP_OUTPUT="yes"
 
 	if [[ -n $DIALOG ]]
 	then
@@ -815,11 +812,9 @@ if [ "$UPLOAD" = "no" ]; then
 			echo "Your ALSA information is in $NFILE"
 			echo ""
 		else
-			if [ -z "$TOSTDOUT" ]; then
-				echo ""
-				echo "Your ALSA information is in $NFILE"
-				echo ""
-			fi
+			echo ""
+			echo "Your ALSA information is in $NFILE"
+			echo ""
 		fi
 	fi
 
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#6 lore raw

PATCH 6/11 alsa-info.sh: Replace gauge with infobox for upload dialog

In reply to David Ward

The gauge did not actually show the upload progress; in fact, the dialog did not even appear until after the upload was completed.

Use an infobox instead, which will be displayed while wget runs.

---
 alsa-info/alsa-info.sh | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
alsa-info/alsa-info.sh +2 -10
index 372d7ae..a02864d 100755
@@ -830,19 +830,11 @@ if [[ -n $DIALOG ]]
 then
 
 if [[ -z $PASTEBIN ]]; then
+	dialog --backtitle "$BGTITLE" --infobox "Uploading information to www.alsa-project.org ..." 6 70
 	wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://www.alsa-project.org/cardinfo-db/" &>$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
-	done
-	echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.alsa-project.org ..." 6 70 0
 else
+	dialog --backtitle "$BGTITLE" --infobox "Uploading information to www.pastebin.ca ..." 6 70
 	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"
-	{ for i in 10 20 30 40 50 60 70 80 90; do
-		echo $i
-		sleep 0.2
-	done
-	echo; } |dialog --backtitle "$BGTITLE" --guage "Uploading information to www.pastebin.ca ..." 6 70 0
 fi
 
 dialog --backtitle "$BGTITLE" --title "Information uploaded" --yesno "Would you like to see the uploaded information?" 5 100 
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#7 lore raw

PATCH 7/11 alsa-info.sh: Remove progress spinner during upload without dialog

In reply to David Ward

The spinner did not actually provide information about the status of the file upload, and caused other problems: it would repeatedly spawn new pgrep processes (without a delay between them), and it blocked the script if any wget process was running on the system.

---
 alsa-info/alsa-info.sh | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
alsa-info/alsa-info.sh +1 -10
index a02864d..9bc8c38 100755
@@ -857,16 +857,7 @@ else
 	wget -O - --tries=5 --timeout=60 --post-file=$FILE http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>$TEMPDIR/wget.tmp &
 fi
 
-#Progess spinner for wget transfer.
-i=1
-sp="/-\|"
-echo -n ' '
-while pgrep wget &>/dev/null
-do
-	echo -en "\b${sp:i++%${#sp}:1}"
-done
-
-echo -e "\b Done!"
+echo -e " Done!"
 echo ""
 
 fi # dialog
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#8 lore raw

PATCH 8/11 alsa-info.sh: Condense nested commands for file upload

In reply to David Ward
---
 alsa-info/alsa-info.sh | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
alsa-info/alsa-info.sh +6 -10
index 9bc8c38..7560b0d 100755
@@ -828,15 +828,19 @@ then
 
 if [[ -n $DIALOG ]]
 then
+	dialog --backtitle "$BGTITLE" --infobox "Uploading information to $WWWSERVICE ..." 6 70
+else
+	echo -n "Uploading information to $WWWSERVICE ..."
+fi
 
 if [[ -z $PASTEBIN ]]; then
-	dialog --backtitle "$BGTITLE" --infobox "Uploading information to www.alsa-project.org ..." 6 70
 	wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://www.alsa-project.org/cardinfo-db/" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit"
 else
-	dialog --backtitle "$BGTITLE" --infobox "Uploading information to www.pastebin.ca ..." 6 70
 	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"
 fi
 
+if [ -n "$DIALOG" ]; 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
@@ -849,14 +853,6 @@ clear
 # no dialog
 else
 
-if [[ -z $PASTEBIN ]]; then
-	echo -n "Uploading information to www.alsa-project.org ... " 
-	wget -O - --tries=5 --timeout=60 --post-file=$FILE http://www.alsa-project.org/cardinfo-db/ &>$TEMPDIR/wget.tmp &
-else
-	echo -n "Uploading information to www.pastebin.ca ... " 
-	wget -O - --tries=5 --timeout=60 --post-file=$FILE http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY &>$TEMPDIR/wget.tmp &
-fi
-
 echo -e " Done!"
 echo ""
 
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#9 lore raw

PATCH 9/11 alsa-info.sh: Condense nested commands for formatting upload result

In reply to David Ward
---
 alsa-info/alsa-info.sh | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
alsa-info/alsa-info.sh +8 -12
index 7560b0d..8b4745b 100755
@@ -858,19 +858,15 @@ echo ""
 
 fi # dialog
 
-# See if tput is available, and use it if it is.
-if [ -n "$TPUT" ]; then
-	if [[ -z $PASTEBIN ]]; then
-		FINAL_URL=$(tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2 ; tput sgr0)
-	else
-		FINAL_URL=$(tput setaf 1; grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p'; tput sgr0)
-	fi
+if [ -z "$PASTEBIN" ]; then
+	FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2)
 else
-	if [[ -z $PASTEBIN ]]; then
-		FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | cut -d ' ' -f 2)
-	else
-		FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p')
-	fi
+	FINAL_URL=$(grep "SUCCESS:" $TEMPDIR/wget.tmp | sed -n 's/.*\:\([0-9]\+\).*/http:\/\/pastebin.ca\/\1/p')
+fi
+
+# See if tput is available, and use it if it is.
+if [ -x "$TPUT" ]; then
+	FINAL_URL=$(tput setaf 1; printf '%s' "$FINAL_URL"; tput sgr0)
 fi
 
 # Output the URL of the uploaded file.	
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#10 lore raw

PATCH 10/11 alsa-info.sh: Perform test for wget earlier

In reply to David Ward

If wget is not present, do not ask about uploading the information.

---
 alsa-info/alsa-info.sh | 73 ++++++++++++++++++++++++--------------------------
 1 file changed, 35 insertions(+), 38 deletions(-)
alsa-info/alsa-info.sh +35 -38
index 8b4745b..399d662 100755
@@ -769,6 +769,41 @@ if [ -z "$WITHALL" ]; then
 	withall
 fi
 
+# Check if wget is installed, and supports --post-file.
+if ! wget --help 2>/dev/null | grep -q post-file; then
+	# We couldn't find a suitable wget. If --upload was passed, tell the user to upload manually.
+	if [ "$UPLOAD" != "yes" ]; then
+		:
+	elif [ -n "$DIALOG" ]; then
+		if [ -z "$PASTEBIN" ]; then
+			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
+		else
+			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
+		fi
+	else
+		if [ -z "$PASTEBIN" ]; then
+			echo ""
+			echo "Could not automatically upload output to http://www.alsa-project.org"
+			echo "Possible reasons are:"
+			echo "    1. Couldn't find 'wget' in your PATH"
+			echo "    2. Your version of wget is less than 1.8.2"
+			echo ""
+			echo "Please manually upload $NFILE to http://www.alsa-project.org/cardinfo-db/ and submit your post."
+			echo ""
+		else
+			echo ""
+			echo "Could not automatically upload output to http://www.pastebin.ca"
+			echo "Possible reasons are:"
+			echo "    1. Couldn't find 'wget' in your PATH"
+			echo "    2. Your version of wget is less than 1.8.2"
+			echo ""
+			echo "Please manually upload $NFILE to http://www.pastebin.ca/upload.php and submit your post."
+			echo ""
+		fi
+	fi
+	UPLOAD="no"
+fi
+
 if [ "$UPLOAD" = "ask" ]; then
 	if [ -n "$DIALOG" ]; then
 		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
@@ -822,10 +857,6 @@ if [ "$UPLOAD" = "no" ]; then
 
 fi # UPLOAD
 
-# Test that wget is installed, and supports --post-file. Upload $FILE if it does, and prompt user to upload file if it does not.
-if [[ -n "${WGET}" ]] && [[ -x "${WGET}" ]] && [[ $(wget --help | grep post-file) ]]
-then
-
 if [[ -n $DIALOG ]]
 then
 	dialog --backtitle "$BGTITLE" --infobox "Uploading information to $WWWSERVICE ..." 6 70
@@ -873,37 +904,3 @@ fi
 echo "Your ALSA information is located at $FINAL_URL"
 echo "Please inform the person helping you."
 echo ""
-
-# We couldnt find a suitable wget, so tell the user to upload manually.
-else
-	mv -f $FILE $NFILE || exit 1
-	KEEP_OUTPUT="yes"
-	if [[ -z $DIALOG ]]
-	then
-		if [[ -z $PASTEBIN ]]; then
-		echo ""
-		echo "Could not automatically upload output to http://www.alsa-project.org"
-		echo "Possible reasons are:"
-		echo "    1. Couldnt find 'wget' in your PATH"
-		echo "    2. Your version of wget is less than 1.8.2"
-		echo ""
-		echo "Please manually upload $NFILE to http://www.alsa-project.org/cardinfo-db/ and submit your post."
-		echo ""
-		else
-		echo ""
-		echo "Could not automatically upload output to http://www.pastebin.ca"
-		echo "Possible reasons are:"
-		echo "    1. Couldnt find 'wget' in your PATH"
-		echo "    2. Your version of wget is less than 1.8.2"
-		echo ""
-		echo "Please manually upload $NFILE to http://www.pastebin.ca/upload.php and submit your post."
-		echo ""
-		fi
-	else
-		if [[ -z $PASTEBIN ]]; then
-			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
-		else
-			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
-		fi
-	fi
-fi
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
author
#11 lore raw

PATCH 11/11 alsa-info.sh: Warn after actual upload failure; do not ping server

In reply to David Ward

Check the return value of wget to determine if the upload actually failed. If so, display the message about upload failure, then exit.

Do not ping the web server; the result does not indicate whether a file upload will succeed or not.

---
 alsa-info/alsa-info.sh | 58 ++++++++++++++++++++++----------------------------
 1 file changed, 25 insertions(+), 33 deletions(-)
alsa-info/alsa-info.sh +25 -33
index 399d662..7bae30a 100755
@@ -35,22 +35,12 @@ BGTITLE="ALSA-Info v $SCRIPT_VERSION"
 PASTEBINKEY="C9cRIO8m/9y8Cs0nVs0FraRx7U0pHsuc"
 
 WGET=$(which wget 2>/dev/null | sed 's|^[^/]*||' 2>/dev/null)
-REQUIRES="mktemp grep pgrep whereis ping awk date uname cat sort dmesg amixer alsactl"
+REQUIRES="mktemp grep pgrep whereis awk date uname cat sort dmesg amixer alsactl"
 
 #
 # Define some simple functions
 #
 
-pbcheck() {
-	[[ $UPLOAD = "no" ]] && return
-
-	if [[ -z $PASTEBIN ]]; then
-		[[ $(ping -c1 www.alsa-project.org) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes"
-	else
-		[[ $(ping -c1 www.pastebin.ca) ]] || KEEP_FILES="yes" UPLOAD="no" PBERROR="yes"
-	fi
-}
-
 update() {
 	test -z "$WGET" -o ! -x "$WGET" && return
 
@@ -650,7 +640,6 @@ fi
 #If no command line options are specified, then run as though --with-all was specified
 if [ -z "$1" ]; then
 	update
-	pbcheck	
 fi
 
 fi # proceed
@@ -662,7 +651,6 @@ if [ -n "$1" ]; then
 	case "$1" in
 		--pastebin)
 		        update
-        		pbcheck
 			;;
 		--update)
 			update
@@ -832,25 +820,11 @@ if [ "$UPLOAD" = "no" ]; then
 
 	if [[ -n $DIALOG ]]
 	then
-		if [[ -n $PBERROR ]]; then
-			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
-		else
-			dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "\n\nYour ALSA information is in $NFILE" 10 60
-		fi
+		dialog --backtitle "$BGTITLE" --title "Information collected" --msgbox "\n\nYour ALSA information is in $NFILE" 10 60
 	else
-		echo
-
-		if [[ -n $PBERROR ]]; then
-			echo "An error occurred while contacting the $WWWSERVICE."
-			echo "Your information was NOT automatically uploaded."
-			echo ""
-			echo "Your ALSA information is in $NFILE"
-			echo ""
-		else
-			echo ""
-			echo "Your ALSA information is in $NFILE"
-			echo ""
-		fi
+		echo ""
+		echo "Your ALSA information is in $NFILE"
+		echo ""
 	fi
 
 	exit
@@ -865,9 +839,27 @@ else
 fi
 
 if [[ -z $PASTEBIN ]]; then
-	wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://www.alsa-project.org/cardinfo-db/" &>$TEMPDIR/wget.tmp || echo "Upload failed; exit"
+	wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://www.alsa-project.org/cardinfo-db/" &>$TEMPDIR/wget.tmp
 else
-	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"
+	wget -O - --tries=5 --timeout=60 --post-file=$FILE "http://pastebin.ca/quiet-paste.php?api=$PASTEBINKEY&encrypt=t&encryptpw=blahblah" &>$TEMPDIR/wget.tmp
+fi
+
+if [ $? -ne 0 ]; then
+	mv -f $FILE $NFILE || exit 1
+	KEEP_OUTPUT="yes"
+
+	if [ -n "$DIALOG" ]; then
+		dialog --backtitle "$BGTITLE" --title "Information not uploaded" --msgbox "An error occurred while contacting $WWWSERVICE.\n Your information was NOT automatically uploaded.\n\nYour ALSA information is in $NFILE" 10 100
+	else
+		echo ""
+		echo "An error occurred while contacting $WWWSERVICE."
+		echo "Your information was NOT automatically uploaded."
+		echo ""
+		echo "Your ALSA information is in $NFILE"
+		echo ""
+	fi
+
+	exit
 fi
 
 if [ -n "$DIALOG" ]; then
Signature · 6 lines
1.8.3.1

_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Applied
#12 lore raw
In reply to David Ward
Quoted 13 lines · David Ward

David Ward (11):
alsa-info.sh: Consolidate PCI device output
alsa-info.sh: Read from /proc/modules and sort the result alsa-info.sh: Simplify iteration over cards when calling amixer alsa-info.sh: Use existing function to print ALSA configuration files alsa-info.sh: Exit script after writing information to stdout alsa-info.sh: Replace gauge with infobox for upload dialog alsa-info.sh: Remove progress spinner during upload without dialog alsa-info.sh: Condense nested commands for file upload alsa-info.sh: Condense nested commands for formatting upload result alsa-info.sh: Perform test for wget earlier
alsa-info.sh: Warn after actual upload failure; do not ping server

Applied all patches now. Thanks!

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel