blob: 8ffbc5f583c8f893d6641a4ec9eb5d0315aac5e6 [file] [log] [blame]
Pawel Wieczoreka65cd1c2019-06-27 17:49:21 +02001#!/usr/bin/env bash
2
Pawel Wieczorekf8a1ad02019-07-24 14:19:46 +02003#
4# @file test/security/k8s/tools/casablanca/get_ranchercli.sh
5# @author Pawel Wieczorek <p.wieczorek2@samsung.com>
6# @brief Utility for obtaining Rancher CLI tool
7#
8
9# Dependencies:
10# wget
11# tar
12# coreutils
13#
14# Privileges:
15# Script expects to be run with administrative privileges for accessing /usr/local/bin
16#
17# Usage:
18# # ./get_ranchercli.sh [VERSION [ARCH [SYSTEM]]]
19#
20
Pawel Wieczorek60fef552019-06-27 18:11:16 +020021# Constants
22DEFAULT_VERSION='v0.6.12'
23DEFAULT_ARCH='amd64'
24DEFAULT_SYSTEM='linux'
25
26# Variables
27VERSION="${1:-$DEFAULT_VERSION}"
28ARCH="${2:-$DEFAULT_ARCH}"
29SYSTEM="${3:-$DEFAULT_SYSTEM}"
30
Pawel Wieczorek03c59352019-07-15 16:24:58 +020031ARCHIVE="rancher-${SYSTEM}-${ARCH}-${VERSION}.tar.gz"
Pawel Wieczorek60fef552019-06-27 18:11:16 +020032DIRECTORY="rancher-${VERSION}"
33URL="https://releases.rancher.com/cli/${VERSION}/${ARCHIVE}"
34
35
Pawel Wieczoreka65cd1c2019-06-27 17:49:21 +020036# Prerequistes
Pawel Wieczorek60fef552019-06-27 18:11:16 +020037wget "$URL"
38tar xf "$ARCHIVE"
Pawel Wieczoreka65cd1c2019-06-27 17:49:21 +020039
40# Installation
Pawel Wieczorekf8a1ad02019-07-24 14:19:46 +020041mv "${DIRECTORY}/rancher" /usr/local/bin/
Pawel Wieczoreka65cd1c2019-06-27 17:49:21 +020042
43# Cleanup
Pawel Wieczorek60fef552019-06-27 18:11:16 +020044rmdir "$DIRECTORY"
45rm "$ARCHIVE"