2022-05-09 14:23:01 +02:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
FORMIDABLE_RELEASES_URL="https://github.com/Bornholm/formidable/releases"
|
|
|
|
FORMIDABLE_DESTDIR="."
|
|
|
|
FORMIDABLE_FILE_BASENAME="frmd"
|
|
|
|
|
|
|
|
function main {
|
2022-05-11 09:32:21 +02:00
|
|
|
test -z "${FORMIDABLE_VERSION}" && FORMIDABLE_VERSION="$(curl -sfL -o /dev/null -w %{url_effective} "${FORMIDABLE_RELEASES_URL}/latest" |
|
2022-05-09 14:23:01 +02:00
|
|
|
rev |
|
|
|
|
cut -f1 -d'/'|
|
|
|
|
rev)"
|
|
|
|
|
|
|
|
# Check version variable initialization
|
2022-05-11 09:32:21 +02:00
|
|
|
test -z "${FORMIDABLE_VERSION}" && {
|
2022-05-09 14:23:01 +02:00
|
|
|
echo "Unable to get Formidable version !" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2022-05-11 09:32:21 +02:00
|
|
|
test -z "${FORMIDABLE_TMPDIR}" && FORMIDABLE_TMPDIR="$(mktemp -d)"
|
|
|
|
export TAR_FILE="${FORMIDABLE_TMPDIR}/${FORMIDABLE_FILE_BASENAME}_${FORMIDABLE_VERSION}_$(uname -s)_$(uname -m).tar.gz"
|
2022-05-09 14:23:01 +02:00
|
|
|
|
|
|
|
(
|
2022-05-11 09:32:21 +02:00
|
|
|
cd "${FORMIDABLE_TMPDIR}"
|
2022-05-09 14:23:01 +02:00
|
|
|
|
|
|
|
# Download Formidable
|
2022-05-11 09:32:21 +02:00
|
|
|
echo "Downloading Formidable ${FORMIDABLE_VERSION}..."
|
|
|
|
curl -sfLo "${TAR_FILE}" \
|
|
|
|
"${FORMIDABLE_RELEASES_URL}/download/${FORMIDABLE_VERSION}/${FORMIDABLE_FILE_BASENAME}_${FORMIDABLE_VERSION}_$(uname -s)_$(uname -m).tar.gz" ||
|
2022-05-09 14:23:01 +02:00
|
|
|
( echo "Error while downloading Formidable !" >&2 && exit 1 )
|
|
|
|
|
|
|
|
# Download checksums
|
2022-05-11 09:32:21 +02:00
|
|
|
curl -sfLo "checksums.txt" "${FORMIDABLE_RELEASES_URL}/download/${FORMIDABLE_VERSION}/checksums.txt"
|
2022-05-09 14:23:01 +02:00
|
|
|
|
|
|
|
echo "Verifying checksums..."
|
|
|
|
sha256sum --ignore-missing --quiet --check checksums.txt ||
|
|
|
|
( echo "Error while verifying checksums !" >&2 && exit 1 )
|
|
|
|
)
|
|
|
|
|
|
|
|
# Extracting archive files
|
2022-05-11 09:32:21 +02:00
|
|
|
tar -xf "${TAR_FILE}" -C "${FORMIDABLE_TMPDIR}"
|
2022-05-09 14:23:01 +02:00
|
|
|
|
|
|
|
# Moving downloaded binary to destination directory
|
2022-05-11 09:32:21 +02:00
|
|
|
mv -f "${FORMIDABLE_TMPDIR}/${FORMIDABLE_FILE_BASENAME}" "${FORMIDABLE_DESTDIR}/"
|
|
|
|
|
|
|
|
echo "You can now use '${FORMIDABLE_DESTDIR}/${FORMIDABLE_FILE_BASENAME}', enjoy !"
|
2022-05-09 14:23:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main $@
|