download() stop script if 404

This commit is contained in:
Yorick Barbanneau 2017-10-03 13:50:06 +02:00
parent 9ef4d922f5
commit 8a62ce69df

View file

@ -118,6 +118,9 @@ download (){
# $2 : url
# $3 : 1 if abort download if file exist
printf "Downloading %s : " "$1"
http_response=$(wget --spider --server-response $2/$1 2>&1 | grep HTTP/ | tail -1 | awk ' { printf $2 }')
if [ $http_response -eq 200 ]
then
wget -c --progress=dot $2/$1 2>&1 | grep --line-buffered "[0-9]\{1,3\}%" -o | awk '{printf ("\b\b\b\b%4s", $1)}'
if [ $? -eq 0 ]
then
@ -126,6 +129,10 @@ download (){
printf " error, exiting.\n"
exit 1
fi
else
printf "Error 404 : file not found, exiting\n"
exit 1
fi
}
process_conf_file (){