Last active
June 2, 2020 17:49
-
-
Save kitos9112/4265c492442865ef0fe54ade671d9f4a to your computer and use it in GitHub Desktop.
Fetches and installs the latest Kops Liux AMD64 version released on GitHub artifacts
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/bash | |
########################################################################### | |
# Fetch and install the latest Kops release from the official GitHub repository | |
# curl -Ls https://gist.githubusercontent.com/kitos9112/4265c492442865ef0fe54ade671d9f4a/raw/50d70d9044a77ade7e7e05aabc34f66155b11b5e/get-kops.sh | bash | |
########################################################################## | |
function get_latest_github_release { | |
curl -s https://api.github.com/repos/$1/$2/releases/latest | grep -oP '"tag_name": "[v]\K(.*)(?=")' | |
} | |
INSTALL_DIR='/usr/local/bin' | |
REGEX="^PATH=.*\K$INSTALL_DIR(?=.*)" | |
if [[ $(env | grep -oP $REGEX) != $INSTALL_DIR ]]; then | |
echo "Looks like your install directory $INSTALL_DIR is not in your PATH. Make sure you export it"; fi | |
INSTALLED_KOPS_VERSION=$(kops version | cut -d " " -f2) | |
LATEST_KOPS_RELEASE=$(get_latest_github_release kubernetes kops) | |
# Download and install Terraform if there is a version mismatch | |
if [[ ${LATEST_KOPS_RELEASE} != ${INSTALLED_KOPS_VERSION} ]]; then | |
echo "Installing Kops ${LATEST_RELEASE}..." | |
wget https://github.com/kubernetes/kops/releases/download/v${LATEST_KOPS_RELEASE}/kops-linux-amd64 | |
sudo install kops-linux-amd64 ${INSTALL_DIR}/kops | |
rm -rf kops-linux-amd64 | |
else | |
echo "Nothing done. Latest KOPS already installed." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment