From 72886986ea095498415ce5947f31891e7f332707 Mon Sep 17 00:00:00 2001 From: ahadda5 Date: Wed, 7 Jul 2021 03:34:42 +0400 Subject: [PATCH] prysm scripts should not save 404 pages (#9072) * first .sh attempt, checked curl * removed echo * more meaningful msg * prysm.bat changes * do not save 404, using -f and grep * removed extra line Co-authored-by: Raul Jordan --- prysm.bat | 24 ++++++++++++++++++++---- prysm.sh | 18 +++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/prysm.bat b/prysm.bat index c369dedc81..06fd6640c2 100644 --- a/prysm.bat +++ b/prysm.bat @@ -67,10 +67,15 @@ if [%1]==[beacon-chain] ( echo Beacon chain is up to date. ) else ( echo Downloading beacon chain %prysm_version% to %BEACON_CHAIN_REAL% %reason% - curl -L https://prysmaticlabs.com/releases/beacon-chain-%prysm_version%-%system%-%arch% -o %BEACON_CHAIN_REAL% - curl --silent -L https://prysmaticlabs.com/releases/beacon-chain-%prysm_version%-%system%-%arch%.sha256 -o %wrapper_dir%\beacon-chain-%prysm_version%-%system%-%arch%.sha256 + for /f "delims=" %%i in ('curl --silent -w "%%{http_code}" -L https://prysmaticlabs.com/releases/beacon-chain-%prysm_version%-%system%-%arch% -o %BEACON_CHAIN_REAL%') do set http=%%i + if %http%==400 ( + echo No prysm beacon chain found for %prysm_version% + exit \b 1 + ) + curl --silent -L https://prysmaticlabs.com/releases/beacon-chain-%prysm_version%-%system%-%arch%.sha256 -o %wrapper_dir%\beacon-chain-%prysm_version%-%system%-%arch%.sha256 curl --silent -L https://prysmaticlabs.com/releases/beacon-chain-%prysm_version%-%system%-%arch%.sig -o %wrapper_dir%\beacon-chain-%prysm_version%-%system%-%arch%.sig ) + goto startprocess ) if [%1]==[validator] ( @@ -78,10 +83,15 @@ if [%1]==[validator] ( echo Validator is up to date. ) else ( echo Downloading validator %prysm_version% to %VALIDATOR_REAL% %reason% - curl -L https://prysmaticlabs.com/releases/validator-%prysm_version%-%system%-%arch% -o %VALIDATOR_REAL% + for /f "delims=" %%i in ('curl --silent -w "%%{http_code}" -L https://prysmaticlabs.com/releases/validator-%prysm_version%-%system%-%arch% -o %VALIDATOR_REAL%') do set http=%%i + if %http%==400 ( + echo No prysm validator found for %prysm_version% + exit \b 1 + ) curl --silent -L https://prysmaticlabs.com/releases/validator-%prysm_version%-%system%-%arch%.sha256 -o %wrapper_dir%\validator-%prysm_version%-%system%-%arch%.sha256 curl --silent -L https://prysmaticlabs.com/releases/validator-%prysm_version%-%system%-%arch%.sig -o %wrapper_dir%\validator-%prysm_version%-%system%-%arch%.sig ) + goto startprocess ) if [%1]==[client-stats] ( @@ -89,10 +99,15 @@ if [%1]==[client-stats] ( echo Client-stats is up to date. ) else ( echo Downloading client-stats %prysm_version% to %CLIENT_STATS_REAL% %reason% - curl -L https://prysmaticlabs.com/releases/client-stats-%prysm_version%-%system%-%arch% -o %CLIENT_STATS_REAL% + for /f "delims=" %%i in ('curl --silent -w "%%{http_code}" -L https://prysmaticlabs.com/releases/client-stats-%prysm_version%-%system%-%arch% -o %CLIENT_STATS_REAL%') do set http=%%i + if %http%==400 ( + echo No prysm client stats found for %prysm_version% + exit \b 1 + ) curl --silent -L https://prysmaticlabs.com/releases/client-stats-%prysm_version%-%system%-%arch%.sha256 -o %wrapper_dir%\client-stats-%prysm_version%-%system%-%arch%.sha256 curl --silent -L https://prysmaticlabs.com/releases/client-stats-%prysm_version%-%system%-%arch%.sig -o %wrapper_dir%\client-stats-%prysm_version%-%system%-%arch%.sig ) + goto startprocess ) if [%1]==[slasher] ( @@ -100,6 +115,7 @@ if [%1]==[slasher] ( exit /b 1 ) +:startprocess if [%1]==[beacon-chain] ( set process=%BEACON_CHAIN_REAL%) if [%1]==[validator] ( set process=%VALIDATOR_REAL%) if [%1]==[client-stats] ( set process=%CLIENT_STATS_REAL%) diff --git a/prysm.sh b/prysm.sh index a1b8f3bd1a..16ef79a06c 100755 --- a/prysm.sh +++ b/prysm.sh @@ -181,7 +181,11 @@ if [[ $1 == beacon-chain ]]; then if [[ ! -x $BEACON_CHAIN_REAL ]]; then color "34" "Downloading beacon chain@${prysm_version} to ${BEACON_CHAIN_REAL} (${reason})" file=beacon-chain-${prysm_version}-${system}-${arch} - curl -L "https://prysmaticlabs.com/releases/${file}" -o "$BEACON_CHAIN_REAL" + res=$(curl -w '%{http_code}\n' -f -L "https://prysmaticlabs.com/releases/${file}" -o "$BEACON_CHAIN_REAL" | ( grep 404 || true ) ) + if [[ $res == 404 ]];then + echo "No prysm beacon chain found for ${prysm_version},(${file}) exit" + exit 1 + fi curl --silent -L "https://prysmaticlabs.com/releases/${file}.sha256" -o "${wrapper_dir}/${file}.sha256" curl --silent -L "https://prysmaticlabs.com/releases/${file}.sig" -o "${wrapper_dir}/${file}.sig" chmod +x "$BEACON_CHAIN_REAL" @@ -195,7 +199,11 @@ if [[ $1 == validator ]]; then color "34" "Downloading validator@${prysm_version} to ${VALIDATOR_REAL} (${reason})" file=validator-${prysm_version}-${system}-${arch} - curl -L "https://prysmaticlabs.com/releases/${file}" -o "$VALIDATOR_REAL" + res=$(curl -w '%{http_code}\n' -f -L "https://prysmaticlabs.com/releases/${file}" -o "$VALIDATOR_REAL" | ( grep 404 || true ) ) + if [[ $res == 404 ]];then + echo "No prysm validator found for ${prysm_version}, (${file}) exit" + exit 1 + fi curl --silent -L "https://prysmaticlabs.com/releases/${file}.sha256" -o "${wrapper_dir}/${file}.sha256" curl --silent -L "https://prysmaticlabs.com/releases/${file}.sig" -o "${wrapper_dir}/${file}.sig" chmod +x "$VALIDATOR_REAL" @@ -209,7 +217,11 @@ if [[ $1 == client-stats ]]; then color "34" "Downloading client-stats@${prysm_version} to ${CLIENT_STATS_REAL} (${reason})" file=client-stats-${prysm_version}-${system}-${arch} - curl -L "https://prysmaticlabs.com/releases/${file}" -o "$CLIENT_STATS_REAL" + res=$(curl -w '%{http_code}\n' -f -L "https://prysmaticlabs.com/releases/${file}" -o "$CLIENT_STATS_REAL" | ( grep 404 || true ) ) + if [[ $res == 404 ]];then + echo "No prysm client stats found for ${prysm_version},(${file}) exit" + exit 1 + fi curl --silent -L "https://prysmaticlabs.com/releases/${file}.sha256" -o "${wrapper_dir}/${file}.sha256" curl --silent -L "https://prysmaticlabs.com/releases/${file}.sig" -o "${wrapper_dir}/${file}.sig" chmod +x "$CLIENT_STATS_REAL"