From 501b1b84dccf6bbce45d991992cc54b31e0703ec Mon Sep 17 00:00:00 2001 From: Bensuperpc Date: Fri, 6 Aug 2021 01:17:47 +0200 Subject: [PATCH] Improve curl with retry on error Improve curl with retry on error Signed-off-by: Bensuperpc --- imagefiles/build-and-install-curl.sh | 8 +++++++- imagefiles/build-and-install-git.sh | 7 ++++++- imagefiles/build-and-install-ninja.sh | 8 +++++++- imagefiles/build-and-install-openssh.sh | 8 +++++++- imagefiles/build-and-install-openssl.sh | 16 ++++++++++++++-- imagefiles/install-cmake-binary.sh | 7 ++++++- imagefiles/install-gosu-binary.sh | 14 ++++++++++++-- 7 files changed, 59 insertions(+), 9 deletions(-) diff --git a/imagefiles/build-and-install-curl.sh b/imagefiles/build-and-install-curl.sh index bb347ad..54f14f9 100755 --- a/imagefiles/build-and-install-curl.sh +++ b/imagefiles/build-and-install-curl.sh @@ -29,7 +29,13 @@ function build_curl { local curl_sha256=$2 check_var ${curl_sha256} check_var ${CURL_DOWNLOAD_URL} - curl -fsSLO ${CURL_DOWNLOAD_URL}/${curl_fname}.tar.gz + curl --connect-timeout 30 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 30 \ + -fsSLO ${CURL_DOWNLOAD_URL}/${curl_fname}.tar.gz + check_sha256sum ${curl_fname}.tar.gz ${curl_sha256} tar -zxf ${curl_fname}.tar.gz (cd curl-*/ && do_curl_build) diff --git a/imagefiles/build-and-install-git.sh b/imagefiles/build-and-install-git.sh index 9d1f249..b6237ef 100755 --- a/imagefiles/build-and-install-git.sh +++ b/imagefiles/build-and-install-git.sh @@ -25,7 +25,12 @@ cd /usr/src url="https://mirrors.edge.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz" echo "Downloading $url" -curl -# -LO $url +curl --connect-timeout 20 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 40 \ + -# -LO $url tar xvzf git-${GIT_VERSION}.tar.gz --no-same-owner rm -f git-${GIT_VERSION}.tar.gz diff --git a/imagefiles/build-and-install-ninja.sh b/imagefiles/build-and-install-ninja.sh index a2789dc..be337e3 100755 --- a/imagefiles/build-and-install-ninja.sh +++ b/imagefiles/build-and-install-ninja.sh @@ -27,7 +27,13 @@ done # Download REV=v1.10.2 -curl -# -o ninja.tar.gz -LO https://github.com/ninja-build/ninja/archive/$REV.tar.gz +curl --connect-timeout 30 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 30 \ + -# -o ninja.tar.gz -LO https://github.com/ninja-build/ninja/archive/$REV.tar.gz + mkdir ninja tar -xzvf ./ninja.tar.gz --strip-components=1 -C ./ninja diff --git a/imagefiles/build-and-install-openssh.sh b/imagefiles/build-and-install-openssh.sh index a8b1d9a..4e1a4fa 100755 --- a/imagefiles/build-and-install-openssh.sh +++ b/imagefiles/build-and-install-openssh.sh @@ -5,7 +5,13 @@ set -ex OPENSSH_ROOT=V_8_5_P1 cd /usr/src -curl -LO https://github.com/openssh/openssh-portable/archive/${OPENSSH_ROOT}.tar.gz +curl --connect-timeout 20 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 40 \ + -LO https://github.com/openssh/openssh-portable/archive/${OPENSSH_ROOT}.tar.gz + tar -xvf ${OPENSSH_ROOT}.tar.gz rm -f ${OPENSSH_ROOT}.tar.gz diff --git a/imagefiles/build-and-install-openssl.sh b/imagefiles/build-and-install-openssl.sh index 19a6610..cc5f7b8 100755 --- a/imagefiles/build-and-install-openssl.sh +++ b/imagefiles/build-and-install-openssl.sh @@ -69,7 +69,13 @@ function build_perl { local perl_sha256=$2 check_var ${perl_sha256} check_var ${PERL_DOWNLOAD_URL} - curl -fsSLO ${PERL_DOWNLOAD_URL}/${perl_fname}.tar.gz + curl --connect-timeout 30 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 30 \ + -fsSLO ${PERL_DOWNLOAD_URL}/${perl_fname}.tar.gz + check_sha256sum ${perl_fname}.tar.gz ${perl_sha256} tar -xzf ${perl_fname}.tar.gz (cd ${perl_fname} && do_perl_build) @@ -88,7 +94,13 @@ function build_openssl { local openssl_sha256=$2 check_var ${openssl_sha256} check_var ${OPENSSL_DOWNLOAD_URL} - curl -fsSLO ${OPENSSL_DOWNLOAD_URL}/${openssl_fname}.tar.gz + curl --connect-timeout 30 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 30 \ + -fsSLO ${OPENSSL_DOWNLOAD_URL}/${openssl_fname}.tar.gz + check_sha256sum ${openssl_fname}.tar.gz ${openssl_sha256} tar -xzf ${openssl_fname}.tar.gz (cd ${openssl_fname} && PATH=/opt/perl/bin:${PATH} do_openssl_build) diff --git a/imagefiles/install-cmake-binary.sh b/imagefiles/install-cmake-binary.sh index 9c34087..2e9fb92 100755 --- a/imagefiles/install-cmake-binary.sh +++ b/imagefiles/install-cmake-binary.sh @@ -38,7 +38,12 @@ cd /usr/src CMAKE_ROOT=cmake-${CMAKE_VERSION}-Centos5-${ARCH} url=https://github.com/dockbuild/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_ROOT}.tar.gz echo "Downloading $url" -curl -# -LO $url +curl --connect-timeout 30 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 30 \ + -# -LO $url tar -xzvf ${CMAKE_ROOT}.tar.gz rm -f ${CMAKE_ROOT}.tar.gz diff --git a/imagefiles/install-gosu-binary.sh b/imagefiles/install-gosu-binary.sh index 2668036..2eb082e 100755 --- a/imagefiles/install-gosu-binary.sh +++ b/imagefiles/install-gosu-binary.sh @@ -26,10 +26,20 @@ gpg --keyserver hkp://pgp.key-server.io:80 --recv-keys B42F6819007F00F88E364FD40 gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 echo "Downloading $url" -curl -o /usr/local/bin/gosu -# -SL $url +curl --connect-timeout 30 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 30 \ + -o /usr/local/bin/gosu -# -SL $url echo "Downloading $url_key" -curl -o /usr/local/bin/gosu.asc -# -SL $url_key +curl --connect-timeout 30 \ + --max-time 10 \ + --retry 5 \ + --retry-delay 10 \ + --retry-max-time 30 \ + -o /usr/local/bin/gosu.asc -# -SL $url_key gpg --verify /usr/local/bin/gosu.asc