Skip to content

Commit

Permalink
Check for tfvm before moving existing tf out of the way.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbuschka committed Sep 27, 2023
1 parent 1efbcb1 commit 7e5b98c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,21 @@ if [ ! -d "${TARGET_DIR}" ]; then
exit 1
fi

VERSION=$(basename $(curl -Ls -o /dev/null -w %\{url_effective\} https://github.com/cbuschka/tfvm/releases/latest))

CURRENT_TFVM_VERSION=$(tfvm version 2>/dev/null || true)
if [ "x${CURRENT_TFVM_VERSION}" = "x${VERSION}" ]; then
echo "tfvm ${VERSION} is already installed."
exit 0
fi

if [ -f "${TARGET_DIR}/terraform" ]; then
mv ${TARGET_DIR}/terraform ${TARGET_DIR}/terraform.${TIMESTAMP}
echo "${TARGET_DIR}/terraform already exists. Moved out of the way as ${TARGET_DIR}/terraform.${TIMESTAMP}."
fi

echo "Will install tfvm as ${TARGET_DIR}/tfvm and ${TARGET_DIR}/terraform."

VERSION=$(basename $(curl -Ls -o /dev/null -w %\{url_effective\} https://github.com/cbuschka/tfvm/releases/latest))

function get_os() {
local unameOut="$(uname -s)"
case "${unameOut}" in
Expand Down Expand Up @@ -66,12 +72,6 @@ function get_arch() {
get_os
get_arch

CURRENT_TFVM_VERSION=$(tfvm version 2>/dev/null || true)
if [ "x${CURRENT_TFVM_VERSION}" = "x${VERSION}" ]; then
echo "tfvm ${VERSION} is already installed."
exit 0
fi

echo "Downloading tfvm ${VERSION}..."
TMP_FILE=$(mktemp)
curl -L --progress-bar -o ${TMP_FILE} https://github.com/cbuschka/tfvm/releases/download/${VERSION}/tfvm-${OS}_${ARCH}${EXT}
Expand Down

0 comments on commit 7e5b98c

Please sign in to comment.