Skip to content

Instantly share code, notes, and snippets.

@woohgit
Last active September 10, 2018 10:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woohgit/d822988807b01561862bbac27c26844b to your computer and use it in GitHub Desktop.
Save woohgit/d822988807b01561862bbac27c26844b to your computer and use it in GitHub Desktop.
#!/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