This repository has been archived on 2024-09-06. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
debian-updater/lib/download.sh
2018-04-27 16:13:59 +02:00

24 lines
578 B
Bash

#!/bin/bash
download (){
#Download function
# $1 : filename
# $2 : url
message "\nDownloading $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
message " \b\b\b\b\b done\n " "ok"
else
message " \b\b\b\b\b error.\n" "ok"
exit 1
fi
else
message "\b\b\b\b\b Error 404\n" "err"
exit 1
fi
}