added timeout to apt-download

This commit is contained in:
bigeagle 2016-05-09 18:04:14 +08:00
parent f6d9201e7d
commit dda03ab110
No known key found for this signature in database
GPG Key ID: 9171A4571C27920A
2 changed files with 6 additions and 3 deletions

View File

@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -o pipefail
_here=`dirname $(realpath $0)`
. ${_here}/helpers/apt-download

View File

@ -1,14 +1,15 @@
#!/bin/bash
set -e
set -o pipefail
LOADED_APT_DOWNLOAD="yes"
function check-and-download() {
remote_file=$1
local_file=$2
wget -q --spider ${remote_file}
timeout -s INT 60 wget -q --spider ${remote_file}
if [ $? -eq 0 ]; then
echo "downloading ${remote_file}"
wget -q -N -O ${local_file} ${remote_file}
timeout -s INT 300 wget -q -N -O ${local_file} ${remote_file}
return
fi
return 0
@ -25,6 +26,7 @@ function apt-download-binary() {
echo "Destination directory is empty, cannot continue"
return 1
fi
echo "Started mirroring ${base_url} ${dist}, ${repo}, ${arch}!"
dest_dir="${dest_base_dir}/dists/${dist}"
[ ! -d "$dest_dir" ] && mkdir -p "$dest_dir"