diff --git a/vault-shim-installer.sh b/vault-shim-installer.sh index fda9d5d..1fed875 100755 --- a/vault-shim-installer.sh +++ b/vault-shim-installer.sh @@ -1,6 +1,16 @@ #!/bin/sh version=$1 +if [ -z "$version" ]; then + echo "Usage: $0 " + exit 1 +fi + +# check if the version starts without a 'v', if so, add it +if [ "${version:0:1}" != "v" ]; then + version="v$version" +fi + # turn to all lowercase and then capitalize the first letter of the OS name os="$(uname -s | tr '[:upper:]' '[:lower:]' | awk '{ print toupper(substr($0, 1, 1)) substr($0, 2) }')" arch="$(uname -m | tr '[:upper:]' '[:lower:]')" @@ -14,5 +24,5 @@ echo "Installing vault-shim version $version" echo "os: $os" echo "arch: $arch" -curl -L "https://github.com/Bandwidth/vault-shim/releases/download/v${version}/vault-shim_${os}_${arch}.tar.gz" --output "/usr/local/bin/vault-shim_${os}_${arch}.tar.gz" +curl -L "https://github.com/Bandwidth/vault-shim/releases/download/${version}/vault-shim_${os}_${arch}.tar.gz" --output "/usr/local/bin/vault-shim_${os}_${arch}.tar.gz" tar xzf "/usr/local/bin/vault-shim_${os}_${arch}.tar.gz" -C "/usr/local/bin"