prysm.sh download only option (#5628)

* format srcipt
* download only option
This commit is contained in:
Victor Farazdagi
2020-04-26 21:25:48 +03:00
committed by GitHub
parent 0806807d61
commit d0f3bea8d2

View File

@@ -3,9 +3,11 @@
set -eu
# Use this script to download the latest Prysm release binary.
# Usage: ./prysm.sh PROCESS FLAGS
# Usage: ./prysm.sh PROCESS [--download-only] FLAGS
# PROCESS can be one of beacon-chain or validator.
# FLAGS are the flags or arguments passed to the PROCESS.
# If --download-only flag is passed, binaries are checked for updates,
# downloaded if necessary, no process is started.
# Downloaded binaries are saved to ./dist.
# Use USE_PRYSM_VERSION to specify a specific release version.
# Example: USE_PRYSM_VERSION=v0.3.3 ./prysm.sh beacon-chain
@@ -64,11 +66,11 @@ function get_realpath() {
# Complain if no arguments were provided.
if [ "$#" -lt 1 ]; then
color "31" "Usage: ./prysm.sh PROCESS FLAGS."
color "31" " ./prysm.sh PROCESS --download-only."
color "31" "PROCESS can be beacon-chain, validator, or slasher."
exit 1
fi
readonly wrapper_dir="$(dirname "$(get_realpath "${BASH_SOURCE[0]}")")/dist"
arch=$(uname -m)
arch=${arch/x86_64/amd64}
@@ -118,20 +120,33 @@ function verify() {
return 0
fi
hash shasum 2>/dev/null || { echo >&2 "shasum is not available. Either install it or run with PRYSM_ALLOW_UNVERIFIED_BINARIES=1."; exit 1; }
hash gpg 2>/dev/null || { echo >&2 "gpg is not available. Either install it or run with PRYSM_ALLOW_UNVERIFIED_BINARIES=1."; exit 1; }
hash shasum 2>/dev/null || {
echo >&2 "shasum is not available. Either install it or run with PRYSM_ALLOW_UNVERIFIED_BINARIES=1."
exit 1
}
hash gpg 2>/dev/null || {
echo >&2 "gpg is not available. Either install it or run with PRYSM_ALLOW_UNVERIFIED_BINARIES=1."
exit 1
}
color "37" "Verifying binary integrity."
gpg --list-keys $PRYLABS_SIGNING_KEY >/dev/null 2>&1 || curl --silent https://prysmaticlabs.com/releases/pgp_keys.asc | gpg --import
(cd $wrapper_dir; shasum -a 256 -c "${file}.sha256" || failed_verification)
(cd $wrapper_dir; gpg -u $PRYLABS_SIGNING_KEY --verify "${file}.sig" $file || failed_verification)
(
cd $wrapper_dir
shasum -a 256 -c "${file}.sha256" || failed_verification
)
(
cd $wrapper_dir
gpg -u $PRYLABS_SIGNING_KEY --verify "${file}.sig" $file || failed_verification
)
color "32;1" "Verified ${file} has been signed by Prysmatic Labs."
}
function failed_verification() {
MSG=$(cat <<-END
MSG=$(
cat <<-END
Failed to verify Prysm binary. Please erase downloads in the
dist directory and run this script again. Alternatively, you can use a
A prior version by specifying environment variable USE_PRYSM_VERSION
@@ -208,11 +223,17 @@ case $1 in
*)
color "31" "Usage: ./prysm.sh PROCESS FLAGS."
color "31" " ./prysm.sh PROCESS --download-only."
color "31" "PROCESS can be beacon-chain, validator, or slasher."
;;
esac
verify $process
if [[ $2 == --download-only ]]; then
color "37" "Only download operation is requested, done."
exit 0
fi
color "36" "Starting Prysm $1 ${*:2}"
exec -a "$0" "${process}" "${@:2}"