From b83f80372a740277c95ee431c740f78ccc17136e Mon Sep 17 00:00:00 2001 From: Thomas Gleason <72998214+tommatime@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:27:29 -0700 Subject: [PATCH] allow install script to print error on failed binary download (#11335) Signed-off-by: Thomas Gleason --- install.sh | 16 ++++++++++++++-- install.sh.sha256sum | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 358f7dc7cb62..b55d2fd4114e 100755 --- a/install.sh +++ b/install.sh @@ -423,22 +423,34 @@ get_k3s_selinux_version() { # --- download from github url --- download() { [ $# -eq 2 ] || fatal 'download needs exactly 2 arguments' + + # Disable exit-on-error so we can do custom error messages on failure set +e + + # Default to a failure status + status=1 + case $DOWNLOADER in curl) curl -o $1 -sfL $2 + status=$? ;; wget) wget -qO $1 $2 + status=$? ;; *) + # Enable exit-on-error for fatal to execute + set -e fatal "Incorrect executable '$DOWNLOADER'" ;; esac - # Abort if download command failed - [ $? -eq 0 ] || fatal 'Download failed' + # Re-enable exit-on-error set -e + + # Abort if download command failed + [ $status -eq 0 ] || fatal 'Download failed' } # --- download hash from github url --- diff --git a/install.sh.sha256sum b/install.sh.sha256sum index 92b7f5609c88..7d2ffb48ec6a 100644 --- a/install.sh.sha256sum +++ b/install.sh.sha256sum @@ -1 +1 @@ -afacec791f66d92cec11880479c42b9e261912e0d97d3e3a3de21315b6ac49f3 install.sh +f49035378daf603b0dbd458efb4d50608d3499aab3b2e724384dfb5801153669 install.sh