From 31ddd25ffd2731872c781502dcd9315e493c0bc9 Mon Sep 17 00:00:00 2001 From: Vladimir Safonkin Date: Thu, 31 Mar 2022 14:24:07 +0200 Subject: [PATCH] Update installer scripts --- externals/install-dotnet.sh | 51 +++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/externals/install-dotnet.sh b/externals/install-dotnet.sh index f80355e..975737a 100755 --- a/externals/install-dotnet.sh +++ b/externals/install-dotnet.sh @@ -637,11 +637,13 @@ get_specific_product_version() { if machine_has "curl" then - specific_product_version=$(curl -s --fail "${download_link}${feed_credential}" 2>&1) - if [ $? = 0 ]; then + if ! specific_product_version=$(curl -s --fail "${download_link}${feed_credential}" 2>&1); then + continue + else echo "${specific_product_version//[$'\t\r\n']}" return 0 fi + elif machine_has "wget" then specific_product_version=$(wget -qO- "${download_link}${feed_credential}" 2>&1) @@ -921,9 +923,15 @@ get_http_header_wget() { local remote_path="$1" local disable_feed_credential="$2" local wget_options="-q -S --spider --tries 5 " - # Store options that aren't supported on all wget implementations separately. - local wget_options_extra="--waitretry 2 --connect-timeout 15 " - local wget_result='' + + local wget_options_extra='' + + # Test for options that aren't supported on all wget implementations. + if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then + wget_options_extra="--waitretry 2 --connect-timeout 15 " + else + say "wget extra options are unavailable for this environment" + fi remote_path_with_credential="$remote_path" if [ "$disable_feed_credential" = false ]; then @@ -931,15 +939,8 @@ get_http_header_wget() { fi wget $wget_options $wget_options_extra "$remote_path_with_credential" 2>&1 - wget_result=$? - if [[ $wget_result == 2 ]]; then - # Parsing of the command has failed. Exclude potentially unrecognized options and retry. - wget $wget_options "$remote_path_with_credential" 2>&1 - return $? - fi - - return $wget_result + return $? } # args: @@ -1030,10 +1031,17 @@ downloadwget() { # Append feed_credential as late as possible before calling wget to avoid logging feed_credential local remote_path_with_credential="${remote_path}${feed_credential}" local wget_options="--tries 20 " - # Store options that aren't supported on all wget implementations separately. - local wget_options_extra="--waitretry 2 --connect-timeout 15 " + + local wget_options_extra='' local wget_result='' + # Test for options that aren't supported on all wget implementations. + if [[ $(wget -h 2>&1 | grep -E 'waitretry|connect-timeout') ]]; then + wget_options_extra="--waitretry 2 --connect-timeout 15 " + else + say "wget extra options are unavailable for this environment" + fi + if [ -z "$out_path" ]; then wget -q $wget_options $wget_options_extra -O - "$remote_path_with_credential" 2>&1 wget_result=$? @@ -1042,17 +1050,6 @@ downloadwget() { wget_result=$? fi - if [[ $wget_result == 2 ]]; then - # Parsing of the command has failed. Exclude potentially unrecognized options and retry. - if [ -z "$out_path" ]; then - wget -q $wget_options -O - "$remote_path_with_credential" 2>&1 - wget_result=$? - else - wget $wget_options -O "$out_path" "$remote_path_with_credential" 2>&1 - wget_result=$? - fi - fi - if [[ $wget_result != 0 ]]; then local disable_feed_credential=false local response=$(get_http_header_wget $remote_path $disable_feed_credential) @@ -1652,4 +1649,4 @@ fi say "Note that the script does not resolve dependencies during installation." say "To check the list of dependencies, go to https://docs.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section." -say "Installation finished successfully." \ No newline at end of file +say "Installation finished successfully."