diff --git a/images/linux/scripts/helpers/install.sh b/images/linux/scripts/helpers/install.sh index 55aa7816..61faedc2 100644 --- a/images/linux/scripts/helpers/install.sh +++ b/images/linux/scripts/helpers/install.sh @@ -19,16 +19,24 @@ download_with_retries() { local COMMAND="curl $URL -4 -sL -o '$DEST/$NAME' -w '%{http_code}'" fi + # Save current errexit state and disable it to prevent unexpected exit on error + if echo $SHELLOPTS | grep '\(^\|:\)errexit\(:\|$\)' > /dev/null; + then + local ERR_EXIT_ENABLED=true + else + local ERR_EXIT_ENABLED=false + fi + set +e + echo "Downloading '$URL' to '${DEST}/${NAME}'..." retries=20 interval=30 while [ $retries -gt 0 ]; do ((retries--)) - # Temporary disable exit on error to retry on non-zero exit code - set +e + test "$ERR_EXIT_ENABLED" = true && set +e http_code=$(eval $COMMAND) exit_code=$? - set -e + test "$ERR_EXIT_ENABLED" = true && set -e if [ $http_code -eq 200 ] && [ $exit_code -eq 0 ]; then echo "Download completed" return 0 diff --git a/images/linux/scripts/installers/firefox.sh b/images/linux/scripts/installers/firefox.sh index 5008d962..39416cc9 100644 --- a/images/linux/scripts/installers/firefox.sh +++ b/images/linux/scripts/installers/firefox.sh @@ -26,7 +26,6 @@ echo 'pref("intl.locale.requested","en_US");' >> "/usr/lib/firefox/browser/defau # Download and unpack latest release of geckodriver downloadUrl=$(get_github_package_download_url "mozilla/geckodriver" "test(\"linux64.tar.gz$\")") -echo "Downloading geckodriver $downloadUrl" download_with_retries "$downloadUrl" "/tmp" geckodriver.tar.gz GECKODRIVER_DIR="/usr/local/share/gecko_driver" diff --git a/images/linux/scripts/installers/pypy.sh b/images/linux/scripts/installers/pypy.sh index 32cb2ffc..5c8e373c 100644 --- a/images/linux/scripts/installers/pypy.sh +++ b/images/linux/scripts/installers/pypy.sh @@ -13,7 +13,7 @@ function InstallPyPy PACKAGE_URL=$1 PACKAGE_TAR_NAME=$(echo $PACKAGE_URL | awk -F/ '{print $NF}') - echo "Downloading tar archive '$PACKAGE_TAR_NAME' - '$PACKAGE_URL'" + echo "Downloading tar archive '$PACKAGE_TAR_NAME'" PACKAGE_TAR_TEMP_PATH="/tmp/$PACKAGE_TAR_NAME" download_with_retries $PACKAGE_URL "/tmp" $PACKAGE_TAR_NAME