chore: fix install script

This commit is contained in:
wpetit 2022-05-11 09:32:21 +02:00
parent 9281685f09
commit c37f292f62
1 changed files with 13 additions and 11 deletions

View File

@ -6,31 +6,31 @@ FORMIDABLE_DESTDIR="."
FORMIDABLE_FILE_BASENAME="frmd" FORMIDABLE_FILE_BASENAME="frmd"
function main { function main {
test -z "$FORMIDABLE_VERSION" && FORMIDABLE_VERSION="$(curl -sfL -o /dev/null -w %{url_effective} "$FORMIDABLE_RELEASES_URL/latest" | test -z "${FORMIDABLE_VERSION}" && FORMIDABLE_VERSION="$(curl -sfL -o /dev/null -w %{url_effective} "${FORMIDABLE_RELEASES_URL}/latest" |
rev | rev |
cut -f1 -d'/'| cut -f1 -d'/'|
rev)" rev)"
# Check version variable initialization # Check version variable initialization
test -z "$FORMIDABLE_VERSION" && { test -z "${FORMIDABLE_VERSION}" && {
echo "Unable to get Formidable version !" >&2 echo "Unable to get Formidable version !" >&2
exit 1 exit 1
} }
test -z "$FORMIDABLE_TMPDIR" && FORMIDABLE_TMPDIR="$(mktemp -d)" test -z "${FORMIDABLE_TMPDIR}" && FORMIDABLE_TMPDIR="$(mktemp -d)"
export TAR_FILE="$FORMIDABLE_TMPDIR/${FILE_BASENAME}_$(uname -s)_$(uname -m).tar.gz" export TAR_FILE="${FORMIDABLE_TMPDIR}/${FORMIDABLE_FILE_BASENAME}_${FORMIDABLE_VERSION}_$(uname -s)_$(uname -m).tar.gz"
( (
cd "$FORMIDABLE_TMPDIR" cd "${FORMIDABLE_TMPDIR}"
# Download Formidable # Download Formidable
echo "Downloading Formidable $FORMIDABLE_VERSION..." echo "Downloading Formidable ${FORMIDABLE_VERSION}..."
curl -sfLo "$TAR_FILE" \ curl -sfLo "${TAR_FILE}" \
"$FORMIDABLE_RELEASES_URL/download/$FORMIDABLE_VERSION/${FORMIDABLE_FILE_BASENAME}_$(uname -s)_$(uname -m).tar.gz" || "${FORMIDABLE_RELEASES_URL}/download/${FORMIDABLE_VERSION}/${FORMIDABLE_FILE_BASENAME}_${FORMIDABLE_VERSION}_$(uname -s)_$(uname -m).tar.gz" ||
( echo "Error while downloading Formidable !" >&2 && exit 1 ) ( echo "Error while downloading Formidable !" >&2 && exit 1 )
# Download checksums # Download checksums
curl -sfLo "checksums.txt" "$FORMIDABLE_RELEASES_URL/download/$FORMIDABLE_VERSION/checksums.txt" curl -sfLo "checksums.txt" "${FORMIDABLE_RELEASES_URL}/download/${FORMIDABLE_VERSION}/checksums.txt"
echo "Verifying checksums..." echo "Verifying checksums..."
sha256sum --ignore-missing --quiet --check checksums.txt || sha256sum --ignore-missing --quiet --check checksums.txt ||
@ -38,10 +38,12 @@ function main {
) )
# Extracting archive files # Extracting archive files
tar -xf "$TAR_FILE" -C "$FORMIDABLE_TMPDIR" tar -xf "${TAR_FILE}" -C "${FORMIDABLE_TMPDIR}"
# Moving downloaded binary to destination directory # Moving downloaded binary to destination directory
mv -f "$FORMIDABLE_TMPDIR/$FORMIDABLE_FILE_BASENAME" "$FORMIDABLE_DESTDIR/" mv -f "${FORMIDABLE_TMPDIR}/${FORMIDABLE_FILE_BASENAME}" "${FORMIDABLE_DESTDIR}/"
echo "You can now use '${FORMIDABLE_DESTDIR}/${FORMIDABLE_FILE_BASENAME}', enjoy !"
} }
main $@ main $@