From a9f945910758a2dc32f02aefb76d2edfed6281d6 Mon Sep 17 00:00:00 2001 From: rdinardi-bw <39524010+rdinardi-bw@users.noreply.github.com> Date: Mon, 7 Oct 2024 15:54:09 -0400 Subject: [PATCH] Error checking and README fix --- vault-shim-installer.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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"