Last active
October 4, 2020 18:03
-
-
Save leopay/eb560e4407c3f2dba70e7b1b33ce194e to your computer and use it in GitHub Desktop.
get RKE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # This script is inspired by Istio installation script | |
| # | |
| # The script fetches the latest RKE release | |
| # It's derived from ../downloadRKE.sh which is for stable releases but lets | |
| # users do curl -L https://git.io/getLatestRKE | ISTIO_VERSION=1.1.1 sh - | |
| # for instance to change the version fetched. | |
| # This is the latest release candidate (matches ../istio.VERSION after basic | |
| # sanity checks) | |
| OS="$(uname)" | |
| if [ "x${OS}" = "xDarwin" ] ; then | |
| OSEXT="darwin" | |
| else | |
| # TODO we should check more/complain if not likely to work, etc... | |
| OSEXT="linux" | |
| fi | |
| if [ "x${RKE_VERSION}" = "x" ] ; then | |
| RKE_VERSION=$(curl -L -s https://api.github.com/repos/rancher/rke/releases | \ | |
| grep tag_name | sed "s/ *\"tag_name\": *\"\\(.*\\)\",*/\\1/" | \ | |
| grep -v -E "rc[0-9]{1,2}$" | sort -t"." -k 1,1 -k 2,2 -k 3,3 -k 4,4 | tail -n 1) | |
| fi | |
| LOCAL_ARCH=$(uname -m) | |
| if [ "${TARGET_ARCH}" ]; then | |
| LOCAL_ARCH=${TARGET_ARCH} | |
| fi | |
| case "${LOCAL_ARCH}" in | |
| x86_64) | |
| RKE_ARCH=amd64 | |
| ;; | |
| armv8*) | |
| RKE_ARCH=arm64 | |
| ;; | |
| aarch64*) | |
| RKE_ARCH=arm64 | |
| ;; | |
| armv*) | |
| RKE_ARCH=armv7 | |
| ;; | |
| amd64|arm64) | |
| RKE_ARCH=${LOCAL_ARCH} | |
| ;; | |
| *) | |
| echo "This system's architecture, ${LOCAL_ARCH}, isn't supported" | |
| exit 1 | |
| ;; | |
| esac | |
| if [ "x${RKE_VERSION}" = "x" ] ; then | |
| printf "Unable to get latest RKE version. Set RKE_VERSION env var and re-run. For example: export RKE_VERSION=1.1.1" | |
| exit; | |
| fi | |
| NAME="rke_${OSEXT}-${RKE_ARCH}" | |
| URL="https://github.com/rancher/rke/releases/download/${RKE_VERSION}/rke_${OSEXT}-${RKE_ARCH}" | |
| printf "Downloading %s from %s ..." "$NAME" "$URL" | |
| if ! curl -fsLO "$URL" | |
| then | |
| printf "\n\n" | |
| printf "Unable to download RKE %s at this moment!\n" "$RKE_VERSION" | |
| printf "Please verify the version you are trying to download.\n\n" | |
| exit | |
| fi | |
| printf "" | |
| printf "\nRKE %s Download Complete!\n" "$RKE_VERSION" | |
| printf "\n" | |
| printf "RKE has been successfully downloaded \n" | |
| printf "\n" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment