install-ngxblocker: print all curl errors

* also print curl errors besides 404 / timeouts
This commit is contained in:
Stuart Cardall 2017-08-26 20:08:54 +00:00
parent d082f3349c
commit 88179046f5
No known key found for this signature in database
GPG key ID: AEB857F1C891D0C6

View file

@ -92,8 +92,8 @@ check_if_updating() {
} }
download_files() { download_files() {
local url= x= local_file= remote_path= remote_dir=$1 local_dir=$2 tmp= # rm leading whitespace local url= x= local_file= remote_path= remote_dir=$1 local_dir=$2 tmp= retval=
local file_list="$(echo $@ | awk '{$1=$2=""; print $0}' | sed -e 's/^[ \t]*//')" local file_list="$(echo $@ | awk '{$1=$2=""; print $0}' | sed -e 's/^[ \t]*//')" # rm leading whitespace
local col_size=$(( $(longest_str $file_list) + $(echo $remote_dir | wc -m) )) local col_size=$(( $(longest_str $file_list) + $(echo $remote_dir | wc -m) ))
if [ -n "$(check_if_updating $local_dir $file_list)" ]; then if [ -n "$(check_if_updating $local_dir $file_list)" ]; then
@ -118,13 +118,15 @@ download_files() {
tmp=$(mktemp) tmp=$(mktemp)
url=$REPO/$remote_path url=$REPO/$remote_path
curl --fail --connect-timeout 60 --retry 10 --retry-delay 5 -so $tmp $url curl --fail --connect-timeout 60 --retry 10 --retry-delay 5 -so $tmp $url
retval=$?
case "$?" in case "$retval" in
0) printf "...OK\n" 0) printf "...OK\n"
mv $tmp $local_file mv $tmp $local_file
;; ;;
22) printf "...ERROR 404: $url\n";; 22) printf "...ERROR 404: $url\n";;
28) printf "...ERROR TIMEOUT: $url\n";; 28) printf "...ERROR TIMEOUT: $url\n";;
*) printf "...ERROR CURL: ($retval)\n";;
esac esac
else else
printf "%-21s %-$(( $col_size +8 ))s %s\n" \ printf "%-21s %-$(( $col_size +8 ))s %s\n" \