Pawel Wieczorek | a65cd1c | 2019-06-27 17:49:21 +0200 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Pawel Wieczorek | f8a1ad0 | 2019-07-24 14:19:46 +0200 | [diff] [blame] | 3 | # |
| 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 Wieczorek | 60fef55 | 2019-06-27 18:11:16 +0200 | [diff] [blame] | 21 | # Constants |
| 22 | DEFAULT_VERSION='v0.6.12' |
| 23 | DEFAULT_ARCH='amd64' |
| 24 | DEFAULT_SYSTEM='linux' |
| 25 | |
| 26 | # Variables |
| 27 | VERSION="${1:-$DEFAULT_VERSION}" |
| 28 | ARCH="${2:-$DEFAULT_ARCH}" |
| 29 | SYSTEM="${3:-$DEFAULT_SYSTEM}" |
| 30 | |
Pawel Wieczorek | 03c5935 | 2019-07-15 16:24:58 +0200 | [diff] [blame] | 31 | ARCHIVE="rancher-${SYSTEM}-${ARCH}-${VERSION}.tar.gz" |
Pawel Wieczorek | 60fef55 | 2019-06-27 18:11:16 +0200 | [diff] [blame] | 32 | DIRECTORY="rancher-${VERSION}" |
| 33 | URL="https://releases.rancher.com/cli/${VERSION}/${ARCHIVE}" |
| 34 | |
| 35 | |
Pawel Wieczorek | a65cd1c | 2019-06-27 17:49:21 +0200 | [diff] [blame] | 36 | # Prerequistes |
Pawel Wieczorek | 60fef55 | 2019-06-27 18:11:16 +0200 | [diff] [blame] | 37 | wget "$URL" |
| 38 | tar xf "$ARCHIVE" |
Pawel Wieczorek | a65cd1c | 2019-06-27 17:49:21 +0200 | [diff] [blame] | 39 | |
| 40 | # Installation |
Pawel Wieczorek | f8a1ad0 | 2019-07-24 14:19:46 +0200 | [diff] [blame] | 41 | mv "${DIRECTORY}/rancher" /usr/local/bin/ |
Pawel Wieczorek | a65cd1c | 2019-06-27 17:49:21 +0200 | [diff] [blame] | 42 | |
| 43 | # Cleanup |
Pawel Wieczorek | 60fef55 | 2019-06-27 18:11:16 +0200 | [diff] [blame] | 44 | rmdir "$DIRECTORY" |
| 45 | rm "$ARCHIVE" |