zulip/tools/setup/install-tusd

35 lines
905 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
set -eu
version=2.5.0
arch="$(uname -m)"
case $arch in
x86_64)
tarball="tusd_linux_amd64"
sha256=f4cbdb8d228b28f46c3e7b9e29e5db262e7416f7ca1033c6c5e8186cf6c7381c
;;
aarch64)
tarball="tusd_linux_arm64"
sha256=b2101951789857765d64c33d672a38b5825946163aa058b208fc862867cdc405
;;
esac
check_version() {
out="$(tusd --version)" && [[ "$out" = *"Version: v$version"* ]]
}
if ! check_version 2>/dev/null; then
set -x
tmpdir="$(mktemp -d)"
trap 'rm -r "$tmpdir"' EXIT
cd "$tmpdir"
curl_opts=(-fLO --retry 3)
curl "${curl_opts[@]}" "https://github.com/tus/tusd/releases/download/v${version}/${tarball}.tar.gz"
sha256sum -c <<<"${sha256} ${tarball}.tar.gz"
tar -xzf "${tarball}.tar.gz" --no-same-owner "${tarball}/tusd"
install -Dm755 "${tarball}/tusd" /usr/local/bin/tusd
check_version
fi