download() stop script if 404
This commit is contained in:
parent
9ef4d922f5
commit
8a62ce69df
1 changed files with 58 additions and 51 deletions
7
init.sh
7
init.sh
|
@ -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 (){
|
||||
|
|
Reference in a new issue