Update install.sh after review comments

Change-Id: I8acf9f0fc0115dd8a45027b1d7610b47aa7462d9
This commit is contained in:
Joakim Roubert 2019-09-03 08:12:22 +02:00
parent b86d08a318
commit 0a67557c4a

View File

@ -307,23 +307,31 @@ get_release_version() {
info "Using ${VERSION_K3S} as release" info "Using ${VERSION_K3S} as release"
} }
# --- download hash from github url --- # --- download from github url ---
download_hash() { download() {
HASH_URL=${GITHUB_URL}/download/${VERSION_K3S}/sha256sum-${ARCH}.txt [ $# -eq 2 ] || fatal 'download needs exactly 2 arguments'
info "Downloading hash ${HASH_URL}"
case $DOWNLOADER in case $DOWNLOADER in
curl) curl)
curl -o ${TMP_HASH} -sfL ${HASH_URL} curl -o $1 -sfL $2
;; ;;
wget) wget)
wget -qO ${TMP_HASH} ${HASH_URL} wget -qO $1 $2
;; ;;
*) *)
fatal "Incorrect executable '$DOWNLOADER'" fatal "Incorrect executable '$DOWNLOADER'"
;; ;;
esac esac
# Abort if download command failed # Abort if download command failed
[ $? -eq 0 ] || fatal 'Hash download failed' [ $? -eq 0 ] || fatal 'Hash download failed'
}
# --- download hash from github url ---
download_hash() {
HASH_URL=${GITHUB_URL}/download/${VERSION_K3S}/sha256sum-${ARCH}.txt
info "Downloading hash ${HASH_URL}"
download ${TMP_HASH} ${HASH_URL}
HASH_EXPECTED=`grep " k3s${SUFFIX}$" ${TMP_HASH} | awk '{print $1}'` HASH_EXPECTED=`grep " k3s${SUFFIX}$" ${TMP_HASH} | awk '{print $1}'`
} }
@ -342,19 +350,7 @@ installed_hash_matches() {
download_binary() { download_binary() {
BIN_URL=${GITHUB_URL}/download/${VERSION_K3S}/k3s${SUFFIX} BIN_URL=${GITHUB_URL}/download/${VERSION_K3S}/k3s${SUFFIX}
info "Downloading binary ${BIN_URL}" info "Downloading binary ${BIN_URL}"
case $DOWNLOADER in download ${TMP_BIN} ${BIN_URL}
curl)
curl -o ${TMP_BIN} -sfL ${BIN_URL}
;;
wget)
wget -qO ${TMP_BIN} ${BIN_URL}
;;
*)
fatal "Incorrect executable '$DOWNLOADER'"
;;
esac
# Abort if download command failed
[ $? -eq 0 ] || fatal 'Binary download failed'
} }
# --- verify downloaded binary hash --- # --- verify downloaded binary hash ---