Skip to content

Instantly share code, notes, and snippets.

@moto-timo
Last active July 3, 2021 00:44
Show Gist options
  • Save moto-timo/a7440231be7b841357e60a0f20c48390 to your computer and use it in GitHub Desktop.
Save moto-timo/a7440231be7b841357e60a0f20c48390 to your computer and use it in GitHub Desktop.
#!/bin/sh
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: Copyright 2021 Tim Orling
USER=derailed
REPO=k9s
VERSION=$(curl -s https://api.github.com/repos/$USER/$REPO/releases/latest | grep -oP '"tag_name": "\K(.*)(?=")')
MACHINE=$(uname -m)
KERNEL_NAME=$(uname -s)
K9S_VERSION=$(k9s version -s | grep -oP '(v\d+\.\d+\.\d+)' )
echo "Current k9s version: $K9S_VERSION"
echo "Upstream k9s version: $VERSION"
# https://github.com/derailed/k9s/releases/download/v0.24.12/k9s_Linux_x86_64.tar.gz
# https://github.com/derailed/k9s/releases/download/v0.24.12/k9s_Linux_arm64.tar.gz
if [ "${MACHINE}" = 'aarch64' ]; then
MACHINE='arm64'
fi
if [ "${K9S_VERSION}" != "${VERSION}" ]; then
wget -qO- https://github.com/${USER}/${REPO}/releases/download/$VERSION/${REPO}_${KERNEL_NAME}_${MACHINE}.tar.gz | tar -xvz -C /tmp
sudo mv /tmp/k9s /usr/local/bin/
else
echo "Nothing to do: \n ${K9S_VERSION} = ${VERSION}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment