From ddd325858016cc8569de9cb4aa2d3144dcf003c4 Mon Sep 17 00:00:00 2001 From: inxi-svn Date: Tue, 26 Apr 2011 19:24:19 +0000 Subject: [PATCH] added failed download due to file corruption error and tweaked regex --- inxi | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/inxi b/inxi index 8b528a8..153e65a 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 1.4.84 +#### version: 1.4.85 #### Date: April 26 2011 ######################################################################## #### SPECIAL THANKS @@ -1011,6 +1011,9 @@ error_handler() 15) error_message="failed set execute permissions on $SCRIPT_NAME at location $SCRIPT_HOME.\nThis usually means you don't have permission to set permissions on files there, maybe you need to be root?\nThe operation failed with error: $2" ;; + 16) + error_message="$SCRIPT_NAME downloaded but the file data is corrupted. Purged data and using current version." + ;; *) error_message="error unknown: $@" set -- 99 ;; @@ -1144,7 +1147,7 @@ script_self_updater() # then do the actual download if [[ $wget_error -eq 0 ]];then # make sure the whole file got downloaded and is in the variable - if [[ -n $( grep '###**EOF**###' <<< "$file_contents" ) ]];then + if [[ -n $( grep '###\*\*EOF\*\*###' <<< "$file_contents" ) ]];then echo "$file_contents" > $SCRIPT_PATH/$SCRIPT_NAME || error_handler 14 "$?" chmod +x $SCRIPT_PATH/$SCRIPT_NAME || error_handler 15 "$?" SCRIPT_VERSION_NUMBER=$( grep -im 1 'version:' $SCRIPT_PATH/$SCRIPT_NAME | gawk '{print $3}' ) @@ -1152,7 +1155,7 @@ script_self_updater() print_screen_output "To run the new version, just start $SCRIPT_NAME again." exit 0 else - error_handler + error_handler 16 fi fi # now run the error handlers on any wget failure