Last active
September 10, 2018 10:45
-
-
Save woohgit/d822988807b01561862bbac27c26844b to your computer and use it in GitHub Desktop.
This file contains 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 | |
export PATH=$PATH:$HOME/.opscore | |
function upgrade() { | |
echo $* | |
tooling=$1 | |
version=$2 | |
curren_version=$3 | |
echo "Upgrading $tooling to $version from $current_version" | |
cd /tmp | |
rm -rf "$tooling"* | |
wget --quiet -O "$tooling"-"$version".zip https://releases.hashicorp.com/"$tooling/$version/$tooling"_"$version"_linux_amd64.zip | |
echo "Unachiving..." | |
unzip "$tooling-$version".zip | |
echo "Installing to ~/.opscore/$tooling" | |
cp "$tooling" ~/.opscore/"$tooling" | |
"$tooling" --version | |
rm "$tooling-$version".zip | |
} | |
version=$(curl -s https://checkpoint-api.hashicorp.com/v1/check/terraform | jq -r ".current_version") | |
current_version=$(terraform --version | grep 'Terraform' | cut -d ' ' -f 2 | cut -c 2-) | |
if [ "$version" != "$current_version" ]; then | |
upgrade "terraform" "$version" "$current_version" | |
else | |
echo "Terraform is up to date: $current_version" | |
fi | |
version=$(curl -fsS https://api.github.com/repos/hashicorp/vault/tags | jq -re '.[].name' | sed 's/^v\(.*\)$/\1/g' | sort -Vr | grep -v 'beta' | head -1) | |
current_version=$(vault version | cut -d ' ' -f 2 | cut -c 2-) | |
if [ "$version" != "$current_version" ]; then | |
upgrade "vault" "$version" "$current_version" | |
else | |
echo "Vault is up to date: $current_version" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment