diff options
-rwxr-xr-x | test/security/k8s/tools/get_ranchercli.sh | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/test/security/k8s/tools/get_ranchercli.sh b/test/security/k8s/tools/get_ranchercli.sh index d36a94edb..a5295fb17 100755 --- a/test/security/k8s/tools/get_ranchercli.sh +++ b/test/security/k8s/tools/get_ranchercli.sh @@ -1,13 +1,28 @@ #!/usr/bin/env bash +# Constants +DEFAULT_VERSION='v0.6.12' +DEFAULT_ARCH='amd64' +DEFAULT_SYSTEM='linux' + +# Variables +VERSION="${1:-$DEFAULT_VERSION}" +ARCH="${2:-$DEFAULT_ARCH}" +SYSTEM="${3:-$DEFAULT_SYSTEM}" + +ARCHIVE="rancher-${SYSTEM}-${ARCHITECTURE}-${VERSION}.tar.gz" +DIRECTORY="rancher-${VERSION}" +URL="https://releases.rancher.com/cli/${VERSION}/${ARCHIVE}" + + # Prerequistes -wget https://releases.rancher.com/cli/v0.6.12/rancher-linux-amd64-v0.6.12.tar.gz -tar xf rancher-linux-amd64-v0.6.12.tar.gz +wget "$URL" +tar xf "$ARCHIVE" # Installation echo '# Privilege elevation needed to move Rancher CLI binary to /usr/local/bin' -sudo mv rancher-v0.6.12/rancher /usr/local/bin/ +sudo mv "${DIRECTORY}/rancher" /usr/local/bin/ # Cleanup -rmdir rancher-v0.6.12/ -rm rancher-linux-amd64-v0.6.12.tar.gz +rmdir "$DIRECTORY" +rm "$ARCHIVE" |