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 #!/bin/bash
set -e set -e
set -o pipefail
_here=`dirname $(realpath $0)` _here=`dirname $(realpath $0)`
. ${_here}/helpers/apt-download . ${_here}/helpers/apt-download
@ -42,7 +43,7 @@ gpgkey=https://packages.gitlab.com/gpg.key
sslverify=0 sslverify=0
EOF EOF
reposync -c $cfg -d -p ${YUM_PATH} -e $cache_dir reposync -c $cfg -d -p ${YUM_PATH} -e $cache_dir
createrepo --update -v -c $cache_dir -o ${YUM_PATH}/el6 ${YUM_PATH}/el6 createrepo --update -v -c $cache_dir -o ${YUM_PATH}/el6 ${YUM_PATH}/el6
createrepo --update -v -c $cache_dir -o ${YUM_PATH}/el7 ${YUM_PATH}/el7 createrepo --update -v -c $cache_dir -o ${YUM_PATH}/el7 ${YUM_PATH}/el7
rm $cfg rm $cfg

View File

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