diff --git a/inxi b/inxi index e3a0298..8b528a8 100755 --- a/inxi +++ b/inxi @@ -1,7 +1,7 @@ #!/bin/bash ######################################################################## #### Script Name: inxi -#### version: 1.4.83 +#### version: 1.4.84 #### Date: April 26 2011 ######################################################################## #### SPECIAL THANKS @@ -1005,6 +1005,12 @@ error_handler() 13) error_message="The -t option requires the following extra arguments (no spaces between letters/numbers):\nc m cm [required], for example: -t cm8 OR -t cm OR -t c9\n(numbers: 1-20, > 5 throttled to 5 in irc clients) You entered: $2" ;; + 14) + error_message="failed to write correctly downloaded $SCRIPT_NAME to location $SCRIPT_HOME.\nThis usually means you don't have permission to write to that location, maybe you need to be root?\nThe operation failed with error: $2" + ;; + 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" + ;; *) error_message="error unknown: $@" set -- 99 ;; @@ -1129,20 +1135,24 @@ create_rotate_logfiles() script_self_updater() { eval $LOGFS - local wget_error=0 + local wget_error=0 file_contents='' print_screen_output "Starting $SCRIPT_NAME self updater." print_screen_output "Currently running $SCRIPT_NAME version number: $SCRIPT_VERSION_NUMBER" print_screen_output "Updating $SCRIPT_NAME in $SCRIPT_PATH using $2 as download source..." - # first test if path is good, need to make sure it's good because we're -O overwriting file - wget -q --spider $1$SCRIPT_NAME || wget_error=$? + + file_contents="$( wget -q -O - $1$SCRIPT_NAME )" || wget_error=$? # then do the actual download - if [[ $wget_error -eq 0 ]];then - wget -q -O $SCRIPT_PATH/$SCRIPT_NAME $1$SCRIPT_NAME || wget_error=$? - if [[ $wget_error -eq 0 ]];then + 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 + 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}' ) print_screen_output "Successfully updated to $2 version: $SCRIPT_VERSION_NUMBER" print_screen_output "To run the new version, just start $SCRIPT_NAME again." exit 0 + else + error_handler fi fi # now run the error handlers on any wget failure