1
0

add viu install script

This commit is contained in:
2022-07-19 14:27:12 +02:00
parent 2cd33a4daa
commit 83db44f73a

View File

@@ -0,0 +1,38 @@
#!/bin/bash
set -eu
source "${BOOTSTRAP_LIB}/helpers"
VERSION="1.4.0"
INSTALL_DIR="${HOME}/.local/bin"
INSTALLED_VERSION=""
if [[ -x "$(command -v viu)" ]]; then
INSTALLED_VERSION="$(viu --version | grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+')"
fi
if [[ "$VERSION" == "$INSTALLED_VERSION" ]]; then
echo "viu version ${VERSION} already installed."
exit 0
fi
echo "Installing viu version ${VERSION}..."
URL="https://github.com/atanunq/viu/releases/download/v${VERSION}/viu"
echo "Downloading from ${URL}..."
TARGET="$(download "$URL")"
if [[ -f "${INSTALL_DIR}/viu" ]]; then
echo "Removing old viu command..."
rm -f "${INSTALL_DIR}/viu"
fi
echo "Installing viu command to ${INSTALL_DIR}..."
mkdir -p "${INSTALL_DIR}"
cp "${TARGET}" "${INSTALL_DIR}/viu"
chmod +x "${INSTALL_DIR}/viu"
echo "Removing ${TARGET}..."
rm -f "${TARGET}"