From 6579883226baae7dfb9e3f0c765b19ae62be4fd8 Mon Sep 17 00:00:00 2001 From: jonas Date: Sun, 24 Oct 2021 13:25:50 +0200 Subject: [PATCH] . --- update.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/update.sh b/update.sh index fad22d0..73d492c 100755 --- a/update.sh +++ b/update.sh @@ -5,6 +5,7 @@ set -aeou pipefail SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" + function printHelp(){ cat << EOF Usage ${0##*/} [options..] @@ -139,7 +140,8 @@ function rmt_mirror(){ function install_tools(){ new_log "Install client tools" echo "- kubectl" - echo "- heml" + echo "- helm" + echo "- stern" if asktobreak; then return fi @@ -149,7 +151,7 @@ function install_tools(){ echo "---- kubectl ----" cd $HOME/bin if [[ -f kubectl ]]; then - KUBECTL_CURRENT=$(./kubectl version 2> /dev/null| sed -n 's/.* GitVersion:"\(v[0-9]*\.[0-9]*\.[0-9]*\)".*/\1/p') + KUBECTL_CURRENT=$(./kubectl version --client 2> /dev/null| sed -n 's/.* GitVersion:"\(v[0-9]*\.[0-9]*\.[0-9]*\)".*/\1/p') else KUBECTL_CURRENT="N/A" fi @@ -157,6 +159,7 @@ function install_tools(){ echo "Installed version: $KUBECTL_CURRENT" echo "Latest stable version: $KUBECTL_STABLE" if [[ "$KUBECTL_CURRENT" != "$KUBECTL_STABLE" ]]; then + echo "updating to $KUBECTL_STABLE" curl -LO https://dl.k8s.io/release/$KUBECTL_STABLE/bin/linux/amd64/kubectl chmod +x kubectl fi @@ -169,16 +172,34 @@ function install_tools(){ else HELM_CURRENT="N/A" fi - HELM_STABLE="$(curl -Ls https://github.com/helm/helm/releases | grep 'href="/helm/helm/releases/tag/v3.[0-9]*.[0-9]*\"' | grep -v no-underline | head -n 1 | cut -d '"' -f 2 | awk '{n=split($NF,a,"/");print a[n]}' | awk 'a !~ $0{print}; {a=$0}')" + HELM_STABLE="$(curl -Ls https://github.com/helm/helm/releases | egrep 'href="/helm/helm/releases/tag/v[0-9]+.[0-9]+.[0-9]+\"' | head -n 1 | sed -n 's/.*tag\/\(v.*\)" data.*/\1/p')" echo "Installed version: $HELM_CURRENT" echo "Latest stable version: $HELM_STABLE" if [[ "$HELM_CURRENT" != "$HELM_STABLE" ]]; then + echo "updating to $HELM_STABLE" curl -LO https://get.helm.sh/helm-$HELM_STABLE-linux-amd64.tar.gz tar xvzf helm-$HELM_STABLE-linux-amd64.tar.gz --strip-components=1 linux-amd64/helm rm helm-$HELM_STABLE-linux-amd64.tar.gz fi echo "" + echo "---- stern ----" + if [[ -f stern ]]; then + STERN_CURRENT="v$(./stern -v | head -n1 | cut -d " " -f2)" + else + STERN_CURRENT="N/A" + fi + STERN_STABLE="$(curl -Ls https://github.com/stern/stern/releases | egrep 'href="/stern/stern/releases/tag/v[0-9]+.[0-9]+.[0-9]+*\"' | head -n 1 | sed -n 's/.*tag\/\(v.*\)" data.*/\1/p')" + echo "Installed version: $STERN_CURRENT" + echo "Latest stable version: $STERN_STABLE" + if [[ "$STERN_CURRENT" != "$STERN_STABLE" ]]; then + echo "updating to $STERN_STABLE" + curl -LO https://github.com/stern/stern/releases/download/$STERN_STABLE/stern_${STERN_STABLE:1}_linux_amd64.tar.gz + tar xvzf stern_${STERN_STABLE:1}_linux_amd64.tar.gz --strip-components=1 stern_${STERN_STABLE:1}_linux_amd64/stern + rm stern_${STERN_STABLE:1}_linux_amd64.tar.gz + fi + echo "" + set -e }